首先:这里是我的页面
目前,我正在用CanvasJS开发一个带有图表的网页,我还面临着.render()函数的问题。我有几个按钮,如果我点击其中一些,网页只是跳到顶部。这是我的代码:
document.getElementById('time-all-time').addEventListener('click', function() {
chart(-1);
});图表函数只包含一些关于画布的说明:
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:我忘记设置一个最小的高度/高度,这是为我做的:https://stackoverflow.com/a/52078559/9360322
发布于 2018-08-29 13:23:55
终于明白了。我忘了在图表上设定高度。这是为了我:
#hashrate-chart {
height: 400px;
}https://stackoverflow.com/questions/52063382
复制相似问题