• <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 问题?

        How to solve a Chart.js 2.0 issue with mouseover and several updates?(如何通过鼠标悬停和多个更新解决 Chart.js 2.0 问题?)

        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 问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  ChartJS Version 3 - common legend for multiple line charts(ChartJS 版本 3 - 多个折线图的常用图例)
                  Charts.js scales yaxes ticks min max doesnt work(Charts.js 缩放 yaxes 刻度 min max 不起作用)
                  How to expand the slice of donut chart in chartjs?(如何在chartjs中扩展圆环图的切片?)
                  Chart.js yAxes Ticks stepSize not working (fiddle)(Chart.js yAxes Ticks stepSize 不起作用(小提琴))
                  Rounded corners on chartJS v.2 - bar charts (with negative values)(chartJS v.2 上的圆角 - 条形图(带负值))
                  How to hide value in Chart JS bar(如何在 Chart JS 栏中隐藏值)

                          <tbody id='VgM4Z'></tbody>
                          <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'>