$(document).ready(function(){
// Our data renderer function, returns an array of the form:
// [[[x1, sin(x1)], [x2, sin(x2)], ...]]
var sineRenderer = function() {
var data = [[]];
for (var i=0; i<13; i+=0.5) {
data[0].push([i, Math.sin(i)]);
}
return data;
};
// we have an empty data array here, but use the "dataRenderer"
// option to tell the plot to get data from our renderer.
var plot1 = $.jqplot('chart1',[],{
title: 'Sine Data Renderer',
dataRenderer: sineRenderer
});
});
在此图表中,我必须在背景中设置虚线网格线。这有可能在jqplot中绘制虚线网格线吗
我不知道是否存在更简单的方法来实现此目的,但这可行:
打开jquery.jqplot.js
。在函数中,$.jqplot.CanvasGridRenderer.prototype.draw
在行ctx.setLineDash([1, 5]);
之后添加行ctx.save();
。然后,只需最小化文件,将其另存为jquery.jqplot.min.js
(或将更改直接应用到最小化版本中)就可以了。
请记住,您的所有图表现在都将带有虚线。如果存在问题,则需要为Grid
类之类添加一个新属性,lineDash
并在中进行相应处理$.jqplot.CanvasGridRenderer.prototype.draw
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句