0

Sometimes RGraph plots "4e-2" instead of "0.02" at the y-axis of a line-chart. I have set scale.decimals to 2 and 0 ist correctly displayed as 0.00, but 0.02, 0.04 etc. are displayed in scientific notation.

If there is no property which can be set to force this, how do I change the labels "manually" via javascript before the chart is printed?

Many thanks in advance. Michael

2 Answers2

0

You can use the chart.ylabels.specific option. Eg:

obj.set('chart.ylabels.specific', ['1.00','0.80','0.60','0.40','0.20']);

Richard
  • 4,809
  • 3
  • 27
  • 46
  • Hello Richard, I know the specific labels, but if I use them, I do not want to do all the calculation about a max-value again, that RGraph already has done. I'd like to use a function that "translates" the lready existing y-labels in scientific notation to "normal" notation. So I'd like to get the ylabels-array, convert it and reassign it with your suggestion. But I do not manage to read out the existing labels: var foo = chart.get('chart.scale2.labels'); does not work, not before drawing the line-chart, nor in a chart.on('draw', function (obj) {...}).draw(); -function. how to do this? Thanks! – TheIndividual Mar 06 '15 at 15:46
  • Hi Richard, many many thanks for your research and especially for your fiddle-workaround! It is working perfectly. Now I also know that I first have to draw the chart, then modify the labels and then redraw - this was my problem when I tried to access the y-labels and only got errors. As stated im the comment to Lightness' answer my data has ~100 values from 0.01 to 0.05 and all of them have exactly 2 decimals (for reproducing the bug). Thanks again! RGraph is a very nice JS-Library!! – TheIndividual Mar 13 '15 at 10:06
0

According to the documentation, no, there are no properties to change this behaviour so, presumably, the change into scientific notation is not intentional.

You're stuck naming the axis points explicitly.

This looks like a library bug to me, so you should contact the authors. Don't forget to send them a proper testcase with actual data that clearly reproduces the problem.

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055