Reputation: 357
Does anyone know how to do this?
Basically, I don't want to show on Y-axis the values like 100000, 200000, 300000 and so on. They should be 10 K, 20 K, 30 K or "1 mil", 2 mil and so on.
Is there a way to do that in jqPlot?
Upvotes: 1
Views: 1148
Reputation: 5920
Try something like this:
tickFormatter = function (format, val) {
var number = val/1000;
return number+"K";
}
And add this option to the plot:
axes: {
yaxis: {
tickOptions: {
formatter: tickFormatter
}
}
Upvotes: 3
Reputation: 108512
Yes, you would have to use an axes formatter
; something like:
tickFormatter = function (format, val) {
if (val >= 110000)
return "110K"
else if (val >= 100000)
return "100K";
else if (val >= 90000)
return "20K";
else if (val >= 80000)
return "30K";
else if (val >= 70000)
return "10K";
else if (val >= 60000)
return "20K";
else if (val >= 50000)
return "30K";
else if (val >= 40000)
return "30K";
else if (val >= 30000)
return "30K";
else if (val >= 20000)
return "20K";
else if (val >= 10000)
return "10K";
else
return val;
}
See working example here.
Upvotes: 0