admin管理员组文章数量:1400161
I am trying to change the background color of the charts to match my body background color.
I have tried to do the two following backgroundColor styles below but it doesn't seem to work. Any ideas on how i can get around this?
<Chart
height={'300px'}
width={'370px'}
chartType='Bar'
loader={<div>Loading Chart..</div>}
data={[
['', 'UPLIFT'],
...topSpend.map(d => [d.PRODUCT, d.UPLIFT]),
]}
options={{
chart: {
title: 'Spend Uplift',
-----> backgroundColor: 'red'
},
colors: ['#FB7A21']
}}
/>
<Chart
height={'300px'}
width={'370px'}
chartType='Bar'
loader={<div>Loading Chart..</div>}
data={[
['', 'UPLIFT'],
...topSpend.map(d => [d.PRODUCT, d.UPLIFT]),
]}
options={{
chart: {
title: 'Spend Uplift',
},
colors: ['#FB7A21'],
-----> backgroundColor: 'red'
}}
/>
I am trying to change the background color of the charts to match my body background color.
I have tried to do the two following backgroundColor styles below but it doesn't seem to work. Any ideas on how i can get around this?
<Chart
height={'300px'}
width={'370px'}
chartType='Bar'
loader={<div>Loading Chart..</div>}
data={[
['', 'UPLIFT'],
...topSpend.map(d => [d.PRODUCT, d.UPLIFT]),
]}
options={{
chart: {
title: 'Spend Uplift',
-----> backgroundColor: 'red'
},
colors: ['#FB7A21']
}}
/>
<Chart
height={'300px'}
width={'370px'}
chartType='Bar'
loader={<div>Loading Chart..</div>}
data={[
['', 'UPLIFT'],
...topSpend.map(d => [d.PRODUCT, d.UPLIFT]),
]}
options={{
chart: {
title: 'Spend Uplift',
},
colors: ['#FB7A21'],
-----> backgroundColor: 'red'
}}
/>
Share
Improve this question
edited Aug 19, 2019 at 16:48
WhiteHat
61.3k7 gold badges53 silver badges136 bronze badges
asked Aug 19, 2019 at 16:21
Kaishan PatelKaishan Patel
691 silver badge2 bronze badges
1
- According to the official docs you should be able to use as is. – silentw Commented Aug 19, 2019 at 16:28
2 Answers
Reset to default 3You need to use chartType
as BarChart
. For some reason, Bar
seems to cause issues. In case you want the chart bars to be vertical, change it to ColumnChart
.
You can see the working fiddle here
'Bar'
is considered a Material chart.
vs. 'BarChart'
, which is a Classic chart.
with Material charts, an options conversion method needs to be used...
google.charts.Bar.convertOptions
which means you would need to access the google.charts
namespace.
options={google.charts.Bar.convertOptions({
chart: {
title: 'Spend Uplift',
},
colors: ['#FB7A21'],
backgroundColor: 'red'
})}
本文标签: javascriptHow do i change React Google Charts background colorStack Overflow
版权声明:本文标题:javascript - How do i change React Google Charts background color? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744134800a2592348.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论