chart.js - chart.js 中的自定义点名称
问题描述
有谁知道如何将自定义名称或工具提示添加到 charts.js 的折线图中的点?只有一个选项可以提供标签(显然是 X)和数据 - 这是 Y....问题是我有另一个数据集 - 它不能与第一个相关联 - 它实际上不是数字......而是字母...但我希望它放在同一个图表上....最好作为点上方的自定义文本 - 但任何其他选项也很好:) 我的代码:hist_fmp_score- 是我想要的标签与 hist_tr_ranks 大小相同的数组
var ctx = document.getElementById('myChart').getContext('2d');
const labels = hist_dates;
const data = {
labels: labels,
datasets: [{
label: 'Ratings',
data: hist_tr_ranks,
fill: false,
borderColor: 'rgb(75, 192, 192)',
tension: 0.1
},
{
label: 'Score as Letter',
data: hist_fmp_score,
fill: false,
borderColor: 'rgb(255, 99, 132)',
tension: 0.1
}]
};
const config = {
type: 'line',
data,
options: {}
};
var myChart = new Chart(
document.getElementById('myChart'),
config
);
解决方案
推荐阅读
- python - Microsoft 是否提供任何 API 来访问启用宏的 Excel 文件
- python - 从 Django 中的两个视图发送回表单
- java - 如何使用 springdoc-openapi 使可选的 OpenAPI 参数为空?
- spring-security - 为什么我的 Spring http 会话会在几秒钟内被破坏?
- redirect - 与来自 IIS 网站的 Plesk 重定向通信的问题
- reactjs - Ant设计Cascader组件中如何反转选项
- python - 合并两个带有共同值提示的数据框
- html - 在 img type="button" 上添加文本
- caching - 如何理解缓存大小?
- c# - 在 ASP.NET Core MVC 中存储用户角色的正确方法