score:2
Accepted answer
you can add autoskip: false
to the yaxis.ticks
configuration as follows
ticks: {
autoskip: false,
if
autoskip
istrue
(default), chart.js automatically calculates how many labels can be shown and hides labels accordingly. turnautoskip
off to show all labels no matter what.
new chart(document.getelementbyid('mychart'), {
type: 'bar',
data: {
labels: ["jan", "feb", "mar", "apr", "may"],
datasets: [{
label: 'events',
data: [0, 5, 6, 0, 0],
backgroundcolor: "#2dce89"
}]
},
options: {
responsive: true,
legend: {
display: false
},
scales: {
yaxes: [{
display: true,
ticks: {
autoskip: false,
beginatzero: true,
stepsize: 2,
max: 30
}
}]
}
}
});
canvas {
max-width: 260px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/chart.js/2.9.3/chart.min.js"></script>
<canvas id="mychart" height="200"></canvas>
Source: stackoverflow.com
Related Query
- How to set custom Y Axis Values (Chart.js v2.8.0) in Chart Bar JS
- chartjs : how to set custom scale in bar chart
- How to add custom text inside the bar and how to reduce the step size in y axis in chart js( Bar chart )
- chart js 2 how to set bar width
- How to display inline values in a stacked bar chart with Chart.js?
- How to hide the y axis and x axis line and label in my bar chart for chart.js
- Adding custom text to Bar Chart label values using Chart.js
- How to set single color on each bar in angular chart js
- How to show data values in top of bar chart and line chart in chart.js 3
- Chartjs 3.x - How to duplicate X axis on both sides of horizontal bar chart with only 1 dataset?
- How do I set a bar chart to default to a suggested maximum in chart.js v1.01?
- 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 X coordinate for each bar with react chart js 2?
- How to show the chartjs bar chart data values labels as text?
- How do you set x and y axis and Title for a line chart using charts.js?
- How to set 3 axis in google chart (V-Axis Left as Qty, V-Axis Right as Series Column and H-Axis as TimeOrder)?
- How can I get my Chart.JS bar chart to stack two data values together on each bar, and print a calculated value on each bar?
- How to remove the extra Y axis from a bar chart in chart.js
- How to set Solid label in bar chart using Chart JS
- How to fix a stacked logarithmic bar chart values to fit the grid
- How to start Y Axis Line at 0 from right for negative values in chart js 2?
- How to set minimal value for bar chart in Chart.js? (ver. 2.0.2)
- How to custom index label on each bar chart using chartjs?
- Set minimum and maximum axis values on chart
- How to assign values to different lables(legends) of my dataset of stacked bar chart
- Chartjs Bar Chart Y Axis set base starting value to not be 0
- how to add multi X axis custom line in chart js
- How to set different colors in each stacked bar chart cell?
- How to set percentage value by default on each bars in horizontal bar chart js
More Query from same tag
- React - How can I pass API data from one component to another in a different js file?
- ChartJs: HorizontalBar Missing Background Colours
- Angular ChartJs colors option not working
- ChartJs showing wrong labels of data (x-axis dates)
- Stacked Bar Chart, Two on Same Line w/ Same Color
- Change point size and color on hover in chartjs
- Dynamically update chart in chartJs
- ChartJS, add new dataset
- chart.js not accepting data in dataset which stored in local storage
- Chart.js pie chart in table shows weird behavior on page resize
- Drawing line chart in chart.js placing dots only when value changes
- Chartjs - how to make line position to vertical center and how to display dotted sharp in the backround?
- Trouble using utcoffset with Chart.js
- Chart JS, backgroundColor not showing
- ChartJS how to generate custom legend?
- Chart.js: Change lengend colors to array
- Chart.js drag points on linear chart
- how to add FAHRENHEIT symbol in chart js donut chart
- ChartJS custom tooltip doesn't render background on labels (only the title)
- Remove x-axis label/text in chart.js
- Draw data in graphics generated by Chart JS
- Need to customize graph behaviour
- How can I style ChartJS to always be at the bottom of a div?
- How to assign values to different lables(legends) of my dataset of stacked bar chart
- polymer, using attribute data binding in the constructor functions
- Legend color not working with randomly generated background colors in chartjs pie chart
- How to rotate custom marker in chart.js?
- How to push an array into an Object which is inside of another array?
- Chart.js Bar Chart - grouping and mapping data
- Chartjs defaults deprecation warning