Google对Barchart的反应图表计数彼此崩溃

问题描述

chartEvents = {
  [{
    eventName: "ready",callback: ({
      chartWrapper,google
    }) => {
      if (this.props.showCountForStudentReport) {
        google.charts.setonLoadCallback(drawChart);
      }

      function drawChart() {
        var data = google.visualization.arrayToDataTable(dataToRender);

        var view = new google.visualization.DataView(data);

        view.setColumns([0,1,{
            calc: function(dt,row) {
              if (dt.getValue(row,1) !== 0) {
                return dt.getValue(row,1);
              } else {
                return null;
              }

            },type: "number",role: "annotation"
          },2,2) !== 0) {
                return dt.getValue(row,2);
              } else {
                return null;
              }
            },3,3) !== 0) {
                return dt.getValue(row,3);
              } else {
                return null;
              }
            },4,4) !== 0) {
                return dt.getValue(row,4);
              } else {
                return null;
              }
            },5,5) !== 0) {
                return dt.getValue(row,5);
              } else {
                return null;
              }
            },row) {
              return 0;
            },// label: "Total",},row) {
              let first = dt.getValue(row,1),second = dt.getValue(row,2),third = dt.getValue(row,3),fourth = dt.getValue(row,4),fifth = dt.getValue(row,5);
              if (dt.getValue(row,1) === 0) {
                first = null;
              }
              if (dt.getValue(row,2) === 0) {
                second = null;
              }
              if (dt.getValue(row,3) === 0) {
                third = null;
              }
              if (dt.getValue(row,4) === 0) {
                fourth = null;
              }
              if (dt.getValue(row,5) === 0) {
                fifth = null;
              }
              return first + second + third + fourth + fifth;
            },role: "annotation"
          }
        ]);

        var chart = new google.visualization.BarChart(document.getElementById("myIdForBarChart"));
        chart.draw(view,optionsForBarChart);
      }
    }
  }]
}

image

我有多个学生入学计数,日期取决于他们的州,不同颜色的图例代表一个学生相对于州的计数,但是当计数较少时,与xAxis计数相比就会相互冲突。 (显示在日期为2020-09-04的图像中)

在callBack中,我使用了view.setColumns方法显示计数。

如何解决此问题?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...