$(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
在此图表中,我必须在背景中设置虚线网格线。这有可能在jqplot中绘制虚线网格线
1 个解决方案
#1
I don't know whether an easier way to accomplish this exists, but this works:
我不知道是否有更简单的方法来实现这一点,但这有效:
Open jquery.jqplot.js
. In function $.jqplot.CanvasGridRenderer.prototype.draw
add line ctx.setLineDash([1, 5]);
after line ctx.save();
. Then just minimize the file, save it as jquery.jqplot.min.js
(or apply those changes directly on minimized version) and you're good to go.
打开jquery.jqplot.js。在函数$ .jqplot.CanvasGridRenderer.prototype.draw中添加行ctx.setLineDash([1,5]);在行ctx.save();之后然后只需最小化文件,将其保存为jquery.jqplot.min.js(或直接在最小化版本上应用这些更改),你就可以了。
Bear in mind that all your charts will have dotted lines now. If that's a problem, then you would need to add a new property to Grid
class like lineDash
and process it accordingly in $.jqplot.CanvasGridRenderer.prototype.draw
.
请记住,所有图表现在都有虚线。如果这是一个问题,那么你需要像GridDash一样向Grid类添加一个新属性,并在$ .jqplot.CanvasGridRenderer.prototype.draw中相应地处理它。
#1
I don't know whether an easier way to accomplish this exists, but this works:
我不知道是否有更简单的方法来实现这一点,但这有效:
Open jquery.jqplot.js
. In function $.jqplot.CanvasGridRenderer.prototype.draw
add line ctx.setLineDash([1, 5]);
after line ctx.save();
. Then just minimize the file, save it as jquery.jqplot.min.js
(or apply those changes directly on minimized version) and you're good to go.
打开jquery.jqplot.js。在函数$ .jqplot.CanvasGridRenderer.prototype.draw中添加行ctx.setLineDash([1,5]);在行ctx.save();之后然后只需最小化文件,将其保存为jquery.jqplot.min.js(或直接在最小化版本上应用这些更改),你就可以了。
Bear in mind that all your charts will have dotted lines now. If that's a problem, then you would need to add a new property to Grid
class like lineDash
and process it accordingly in $.jqplot.CanvasGridRenderer.prototype.draw
.
请记住,所有图表现在都有虚线。如果这是一个问题,那么你需要像GridDash一样向Grid类添加一个新属性,并在$ .jqplot.CanvasGridRenderer.prototype.draw中相应地处理它。