2

我遇到了麻烦chartist.jsy-axis我想将网格线之间的间距调整为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);

如果您知道,请告诉我。谢谢。

4

2 回答 2

5

请像这样更改axisY选项。

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

如需更多信息,请访问 https://gionkunz.github.io/chartist-js/api-documentation.html

于 2017-03-07T16:09:17.667 回答
1

使用scaleMinSpaceonaxisY选项对我有用

options = {
    axisY: {
         scaleMinSpace: 40
    }
}
于 2016-11-17T04:29:03.677 回答