score:0
this.data = {
labels: Xaxis,
datasets: [
{
label: "Primary",
data:Primyaxis,
type: 'line',
borderColor:'#eddb1c',
backgroundColor:'#FFF3D6',
fill: false,
pointBorderColor: 'yellow',
pointBackgroundColor: 'yellow',
borderWidth: 1.5
},
{
label: "Secondary",
data: Secyaxis,
type: 'line',
borderColor:'#FF7A96',
backgroundColor:'#EAC3CC',
fill: false,
pointBorderColor: 'red',
pointBackgroundColor: 'red'
}
]
};
this.options = {
scales: {
xAxes: [{
display: true,
scaleLabel: {
display: true,
labelString: 'Extra Distance Interval From Origin'
}
}],
yAxes: [{
display: true,
scaleLabel: {
display: true,
labelString: 'Percentage of Employees'
},
ticks: {
// min: 50,
max: 100,
// forces step size to be 5 units
stepSize: 2 // <----- This prop sets the stepSize
}
}]
},
pan: {
enabled: true,
},
zoom: {
enabled: true,
},
responsive: true,
}}
score:22
How can I set step size here?
Straight from the samples (Linear Scale, step size):
By setting a stepSize
value.
scales: {
xAxes: [{
display: true,
scaleLabel: {
display: true,
labelString: 'Month'
}
}],
yAxes: [{
display: true,
scaleLabel: {
display: true,
labelString: 'Value'
},
ticks: {
min: 0,
max: 100,
// forces step size to be 5 units
stepSize: 5 // <----- This prop sets the stepSize
}
}]
}
Here's a live example:
var ctx = document.getElementById('chartJSContainer').getContext('2d')
new Chart(ctx, {
type: 'line',
data: {
labels: ['Red', 'Blue', 'Yellow', 'Green', 'Purple', 'Orange'],
datasets: [
{
label: '# of Votes',
data: [12, 19, 3, 5, 2, 3],
borderWidth: 1
},
{
label: '# of Points',
data: [7, 11, 5, 8, 3, 7],
borderWidth: 1
}
]
},
options: {
scales: {
yAxes: [{
ticks: {
reverse: false,
stepSize: 3
},
}]
}
}
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.3.0/Chart.js"></script>
<body>
<canvas id="chartJSContainer" width="600" height="400"></canvas>
</body>
Source: stackoverflow.com
Related Query
- Set minimum step size in chart js
- How to set axes' step size in Chart.js 2?
- Chart.js how set equal step size depending on actual data (xaxis)?
- How do I get the current step size of a chartjs chart whose stepSize I have not defined?
- How to add custom text inside the bar and how to reduce the step size in y axis in chart js( Bar chart )
- Can i set dynamic step size on stepped line chart in chart.js?
- Chart.js - How to set a line chart dataset as disabled on load
- chart js 2 how to set bar width
- How set color family to pie chart in chart.js
- chartjs : how to set custom scale in bar chart
- how to set chart.js grid color for line chart
- How to set ticks on axes dynamically with chart.js?
- How do you set pie chart colors in angular-chart.js
- How to dynamically set ChartJs line chart width based on dataset size?
- How to set single color on each bar in angular chart js
- ng2-charts: How to set Title of chart dynamically in typescript
- Chart is too big. How can I reduce size for the chart in vue js?
- How do I set a bar chart to default to a suggested maximum in chart.js v1.01?
- How do I remove cartesian axes from chart js?
- How to use set the color for each bar in a bar chart using chartjs?
- How to set the xAxes min and max values of time cartesian chart in Chart.js
- How to set custom Y Axis Values (Chart.js v2.8.0) in Chart Bar JS
- How to set the size of the arc in ChartJS?
- How to set a time scale to a ChartJS chart from JSON?
- Set fixed label size for grouped bar chart in angular Chartjs
- How to set X coordinate for each bar with react chart js 2?
- How to scale label size radar chart chart.js
- How to set the gap between data items in a chartjs chart
- How to set minimum value to Radar Chart in chart js
- How do you set x and y axis and Title for a line chart using charts.js?
More Query from same tag
- Filling area between two lines - Chart.js v2
- Chart JS: Bar Chart to have min Length as value range is too big
- How to print angular-chart
- Put tooltip on the middle of two bars
- chart.js with JSON Data on Same page not displaying
- ChartJs - stacked bar chart with groups - how to create second x-axis with stack id
- Enabling chartsJS bar chart to start on y axis
- Pie chart legend styling using Chart js
- Chartjs stacked bar separate tooltip for all stacked
- how to add FAHRENHEIT symbol in chart js donut chart
- How to show labels above pie chart in chart.js
- chartjs resizing very quickly (flickering) on mouseover
- export 'h' was not found in 'vue'
- Laravel trying to display chart on welcome page
- Chartjs Bar chart shows undefined values
- chart.js with null data point in dataset
- ChartJS / Chartjs-plugin-annotation How to draw multiple vertical lines using an array?
- import Json formatted values to create bar charts with Chart.js
- how to modify horizontal bar chart using chart js
- How do I resolve this error; 'document.getElementById('myChart').getContext' is undefined)?
- How to add additional label in the middle of each bar using ChartJS
- Dynamically create chart with Chart.js and PHP
- Using Chart.Js to plot a scatter plot from an Array
- Can we draw a Line Chart with both solid and dotted line in it?
- How to center bars on x-axis of Chart.js bar graph?
- How can i change tick val to title in ChartJS
- Chart JS Error: Chart is not defined Firefox
- How to create a line chart indicating which month a user wrote more or less blogs?
- ChartJS 2.0 - Huddle labels on pie chart
- Retrieving daily & monthly totals from MySQL for use in a chart