gpt4 book ai didi

javascript - ChartJS 设置默认轴

转载 作者:行者123 更新时间:2023-11-28 07:57:54 25 4
gpt4 key购买 nike

我正在我的网站上开发 ChartJs,但问题是我无法设置折线图的轴,所以有人可以帮助解决这个问题吗?

这是我当前图表的 View :

enter image description here

这是我的图表代码:

var lineChartData = {
labels : ["00:00","06:00","12:00", "18:00"],
datasets : [{
labels: "PR",
fillColor : "rgba(247, 70, 74, 0.1)",
//fillColor : "rgba(220,220,220,0.2)",
strokeColor : "rgba(220,220,220,1)",
pointColor : "rgba(220,220,220,1)",
pointStrokeColor : "#FF0040",
pointHighlightFill : "#fff",
pointHighlightStroke : "rgba(220,220,220,1)",
data : [65,59,90,81,56,55,40]
}, {
label: "QTY",
fillColor : "rgba(0, 0, 255, 0.1)",
//fillColor : "rgba(151,187,205,0.2)",
strokeColor : "rgba(151,187,205,1)",
pointColor : "rgba(151,187,205,1)",
pointStrokeColor : "#0000FF",
pointHighlightFill : "#fff",
pointHighlightStroke : "rgba(151,187,205,1)",
data : [28,48,40,19,96,27,100]
}]
}

我想在图表中显示的是轴的值在当前图表中显示 0,20,30,40,50,...,100

我希望将默认值设置为 0,25%,50%,75%,100%

谁能帮我解决这个问题吗?

最佳答案

http://jsfiddle.net/qsosLya0/

诀窍是以下配置选项:

var lineChartOptions = {
scaleOverride: true,
scaleSteps: 4,
scaleStepWidth: 25,
scaleStartValue: 0,
scaleLabel: "<%=value%>%"
};

来源:http://www.chartjs.org/docs/#getting-started-global-chart-configuration

关于javascript - ChartJS 设置默认轴,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25840474/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com