我如何更改React Google图表中特定targetaxisindex系列的格式vaxis
我想将类型行格式系列更改为百分比我尝试此配置:
vAxis: {
minValue: 0,
maxValue: 1,
gridlines: { count: 10 },
minorGridlines: { count: 0 },
// Format for targetAxisIndex 1
1: {format: 'percent'},
}
它也不起作用我没有看到任何用于在特定targetAxisIndex
上进行格式化的文档
当前代码:
const chartData = [
[
"Test Product 003",
20,
"This",
0.5
],
[
"Test Product 003",
10,
"This",
0.75
],
[
"Campus Shirt",
10,
"This",
1
]
]
<Chart
width={900}
height={720}
chartType="ComboChart"
loader={<Spin />}
data={[
[
'#',
'Sales Quantity',
{ role: 'tooltip', type: 'string', p: { html: true } },
'Cumulative Sales Quantity',
],
...chartData,
]}
options={{
series: {
0: { type: 'bars' },
1: {
type: 'line',
curveType: 'function',
targetAxisIndex: 1,
},
},
vAxis: {
minValue: 0,
maxValue: 1,
gridlines: { count: 10 },
minorGridlines: { count: 0 },
},
hAxis: {
slantedText: true,
},
tooltip: { isHtml: true, trigger: 'visible' },
}}
/>
这是沙箱
I want to change the type line format series to percentage I try this config:
vAxis: {
minValue: 0,
maxValue: 1,
gridlines: { count: 10 },
minorGridlines: { count: 0 },
// Format for targetAxisIndex 1
1: {format: 'percent'},
}
it doesn't work also I don't see any docs for formating on spesific targetAxisIndex
Current code:
const chartData = [
[
"Test Product 003",
20,
"This",
0.5
],
[
"Test Product 003",
10,
"This",
0.75
],
[
"Campus Shirt",
10,
"This",
1
]
]
<Chart
width={900}
height={720}
chartType="ComboChart"
loader={<Spin />}
data={[
[
'#',
'Sales Quantity',
{ role: 'tooltip', type: 'string', p: { html: true } },
'Cumulative Sales Quantity',
],
...chartData,
]}
options={{
series: {
0: { type: 'bars' },
1: {
type: 'line',
curveType: 'function',
targetAxisIndex: 1,
},
},
vAxis: {
minValue: 0,
maxValue: 1,
gridlines: { count: 10 },
minorGridlines: { count: 0 },
},
hAxis: {
slantedText: true,
},
tooltip: { isHtml: true, trigger: 'visible' },
}}
/>
Here's the sandbox
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
vaxes
选项来格式化特定的y轴。vaxis
选项中的任何内容都将应用于所有Y轴。对于
vaxes
,请使用索引号,剩下0的索引号,而1是右侧。you can use the
vAxes
option to format a specific y-axis.anything in the
vAxis
option will be applied to all y-axis.for
vAxes
, use the index number, where 0 is left, and 1 is first right.