问题
I've got data with X values from 0 to 55. I would like to see these values as a custom text in tick labels. Ideally, I want to specify some callback, like
function tickLabel(tickValue) {
return "This is " + tickValue;
}
Is it possible?
回答1:
I've found a solution.
xaxis: {
tickRenderer: $.jqplot.AxisTickRenderer,
tickOptions: {
formatter: function(format, value) { return "This is " + value; }
}
}
回答2:
Use something like:
var line1 = [['This is '.$value, $value], ...]
And call your plot as:
var plot1 = $.jqplot('chart1', [line1], {
title: 'Title of your plot',
series:[{renderer:$.jqplot.BarRenderer}],
axesDefaults: {
tickRenderer: $.jqplot.CanvasAxisTickRenderer ,
tickOptions: {
angle: -30,
fontSize: '10pt'
}
},
axes: {
xaxis: {
renderer: $.jqplot.CategoryAxisRenderer
}
}
});
来源:https://stackoverflow.com/questions/9263551/jqplot-custom-tick-labels