最好的我发现这样做是通过访问画布本身并直接绘制,就像这样:
// Get the axis, so that we can figure out what canvas coordinates
// correspond to our plot coordinates
xAxis = plot.getXAxes()[0];
yAxis = plot.getYAxes()[0];
// determine how much space flot left on the edges of the graphs
offset = plot.getPlotOffset();
// get the context, so that we can draw on the canvas
ctx = plot.getCanvas().getContext("2d");
// Convert our coordinates to canvas coordinates
x1 = xAxis.p2c(plotX) + offset.left;
y1 = yAxis.p2c(plotY) + offset.top;
// draw a translucent, red rectangle
ctx.fillStyle = "rgba(200,0,0,.1)";
ctx.fillRect (x1, y1, 5, 5);
当然,这不会让你为部分点的任何访问但是如果您只需要将很多点添加到一个情节而不重绘整个情节,那么这是一种方法。
你可以举一些jqPlot的例子代码吗?我阅读您发布的帮助页的方式,我必须添加一个系列(包含一个点),然后重新绘制该系列。但是,我无法得到这个工作。 – richarddmorey 2012-01-07 15:59:52
看来HighCharts的addPoint方法会重绘整个图表。我不想使用flot的原因是因为它重绘了图表,所以addPoint没有帮助。 – richarddmorey 2012-01-07 18:54:57
@ user1129889,请参阅编辑... – Mark 2012-01-07 21:23:21