問題:大家好!我正在使用chart.js繪製圖表。圖表是一種動態的有時顯示10點,有時可以超過1000我已經成功地應用了一個面板,以便我的點可以顯示在一定的距離以便輕鬆閱讀。如何固定圖表中水平點(x軸)之間的距離
現在我想知道是否有任何選項來設置x軸網格中的點之間的距離。現在它會自動調整點數。
我試過了: 我試圖通過搜索其他stackoverflow答案,但沒有成功做stepize和scalewidth。任何形式的幫助將不勝感激。
PS:即時通訊使用chart.js2
這是我的數據集chartjs
var data = {
labels: data.graph_date,
datasets: [
{
label: 'Assay Values',
fill: false,
lineTension: 0,
backgroundColor: "rgba(255, 0, 0,1)",
borderColor: "rgba(255, 0, 0,1)",
borderCapStyle: 'butt',
borderDash: [],
borderDashOffset: 0.0,
borderWidth: 1,
borderJoinStyle: 'miter',
pointBorderColor: "rgba(255, 0, 0,1)",
pointBackgroundColor: "#fff",
pointBorderWidth: 1,
pointHoverRadius: 5,
pointHoverBackgroundColor: "rgba(255, 0, 0,1)",
pointHoverBorderColor: "rgba(255, 0, 0,1)",
pointHoverBorderWidth: 2,
pointRadius: 1,
pointHitRadius: 10,
data: data.assay_value,
spanGaps: false
},var options = {
responsive: false,
title: {
display: true,
position: "top",
text: label,
fontSize: 18,
fontColor: "#111"
},
legend: {
display: true,
position: "bottom",
labels: {
fontColor: "#333",
fontSize: 16
}
},
tooltips: {
enabled: true,
mode: 'single',
callbacks: {
label: function(tooltipItems, data) {
var multistringText = ['Assay Value: '+tooltipItems.yLabel];
multistringText.push('Assigned Value: '+assigned_value[tooltipItems.index]);
multistringText.push('Sample ID: '+sample_id[tooltipItems.index]);
return multistringText;
}
}
},
scales:{
yAxes:[{
ticks:{
min:graph_min
}
}],
xAxes: [{
gridLines: {
display:false
}
}]
}
};
if(new_chart[ctx.canvas.id] != null)
new_chart[ctx.canvas.id].destroy();
new_chart[ctx.canvas.id] =new Chart(ctx, {
type: 'line',
data: data,
options: options
});
在x軸有這樣
[19-Aug-2015,21-Aug-2015,21-Aug-2015,21-Aug-2015,21-Aug-2015,22-Aug-2015,27-Aug-2015,29-Aug-2015,1-Sep-2015,2-Sep-2015,3-Sep-2015,]
在y軸
數據是像數據此
[0.1,0.05,0.89,0.89,0.79,0.58,0.68,0.25,0.98]
stepSize的不工作,你什麼意思,你沒suceed? –
kristjan它沒有在xaxis上工作,只能用於yaxis –
你可以發佈你的整個chart.js配置和你的數據樣本嗎?這是提供特定答案所需要的。 – jordanwillis