chart.js - 在chart.js中将y轴旋转到顶部,将x轴旋转到左边
问题描述
我有一个图表,目前显示如下:
(不改变“你的评分”)方向。
将 x 轴放在左侧,将 y 轴放在顶部应该相对简单,但我很挣扎。
以下是相关代码:
var ctx = document.getElementById('canvas').getContext('2d');
window.myHorizontalBar = new Chart(ctx, {
type:'line', // 'horizontalBar',
data: horizontalBarChartData,
options: {
annotation: {
annotations: [{
type: 'line',
mode: 'vertical',
scaleID: 'y-axis-0',
value: 20,
label: {
content: 'Your Rating ',
enabled: true
}
}]
},
scales: {
xAxes: [{
gridLines: {
display:false
}
}],
yAxes: [{
gridLines: {
display:false
}
}]
},
// Elements options apply to all of the options unless overridden in a dataset
// In this case, we are setting the border of each horizontal bar to be 2px wide
responsive: true,
legend: {
display: false
},
title: {
display: false,
text: 'text4'
}
}
});
}
解决方案
推荐阅读
- mysql - 如何在mysql中使用laravel迁移将数据库列'null'更改为'nullable'?
- scheduled-tasks - Powershell 脚本仅在手动调用时才会触发进程。通过计划任务触发时超时
- android - 无尽的前台服务永远不会按预期工作
- javascript - 无法解析 CSS 样式表 Jest & js-dom
- angular - Angular Ractive Forms:从自定义组件中获取验证器
- html - 当作为 wordpress 帖子上传时,Rmarkdown 在文档中创建选项卡不起作用
- react-native - 如何用 react-native 创建一个逼真的 3D 头像?
- triggers - 如何在任务计划程序 Windows 10 中启动触发器
- imagemagick - ImageMagick:将灰度值精确重映射为 RGB 值
- c# - 如何将 System.Windows.Media.Visual 转换为 System.Windows.Controls.Control?