score:1
Accepted answer
you have to use the axis callbacks (docs), especially afterbuildticks
.
in my linked example (jsbin) i push 0 to my data because you can't use beginatzero: true
and remove all the duplicates in the array.
data.push(0); //if 'beginatzero' is wanted
let uniquedata = data.filter((v, i, a) => a.indexof(v) === i);
in the options you define the min and max values and the ticks in afterbuildticks
.
options: {
scales: {
yaxes: [{
ticks: {
autoskip: false,
min: math.min(...uniquedata),
max: math.max(...uniquedata)
},
afterbuildticks: function(scale) {
scale.ticks = uniquedata;
}
}]
}
}
you will have problems with overlapping ticks but i don't know a general way to prevent that and i don't know your specific use case.
Source: stackoverflow.com
Related Query
- How to show Y axis ticks for every point in the graph
- In Chart.js >3.0, on axis of type time, how to show labels and ticks only for existing data points (make labels reflect data)?
- How to show tick marks and labels with grid line for the specific one on the X axis with Chart.js?
- How to hide the y axis and x axis line and label in my bar chart for chart.js
- PrimeNg bar chart how to show a label for the y-axis
- How to start the line graph from the left Y axis in a line/bar mixed chart (Chart.js)?
- Chartjs: Is it possible to hide the data labels on the axis but show up on the graph on hover?
- How to show different product name for every bar in chart js
- How to show tooltip value of all data falling on the same axis in chart js?
- How to create a graph where the vertical axis (Y-axis) is a string?
- How do I persist the gridlines for ticks that are not displayed? [Chart.js]
- How to change the Y-Axis to show $ in graph
- How show data label in the graph on Chart.js?
- How to get rid of the line on top of every point on a line chart (Chart.js)
- how to show bar graph on y axis in charjs
- Show label for every data point in line chart
- How to change the angle of x axis ticks dynamically based on size of name?
- chart.js how to configure the lable for both axis
- How to pass a variable to the dataset for a graph in chart.js?
- How to update chart at the end of every for loop in Chart.js?
- Ticks for the minimum and maximum values in a Chart.js v2 axis
- how to show bar chart for every product
- how to label the x and y axis - in a line graph
- How do you output the correct value for Chart.js Radar graph on label?
- How to set max and min value for Y axis
- Chart.js how to show cursor pointer for labels & legends in line chart
- How to remove the line/rule of an axis in Chart.js?
- show label in tooltip but not in x axis for chartjs line chart
- chart js tooltip how to control the data that show
- ng2-charts: How to set fixed range for y axis
More Query from same tag
- Create IF to change chart.js bar color
- Remove empty spaces created by null values in Chart.js
- How to add margin bottom in Tittle ChartJS
- How to have onclick/hover display associated value in ChartJS
- chart.js show no charts in IE11
- TypeError: Cannot read property 'legend' of undefined | Angular + ng2-charts
- Different color for each column in angular-chartjs bar chart
- How to add border in chartjs?
- Get method in php then pass the value into json format
- ChartJS - Draw chart with label by month, data by day
- Chart.js - remove labels
- Chart.js - How do I dynamically change bar's stack
- Why are the default Chart.js legend boxes transparent rectangles?
- chart.js mix chart (bar + line): get lines to start at x = 0
- Chartjs not giving 'xLabel' properly on tooltip
- How Export an Editable Chart with content to PPT and Excel
- How do I use NuGet to install ChartJS?
- Chartjs - Shift line plot to the right?
- Chartjs multi dimensional bar chart
- Chartjs: Is it possible to add phases in line chart?
- chartjs Line chart Javascript
- Specify varying thickness of each bar in Chart.js bar chart
- Loading and updating dynamic charts with dynamic data (chart.js)
- Change point color on click using ChartJS
- ng2-chart tooltip position change option?
- why is the background black when with Chartjs export to a image
- in chart js tooltip font size is not working
- Chartjs 2.0 - Increase height of x-axis labels
- Legend isnt moving to the right on my doughnut chart created with chart.js
- ChartJS do not render any legend if the label is falsy