Charts.js graph not scaling to canvas size

后端 未结 11 1231
隐瞒了意图╮
隐瞒了意图╮ 2020-12-08 09:45

I\'m trying to make a graph with Charts.js (current one is just a really simple example I\'m trying to get working, somewhat taken from the Chart.js documentation) and the g

11条回答
  •  难免孤独
    2020-12-08 10:09

    This should work. Basically, just add the width and height properties to your javascript:

    var ctx = document.getElementById("myChart").getContext("2d");
    ctx.canvas.width = 200;
    ctx.canvas.height = 200;
    var myChart = new Chart(ctx,.........
    

    Reference: Chart.js canvas resize

提交回复
热议问题