# chart-stacked-column

> Stacked Column chart of country-level cotton production from 2019-2024 with legend-driven colors.

**Framework:** javascript  **Component:** Chart  **Variant:** stacked-column

## Get this item

**If you are an agent, fetch the JSON.** Source is inlined, so one request is enough and no tooling is required:

```
GET https://ai.syncfusion.com/r/javascript/chart-stacked-column.json
```

**Install Package(s)**

```bash
npm install @syncfusion/ej2-charts
```

**Notes**

- Syncfusion release: 2026 Volume 3 (v35.1.37)
- The Syncfusion package is licensed. The composition in this file is source you own and edit. See https://ai.syncfusion.com/licensing.md

## Source files

### src/components/chart-stacked-column/chart.html

```html
<div class="control-section">
    <div id="container" align="center"></div>
</div>
```

### src/components/chart-stacked-column/chart.ts

```typescript
import { Chart, StackingColumnSeries, Category, Legend, Tooltip, DataLabel, type ILoadedEventArgs, Highlight } from '@syncfusion/ej2-charts';
import { Browser } from '@syncfusion/ej2-base';
import { stackedColumnChartData } from '../datasource/chart-data';

Chart.Inject(StackingColumnSeries, Category, Legend, Tooltip, Highlight, DataLabel);

/**
 * Sample for StackedColumn Series
 * Initializes chart within the pre-loaded HTML element from chart.html
 */
export function initStackedColumnChart(): void {
  const data = stackedColumnChartData[0];

  let chart: Chart = new Chart({
    //Initializing Primary X Axis
    primaryXAxis: {
      majorGridLines: { width: 0 },
      minorGridLines: { width: 0 },
      majorTickLines: { width: 0 },
      minorTickLines: { width: 0 },
      interval: 1,
      lineStyle: { width: 0 },
      labelIntersectAction: 'Rotate45',
      valueType: 'Category'
    },
    //Initializing Primary Y Axis
    primaryYAxis: {
      title: 'Production (60KG Bags)',
      lineStyle: { width: 0 },
      majorTickLines: { width: 0 },
      majorGridLines: { width: 1 },
      minorGridLines: { width: 1 },
      minorTickLines: { width: 0 },
      labelFormat: '{value}M',
      interval: 20
    },
    chartArea: {
      border: {
        width: 0
      },
      margin: {
        bottom: 12
      }
    },
    //Initializing Chart Series
    series: data.series.map((s, index) => ({
      type: 'StackingColumn',
      dataSource: s.data,
      xName: 'x',
      yName: 'y',
      name: s.name,
      columnWidth: 0.4,
      border: { width: 1, color: 'white' },
      cornerRadius: index === 2 ? { topLeft: 4, topRight: 4 } : undefined,
      marker: {
        dataLabel: {
          visible: true,
          font: { size: Browser.isDevice ? '10px' : '12px' }
        }
      },
      legendShape: 'Rectangle'
    })),

    //Initializing Chart title
    title: data.title,
    subTitle: data.subTitle,
    //Initializing User Interaction Tooltip
    tooltip: {
      enable: true,
      enableHighlight: true,
      header: '<b>${point.x}</b>',
      format: '${series.name} : <b>${point.y}</b>'
    },
    width: Browser.isDevice ? '100%' : '75%',
    legendSettings: { enableHighlight: true },
    load: (_args: ILoadedEventArgs) => {
      // Load event handler
    }
  });
  chart.appendTo('#container');
}

```
