score:2
Accepted answer
You can stack the x axis together with a smaller bar percentage for the inner bar:
const options = {
type: 'bar',
data: {
labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
datasets: [{
label: '# of Points',
data: [7, 11, 5, 8, 3, 7],
backgroundColor: 'orange',
barPercentage: 0.6
},
{
label: '# of Votes',
data: [12, 19, 8, 10, 5, 13],
backgroundColor: 'pink'
}
]
},
options: {
scales: {
x: {
stacked: true
}
}
}
}
const 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/3.6.2/chart.js"></script>
</body>
Source: stackoverflow.com
Related Query
- chart.js version 3 - How to make an overlapping bar chart?
- how to make a chart.js bar chart scrollable
- How to make bar chart animation where all bars grow at the same speed?
- ChartJS: how to make a bar chart with a horizontal guideline:
- How to make bar chart cover multiple labels?
- How to make 2 bar in a certain section of chart
- How to make a Chart.js Bar chart stay in its place
- How to make labels on both side from horizontal bar chart js
- How is it possible to make curved bar chart or curved column charts in chart.js?
- chart js 2 how to set bar width
- How can I make two of my lines in Chart JS thicker
- Chart.js Bar Chart - how to chart bars from 0
- How to put rounded corners on a Chart.js Bar chart
- chartjs : how to set custom scale in bar chart
- How can I make a stepline or stepped chart in chart.js or D3?
- How to add second Y-axis for Bar and Line chart in Chart.js?
- Overlapping Bar Chart using Chart.js
- How to create stacked bar chart using react-chartjs-2?
- How do I draw a vertical line on a horizontal bar chart with ChartJS?
- 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
- How to create a gradient fill line chart in latest Chart JS version (3.3.2)?
- How to have solid colored bars in angular-chart bar chart
- How to draw Horizontal line on Bar Chart Chartjs
- how to add a title to my ng2-charts bar chart
- PrimeNg bar chart how to show a label for the y-axis
- how to programmatically make a line chart point active/highlighted
- How do I make line charts overlay over bar charts in chartjs
- How to make Chart JS responsive?
- How to set single color on each bar in angular chart js
More Query from same tag
- how to change Y axis value dynamically based on user input in Chartjs for Line chart?
- Chartjs change grid line color
- Synchronous XMLHttpRequest when loading charts.js in to a div
- chart js tooltip how to control the data that show
- Chart.js HTML custom legend issues with doughnut chart
- Chart.js just disappears for no reason
- how to update chartjs2 option (scale.tick.max)
- How to delete a chart (canvas) out of its scope?
- ChartJS:align zeros on chart with multi axes
- How to import Patternomaly into Ionic 2 project?
- Uncaught type error: mychart.update is not a function
- Setting axis scales in ChartsJS
- React chartjs 2 - Type 'string' is not assignable to type '"timeseries"'
- ng2 charts on Angular 9 not responsive
- Is it possible to remove the border between the segments but leave the border around the pie chart in react-chartjs-2?
- Place Text in Chart-Canvas Area in ChartJS
- Chart.js / Javascript How to Override Mouseout Event Listener
- Chart.js annotations in Vue.js break when defined in data ()
- Angular PrimeNG Chart Module: Customize hover text
- Statistics page - Load every stats <div> one by one
- Chart.js can't push dataset to charts made dynamically
- Reactive Vue Chart.js component using Typescript
- How to use the useEffect function in react js chart 2 to change the labels?
- I can't change the color of the grids in Chart.js
- chart.js legend not working for pie chart
- How to plot object to charts.js
- How to allow copying of text within Chart.js tooltips?
- Chartjs doughnut chart rounded corners for half doghnut
- plot a point on top on line chart in chartjs
- ChartJs - set x-axis ticks at specified/fixed intervals