highcharts - Sorting Scatter Highstock Chart with Multiple Series -
i running issues when attempting sort highstocks chart series. continue highcharts error #15. understand why i'm getting error i'm looking way around it. have 3 element array following [[x],[y],[time]]
im attempting use stock chart allow me slide through time while updating x , y scatter plot. understand i'm plotting reasoning plot type may helpful. x in case engine load percent while y exhaust temp.
i error because no matter how sort data because have 2 x series , highstock requires data sorted according x-axis. can imagine, x1 , x2 not dependent on 1 , limited programming skills have left me scratching head here.
a js fiddle of code i'm using located here - jsfiddle
thanks in advance help!
highcharts.stockchart('container', { xaxis: { labels: { enabled: false } }, rangeselector: { buttons: [{ type: 'day', count: 1, text: '1 day' }, { type: 'day', count: 3, text: '3 day' }, { type: 'day', count: 6, text: '6 days' }, { type: 'ytd', text: 'ytd' }, { type: 'year', count: 1, text: '1y' }, { type: 'all', text: 'all' }] }, chart: { type: 'scatter', reflow: false, }, tooltip: { enabled: true, }, boost: { usegputranslations: true, usepreallocated: true }, series: [{ //grouppixelwdith: 100000, //turbothreshold: 10, id: 'main-series', data: points.map(function(point) { return [point[0], point[1], point[2], point[1]] }), showinnavigator: false, xaxis: 1, min: 0, keys: ['x', 'y', 'date', 'holdy'], labels: { enabled: false }, }, { name: 'null_lower', xaxis: 1, labels: { enabled: false }, type: 'area', showinlegend: false, fillopacity: .5, color: 'rgba(255,0,0,0.5)', data: [ [0, 257], [10, 276], [20, 286], [30, 290], [40, 290], [50.0, 291], [60.0, 294], [70.0, 304], [80.0, 323], [90.0, 354] ] }, { xaxis: 0, labels: { enabled: false }, //min:0, //max: 1000, data: points.map(function(point) { return [point[2]]; //, point[1]]; }), showinnavigator: true, enablemousetracking: false, color: '#ff0000', showinlegend: false } ], yaxis: { title: { enabled: true, text: 'exhaust cylinder temperature', }, opposite: false, labels: { enabled: true }, min: 100, max: 500 }, xaxis: [{ //min: 0, //minrange: 1000 * 3600 * 24, type: 'linear', ticklength: 0, //ticklength: 0, labels: { enabled: false }, events: { setextremes: function(e) { var points = this.chart.get('main-series').points; points.foreach(function(point) { point.update({ y: e.min <= point.date && point.date <= e.max ? point.holdy : null }, false, false); }); //this.chart.redraw; } } }, { type: 'linear' }], navigator: { enabled: true, xaxis: { //tickinterval: 0 }, } });
i think should create 2 separate series this:
var seriesarr = [{ data: [] }, { data: [] }]; // create new points , add them respective series points.foreach(function(point) { seriesarr[0].data.push([point[2], point[0]]); seriesarr[1].data.push([point[2], point[1]]); });
live demo: http://jsfiddle.net/kkulig/qazkxary/
for every element points array take third item (timestamp) , make x value 2 points.
handling data in highcharts explained here: https://www.highcharts.com/docs/chart-concepts/series
you may find useful.
Comments
Post a Comment