在此垂直条形图中,y 轴有正值、负值。
我想根据零值上下使用正整数。
我使用的是4.2.1版本
我该怎么办?
垂直图表示例
var MONTHS = [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December",
];
var color = Chart.helpers.color;
var barChartData = {
labels: ["January", "February", "March", "April", "May", "June", "July"],
datasets: [
{
label: "Dataset 1",
backgroundColor: 'rgba(255, 201, 14, 1)',
borderColor: 'rgba(255, 201, 14, 1)',
borderWidth: 1,
data: [
10,
20,
30,
40,
50
],
},
{
label: "Dataset 2",
backgroundColor: 'rgba(255, 201, 14, 1)',
borderColor: 'rgba(255, 201, 14, 1)',
borderWidth: 1,
data: [
-100,
-200,
-300,
-400,
-500
],
},
],
};
var ctx = bloodPressureChart;
new Chart(ctx, {
type: "bar",
data: barChartData,
options: {
responsive: true,
legend: {
position: "top",
},
title: {
display: true,
text: "Chart.js Bar Chart",
},
},
});
这是我使用图表 JS 的代码。
我的代码图表
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号