[英]chart.js? Specifically Radar Charta and Negative Numbers
我是JavaScript的新手,使用chart.js中的雷達圖表,但每次我在圖表的數據上加上負數時,我總會得到變形的圖像。
代碼在這里:
var radarChartData = {
labels: [
"Soccer",
"Basketball",
"Swimming",
"Volleyball",
"Computer games",
"Tennis",
],
datasets: [
{
label: "My First dataset",
fillColor: "rgba(220,220,220,0.2)",
strokeColor: "rgba(220,220,220,1)",
pointColor: "rgba(220,220,220,1)",
pointStrokeColor: "#fff",
pointHighlightFill: "#fff",
pointHighlightStroke: "rgba(220,220,220,1)",
data: [-3,7,6,6,4,6]
},
]
};
window.onload = function(){
window.myRadar = new Chart(document.getElementById("canvas").getContext("2d")).Radar(radarChartData,
{
responsive: true
});
}
1 /將實際值更改為整數,可以使用:
var intvalue = Math.floor( floatvalue );
var intvalue = Math.ceil( floatvalue );
var intvalue = Math.round( floatvalue );
2 /對於變形圖像:嘗試Math.abs(val);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.