【发布时间】:2019-10-16 14:38:48
【问题描述】:
我正在使用 react google 时间线图来显示数据。
我想要标签背景,例如: Thomas Jefferson -> 红色,George Washington -> 绿色,John Jay -> 黄色,John Adams -> 橙色
我正在使用图表的颜色选项,例如:
options={{
colors: ['red', 'orange', 'yellow', 'green'],
}}
我的图表代码如下:
<Chart
width={'100%'}
height={'400px'}
chartType="Timeline"
loader={<div>Loading Chart</div>}
data={[
[
{ type: 'string', id: 'Position' },
{ type: 'string', id: 'Name' },
{ type: 'date', id: 'Start' },
{ type: 'date', id: 'End' },
],
[
'President',
'George Washington',
new Date(2019, 2, 4),
new Date(2019, 3, 30),
],
[
'President',
'Thomas Jefferson',
new Date(2019, 2, 4),
new Date(2019, 4, 4),
],
[
'Vice President',
'John Adams',
new Date(2019, 3, 21),
new Date(2019, 6, 4),
],
[
'Secretary of State',
'John Jay',
new Date(2019, 5, 4),
new Date(2019, 8, 20),
],
[
'President',
'John Adams',
new Date(2019, 2, 25),
new Date(2019, 8, 22),
],
[
'Vice President',
'George Washington',
new Date(2019, 7, 22),
new Date(2019, 11, 31),
],
]}
options={{
colors: ['red', 'orange', 'yellow', 'green'],
}}
rootProps={{ 'data-testid': '7' }}
/>
有人可以帮忙吗?提前致谢。
【问题讨论】:
-
使用选项 = {{ 颜色: ['#FF0000', '#FFA500', '#FFFF00', '#00FF00'], }};
-
感谢您的回复。试过这个但没有用。顺便说一句,我找到了解决方案。
标签: reactjs google-visualization