reactjs - React Google 饼图样式化标题
问题描述
我正在尝试使用谷歌反应饼图但是我很难定位标题。
这是我的代码:
const pieOptions = {
title: 'my awesome chart',
pieHole: 0.6,
slices: [
{
color: '#00a3e0',
},
{
color: '#f2a900',
},
{
color: 'F16A21',
},
{
color: '#e9a227',
},
],
legend: {
position: 'right',
alignment: 'center',
textStyle: {
color: '233238',
fontSize: 14,
},
},
tooltip: {
showColorCode: true,
},
// chartArea: {
// left: 0,
// top: 0,
// width: '100%',
// height: '70%',
// },
fontName: 'Roboto',
fontSize: 20,
}
<Chart
chartType="PieChart"
data={[
['Item', 'Numbers'],
['Item 1', 5000],
['Item 2', 20000],
['Item 3', 6000],
]}
options={pieOptions}
graph_id="PieChart"
width={'100%'}
height={'220px'}
legend_toggle
/>
这是我得到的:
我想要的结果是将标题放在图例之上,但我不知道该怎么做。
这是我正在使用的 npm 包的链接:
https://github.com/RakanNimer/react-google-charts#donut-chart https://github.com/rakannimer/react-google-charts/blob/master/sandboxes/pie-chart/index.js
解决方案
似乎没有办法定位标题。您必须titlePosition: 'none'
单独设置和创建标题,然后按您的需要设置样式。
阅读更多文档。
推荐阅读
- sharepoint - 共享的共享点权限
- arrays - 如何在颤动中从数组中获取随机变量
- python - Docker 中的 Cron 作业不工作 - python 应用程序
- angular - Jest 测试失败,因为在使用 quill 编辑器测试组件时缺少 angular 10 中的动态导入
- jdbc - 结果集的 JDBC 事务
- google-cloud-platform - 如何在谷歌云上托管“多页”的静态网站
- powerbi - 对功率 BI 矩阵进行排序以保持年份升序
- python - 脚本中断,因为列表中不存在索引
- docker - Jenkins构建如何获取docker镜像
- php - 在 Laravel 7/8 中获取当前 URL 的一部分