• <tfoot id='igxrB'></tfoot>

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

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

        <i id='igxrB'><tr id='igxrB'><dt id='igxrB'><q id='igxrB'><span id='igxrB'><b id='igxrB'><form id='igxrB'><ins id='igxrB'></ins><ul id='igxrB'></ul><sub id='igxrB'></sub></form><legend id='igxrB'></legend><bdo id='igxrB'><pre id='igxrB'><center id='igxrB'></center></pre></bdo></b><th id='igxrB'></th></span></q></dt></tr></i><div id='igxrB'><tfoot id='igxrB'></tfoot><dl id='igxrB'><fieldset id='igxrB'></fieldset></dl></div>
      1. <legend id='igxrB'><style id='igxrB'><dir id='igxrB'><q id='igxrB'></q></dir></style></legend>
      2. 悬停在chartjs饼图上时画布填充文本消失

        canvas fill text vanishes when hovering over chartjs pie chart(悬停在chartjs饼图上时画布填充文本消失)

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

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

      4. <legend id='ASLyV'><style id='ASLyV'><dir id='ASLyV'><q id='ASLyV'></q></dir></style></legend>
        • <bdo id='ASLyV'></bdo><ul id='ASLyV'></ul>

              <tfoot id='ASLyV'></tfoot>

                  本文介绍了悬停在chartjs饼图上时画布填充文本消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在使用来自 chartjs 的圆环图,在此画布的中心我填充了两行文本.这些在初始动画之后显示得很好,但是当我将鼠标悬停在甜甜圈上时,会显示相关元素的工具提示(这是预期的),但填充文本消失了.为什么会发生这种情况以及我该如何纠正它?

                  I am using a doughnut chart from chartjs, and in the center of this canvas I am filling two lines of text. These show up fine after the initial animation, but when I hover over the doughnut, a tool tip shows up for the relevant element (which is expected), but the fill text vanishes. Any reason why this might be happening and how I can rectify it ?

                  这是我用来在画布上生成文本的代码

                  here is the code I am using to generate the text on the canvas

                  var pieChart = document.getElementById("pieChart").getContext("2d");
                  new Chart(pieChart).Doughnut(pieData, {percentageInnerCutout : 80, animationEasing: "easeOutQuart", onAnimationComplete: function() {
                          pieChart.fillStyle = 'black'
                          pieChart.font = "50px Roboto";
                          pieChart.textAlign = "center";
                          pieChart.fillText(distributionChartData[3]+" %", 135, 120);
                          pieChart.font = "20px Roboto";
                          pieChart.fillText((distributionChartData[0]+distributionChartData[1]+distributionChartData[2])+" Responses", 135, 160);
                      }
                  });
                  

                  这是初始加载后图表的图像

                  Here is an image of the chart after initial load

                  这是悬停后的图像

                  推荐答案

                  实际上,您可以通过简单扩展您正在使用的图表类型并将绘制代码移动到绘制覆盖内部来做到这一点

                  Actually you can do this with a simple extension of the chart type you are using and moving your draw code to inside the draw override

                  预览

                  代码

                  Chart.types.Doughnut.extend({
                      name: "DoughnutAlt",
                      draw: function () {
                          Chart.types.Doughnut.prototype.draw.apply(this, arguments);
                  
                          this.chart.ctx.textBaseline = "middle";
                          this.chart.ctx.fillStyle = 'black'
                          this.chart.ctx.font = "50px Roboto";
                          this.chart.ctx.textAlign = "center";
                          this.chart.ctx.fillText(distributionChartData[3] + " %", 135, 120);
                          this.chart.ctx.font = "20px Roboto";
                          this.chart.ctx.fillText((distributionChartData[0] + distributionChartData[1] + distributionChartData[2]) + " Responses", 135, 160);
                      }
                  });
                  
                  var pieChart = document.getElementById("pieChart").getContext("2d");
                  new Chart(pieChart).DoughnutAlt(pieData, {
                      percentageInnerCutout: 80, animationEasing: "easeOutQuart"
                  });
                  

                  <小时>

                  小提琴 - http://jsfiddle.net/p979zyLj/

                  这篇关于悬停在chartjs饼图上时画布填充文本消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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 栏中隐藏值)
                • <small id='QDC3a'></small><noframes id='QDC3a'>

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

                    1. <legend id='QDC3a'><style id='QDC3a'><dir id='QDC3a'><q id='QDC3a'></q></dir></style></legend>

                            <tbody id='QDC3a'></tbody>