I have a line graph on Chart.js and am trying to edit the intervals on the x-axis and the y-axis.
My y-axis intervals are functioning as expected, but my x-axis intervals are not.
I tried the following code
let myChart = new Chart(inputChart, {
type: 'line',
data: {
labels: [1,2,....,360] // list of values from python script
data: [360 random numbers here]
}
options: {
scales: {
yAxes: [{
id:'main-axis',
ticks: {
stepSize: 40 // this worked as expected
}
}],
xAxes: [{
id: 'main-x-axis',
ticks: {
stepSize: 30 // this did not work as expected
}
}]
}
}
})
With 360 datapoints, I just want to basically see 12 intervals (in increments of 30), but I am seeing 90 intervals in increments of 4 instead. Am I just using the wrong property for stepSize? If so what is the correct property?
To change the interval between axis labels, expand Labels, and then under Interval between labels, select Specify interval unit and type the number you want in the text box.
The X-axis contains either strings of text or a date under each set of data points. You can choose to have this axis only display the text or date at certain intervals, but the process is a little different depending on what kind of axis you have.
To change the axis scales on a plot in base R Language, we can use the xlim() and ylim() functions. The xlim() and ylim() functions are convenience functions that set the limit of the x-axis and y-axis respectively.
The linear scale is used to chart numerical data. It can be placed on either the x or y-axis. The scatter chart type automatically configures a line chart to use one of these scales for the x-axis. As the name suggests, linear interpolation is used to determine where a value lies on the axis.
It can be done using the maxTicksLimit
option of xAxes, see this working fiddle -> http://jsfiddle.net/Lzo5g01n/3/
xAxes: [{
type: 'time',
ticks: {
autoSkip: true,
maxTicksLimit: 20
}
}]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With