1. <small id='Fsptz'></small><noframes id='Fsptz'>

      <legend id='Fsptz'><style id='Fsptz'><dir id='Fsptz'><q id='Fsptz'></q></dir></style></legend>
    2. <i id='Fsptz'><tr id='Fsptz'><dt id='Fsptz'><q id='Fsptz'><span id='Fsptz'><b id='Fsptz'><form id='Fsptz'><ins id='Fsptz'></ins><ul id='Fsptz'></ul><sub id='Fsptz'></sub></form><legend id='Fsptz'></legend><bdo id='Fsptz'><pre id='Fsptz'><center id='Fsptz'></center></pre></bdo></b><th id='Fsptz'></th></span></q></dt></tr></i><div id='Fsptz'><tfoot id='Fsptz'></tfoot><dl id='Fsptz'><fieldset id='Fsptz'></fieldset></dl></div>
        • <bdo id='Fsptz'></bdo><ul id='Fsptz'></ul>
        <tfoot id='Fsptz'></tfoot>
      1. Chart.js 忽略画布高度和宽度

        时间:2023-11-02

        <small id='Mzpbz'></small><noframes id='Mzpbz'>

        <legend id='Mzpbz'><style id='Mzpbz'><dir id='Mzpbz'><q id='Mzpbz'></q></dir></style></legend>

                <tbody id='Mzpbz'></tbody>
              <i id='Mzpbz'><tr id='Mzpbz'><dt id='Mzpbz'><q id='Mzpbz'><span id='Mzpbz'><b id='Mzpbz'><form id='Mzpbz'><ins id='Mzpbz'></ins><ul id='Mzpbz'></ul><sub id='Mzpbz'></sub></form><legend id='Mzpbz'></legend><bdo id='Mzpbz'><pre id='Mzpbz'><center id='Mzpbz'></center></pre></bdo></b><th id='Mzpbz'></th></span></q></dt></tr></i><div id='Mzpbz'><tfoot id='Mzpbz'></tfoot><dl id='Mzpbz'><fieldset id='Mzpbz'></fieldset></dl></div>
              • <bdo id='Mzpbz'></bdo><ul id='Mzpbz'></ul>
                <tfoot id='Mzpbz'></tfoot>

                  本文介绍了Chart.js 忽略画布高度和宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  遵循 Chart.js 文档我正在尝试绘制一个小图表:

                  Following the Chart.js documentation I am trying to draw a small chart:

                  <canvas id="myChart" width="400" height="400"></canvas>
                  <script>
                  var ctx = document.getElementById("myChart");
                  var myChart = new Chart(ctx, {
                    type: 'line',
                    data: {
                      labels:['15-2016','16-2016','17-2016',],
                      datasets:[
                        {
                          label:'Yes',
                          data:[3.4884,1.1628,1.3514,],
                          backgroundColor:'rgba(75,192,192,1)',
                          borderColor:'rgba(75,192,192,1)',
                          pointRadius:0
                        },
                        {
                          label:'Maybe',
                          data:[0.5571,1.3298,0.791,],
                          backgroundColor:'rgba(255,206,86,1)',
                          borderColor:'rgba(255,206,86,1)',
                          pointRadius:0
                        },
                        {
                          label:'No',
                          data:[0,0,0,],
                          backgroundColor:'rgba(255,99,132,1)',
                          borderColor:'rgba(255,99,132,1)',
                          pointRadius:0
                        }
                      ]
                    }        
                  });
                  </script>
                  

                  但是,当页面被渲染时,画布会以某种方式变成

                  However, when the page is rendered the canvas somehow becomes

                  <canvas style="height: 929px; width: 929px;" id="myChart" width="1858" height="1858"></canvas>
                  

                  这对我的需要来说太大了.如何将画布的宽度和高度设置为我想要的?

                  which is waaaaay too big for my needs. How can I set the width and height of the canvas to be what I want?

                  推荐答案

                  我可以通过关闭响应来硬编码图表的大小:

                  I was able to hardcode the size of the graph by turning off responsiveness:

                  options: {
                    responsive: false
                  }
                  

                  这篇关于Chart.js 忽略画布高度和宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何在 Chart.js 中为条形设置默认颜色 下一篇:使用 ChartJS 单击更改点颜色

                  相关文章

                    <small id='SmH6Z'></small><noframes id='SmH6Z'>

                    • <bdo id='SmH6Z'></bdo><ul id='SmH6Z'></ul>
                    <i id='SmH6Z'><tr id='SmH6Z'><dt id='SmH6Z'><q id='SmH6Z'><span id='SmH6Z'><b id='SmH6Z'><form id='SmH6Z'><ins id='SmH6Z'></ins><ul id='SmH6Z'></ul><sub id='SmH6Z'></sub></form><legend id='SmH6Z'></legend><bdo id='SmH6Z'><pre id='SmH6Z'><center id='SmH6Z'></center></pre></bdo></b><th id='SmH6Z'></th></span></q></dt></tr></i><div id='SmH6Z'><tfoot id='SmH6Z'></tfoot><dl id='SmH6Z'><fieldset id='SmH6Z'></fieldset></dl></div>
                    <tfoot id='SmH6Z'></tfoot><legend id='SmH6Z'><style id='SmH6Z'><dir id='SmH6Z'><q id='SmH6Z'></q></dir></style></legend>