javascript - 如何调整 chartist.js 中网格线的间距?

标签 javascript charts linechart chartist.js

我在使用 chartist.js 时遇到问题。 我想将 y 轴 网格线之间的间距调整为 40px。(现在是 36px) 我已经尝试找到一些示例,但找不到。

.ct-grids line {
  stroke: #fff;
  opacity: .05;
  stroke-dasharray: none;
}

这是我当前的网格样式。

var data = {
  labels: ['JAN 1', 'JAN 18', 'FEB 14', 'MAR 9', 'APR 22', 'May 2'],
  series: [
  [40.8, 46.5, 48.8, 56.9, 68.7, 72.7],
  [12.8, 13.7, 13.9, 14.8, 15.3, 15.6],
  [5.2, 3.8, 4.2, 5, 3.9, 4.3],
  [1.2, 1.8, 1.7, 2.1, 1.8, 1.9]
  ]
};

var options = {
   showPoint: false,
   lineSmooth: false,
   axisX: {
        showGrid: false,
        showLabel: false
    },
    axisY: {
        offset: 0,
        showGrid: true,
        showLabel: false
    }
};

var chart = new Chartist.Line('.ct-chart', data, options);

如果你知道请告诉我。 谢谢。

最佳答案

请像这样更改 axisY 选项。

options = {
    axisY: {
        offset: 0,
        scaleMinSpace: 40
        showGrid: true,
        showLabel: false
    }
}

欲了解更多信息,https://gionkunz.github.io/chartist-js/api-documentation.html .

关于javascript - 如何调整 chartist.js 中网格线的间距?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37432915/

相关文章:

javascript - 从base64得到的数组的值是多少

javascript - AngularJS:点击显示html表格中行之间的一些信息?

html - 如何使用 Perl 向网页添加图形?

javascript - Chart.js 缩放开始于放大

javascript - 悬停工具提示上的 Google 折线图未显示值

javascript - 所有以前缀开头的元素的 CSS 选择器

javascript - 尝试使用 HTML 中的 javascript 打开/关闭 twitch 播放器

javascript - 在 chart.js 中的图例上显示点样式

Android AChartEngine - 无法更改 Y 轴标签的文本颜色

javascript - 如何设置d3中x轴的年份范围