javascript - Chart.js 如何格式化属于特定轴的数据集(我有两个 yAxes)
问题描述
我有一个带有两个 yAxes 的图表。右侧以 % 显示,但数据集的值类似于 [0.23, 0.7,..] 而不是 [23%,70%,..]。
因此,我想以百分比显示属于“百分比”轴的数据集的工具提示和标签(chartjs-plugin-datalabels),但不显示属于其他 yAxis 的数据集。我该怎么做呢?
parasails.registerComponent('chart', {
props: {
chartData: Array,
title: String,
yAxes: Array
},
data: function (){
supportedAxes: {
percentAxis : {
id: 'percent',
type: 'linear',
position: 'right',
scaleLabel: {
display: true,
labelString: 'PERCENT',
},
ticks: {
callback: function (value) {
return (value * 100).toFixed(1) + '%'; // convert it to percentage
}
}
},
hoursAxis : {
id: 'hours',
type: 'linear',
scaleLabel: {
display: true,
labelString: 'HOURS'
}
//position: 'left'
}
}
},
methods: {
var options = {
plugins:{
datalabels:{
display: this.displayDatalabels
}
}
}
解决方案
推荐阅读
- python-3.x - 从 Steam 社区市场上的 Item 获取检查链接
- android - 有没有办法在颤动的文本字段中更改文本时仅更改文本?
- python - scrapy+selenium 完成后如何抓取不同的页面列表?
- java - 如何在签名和证书部分删除 XML 数字签名中奇怪的行尾?
- python - 无法从 Windows 访问在 8000 上运行的 Django 应用程序
- swift - 在任何情况下都需要调用 `disposed(by:)` 吗?
- python - PermissionError:[Errno 13] 使用带有 pip-20.0.2-py2.py3-none-any.whl 轮文件的 virtualenv 和 virtualenvwrapper 的权限被拒绝
- python - 如何从 pcap 文件中提取所有数据包的 TCP 标头?
- r - 添加一个单独的 index.html 作为主页并将 shinyapp 路由到其他页面
- android - 如何在android中每2秒解析一次来自OBD II模拟器的数据