【问题标题】:How to get the actual chart width and height in chart.js如何在chart.js中获取实际的图表宽度和高度
【发布时间】:2018-09-26 06:28:44
【问题描述】:

我在画布中有折线图,想知道图表的确切宽度和高度(不是画布宽度和高度)。 请帮忙。

【问题讨论】:

    标签: chart.js chart.js2


    【解决方案1】:

    chartArea 属性包含一个对象,该对象显示由 x 轴和 y 轴界定的区域:

    let myChart = new Chart(ctx, {
      ...
    });
    
    console.log(myChart.chartArea);
    

    结果:

    {
      bottom: 500,
      left: 30,
      right: 1000,
      top: 30
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-09-24
      • 2012-11-07
      • 1970-01-01
      • 2012-11-23
      • 1970-01-01
      • 1970-01-01
      • 2020-11-28
      • 1970-01-01
      相关资源
      最近更新 更多