score:11
Accepted answer
const options = {
scales: {
xAxes: [{
stacked: true
}],
yAxes: [{
stacked: true
}]
}
}
let data ={
datasets:[{
label: 'test1',
data :[1]
},
{
label: 'test2',
data: [2]
}],
labels:['label']
}
render(){
return <Bar data={data} options={options} />
}
score:10
Add the stack
option to your datasets.
Identical stack values are stacked together.
const arbitraryStackKey = "stack1";
const data = {
labels: ['a', 'b', 'c', 'd', 'e'],
datasets: [
// These two will be in the same stack.
{
stack: arbitraryStackKey,
label: 'data1',
data: [1, 2, 3, 4, 5]
},
{
stack: arbitraryStackKey,
label: 'data2',
data: [5, 4, 3, 2, 1]
}
]
}
Source: stackoverflow.com
Related Query
- How to create stacked bar chart using react-chartjs-2?
- ChartJs - stacked bar chart with groups - how to create second x-axis with stack id
- How to create an animate-on-update Stacked Bar chart using Chart.js(or Chartist)?
- Multiple stacked bar chart using ChartJs
- Stacked bar chart starting from 0 - ChartJS React
- How to create a stacked graph using ChartJS
- How to highlight single bar in bar chart using Chartjs
- How do I create a stacked horizontal bar chart with Chart.js in React?
- Unable to create Stacked Grouped Bar Chart with chart.js / react-chartjs-2 in React
- Using ChartJS to create a multiple grouped bar chart - see picture below
- How can I create a stacked bar chart with Charts.JS that displays relative rather than absolute values?
- How to set up a simple pie chart using React in ChartJS on codesandbox
- how to insert dynamic data from sql into chartjs stacked bar chart javascript
- Draw stacked horizontal bar chart with Average line using ChartJS
- How to configure Chartjs Bar Stacked Chart in Laravel 8
- How Can I Get An Instance of a ChartJS Bar Chart Using Angular
- How to create Stacked bar chart from JSON in chart.js
- How to add vertical line in bar chart using chartJs and ng2-charts?
- How to access custom property in dataset object in Bar Chart in React ChartJS 2?
- how to create bar chart with group and sam color for each group using chart.js?
- Chartjs v2.0: stacked bar chart
- chartjs : how to set custom scale in bar chart
- Chartjs 2 - Stacked bar and unstacked line on same chart with same y axis
- Click event on stacked bar chart - ChartJs
- How to display inline values in a stacked bar chart with Chart.js?
- How to access labels array using chart plugin (Chart.pluginService.register) in Chartjs 2.x?
- Chartjs - show elements in all datasets on hover using bar chart
- How to create single value Doughnut or Pie chart using Chart.js?
- How to draw Horizontal line on Bar Chart Chartjs
- Create multiple dynamic stacked chart using chart.js in Angular 10?
More Query from same tag
- Chart.js change label color
- Using chart.js, how do I align bars instead of centering them when there are only a few bars to display?
- ng-chart.js - First data set always has color gray
- Chart.js will not render using vue.js until window resizes
- How do I draw a vertical line on a horizontal bar chart with ChartJS?
- How to add chart js legends in ember?
- Dynamic Chart Data
- Failing to render chart – "can't acquire context from the given item"
- Unable to clone a Chart.js chart in a pop up
- Line chart: align x axis (timestamps) for multiple data sets
- ChartJs line chart - display permanent icon above some data points with text on hover
- How to combine lines with different starting points in chartjs
- ChartJs: HorizontalBar Missing Background Colours
- Are you able to offset a secondary y-axis in ChartJS, by a decimal value, whilst keeping the same scale for both y-axes?
- In chartjs, add link text on tooltip
- Correct config location of chartjs-plugin-annotation with ng2-charts?
- Chart.js with Angular component - Type 'string' is not assignable to type 'ChartTitleOptions | undefined'
- Chart.js update function (chart,labels,data) will not update the chart
- Keep the Y axis fixed when the chart scrolls horizontally, regardless of DPI settings?
- Chart JS: All Values Displayed on x-axis After Callback Conversion
- How to hide a portion of chart or a div in Angular?
- X-axis of Chart.js not taking type : 'time'
- displaying the output on chart.js using Django and HTML
- Numeric X axis for linechart
- how to always show label in chartjs without mouseover?
- Chart JS data labels getting cut
- ChartJS and JSON result: Cannot set property 'fillColor' of undefined
- angular 7 how to draw dynamic number of charts
- Chart.js shows no graphs
- Chart JS - Line chart with days in x-axis