Chart.js canvas resize

前端 未结 13 1157
北海茫月
北海茫月 2020-11-30 23:39

In (Android WebView HTML5 canvas error) i posted a question regarding plotting graphs using Graph.js library. The problem i have now is that if i call the function to plot t

13条回答
  •  渐次进展
    2020-11-30 23:58

     let canvasBox = ReactDOM.findDOMNode(this.refs.canvasBox);
     let width = canvasBox.clientWidth;
     let height = canvasBox.clientHeight;
     let charts = ReactDOM.findDOMNode(this.refs.charts);
     let ctx = charts.getContext('2d');
     ctx.canvas.width = width;
     ctx.canvas.height = height;
     this.myChart = new Chart(ctx);
    

提交回复
热议问题