jquery - 如何在jqplot中显示虚线网格线而不是实线

标签 jquery jqplot

$(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 (或直接在最小化版本上应用这些更改)就可以了。

请记住,您的所有图表现在都将带有虚线。如果这是一个问题,那么您需要将新属性添加到 GridlineDash这样的类并在 $.jqplot.CanvasGridRenderer.prototype.draw 中进行相应处理.

enter image description here

关于jquery - 如何在jqplot中显示虚线网格线而不是实线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30098787/

相关文章:

javascript - 无法在 JQuery 中为 GET 请求动态使用 id 元素

javascript - 如何访问此 json 对象中的 'img'? PHP,Laravel-5

javascript - 如何在 jquery 对话框中添加日期选择器

javascript - jqplot 到图像在 IE7 上不起作用

javascript - 图外的 JQPlot 图例

javascript - jQuery 查找标签之间的文本

JavaScript Date() 返回无效日期

jquery - 如何动态更改jqplot渲染器?

javascript - jqPlot 图 "TypeError"

javascript - jqPlot - 条形图 - 将最高值设置为图表顶部