How can I increase the size of the pie (Chart.JS)?

后端 未结 1 1106
你的背包
你的背包 2021-02-19 23:40

I\'m generating a pie chart with legend that looks like so:

As you can perceive, the pie is pitifully puny. I prefer it to be twice as tall and twice as wide.

1条回答
  •  南笙
    南笙 (楼主)
    2021-02-20 00:01

    You just need to change the canvas size.

    When you are creating the chart you can specify it right in the element:

    Or if you prefer to do it in javascript

    var ctx = $("#top10ItemsChart").get(0).getContext("2d");
    ctx.width = 1000;
    ctx.height = 1000;
    

    If the resizing doesn't work as you wish, you can also try setting the maintainAspectRatio option to false:

    var optionsPie = {
        /** ... */
        responsive: true,
        maintainAspectRatio: false,
        /** ... */
    };
    

    Hope it helps.

    0 讨论(0)
提交回复
热议问题