简体   繁体   English

如何从Google Chart Timeline隐藏条形标签

[英]How to hide bar labels from Google Chart Timeline

I'm trying to remove labels(c1,c2,c3,c4) from my bars. 我正在尝试从我的酒吧中删除标签(c1,c2,c3,c4)。

I tried styling with: timeline: {barLabelStyle: ...} but nothing works for me (I thought about set font color to color of bar, but docs says ,,You can't set the color of barLabel text." 我尝试使用以下方式进行样式设置: timeline: {barLabelStyle: ...}但对我没有任何帮助(我曾考虑过将字体颜色设置为bar颜色,但是文档说,您不能设置barLabel文本的颜色。”

jsfiddle: https://jsfiddle.net/550wb2t0/1/ jsfiddle: https ://jsfiddle.net/550wb2t0/1/

You can use --> timeline: { showBarLabels: false } 您可以使用-> timeline: { showBarLabels: false }

 google.charts.load('44', { callback: drawChart, packages: ['timeline'] }); function drawChart() { var data = google.visualization.arrayToDataTable([ ['Activity', 'Category', 'Start Time', 'End Time'], ['Sleep', 'c1', new Date(2014, 10, 15, 12, 30, 0, 120), new Date(2014, 10, 15, 14, 30, 20, 550) ], ['Eat Breakfast', 'c2', new Date(2014, 10, 15, 12, 30, 55), new Date(2014, 10, 15, 14, 31, 55) ], ['Commute Home', 'c3', new Date(2014, 10, 15, 12, 29, 30), new Date(2014, 10, 15, 14, 30, 0) ], ['Commute Home', 'c4', new Date(2014, 10, 15, 14, 30), new Date(2014, 10, 15, 18) ] ]); var colors = []; var colorMap = { // should contain a map of category -> color for every category c1: '#e63b6f', c2: '#19c362', c3: '#592df7', c4: '#000000' } for (var i = 0; i < data.getNumberOfRows(); i++) { colors.push(colorMap[data.getValue(i, 1)]); } console.log(JSON.stringify(colors)); var options = { height: 450, colors: colors, timeline: { showBarLabels: false } }; var chart = new google.visualization.Timeline(document.getElementById('chart_div')); chart.draw(data, options); } 
 <script src="https://www.gstatic.com/charts/loader.js"></script> <div id="chart_div"></div> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM