score:1
Accepted answer
to achieve this you will need to know the max value of your first chart. if you know this you can set the the suggestedmax
value in the ticks
options for the yaxes to that value.
var options = {
type: 'bar',
data: {
labels: ["red"],
datasets: [{
label: '# of votes',
data: [2],
borderwidth: 1,
}]
},
options: {
scales: {
yaxes: [{
ticks: {
suggestedmax: 25
}
}]
}
}
}
var ctx = document.getelementbyid('chartjscontainer').getcontext('2d');
new chart(ctx, options);
<body>
<canvas id="chartjscontainer" width="600" height="400"></canvas>
<script src="https://cdnjs.cloudflare.com/ajax/libs/chart.js/2.9.4/chart.js" integrity="sha512-hzf9qhp3rldjbvakvmig+goaakrza6lkuo35ok6esm0/kjpk32yw7urqrq3q+nvbbt8usss+iekl7crn83dymw==" crossorigin="anonymous"></script>
</body>
Source: stackoverflow.com
Related Query
- (Chart.js) Is there a way to compare one chart with another so as not to have this inconsistent effect of small values being as big as big values?
- Bar chart (chart.js) with only 2 points does not show one of the bars
- Is there a way to style multiple borders on Doughnut chart with Chart.js library?
- Is there any way to show a tooltip for points which are not visible on the chart in Chart.js?
- I have a chart but it is not updating the chart with react chart-js-2
- Is there a way to create a chart with only a single axis?
- Chart.js v2 is there a way to draw bar chart horizontally?
- Draw two plots using chartjs over one another with transparency
- Series Details Not Showing in Angular Chart with Charts.js
- Chart JS not showing On hover with small data
- Chart.js: compare two periods like Google Analytics with a line chart
- Is there any way to get Chiselled Effect in chart js?
- code works fine on jsfiddle but one function is not working on website
- Chartjs not working with d3 from csv source
- Is there a way to change part of the title to another font style or set a custom title format in Chart.js?
- Doughnut Chart not displaying data with Chart Js and Backbone js
- chart.js pie chart background colors: is there any way to generate them randomly?
- Chart JS not working with date
- Is there a convenient way to print values to a JS chart from a CSV file without converting it?
- Is there any way to get y of specific x which not belongs to the dataset in Chart.js graph?
- Chartjs with Vue, Bar Chart Border Radius not working
- Is there a way to highlight a line on a line graph with hover?
- Issue with chartjs linear gradient for the mixed bar chart in ReactJS is not calculated for each individual Bars
- Is there a way in chartjs to display different Boolean values with an offset in Y over a common timeline?
- Chart not rendering with pug/jade and nodejs
- chart.js one of the chart from mixed chart is not plotting
- Chart JS not working with Phonegap
- Is there a way to give a pie chart in chart.js a different color outer border than the border color between segments?
- Problem with script src for Chart.js. The CDN for Chart.js funtions fine, so my code is ok. Somehow I'm not linking the file correctly
- Legend color not working with randomly generated background colors in chartjs pie chart
More Query from same tag
- Time Series Line chart js in react not working
- chart.js is not visible on blank data
- ChartJs php array into 'labels' and 'datasets'
- chartjs bar chart filter using datetimepicker
- ChartJS distinguish clicks between chart area, dataset and legend
- Using Chart.js in functional React component, not allowing me to toggle data: "properties undefined"
- Align doughnut/pie charts vertically in the container
- re-creating an animated graph in javascript with charts.js
- Change 'points' on a line chart to donuts using Chart.js
- Move y-Axis and hide in Chart.JS V3
- Angular Chart.js Bar Chart
- Chart.js not showing when i try to format dates
- Using Datalabels and ChartJS with Chartjs-node-canvas
- How to skip labels on x-axes?
- Custom gridLines and Axes Chartjs
- Issues with ng2-charts
- How to remove square label from tooltip and make its information in one line?
- How to pass data for stacked chart in vue-chartkick
- ChartJS – Set baseline above zero
- ChartJS custom legend doughnut separate legend from chart area
- Chart.js legend is undefined
- Keep chart.js doughnut with fixed width and height centered in container
- Update Chart JS data dynamically and add new data, remove old data to create timeline "like" chart
- How do I put this on Real-Time? I already put (async: True) but it doesnt work
- How to align ChartJS bars to the left?
- React JS Chart JS 2 is not hiding the grid lines in the background
- Pass function elements to render in js
- Split assoc array by keys
- I'm getting the error "TypeError: Cannot read property 'extend' of undefined" when trying to import chartjs-plugin-datalabels
- Plot multiple graphs (Chart.js) from php loop for reading multiple files