<tfoot id='GaACN'></tfoot>

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

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

      <legend id='GaACN'><style id='GaACN'><dir id='GaACN'><q id='GaACN'></q></dir></style></legend>
          <bdo id='GaACN'></bdo><ul id='GaACN'></ul>

        如何在 Chart.js 中隐藏特定数据标签上的工具提示?

        How can I hide tooltip in Chart.js on a specific data label?(如何在 Chart.js 中隐藏特定数据标签上的工具提示?)
        <tfoot id='NNPdh'></tfoot>
      1. <i id='NNPdh'><tr id='NNPdh'><dt id='NNPdh'><q id='NNPdh'><span id='NNPdh'><b id='NNPdh'><form id='NNPdh'><ins id='NNPdh'></ins><ul id='NNPdh'></ul><sub id='NNPdh'></sub></form><legend id='NNPdh'></legend><bdo id='NNPdh'><pre id='NNPdh'><center id='NNPdh'></center></pre></bdo></b><th id='NNPdh'></th></span></q></dt></tr></i><div id='NNPdh'><tfoot id='NNPdh'></tfoot><dl id='NNPdh'><fieldset id='NNPdh'></fieldset></dl></div>
        <legend id='NNPdh'><style id='NNPdh'><dir id='NNPdh'><q id='NNPdh'></q></dir></style></legend>

                <tbody id='NNPdh'></tbody>
              • <bdo id='NNPdh'></bdo><ul id='NNPdh'></ul>

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

                  本文介绍了如何在 Chart.js 中隐藏特定数据标签上的工具提示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我试图在 Chart.js 中隐藏工具提示单击的对象是某物".我已经尝试过了:

                  I am trying to hide a tooltip in Chart.js whenever the name of a clicked object is "Something". I have already tried this:

                    this.doughnutChart = new Chart(this.doughnutCanvas.nativeElement, {
                    type: 'doughnut',
                    data: {
                      datasets: [{
                        label: _.map(this.dataService.AmTimeSlots, 'ProjectName'),
                        data: _.map(this.dataService.AmTimeSlots, 'Duration'),
                        backgroundColor: _.map(this.dataService.AmTimeSlots, 'Color'),
                        hoverBackgroundColor: _.map(this.dataService.AmTimeSlots, 'HoverColor'),
                        borderColor: _.map(this.dataService.AmTimeSlots, 'BorderColor'),
                        borderWidth: 1.5
                      },
                      {
                        label: _.map(this.dataService.PmTimeSlots, 'ProjectName'),
                        data: _.map(this.dataService.PmTimeSlots, 'Duration'),
                        backgroundColor: _.map(this.dataService.PmTimeSlots, 'Color'),
                        hoverBackgroundColor: _.map(this.dataService.PmTimeSlots, 'HoverColor'),
                        borderColor: _.map(this.dataService.PmTimeSlots, 'BorderColor'),
                        borderWidth: 1.5
                      }],
                    },
                    options: {
                      elements: {
                        arc: {
                          roundedCornersFor: 0
                        }
                      },
                      segmentShowStroke: false,
                      responsive: true,
                      maintainAspectRatio: true,
                      legend: {
                        display: false
                      },
                      onClick: this.chartClick.bind(this),
                      cutoutPercentage: 65,
                      tooltips: {
                        filter: function (tooltipItem) {
                          if (tooltipItem.xLabel == "Free Slot") {
                            return false;
                          } else {
                            return true;
                          }
                        },
                        callbacks: {
                          label: function (tooltipItems, data) {
                          return data.datasets[tooltipItems.datasetIndex].label[tooltipItems.index];
                          },
                          afterLabel: function (tooltipItems, data) {
                          return Math.floor(data.datasets[tooltipItems.datasetIndex].data[tooltipItems.index] / 6) + 'h ' + data.datasets[tooltipItems.datasetIndex].data[tooltipItems.index] * 10 % 60 + 'm';
                          }
                        }
                      }
                    },
                    config: {
                      data: this.dataService,
                      settings: this.settingsService
                    }
                  });
                  

                  上面的代码运行良好.它成功隐藏了工具提示的文本,但问题是黑色标签/边框仍然存在.怎么隐藏?

                  And this code above is working fine. It’s successfully hiding the text of tooltip, but the problem is that the black label/border still remains. How can I hide it?

                  推荐答案

                  你可以简单过滤器 工具提示:

                  You can simply filter tooltips:

                  options: {
                      tooltips: {
                         filter: function (tooltipItem, data) {
                             var label = data.labels[tooltipItem.index];
                             if (label == "Red") {
                               return false;
                             } else {
                               return true;
                             }
                         }
                      }
                  }
                  

                  查看这个 jsfiddle:https://jsfiddle.net/beaver71/ndc2uao2/

                  See this jsfiddle: https://jsfiddle.net/beaver71/ndc2uao2/

                  这篇关于如何在 Chart.js 中隐藏特定数据标签上的工具提示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  在开发JS过程中,会经常遇到两个小数相运算的情况,但是运算结果却与预期不同,调试一下发现计算结果竟然有那么长一串尾巴。如下图所示: 产生原因: JavaScript对小数运算会先转成二进制,运算完毕再转回十进制,过程中会有丢失,不过不是所有的小数间运算会
                  问题描述: 在javascript中引用js代码,然后导致反斜杠丢失,发现字符串中的所有\信息丢失。比如在js中引用input type=text onkeyup=value=value.replace(/[^\d]/g,) ,结果导致正则表达式中的\丢失。 问题原因: 该字符串含有\,javascript对字符串进行了转
                  Rails/Javascript: How to inject rails variables into (very) simple javascript(Rails/Javascript:如何将 rails 变量注入(非常)简单的 javascript)
                  CoffeeScript always returns in anonymous function(CoffeeScript 总是以匿名函数返回)
                  Ordinals in words javascript(javascript中的序数)
                  getFullYear returns year before on first day of year(getFullYear 在一年的第一天返回前一年)
                  <legend id='YisZz'><style id='YisZz'><dir id='YisZz'><q id='YisZz'></q></dir></style></legend>
                      <bdo id='YisZz'></bdo><ul id='YisZz'></ul>
                      <i id='YisZz'><tr id='YisZz'><dt id='YisZz'><q id='YisZz'><span id='YisZz'><b id='YisZz'><form id='YisZz'><ins id='YisZz'></ins><ul id='YisZz'></ul><sub id='YisZz'></sub></form><legend id='YisZz'></legend><bdo id='YisZz'><pre id='YisZz'><center id='YisZz'></center></pre></bdo></b><th id='YisZz'></th></span></q></dt></tr></i><div id='YisZz'><tfoot id='YisZz'></tfoot><dl id='YisZz'><fieldset id='YisZz'></fieldset></dl></div>
                        <tfoot id='YisZz'></tfoot>

                          <tbody id='YisZz'></tbody>

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