A custom formatter function that returns label to be displayed on axisY.
Notesvar chart = new CanvasJS.Chart("container", { . . axisY:{ labelFormatter: function ( e ) { return "y: " + e.value; } }, . . }); chart.render();
e: { // parameter sent to function chart, axis, value }
10 Comments
for some reason in my script labelFormatter option has no effect on labels as it was not there – no errors in concsole
Can you please create a jsfiddle so that we can have a look ?
Noticing the same thing here. Label Formatter is not working at all and no errors
Can you please create a jsfiddle so that we can have a look ?
How i can pass dynamically values to labelFormatter
Hi,
Here values have only read-only properties. If you want to pass any other custom variable you have to assign it with a key inside axis or chart and in labelFormatter you can retrieve it using e.axis.key or e.chart.options.key correspondingly.
i want to use string data on Axis -Y and time data will be on Axis-x
e.g.
Axis – Y : “A”,”B”,”C”,”D”,”E”… and so on and
Axis – X : 10:30 , 10:35,10:40 ……
Thanks in advance
can you please give me example for that
i want to show dynamic string on y axis
e.g :
“A”
“B”
“C”
and my x axis will be
10:30 , 10:40 ….
Setting intervalType of axisX to hour you can show time data. And for showing axisY label in your format you can use
axisY:{
interval: 1,
labelFormatter: function(e){
return String.fromCharCode( e.value%26 +65);
}
}
Thanks Sanjoy ? its working for me.. ?