• <bdo id='ZGMfp'></bdo><ul id='ZGMfp'></ul>

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

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

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

        如何通过鼠标悬停和多个更新解决 Chart.js 2.0 问题?

        时间:2023-11-01

        1. <tfoot id='fKxgw'></tfoot>

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

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

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

                1. 本文介绍了如何通过鼠标悬停和多个更新解决 Chart.js 2.0 问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  Very strange, I have a Chart.js chart that I need to update dinamically. The update works fine, but if you move the mouse over the chart or click several times the button Update (Add data), the bars and the lines disappear and in the console shows this error:

                  Uncaught TypeError: Cannot read property 'draw' of null
                  

                  Please click on the button several times, you can test it slowly or quickly. Pass the mouse over chart too after click the "Add data" button.

                  You can test this at: https://jsfiddle.net/s9zraysh/

                  How can I avoid this error?

                  解决方案

                  It is because you mixed up the functions to create a chart and add more data. Fixed it by separating them as shown below.

                  var canvas = document.getElementById("canvasChart");
                  var $chart;
                  function createChart(ID) {
                    console.log(canvas);
                    console.log(chartsParams);
                    $chart = new Chart(canvas, chartsParams['myChart']);
                  }
                  
                  function addData() {
                    $chart.data.datasets.push({
                      label: 'Added',
                      data: [12, 32, 43, 53]
                    });
                    $chart.update();
                  }
                  
                  createChart();
                  document.getElementById("addButton").addEventListener("click", addData);
                  

                  demo here : https://jsfiddle.net/es0kt36e/2/

                  这篇关于如何通过鼠标悬停和多个更新解决 Chart.js 2.0 问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Vuejs上下文中chartjs的闪烁图表和getcontext错误 下一篇:Chart.js 图片在甜甜圈段内

                  相关文章

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

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

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