• <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时如何保持圆角?

        时间:2023-11-02
        <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 图表未在选项卡中生成 下一篇:无法使图表 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>

                  1. <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>