我使用的是react-google-charts,我的项目需要使用像chartType="BarChart“这样的竖条。问题是我需要它垂直。
我尝试在选项中添加“bar:‘垂直’”,并且在没有组件的情况下,我检查了所有构建图表的示例。我知道如何使用我从react组件中得到的东西。
这是我正在使用的exsample。
https://react-google-charts.com/bar-chart#labeling-bars
<Chart
width={'500px'}
height={'300px'}
chartType="BarChart"
loader={<div>Loading Chart</div>}
data={[
[
'Element',
'Density',
{ role: 'style' },
{
sourceColumn: 0,
role: 'annotation',
type: 'string',
calc: 'stringify',
},
],
['Copper', 8.94, '#b87333', null],
['Silver', 10.49, 'silver', null],
['Gold', 19.3, 'gold', null],
['Platinum', 21.45, 'color: #e5e4e2', null],
]}
options={{
title: 'Density of Precious Metals, in g/cm^3',
width: 600,
height: 400,
bar: { groupWidth: '95%' },
legend: { position: 'none' },
}}
/>这里我漏掉了什么?
谢谢,
发布于 2019-05-03 04:15:50
请尝试使用chartType="ColumnChart"。example
<Chart
width={'500px'}
height={'300px'}
chartType="ColumnChart"
loader={<div>Loading Chart</div>}
data={[
[
'Element',
'Density',
{ role: 'style' },
{
sourceColumn: 0,
role: 'annotation',
type: 'string',
calc: 'stringify',
},
],
['Copper', 8.94, '#b87333', null],
['Silver', 10.49, 'silver', null],
['Gold', 19.3, 'gold', null],
['Platinum', 21.45, 'color: #e5e4e2', null],
]}
options={{
title: 'Density of Precious Metals, in g/cm^3',
width: 600,
height: 400,
bar: { groupWidth: '95%' },
legend: { position: 'none' },
}}
/>https://stackoverflow.com/questions/55959533
复制相似问题