angular6 - 将标题和子标题包装到饼图 3 中的下一行
问题描述
我正在使用 pie amchart v3,并且我正在使用allLabels属性来显示标题和副标题。但问题是,标题没有换行到下一行,如下所示
如何将文本“ TOP BUS TYPES: BUS TYPES ”换行到下一行?
下面是我的代码。
const chart = this.AmCharts.makeChart( "mychart", {
"type": "pie",
"theme": "light",
"dataProvider": busvalue,
"titleField": "title",
"valueField": "value",
"labelsEnabled": false,
"radius": "40%",
"innerRadius": "60%",
"colorField": "color",
"allLabels": [{
"y": "48%",
"align": "center",
"size": 17,
"bold": true,
"text": 'TOP BUS TYPES: BUS TYPES',
"color":'#000000'
},{
"y": "52%",
"align": "center",
"size": 12,
"text": ''
"color": '#000000
}],
...
});
}
解决方案
allLabels
在 amcharts v3中没有任何机制可以自动包装自由标签 ( )。您必须根据需要在字符串中插入自己的换行符,例如"text": 'TOP BUS TYPES:\nBUS TYPES'
AmCharts.makeChart("mychart", {
"type": "pie",
"theme": "light",
"dataProvider": [{
"title": "1",
"value": 10
}, {
"title": "2",
"value": 10
}, {
"title": "3",
"value": 10
}],
"titleField": "title",
"valueField": "value",
"labelsEnabled": false,
"radius": "40%",
"innerRadius": "60%",
"colorField": "color",
"allLabels": [{
"y": "48%",
"align": "center",
"size": 17,
"bold": true,
"text": 'TOP BUS TYPES:\nBUS TYPES',
"color": '#000000'
}, {
"y": "52%",
"align": "center",
"size": 12,
"text": '',
"color": '#000000'
}]
});
<script src="https://www.amcharts.com/lib/3/amcharts.js"></script>
<script src="https://www.amcharts.com/lib/3/pie.js"></script>
<script src="https://www.amcharts.com/lib/3/themes/light.js"></script>
<div id="mychart" style="width: 100%; height: 400px;"></div>
推荐阅读
- javascript - 比萨促销的JS算法
- javascript - 在 Ruby on Rails 上使用 javascript 注入 ruby
- google-sheets - 例外:对 https://docs.google.com 的请求失败,返回代码 401。截断的服务器响应:
- python - 我不明白如何在 Python 中实现这个逻辑条件
- javascript - 如何立即使用 Intersection Observer API?
- java - 如何使用自定义 ClassLoader 进行 Spring Junit 测试?
- .net - 实体框架核心脚手架“找不到数据类型为‘hierarchyid’的列的类型映射。跳过列”
- python - 无法通过 setup.py 使 Python 脚本在 Linux 机器上的任何位置运行
- node.js - vue-cli-service:运行 npm run serve 时权限被拒绝
- javascript - 将 js 库添加到 Vue 原型?