0

I'm using jqplot for my chart. As you can see the picture I attached. The data used in chart is 1458 points, and it's look like I have fulfilled the chart with the ball blue color.

enter image description here

I'm looking for a solution to make it look better, even if I use more than 100,000 points. So, Could you please tell me a good solution to solve this issue? I really appreciate any your idea about it

After replot with _databound min and max enter image description here

ted
  • 57
  • 2
  • 12

1 Answers1

2

You can get your dataBounds value after rendering using :

var minX = plot.axes.xaxis._dataBounds.min;
var maxX = plot.axes.xaxis._dataBounds.max;

(You can get minY and maxY similarly using yaxis.)

Then you can ask jqplot to use this bounds to plot exact range using :

plot.axes.xaxis.min = minX;
plot.axes.xaxis.max = maxX;

(Again act similarly for yaxis);

Finally, replot your graph : plot.replot();

Your final graph has bounds according to your data values and thus no useless blank on both sides.

AnthonyLeGovic
  • 2,335
  • 1
  • 13
  • 22
  • the xaxis's value gone, after I changed min and max of xaxis. It just show only one tickle. do you know why? – ted Mar 22 '13 at 09:20
  • Did you mean you plot was reloaded (after zoom in/out for example) and your xaxis's values were set by their default values? Or is your xaxis no longer displayed? – AnthonyLeGovic Mar 22 '13 at 09:23
  • Thank for quick reply. It just change the xaxis's value, but there's only one value displayed as you can see in the new pictured I just added (after_replot.png). I have tried with the hard values (min and max) get from _dataBounds and it's fine. But if I change to flexible ways, the issue with xaxis happen – ted Mar 22 '13 at 09:47
  • 1
    Anyway, I found the solution for next issue. I used this $plot.replot({axes:{xaxis:{min:minX, max:maxX, numberTicks:10}}}); to replot the chart instead of just call $plot.replot() – ted Mar 22 '13 at 09:58
  • Nice way to do it! Congrats ;) – AnthonyLeGovic Mar 22 '13 at 10:10