Javascript jqPlot自定义标记标签
我得到了X值从0到55的数据。我希望将这些值视为勾号标签中的自定义文本。理想情况下,我想指定一些回调,比如Javascript jqPlot自定义标记标签,javascript,jqplot,Javascript,Jqplot,我得到了X值从0到55的数据。我希望将这些值视为勾号标签中的自定义文本。理想情况下,我想指定一些回调,比如 function tickLabel(tickValue) { return "This is " + tickValue; } 有可能吗?使用以下方法: var line1 = [['This is '.$value, $value], ...] 并将您的绘图称为: var plot1 = $.jqplot('chart1', [line1], { title: 'T
function tickLabel(tickValue) {
return "This is " + tickValue;
}
有可能吗?使用以下方法:
var line1 = [['This is '.$value, $value], ...]
并将您的绘图称为:
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
}
}
});
我找到了解决办法
xaxis: {
tickRenderer: $.jqplot.AxisTickRenderer,
tickOptions: {
formatter: function(format, value) { return "This is " + value; }
}
}
这似乎是最好的通用答案,但我发现有两种情况需要注意:(1)它可能不适用于DateAxisRenderer;(2) 如果需要在多个绘图的页面上输出特定于一个绘图上下文的标签,格式化程序将不具有此上下文。在这两种非标准情况下,我建议使用monkey补丁jQuery.jqplot.DateTickFormatter或jQuery.jqplot.CanvasAxisTickRenderer.prototype.draw(通过替换或包装调用),具体取决于您的需要。