CanvasJS .render() 函数跳转到屏幕顶部

CanvasJS .render() function jumps to top of screen

首先:here是我的页面

我目前正在开发一个带有 CanvasJS 图表的网页,我遇到了 .render() 函数的问题。我有几个按钮,如果我点击其中的一些按钮,网页就会跳到顶部。这是我的代码:

document.getElementById('time-all-time').addEventListener('click', function() {
    chart(-1);
});

图表函数只包含一些关于canvas:

的说明
var chart = new CanvasJS.Chart('hashrate-chart', {
  animationEnabled: true,
  title:{
  },
  axisX: {
    valueFormatString: 'HH:mm:ss - DD. MM'
  },
  axisY: {
    title: 'Hashrate (H/s)',
    includeZero: false,
    suffix: ' H/s'
  },
  legend:{
    cursor: 'pointer',
    fontSize: 16,
    itemclick: toggleDataSeries
  },
  toolTip:{
    shared: true
  },
  data: [
    {
      name: '$workr',
      type: 'spline',
      yValueFormatString: '#0.## H/s',
      showInLegend: true,
      dataPoints: [
        { x: 'test', y: 123 }
      ]
    }
  ]
});
chart.render();

提前致谢!

Edit/Solution: 我忘了设置 min-height/height,这是帮我设置的:

终于明白了。我忘了在图表上设置高度。这对我有用:

#hashrate-chart {
    height: 400px;
}