$(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
});
});
In this chart i have to set dotted grid lines in background. is this possible to draw dotted grid lines in jqplot
最佳答案
我不知道是否存在更简单的方法来完成此任务,但这可行:
打开jquery.jqplot.js
。在功能$.jqplot.CanvasGridRenderer.prototype.draw
添加行ctx.setLineDash([1, 5]);
行后ctx.save();
。然后只需最小化文件,将其另存为jquery.jqplot.min.js
(或直接在最小化版本上应用这些更改)就可以了。
请记住,您的所有图表现在都将带有虚线。如果这是一个问题,那么您需要将新属性添加到 Grid
像lineDash
这样的类并在 $.jqplot.CanvasGridRenderer.prototype.draw
中进行相应处理.
关于jquery - 如何在jqplot中显示虚线网格线而不是实线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30098787/