charts - 在图表中 js 工具提示字体大小不起作用
问题描述
我想在图表 js 中制作大字体的工具提示,但不幸的是它对我不起作用,我在这里添加了我的代码,任何人都可以检查我的代码,并帮助我解决这个问题吗?
options: {
plugins: {
legend: {
display: true,
position: 'bottom',
labels: {
font: {
size: 30
}
}
},
tooltips: {
font: {
size: 30
}
}
},
}
解决方案
您可以为工具提示的标题、正文和页脚定义不同的字体,因此您需要在这些特定位置定义它:
var options = {
type: 'line',
data: {
labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
datasets: [{
label: '# of Votes',
data: [12, 19, 3, 5, 2, 3],
borderColor: 'pink'
}
]
},
options: {
plugins: {
tooltip: {
titleFont: {
size: 100
},
bodyFont: {
size: 50
},
footerFont: {
size: 20 // there is no footer by default
}
}
}
}
}
var ctx = document.getElementById('chartJSContainer').getContext('2d');
new Chart(ctx, options);
<body>
<canvas id="chartJSContainer" width="600" height="400"></canvas>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.5.1/chart.js"></script>
</body>
推荐阅读
- php - 如何在读取问候包和 MySQL 消失时修复错误?
- python - 在 Python 中显示类属性的 dict 中将枚举名称作为枚举值输出
- mongodb - 尝试创建前缀命令时出现错误消息
- python-3.x - 如何指定在 pyarrow.dataset 中加载哪些列
- javascript - 如何按顺序使用 Axios 获取远程文档/对象数组?
- javascript - 如何将流分成可以使用 Media Source API 播放的块?
- kotlin - 抛出 NoWhenBranchMatchedException 时如何穷举?
- html - CSS 无法与 Angular Material 一起按预期工作
- javascript - 使 HTML 行可点击,然后显示来自数据库的行用户配置文件,用于使用 while 循环创建的表
- r - 将自定义函数应用于现有列以在 R 的数据框中创建新列的最佳方法