gpt4 book ai didi

javascript - Google Chart 无法为水平轴 (hAxis) 着色

转载 作者:太空狗 更新时间:2023-10-29 16:35:26 25 4
gpt4 key购买 nike

不知何故,我无法为水平轴的文本着色。这是我为选项设置的:

var options = {
colors: ['#B20054', '#993D69', '#BD00FF', '#FFFE40', '#CCB814', '#998F3D', '#40B2FF'],
timeline: { colorByRowLabel: true, rowLabelStyle: { fontSize: 9, color: '#603913' },
barLabelStyle: { fontSize: 9 } }
hAxis: {
textStyle:{color: '#FFF'}
}
};

截图:

Screenshot problem

完整代码:

var container = document.getElementById('timetracking_Dennis');
var chart = new google.visualization.Timeline(container);
var dataTable = new google.visualization.DataTable();

dataTable.addColumn({ type: 'string', id: 'Term' });
dataTable.addColumn({ type: 'string', id: 'Name' });
dataTable.addColumn({ type: 'date', id: 'Start' });
dataTable.addColumn({ type: 'date', id: 'End' });

dataTable.addRows([
[ '#5700', 'Vernieuwing wifi-netwerk', new Date(0,0,0,10,16,0), new Date(0,0,0,10,17,0) ],
[ '#5704', 'Account Mike Hees', new Date(0,0,0,10,23,0), new Date(0,0,0,10,28,0) ],
[ '#5798', 'Laptop Bas van der Beer traag', new Date(0,0,0,10,15,0), new Date(0,0,0,11,14,0) ],
[ '#5832', 'Problemen iMac', new Date(0,0,0,11,24,0), new Date(0,0,0,11,25,0) ],
[ '#5832', 'Problemen iMac', new Date(0,0,0,11,34,0), new Date(0,0,0,11,35,0) ],
[ '#5856', 'Problemen iMac', new Date(0,0,0,17,28,0), new Date(0,0,0,18,0,0) ],
[ '#5856', 'Internet Broekseweg', new Date(0,0,0,9,14,0), new Date(0,0,0,9,15,0) ],
[ '#5856', 'Internet Broekseweg', new Date(0,0,0,9,0,0), new Date(0,0,0,10,0,0) ],
[ '#5856', 'Internet Broekhovenseweg', new Date(0,0,0,16,2,0), new Date(0,0,0,16,12,0) ],
[ '#5857', 'gebruiker Abdel issues met opstarten', new Date(0,0,0,11,37,0), new Date(0,0,0,11,38,0) ],
[ '#5895', 'Printer uit flexplek halen', new Date(0,0,0,11,9,0), new Date(0,0,0,11,17,0) ]
]);

var options = {
colors: ['#B20054', '#993D69', '#BD00FF', '#FFFE40', '#CCB814', '#998F3D', '#40B2FF'],
timeline: { colorByRowLabel: true, rowLabelStyle: { fontSize: 9, color: '#603913' },
barLabelStyle: { fontSize: 9 } }
};

chart.draw(dataTable, options);

最佳答案

有一个非常肮脏的 hack 可以用来给 X 轴着色。

时间轴的 svg 包含许多 <text>元素。这些包括 X 轴上的数字。

如果您找到 <svg>图表的元素,并将其分配给名为 svg 的变量,您可以执行以下操作:

svg.find('[font-size="13"]').attr('fill', '#ffffff');

假设您要将 X 轴涂成白色。

这只适用于您的特定情况,因为您已经更改了 rowLabelStyle .默认情况下,行标签也有 font-size="13" .

关于javascript - Google Chart 无法为水平轴 (hAxis) 着色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33038815/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com