100% Stacked bar chart in React 3D Chart control
10 Jan 202420 minutes to read
100% Stacked bar chart
To render a 100% stacked bar series, use series type as StackingBar100 and inject StackingBarSeries3D module into the services.
import { Chart3DComponent, Chart3DSeriesCollectionDirective, Chart3DSeriesDirective, Category3D, Inject, Legend3D, DataLabel3D, Tooltip3D, StackingBarSeries3D, Highlight3D } from '@syncfusion/ej2-react-charts';
import * as React from "react";
import * as ReactDOM from "react-dom";
function App() {
const data = [
{ x: '2013', y: 9628912, y1: 4298390, y2: 2842133, y3: 2006366 },
{ x: '2014', y: 9609326, y1: 4513769, y2: 3016710, y3: 2165566 },
{ x: '2015', y: 7485587, y1: 4543838, y2: 3034081, y3: 2279503 },
{ x: '2016', y: 7793066, y1: 4999266, y2: 2945295, y3: 2359756 },
{ x: '2017', y: 6856880, y1: 5235842, y2: 3302336, y3: 2505741 }
];
return <Chart3DComponent id='charts' primaryXAxis=
primaryYAxis=
wallColor='transparent'
enableRotation={true} rotation={7} tilt={10} depth={100}>
<Inject services={[StackingBarSeries3D, Category3D, Legend3D, Tooltip3D, DataLabel3D, Highlight3D]} />
<Chart3DSeriesCollectionDirective >
<Chart3DSeriesDirective dataSource={data} xName='x' yName='y' type='StackingBar100'>
</Chart3DSeriesDirective>
<Chart3DSeriesDirective dataSource={data} xName='x' yName='y1' type='StackingBar100'>
</Chart3DSeriesDirective>
<Chart3DSeriesDirective dataSource={data} xName='x' yName='y2' type='StackingBar100'>
</Chart3DSeriesDirective>
</Chart3DSeriesCollectionDirective>
</Chart3DComponent>;
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));import { Chart3DComponent, Chart3DSeriesCollectionDirective, Chart3DSeriesDirective, Category3D, Inject, Legend3D, DataLabel3D, Tooltip3D, StackingBarSeries3D, Highlight3D } from '@syncfusion/ej2-react-charts';
import * as React from "react";
import * as ReactDOM from "react-dom";
function App() {
const data = [
{ x: '2013', y: 9628912, y1: 4298390, y2: 2842133, y3: 2006366 },
{ x: '2014', y: 9609326, y1: 4513769, y2: 3016710, y3: 2165566 },
{ x: '2015', y: 7485587, y1: 4543838, y2: 3034081, y3: 2279503 },
{ x: '2016', y: 7793066, y1: 4999266, y2: 2945295, y3: 2359756 },
{ x: '2017', y: 6856880, y1: 5235842, y2: 3302336, y3: 2505741 }
];
return <Chart3DComponent id='charts' primaryXAxis=
primaryYAxis=
wallColor='transparent'
enableRotation={true} rotation={7} tilt={10} depth={100}>
<Inject services={[StackingBarSeries3D, Category3D, Legend3D, Tooltip3D, DataLabel3D, Highlight3D]} />
<Chart3DSeriesCollectionDirective >
<Chart3DSeriesDirective dataSource={data} xName='x' yName='y' type='StackingBar100'>
</Chart3DSeriesDirective>
<Chart3DSeriesDirective dataSource={data} xName='x' yName='y1' type='StackingBar100'>
</Chart3DSeriesDirective>
<Chart3DSeriesDirective dataSource={data} xName='x' yName='y2' type='StackingBar100'>
</Chart3DSeriesDirective>
</Chart3DSeriesCollectionDirective>
</Chart3DComponent>;
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));100% Cylindrical stacked bar chart
To render a cylindrical 100% stacked bar chart, set the columnFacet property to Cylinder in the chart series.
import { Chart3DComponent, Chart3DSeriesCollectionDirective, Chart3DSeriesDirective, Category3D, Inject, Legend3D, DataLabel3D, Tooltip3D, StackingBarSeries3D, Highlight3D } from '@syncfusion/ej2-react-charts';
import * as React from "react";
import * as ReactDOM from "react-dom";
function App() {
const data = [
{ x: '2013', y: 9628912, y1: 4298390, y2: 2842133, y3: 2006366 },
{ x: '2014', y: 9609326, y1: 4513769, y2: 3016710, y3: 2165566 },
{ x: '2015', y: 7485587, y1: 4543838, y2: 3034081, y3: 2279503 },
{ x: '2016', y: 7793066, y1: 4999266, y2: 2945295, y3: 2359756 },
{ x: '2017', y: 6856880, y1: 5235842, y2: 3302336, y3: 2505741 }
];
return <Chart3DComponent id='charts' primaryXAxis=
primaryYAxis=
wallColor='transparent'
enableRotation={true} rotation={7} tilt={10} depth={100}>
<Inject services={[StackingBarSeries3D, Category3D, Legend3D, Tooltip3D, DataLabel3D, Highlight3D]} />
<Chart3DSeriesCollectionDirective >
<Chart3DSeriesDirective dataSource={data} xName='x' yName='y' type='StackingBar100' columnFacet="Cylinder">
</Chart3DSeriesDirective>
<Chart3DSeriesDirective dataSource={data} xName='x' yName='y1' type='StackingBar100' columnFacet="Cylinder">
</Chart3DSeriesDirective>
<Chart3DSeriesDirective dataSource={data} xName='x' yName='y2' type='StackingBar100' columnFacet="Cylinder">
</Chart3DSeriesDirective>
</Chart3DSeriesCollectionDirective>
</Chart3DComponent>;
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));import { Chart3DComponent, Chart3DSeriesCollectionDirective, Chart3DSeriesDirective, Category3D, Inject, Legend3D, DataLabel3D, Tooltip3D, StackingBarSeries3D, Highlight3D } from '@syncfusion/ej2-react-charts';
import * as React from "react";
import * as ReactDOM from "react-dom";
function App() {
const data = [
{ x: '2013', y: 9628912, y1: 4298390, y2: 2842133, y3: 2006366 },
{ x: '2014', y: 9609326, y1: 4513769, y2: 3016710, y3: 2165566 },
{ x: '2015', y: 7485587, y1: 4543838, y2: 3034081, y3: 2279503 },
{ x: '2016', y: 7793066, y1: 4999266, y2: 2945295, y3: 2359756 },
{ x: '2017', y: 6856880, y1: 5235842, y2: 3302336, y3: 2505741 }
];
return <Chart3DComponent id='charts' primaryXAxis=
primaryYAxis=
wallColor='transparent'
enableRotation={true} rotation={7} tilt={10} depth={100}>
<Inject services={[StackingBarSeries3D, Category3D, Legend3D, Tooltip3D, DataLabel3D, Highlight3D]} />
<Chart3DSeriesCollectionDirective >
<Chart3DSeriesDirective dataSource={data} xName='x' yName='y' type='StackingBar100' columnFacet="Cylinder">
</Chart3DSeriesDirective>
<Chart3DSeriesDirective dataSource={data} xName='x' yName='y1' type='StackingBar100' columnFacet="Cylinder">
</Chart3DSeriesDirective>
<Chart3DSeriesDirective dataSource={data} xName='x' yName='y2' type='StackingBar100' columnFacet="Cylinder">
</Chart3DSeriesDirective>
</Chart3DSeriesCollectionDirective>
</Chart3DComponent>;
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));Series customization
The following properties can be used to customize the 100% stacked bar series.
import { Chart3DComponent, Chart3DSeriesCollectionDirective, Chart3DSeriesDirective, Category3D, Inject, Legend3D, DataLabel3D, Tooltip3D, StackingBarSeries3D, Highlight3D } from '@syncfusion/ej2-react-charts';
import * as React from "react";
import * as ReactDOM from "react-dom";
function App() {
const data = [
{ x: '2013', y: 9628912, y1: 4298390, y2: 2842133, y3: 2006366 },
{ x: '2014', y: 9609326, y1: 4513769, y2: 3016710, y3: 2165566 },
{ x: '2015', y: 7485587, y1: 4543838, y2: 3034081, y3: 2279503 },
{ x: '2016', y: 7793066, y1: 4999266, y2: 2945295, y3: 2359756 },
{ x: '2017', y: 6856880, y1: 5235842, y2: 3302336, y3: 2505741 }
];
return <Chart3DComponent id='charts' primaryXAxis=
primaryYAxis=
wallColor='transparent'
enableRotation={true} rotation={7} tilt={10} depth={100}>
<Inject services={[StackingBarSeries3D, Category3D, Legend3D, Tooltip3D, DataLabel3D, Highlight3D]} />
<Chart3DSeriesCollectionDirective >
<Chart3DSeriesDirective dataSource={data} xName='x' yName='y' type='StackingBar100' fill="red">
</Chart3DSeriesDirective>
<Chart3DSeriesDirective dataSource={data} xName='x' yName='y1' type='StackingBar100' fill="green">
</Chart3DSeriesDirective>
<Chart3DSeriesDirective dataSource={data} xName='x' yName='y2' type='StackingBar100' fill="yellow">
</Chart3DSeriesDirective>
<Chart3DSeriesDirective dataSource={data} xName='x' yName='y3' type='StackingBar100' fill="blue">
</Chart3DSeriesDirective>
</Chart3DSeriesCollectionDirective>
</Chart3DComponent>;
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));import { Chart3DComponent, Chart3DSeriesCollectionDirective, Chart3DSeriesDirective, Category3D, Inject, Legend3D, DataLabel3D, Tooltip3D, StackingBarSeries3D, Highlight3D } from '@syncfusion/ej2-react-charts';
import * as React from "react";
import * as ReactDOM from "react-dom";
function App() {
const data = [
{ x: '2013', y: 9628912, y1: 4298390, y2: 2842133, y3: 2006366 },
{ x: '2014', y: 9609326, y1: 4513769, y2: 3016710, y3: 2165566 },
{ x: '2015', y: 7485587, y1: 4543838, y2: 3034081, y3: 2279503 },
{ x: '2016', y: 7793066, y1: 4999266, y2: 2945295, y3: 2359756 },
{ x: '2017', y: 6856880, y1: 5235842, y2: 3302336, y3: 2505741 }
];
return <Chart3DComponent id='charts' primaryXAxis=
primaryYAxis=
wallColor='transparent'
enableRotation={true} rotation={7} tilt={10} depth={100}>
<Inject services={[StackingBarSeries3D, Category3D, Legend3D, Tooltip3D, DataLabel3D, Highlight3D]} />
<Chart3DSeriesCollectionDirective >
<Chart3DSeriesDirective dataSource={data} xName='x' yName='y' type='StackingBar100' fill="red">
</Chart3DSeriesDirective>
<Chart3DSeriesDirective dataSource={data} xName='x' yName='y1' type='StackingBar100' fill="green">
</Chart3DSeriesDirective>
<Chart3DSeriesDirective dataSource={data} xName='x' yName='y2' type='StackingBar100' fill="yellow">
</Chart3DSeriesDirective>
<Chart3DSeriesDirective dataSource={data} xName='x' yName='y3' type='StackingBar100' fill="blue">
</Chart3DSeriesDirective>
</Chart3DSeriesCollectionDirective>
</Chart3DComponent>;
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));