---
title: "Combination Charts"
framework: vue
version: "14.1.0"
---

# Combination Charts

A combination chart combines two or more series types allowing for flexible data visualisations. They are ideal for making visual comparisons of different sets of data in a single chart.

## Combination Series Types

It is possible to create Combination Charts using the following series types: `bar`, `line`, `area`, `scatter` and `bubble`.

The `type` property must be specified explicitly on each individual series object in the `series` options array, as shown below:

```js
{
    series: [
        {
            type: 'bar', // use 'bar' series
            xKey: 'year',
            yKey: 'men',
            // ...other series options
        },
        {
            type: 'line', // use 'line' series
            xKey: 'year',
            yKey: 'portions',
            // ...other series options
        },
    ],
}
```

The snippet above shows the configuration required for a combination chart consisting of a `bar` and `line` series.

The example below demonstrates two common combination chart types. You can switch between these two combination chart types using the buttons above the chart. Please note:

- Series are rendered according to the order in which they are added in the `series` array.
- The area and line series are plotted on a [Secondary Axis](https://www.ag-grid.com/charts/vue/axes-secondary/) with a different scale.

#### Combination Charts

```ts
import { createApp, defineComponent, ref } from "vue";
import { AgCharts } from "ag-charts-vue3";
import type { AgChartOptions } from "ag-charts-types";
import {
  AreaSeriesModule,
  BarSeriesModule,
  CategoryAxisModule,
  LegendModule,
  LineSeriesModule,
  ModuleRegistry,
  NumberAxisModule,
} from "ag-charts-community";
import { getData } from "./data";
import clone from "clone";

const WOMEN = {
  type: "bar",
  xKey: "year",
  yKey: "women",
  yName: "Women",
  grouped: true,
};

const MEN = {
  type: "bar",
  xKey: "year",
  yKey: "men",
  yName: "Men",
  grouped: true,
};

const PORTIONS = {
  type: "line",
  xKey: "year",
  yKey: "portions",
  yName: "Portions",
  yKeyAxis: "ySecondary",
};

const BAR_AND_LINE = [
  { ...WOMEN, type: "bar" },
  { ...MEN, type: "bar" },
  { ...PORTIONS, type: "line" },
];

const AREA_AND_BAR = [
  { ...PORTIONS, type: "area" },
  { ...WOMEN, type: "bar" },
  { ...MEN, type: "bar" },
];

ModuleRegistry.registerModules([
  AreaSeriesModule,
  BarSeriesModule,
  CategoryAxisModule,
  LineSeriesModule,
  NumberAxisModule,
  LegendModule,
]);

const ChartExample = defineComponent({
  template: `
    <div class="example-controls">
      <div class="controls-row">
        <button v-on:click="areaBar()">Area &amp; Bar</button>
        <button v-on:click="barLine()">Bar &amp; Line</button>
      </div>
    </div>
    <ag-charts
      :options="options"
    />
  `,
  components: {
    "ag-charts": AgCharts,
  },
  setup(props) {
    const options = ref<AgCartesianChartOptions>({
      data: getData(),
      title: {
        text: "Fruit & Vegetable Consumption",
      },
      series: BAR_AND_LINE,
      axes: {
        y: {
          type: "number",
          position: "left",
          title: {
            text: "Adults Who Eat 5 A Day (%)",
          },
        },
        ySecondary: {
          type: "number",
          position: "right",
          title: {
            text: "Portions Consumed (Per Day)",
          },
        },
      },
    });

    const barLine = () => {
      const optionsCopy = clone(options.value);

      optionsCopy.series = BAR_AND_LINE;

      options.value = optionsCopy;
    };
    const areaBar = () => {
      const optionsCopy = clone(options.value);

      optionsCopy.series = AREA_AND_BAR;

      options.value = optionsCopy;
    };

    return {
      options,
      barLine,
      areaBar,
    };
  },
});

createApp(ChartExample).mount("#app");
```

[Live example: Combination Charts](https://www.ag-grid.com/charts/vue3/combination-series/examples/combination)
