我有一个 jqplot 线图,它按日期显示用户计数。
我希望在特定日期添加一条标记线,描述我更新应用程序的时间,以便我可以查看应用程序更改是否会造成任何影响。有什么想法吗?
This是一个例子 看上面的图。
我希望在 x=3 上添加带有标签的垂直线。我该怎么做?
最佳答案
这很大程度上是一个黑客,但我发现当你想做“正常”之外的事情时,jqplot 非常不灵活:
$(document).ready(function(){
plot1 = $.jqplot ('chart1', [[3,7,9,1,4,6,8,2,5],[]], // leave an empty series at the end
{
series: [{
showMarker:true
},
{
showMarker:false,
pointLabels: { show:true, location: 'ne' } // do not show marker, but do show point label
}]
});
plot1.series[1].data = [[2,plot1.axes.yaxis.min],[2,plot1.axes.yaxis.max]]; //dynamically add the data for the empty series, we do this so we can get the auto-scaled yaxis min/max
plot1.redraw(); // redraw the plot with adjusted 2nd series
$('.jqplot-point-label.jqplot-series-1.jqplot-point-0').html('x=2'); // manually adjust the label on the 2nd series (I could not find a way to do this with the builtin methods)
})
产品:
示例 here .
关于jquery - 用jqplot标记特定数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14031554/