javascript - How to duplicate Y Axis on JQuery Flot -


i'm being able use jquery flot, , it's nice tool. however, not find solution problem.

i want duplicate y axis, can display 1 on left , 1 on right, users, when comparing data rightmost side of chart, won't have scroll through leftmost side of chart. i'm assuming accessing through smartphone.

jquery flot allows multiple axis, each axis, need different set of data, in example: http://people.iola.dk/olau/flot/examples/multiple-axes.html

but don't want duplicate data. can't 'tell' flot duplicate yaxis using same set of data?

a busy cat

you can use hooks functionality force flot show second yaxis though has no data series assigned it:

// hook function mark axis "used" // , assign min/max left axis poff = function(plot, offset){     plot.getyaxes()[1].used = true;     plot.getyaxes()[1].datamin = plot.getyaxes()[0].datamin;     plot.getyaxes()[1].datamax = plot.getyaxes()[0].datamax; }  $.plot("#placeholder2", [ { data: d2 } ], {      hooks: { processoffset: [poff] },     yaxes: [ {},              {position: 'right'} // add second axis     ] }); 

depending on how axis configured though, might messy. you'll have steal parameters left axis work (as i've done above datamin/datamax).

if code, i'd go duplicate data approach. aren't duplicating anything, assigned same array 2 series. i'd configure 2nd series not draw.

var d2 = [[0, 3], [4, 8], [8, 5], [9, 13]];  // use same data toggle off lines... $.plot("#placeholder", [ { data: d2 }, {data: d2, yaxis: 2, lines: {show: false}} ], {     yaxes: [ {},              {position: 'right'} ] }); 

here's fiddle demonstrating 2 approaches.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -