首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >CanvasJS .render()函数跳转到屏幕顶部

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

Stack Overflow用户
提问于 2018-08-28 17:25:14
回答 1查看 45关注 0票数 0

首先:这里是我的页面

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

代码语言:javascript
复制
document.getElementById('time-all-time').addEventListener('click', function() {
    chart(-1);
});

图表函数只包含一些关于画布的说明:

代码语言:javascript
复制
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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-08-29 13:23:55

终于明白了。我忘了在图表上设定高度。这是为了我:

代码语言:javascript
复制
#hashrate-chart {
    height: 400px;
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52063382

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档