[英]Add custom data scale to Chart.js
我在Chart.js中使用基本图表-我想知道是否有可能在轴上使用自定义比例 ,因此例如,我希望将数据点绘制在0-10数据比例上。 这可能吗?
<canvas id="myChart" width="150" height="150"></canvas>
<script>
var ctx = document.getElementById("myChart");
var myChart = new Chart(ctx, {
type: 'radar',
data: {
labels: ["Staying well", "Looking after yourself", "Where you live", "Feeling safe and being listened to", "Making decisions and managing money", "How you feel"],
datasets: [{
label: "Careplan",
backgroundColor: "rgba(179,181,198,0.2)",
borderColor: "rgba(179,181,198,1)",
pointBackgroundColor: "rgba(179,181,198,1)",
pointBorderColor: "#fff",
pointHoverBackgroundColor: "#fff",
pointHoverBorderColor: "rgba(179,181,198,1)",
data: [5, 8, 9, 4, 6, 6, 5]
}]
},
});
</script>
在这里查看我的问题并回答
您需要设置scaleSteps
, scaleStepWidth
和scaleStartValue
。 在上面的示例中是:
scaleSteps: 4,
scaleStepWidth: 5,
scaleStartValue: 0
其中总共有20条带有4行。 您可以使用这些值来获得所需的效果。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.