时间线谷歌图表:删除行内的文本/标签

问题描述

我正在使用按行标签时间线分组的谷歌图表模型,我想删除每行内显示的文本。这是现在的样子:

time line

这是我的代码html/脚本代码

window.onload = function() { 
        google.charts.load("current",{packages:["timeline"]});
        google.charts.setonLoadCallback(drawChart);
    }; 
    function drawChart() {
        window.myChart = new google.visualization.Timeline(document.getElementById('timeline'));
        window.dataTable = new google.visualization.DataTable();

        window.dataTable.addColumn({ type: 'string',id: 'Role' });
        window.dataTable.addColumn({ type: 'string',id: 'Name' });
        window.dataTable.addColumn({ type: 'date',id: 'Start' });
        window.dataTable.addColumn({ type: 'date',id: 'End' });
        window.dataTable.addRows([]);

        window.options = {
        //increase font size to make timeline more bigger
          timeline: {groupByRowLabel: true,showRowLabels: false,rowLabelStyle: {fontSize: 50},barLabelStyle: {fontSize: 50}},backgroundColor: '#000'
        };
window.myChart.draw(window.dataTable,window.options);
      }

这是在 JS 文件中设置的:

var _reloadCallback = function (info) {
    window.dataTable.removeRows(0,window.dataTable.getNumberOfRows())
    var rows = []   
    //Join datettimearrays
    window.arrayDatetimes = window.arrayDatetimes1.concat(window.arrayDatetimes2,window.arrayDatetimes3,window.arrayDatetimes4,window.arrayDatetimes5,window.arrayDatetimes6,window.arrayDatetimes7,window.arrayDatetimes8,window.arrayDatetimes9,window.arrayDatetimES10).split(",");
    for (var i = 0; i < window.arrayValues.length; i++) {
        var row = []
        row.push("Interval")
        row.push(window.arrayValues[i])
        row.push ( new Date(window.arrayDatetimes[i]))
        row.push ( new Date(window.arrayDatetimes[i+1]))
        rows.push(row)
    }
    window.dataTable.addRows(rows)
    window.myChart.draw(window.dataTable,window.options);
};

我已尝试删除名称”列,但随后时间线未按行分组并显示不止一行。有什么想法吗?

解决方法

我自己回答。 只需将 showBarLabels 设置为 false 即可解决我的问题。