JqPlot repeating y-axis values

I have a graph whose values ​​along the Y axis can vary greatly. The only information I have is:

  • all values ​​are integers
  • value> = 0

Now, if I have only a few values ​​with very low volatility, for example (let's take extremes) [0,0,0,0,0,0,0] I got duplicate Y-axis values. It looks like this:

  | 1+ | 1+ | 1+ | 0+ | 0+ | 0+----------------------------------------- 

I would like to make jqPlot skip repeating values, maybe only display 2 ticks - 0.1 on the Y axis (lowest and highest).

Any ideas? Adding my code for reference:

 yaxis:{ label:'Count', padMin: 0, labelRenderer: $.jqplot.CanvasAxisLabelRenderer, tickRenderer: $.jqplot.CanvasAxisTickRenderer, tickOptions:{ formatString:'%d' } } 
+4
source share
5 answers

its a bug with the plugin, I can play it on my demo code and I have the same problem.

Now set the chart to a lower dimension, as the current flaw with the plugin.

hope this helps.

0
source

It's not a mistake. jqplot uses some kind of scale in its graph, so when you say formatString:'%d' you force the value of int to be shown along the y axis. By deleting this line, it will return to values ​​such as 1.3, 1.8, ... or so on. I think you want to show tickInterval int values ​​(I found this post looking for the same problem without an answer).

Guess it's not done yet

+2
source

If you need to show only integer digits, you can use your own line formatter:

  tickOptions:{ formatString:'%d', formatter: yourCustomFormater } 

Where 'yourCustomFormatter' is enhanced by default '$ .jqplot.DefaultTickFormatter':

 var yourCustomFormatter = function (format, val) { if (typeof val == 'number') { if (!format) { format = $.jqplot.config.defaultTickFormatString; } if (val % 1 === 0) { return $.jqplot.sprintf(format, val); } else { //ignore items with not integer values return ''; } } else { return String(val); } }; 

But remember that this formatter by default affects the labels on the panel if you do not use other plugins with highlighting.

+1
source

you can use this

axes:{ xaxis:{ numberTicks: 2 } }

0
source

for me the problem was fixed below: 1- the tickOptions parameter was tickOptions: {formatString: "% d"} I changed it to tickOptions: {formatString: "% .2f"}, because if two elements are rounded to the same same integer value, its check mark is displayed twice,

2- I added an additional parameter numberTicks: 4, so that the axis has only 4 graphics

with these two changes, the current problem has been fixed, but it can again be displayed in accordance with the data transferred to the chart

0
source

Source: https://habr.com/ru/post/1433790/


All Articles