Charts 如何给谷歌时间线图中的每一条线上色?
我在这里阅读了一些其他答案,并相应地添加了Charts 如何给谷歌时间线图中的每一条线上色?,charts,google-visualization,react-google-charts,Charts,Google Visualization,React Google Charts,我在这里阅读了一些其他答案,并相应地添加了角色属性,但它不起作用 <Chart width={'500px'} height={'300px'} chartType="Timeline" loader={<div>Loading Chart</div>} data={[ [ { type: 'string', id: 'President' }, { type: 'date', id: 'Sta
角色
属性,但它不起作用
<Chart
width={'500px'}
height={'300px'}
chartType="Timeline"
loader={<div>Loading Chart</div>}
data={[
[
{ type: 'string', id: 'President' },
{ type: 'date', id: 'Start' },
{ type: 'date', id: 'End' },
{type: 'string', role: 'style'}
],
['Washington', new Date(1789, 3, 30), new Date(1797, 2, 4), 'gold'],
['Adams', new Date(1797, 2, 4), new Date(1801, 2, 4), 'color: #ccc'],
['Jefferson', new Date(1801, 2, 4), new Date(1809, 2, 4), 'gold'],
]}
options={{
showRowNumber: true,
}}
rootProps={{ 'data-testid': '1' }}
/>
请参阅:在时间轴图表上,样式角色仅在用作第三列时有效 因此,您还需要为条形标签添加第二列。
但是如果需要,您可以为该列使用
null
值
<Chart
width={'500px'}
height={'300px'}
chartType="Timeline"
loader={<div>Loading Chart</div>}
data={[
[
{ type: 'string', id: 'President' },
{ type: 'string', id: 'Bar' }, // <-- add bar label here...
{ type: 'string', role: 'style' }, // <-- add style role here...
{ type: 'date', id: 'Start' },
{ type: 'date', id: 'End' }
],
['Washington', null, 'gold', new Date(1789, 3, 30), new Date(1797, 2, 4)],
['Adams', null, '#ccc', new Date(1797, 2, 4), new Date(1801, 2, 4)],
['Jefferson', null, 'gold', new Date(1801, 2, 4), new Date(1809, 2, 4)],
]}
options={{
showRowNumber: true,
}}
rootProps={{ 'data-testid': '1' }}
/>