本文介绍了谷歌图表(材料) - 类型栏 - 在角色风格KO arrayToDataTable中的数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我想通过arrayToDataTable中提供的选项来使用google条形图(材质设计)来自定义栏的颜色。 示例: return google.visualization.arrayToDataTable([ ['1','2',{角色:'style'}], ['1',1000,'#000000'], ['2',1170,'#000000'], ['3' ,660,'#000000'], ['4',1030,'#000000'] ]); 正如您所看到的,如果我引用文档,栏应该是黑色。 不是。此外,这第三列不会被添加(所以有些东西会将其作为一个角色来捕获它,但不会执行相关的行为)。 我看到了多个主题尽管如此,他们仍在使用旧包装(不是材料设计)。 感谢您的帮助。 更新1: 替换#00000 颜色到#000000 (没有解决问题,写这个例子时我忘了0) 解决方案不幸的是,专栏 与材质不兼容图表 以及几个配置选项 建议使用 core 图表 是一个配置选项,它将核心图表设置为 material 主题:'材料' 但不准确,请参阅以下工作片段... google.charts.load('current',{callback:drawChart,packages:['corechart']}); function drawChart(transparent ){var data = google.visualization.arrayToDataTable([['1','2',{role:'style'}],['1',1000,'#000000'],['2',1170, '#000000'],['3',660,'#000000 ],[ 4’ ,1030,#000000’ ]]); var options = {legend:'none',theme:'material'}; var chartDiv = document.getElementById('chart_div'); var chart = new google.visualization.ColumnChart(chartDiv); chart.draw(data,options);} < script>< / div>< / script>同样,黑色的样式列值应该有6个零点,而黑色的样式列值应该有6个零点,而 5 - > '#000000' VS。 - > '#00000' I want to use a google bar chart (material design) with the options provided in the arrayToDataTable to customize the color of the bar.Example: return google.visualization.arrayToDataTable([ ['1', '2', {role: 'style'}], ['1', 1000, '#000000'], ['2', 1170, '#000000'], ['3', 660, '#000000'], ['4', 1030, '#000000'] ]);As you can see, if I refer to the documentation, the bar should be in black.It is not.Moreover, this third column is not added (so something catch it as an role, but do not execute associated behavior).I saw multiples topics about it nevertheless they were working with old packages (not material design).Thanks for the help guys.Update 1: Replaced #00000 color to #000000 (doesn't solve the problem, I just forgot a 0 when writing this example) 解决方案 unfortunately, column roles do not work with material charts along with several configuration options recommend using core chart instead there is a configuration option that will style a core chart as material theme: 'material'but it's not exact, see following working snippet... google.charts.load('current', { callback: drawChart, packages: ['corechart']});function drawChart(transparent) { var data = google.visualization.arrayToDataTable([ ['1', '2', {role: 'style'}], ['1', 1000, '#000000'], ['2', 1170, '#000000'], ['3', 660, '#000000'], ['4', 1030, '#000000'] ]); var options = { legend: 'none', theme: 'material' }; var chartDiv = document.getElementById('chart_div'); var chart = new google.visualization.ColumnChart(chartDiv); chart.draw(data, options);}<script src="https://www.gstatic.com/charts/loader.js"></script><div id="chart_div"></div>also, the style column value for black should have six zeroes vs. five --> '#000000' vs. --> '#00000' 这篇关于谷歌图表(材料) - 类型栏 - 在角色风格KO arrayToDataTable中的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-29 08:42