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

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

        数据被过滤chartJs时如何保持圆角?

        How to keep rounded bar corners when data is filtered chartJs?(数据被过滤chartJs时如何保持圆角?)
        <tfoot id='8xGne'></tfoot>
          • <i id='8xGne'><tr id='8xGne'><dt id='8xGne'><q id='8xGne'><span id='8xGne'><b id='8xGne'><form id='8xGne'><ins id='8xGne'></ins><ul id='8xGne'></ul><sub id='8xGne'></sub></form><legend id='8xGne'></legend><bdo id='8xGne'><pre id='8xGne'><center id='8xGne'></center></pre></bdo></b><th id='8xGne'></th></span></q></dt></tr></i><div id='8xGne'><tfoot id='8xGne'></tfoot><dl id='8xGne'><fieldset id='8xGne'></fieldset></dl></div>

            <legend id='8xGne'><style id='8xGne'><dir id='8xGne'><q id='8xGne'></q></dir></style></legend>
                <tbody id='8xGne'></tbody>

              1. <small id='8xGne'></small><noframes id='8xGne'>

                  <bdo id='8xGne'></bdo><ul id='8xGne'></ul>

                  本文介绍了数据被过滤chartJs时如何保持圆角?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想出了这个 JSFiddle:

                  I came up with this JSFiddle : https://www.jsfiddle.net/gcb1dyou which has rounded chartJs bar corners.Problem is when legend clicked to filter data,corners disappear like below

                  当我点击橙色标签时,你可以看到黄色条上的圆形边框消失了.

                  When I clicked orange label as you can see rounded border disappeared on the yellow bar.

                  var lastVisible = 0;
                  for (var findLast = 0, findLastTo = this._chart.data.datasets.length; findLast < findLastTo; findLast++) {
                  if (!this._chart.getDatasetMeta(findLast).hidden) {
                    lastVisible = findLast;
                    if (this._chart.data.datasets[findLastTo - 1].data[this._index] == 0) {
                      lastVisible -= 1;
                    }
                  }
                  

                  }在这里,我尝试添加另一个 if 以使 lastVisible findLast-1 当数据被隐藏(图例单击)并且先前的索引为空但不起作用时

                  } Here I tried to add another if to make lastVisible findLast-1 when data is hidden(legend clicked) and previous index is null but didn't work

                  else{
                            if(this._chart.data.datasets[findLastTo - 1].data[this._index] == 0){
                              lastVisible=findLastTo-2;
                            }
                          }
                  

                  我该如何解决这个问题?期待看到你的答案.

                  How can I solve this?Expecting to see your answers.

                  推荐答案

                  我通过动态计算数据集的深度解决了这个问题.感谢回答

                  I fixed this problem by calculating the depth of dataset dynamically.Thanks for answers

                   var lastVisible;
                    var datasetsLength = this._chart.data.datasets.length;
                    this._chart.data.datasets.map((e,index)=>{
                      lastVisible=datasetsLength-1;
                      //to find the depth of datasets and get non-zero value
                      for(var i=lastVisible;i>0;i--){
                      if(!this._chart.getDatasetMeta(i).hidden){
                        if(this._chart.data.datasets[i].data[this._index] != 0){
                          lastVisible = i;
                          break;
                        }
                      }
                      } 
                    })
                  

                  这篇关于数据被过滤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 栏中隐藏值)
                • <i id='JJ0Mx'><tr id='JJ0Mx'><dt id='JJ0Mx'><q id='JJ0Mx'><span id='JJ0Mx'><b id='JJ0Mx'><form id='JJ0Mx'><ins id='JJ0Mx'></ins><ul id='JJ0Mx'></ul><sub id='JJ0Mx'></sub></form><legend id='JJ0Mx'></legend><bdo id='JJ0Mx'><pre id='JJ0Mx'><center id='JJ0Mx'></center></pre></bdo></b><th id='JJ0Mx'></th></span></q></dt></tr></i><div id='JJ0Mx'><tfoot id='JJ0Mx'></tfoot><dl id='JJ0Mx'><fieldset id='JJ0Mx'></fieldset></dl></div>

                        <tbody id='JJ0Mx'></tbody>
                    • <small id='JJ0Mx'></small><noframes id='JJ0Mx'>

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

                            <tfoot id='JJ0Mx'></tfoot>