不显示第一个图表点chartjs

时间:2017-10-16 18:56:19

标签: javascript chart.js

我使用chartjs lib绘制图表。 我想绘制一些简单的线性图表,但是当这样做时,图表的第一点是如何正确显示的:

https://scr.hu/ALkPXP

当最低数据点x值与最小xAxes具有相同值时,就会发生这种情况。

当我减少最小ax值时,它的工作正确:

https://scr.hu/Gw4Lpy

我的整个图表如下:

const scatterChart2 = new Chart(this.canvas.nativeElement,
      {
      'type': 'line',
      'data':
        {
          'datasets': [
            {
              'label': 'Scatter Dataset',
              'data': [
                {
                  x: 1,
                  y: 0,
                }, {
                x: 65,
                y: 20,
              }, {
                x: 30,
                y: 22,
              }, {
                x: 44,
                y: 55,
              }],
              'fill': false,
              'borderColor': 'rgb(75, 192, 192)'
            }]
        },
        'options': {
          scales: {
            xAxes: [{
              ticks: {
                min: 1,
                stepSize: 1
              },
              offset: true,
              type: 'linear',
              position: 'bottom'
            }]
          },
          'showLines': true
        }
      });

  }

在HTML中我的Canvas看起来像:

<div style="max-width: 1000px;max-height: 1000px;">
  <canvas #canvas id="myChart" ></canvas>
</div>

我应该如何正确显示第一点?

0 个答案:

没有答案