Stacked line Chart in Vue Component
7 Apr 202524 minutes to read
Stacked line
To render a stacked line series in your chart, you need to follow a few steps to configure it correctly. Here’s a concise guide on how to do this:
-
Set the series type: Define the series
type
asStackingLine
in your chart configuration. This indicates that the data should be represented as a stacked line chart, allowing multiple data series to be stacked on top of each other. This makes it easier to compare the contribution of each series to the total over a specific period. -
Inject the StackingLineSeries module: Use the
provide: { chart: [StackingLineSeries]}
method to inject theStackingLineSeries
module into your chart. This step is essential, as it ensures that the necessary functionalities for rendering stacked line series are available in your chart.
<template>
<div id="app">
<ejs-chart id="chartcontainer" :primaryXAxis="primaryXAxis" :primaryYAxis="primaryYAxis" :tooltip="tooltip" :chartArea="chartArea">
<e-series-collection>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y" name="John" :marker="marker"></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y1" name="Peter" :marker="marker"></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y2" name="Steve" :marker="marker"></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y3" name="Charle" :marker="marker"></e-series>
</e-series-collection>
</ejs-chart>
</div>
</template>
<script setup>
import { provide } from "vue";
import { ChartComponent as EjsChart, SeriesCollectionDirective as ESeriesCollection, SeriesDirective as ESeries, Category, Legend, Tooltip, StackingLineSeries } from "@syncfusion/ej2-vue-charts";
const seriesData = [
{ x: "Food", y: 90, y1: 40, y2: 70, y3: 120 },
{ x: "Transport", y: 80, y1: 90, y2: 110, y3: 70 },
{ x: "Medical", y: 50, y1: 80, y2: 120, y3: 50 },
{ x: "Clothes", y: 70, y1: 30, y2: 60, y3: 180 },
{ x: "Personal Care", y: 30, y1: 80, y2: 80, y3: 30 },
{ x: "Books", y: 10, y1: 40, y2: 30, y3: 270 },
{ x: "Fitness", y: 100, y1: 30, y2: 70, y3: 40 },
{ x: "Electricity", y: 55, y1: 95, y2: 55, y3: 75 },
{ x: "Tax", y: 20, y1: 50, y2: 40, y3: 65 },
{ x: "Pet Care", y: 40, y1: 20, y2: 80, y3: 95 },
{ x: "Education", y: 45, y1: 15, y2: 45, y3: 195 },
{ x: "Entertainment", y: 75, y1: 45, y2: 65, y3: 115 }
];
const primaryXAxis = {
interval: 1,
valueType: 'Category'
};
const primaryYAxis = {
title: 'Expense',
interval: 100,
labelFormat: '${value}'
};
const chartArea = {
border: {
width: 0
}
};
const marker = {
visible: true
};
const tooltip = {
enable: true
};
provide('chart', [Category, Legend, Tooltip, StackingLineSeries]);
</script>
<style>
#container {
height: 350px;
}
</style>
<template>
<div id="app">
<ejs-chart id="chartcontainer" :primaryXAxis="primaryXAxis" :primaryYAxis="primaryYAxis" :tooltip="tooltip" :chartArea="chartArea">
<e-series-collection>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y" name="John" :marker="marker"></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y1" name="Peter" :marker="marker"></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y2" name="Steve" :marker="marker"></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y3" name="Charle" :marker="marker"></e-series>
</e-series-collection>
</ejs-chart>
</div>
</template>
<script>
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Category, Legend, Tooltip, StackingLineSeries } from "@syncfusion/ej2-vue-charts";
export default {
name: "App",
components: {
'ejs-chart': ChartComponent,
'e-series-collection': SeriesCollectionDirective,
'e-series': SeriesDirective
},
data() {
return {
seriesData: [
{ x: 'Food', y: 90, y1: 40, y2: 70, y3: 120 },
{ x: 'Transport', y: 80, y1: 90, y2: 110, y3: 70 },
{ x: 'Medical', y: 50, y1: 80, y2: 120, y3: 50 },
{ x: 'Clothes', y: 70, y1: 30, y2: 60, y3: 180 },
{ x: 'Personal Care', y: 30, y1: 80, y2: 80, y3: 30 },
{ x: 'Books', y: 10, y1: 40, y2: 30, y3: 270 },
{ x: 'Fitness', y: 100, y1: 30, y2: 70, y3: 40 },
{ x: 'Electricity', y: 55, y1: 95, y2: 55, y3: 75 },
{ x: 'Tax', y: 20, y1: 50, y2: 40, y3: 65 },
{ x: 'Pet Care', y: 40, y1: 20, y2: 80, y3: 95 },
{ x: 'Education', y: 45, y1: 15, y2: 45, y3: 195 },
{ x: 'Entertainment', y: 75, y1: 45, y2: 65, y3: 115 }
],
primaryXAxis: {
interval: 1,
valueType: 'Category'
},
primaryYAxis: {
title: 'Expense',
interval: 100,
labelFormat: '${value}'
},
chartArea: {
border: {
width: 0
}
},
marker: {
visible: true
},
tooltip: {
enable: true
}
};
},
provide: {
chart: [Category, Legend, Tooltip, StackingLineSeries]
}
};
</script>
<style>
#container {
height: 350px;
}
</style>
Binding data with series
You can bind data to the chart using the dataSource
property within the series configuration. This allows you to connect a JSON dataset or remote data to your chart. To display the data correctly, map the fields from the data to the chart series xName
and yName
properties.
<template>
<div id="app">
<ejs-chart id="chartcontainer" :primaryXAxis="primaryXAxis" :primaryYAxis="primaryYAxis" :tooltip="tooltip" :chartArea="chartArea">
<e-series-collection>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y" name="John" :marker="marker"></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y1" name="Peter" :marker="marker"></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y2" name="Steve" :marker="marker"></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y3" name="Charle" :marker="marker"></e-series>
</e-series-collection>
</ejs-chart>
</div>
</template>
<script setup>
import { provide } from "vue";
import { ChartComponent as EjsChart, SeriesCollectionDirective as ESeriesCollection, SeriesDirective as ESeries, Category, Legend, Tooltip, StackingLineSeries } from "@syncfusion/ej2-vue-charts";
const seriesData = [
{ x: "Food", y: 90, y1: 40, y2: 70, y3: 120 },
{ x: "Transport", y: 80, y1: 90, y2: 110, y3: 70 },
{ x: "Medical", y: 50, y1: 80, y2: 120, y3: 50 },
{ x: "Clothes", y: 70, y1: 30, y2: 60, y3: 180 },
{ x: "Personal Care", y: 30, y1: 80, y2: 80, y3: 30 },
{ x: "Books", y: 10, y1: 40, y2: 30, y3: 270 },
{ x: "Fitness", y: 100, y1: 30, y2: 70, y3: 40 },
{ x: "Electricity", y: 55, y1: 95, y2: 55, y3: 75 },
{ x: "Tax", y: 20, y1: 50, y2: 40, y3: 65 },
{ x: "Pet Care", y: 40, y1: 20, y2: 80, y3: 95 },
{ x: "Education", y: 45, y1: 15, y2: 45, y3: 195 },
{ x: "Entertainment", y: 75, y1: 45, y2: 65, y3: 115 }
];
const primaryXAxis = {
interval: 1,
valueType: 'Category'
};
const primaryYAxis = {
title: 'Expense',
interval: 100,
labelFormat: '${value}'
};
const chartArea = {
border: {
width: 0
}
};
const marker = {
visible: true
};
const tooltip = {
enable: true
};
provide('chart', [Category, Legend, Tooltip, StackingLineSeries]);
</script>
<style>
#container {
height: 350px;
}
</style>
<template>
<div id="app">
<ejs-chart id="chartcontainer" :primaryXAxis="primaryXAxis" :primaryYAxis="primaryYAxis" :tooltip="tooltip" :chartArea="chartArea">
<e-series-collection>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y" name="John" :marker="marker"></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y1" name="Peter" :marker="marker"></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y2" name="Steve" :marker="marker"></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y3" name="Charle" :marker="marker"></e-series>
</e-series-collection>
</ejs-chart>
</div>
</template>
<script>
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Category, Legend, Tooltip, StackingLineSeries } from "@syncfusion/ej2-vue-charts";
export default {
name: "App",
components: {
'ejs-chart': ChartComponent,
'e-series-collection': SeriesCollectionDirective,
'e-series': SeriesDirective
},
data() {
return {
seriesData: [
{ x: 'Food', y: 90, y1: 40, y2: 70, y3: 120 },
{ x: 'Transport', y: 80, y1: 90, y2: 110, y3: 70 },
{ x: 'Medical', y: 50, y1: 80, y2: 120, y3: 50 },
{ x: 'Clothes', y: 70, y1: 30, y2: 60, y3: 180 },
{ x: 'Personal Care', y: 30, y1: 80, y2: 80, y3: 30 },
{ x: 'Books', y: 10, y1: 40, y2: 30, y3: 270 },
{ x: 'Fitness', y: 100, y1: 30, y2: 70, y3: 40 },
{ x: 'Electricity', y: 55, y1: 95, y2: 55, y3: 75 },
{ x: 'Tax', y: 20, y1: 50, y2: 40, y3: 65 },
{ x: 'Pet Care', y: 40, y1: 20, y2: 80, y3: 95 },
{ x: 'Education', y: 45, y1: 15, y2: 45, y3: 195 },
{ x: 'Entertainment', y: 75, y1: 45, y2: 65, y3: 115 }
],
primaryXAxis: {
interval: 1,
valueType: 'Category'
},
primaryYAxis: {
title: 'Expense',
interval: 100,
labelFormat: '${value}'
},
chartArea: {
border: {
width: 0
}
},
marker: {
visible: true
},
tooltip: {
enable: true
}
};
},
provide: {
chart: [Category, Legend, Tooltip, StackingLineSeries]
}
};
</script>
<style>
#container {
height: 350px;
}
</style>
Series customization
The following properties can be used to customize the stacked line
series.
Fill
The fill property determines the color applied to the series.
<template>
<div id="app">
<ejs-chart id="chartcontainer" :primaryXAxis="primaryXAxis" :primaryYAxis="primaryYAxis" :tooltip="tooltip" :chartArea="chartArea">
<e-series-collection>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y" name="John" :marker="marker" fill='#ff4251'></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y1" name="Peter" :marker="marker" fill='#4C4C4C'></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y2" name="Steve" :marker="marker" fill='#794F1B'></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y3" name="Charle" :marker="marker" fill='#1a9a6f'></e-series>
</e-series-collection>
</ejs-chart>
</div>
</template>
<script setup>
import { provide } from "vue";
import { ChartComponent as EjsChart, SeriesCollectionDirective as ESeriesCollection, SeriesDirective as ESeries, Category, Legend, Tooltip, StackingLineSeries } from "@syncfusion/ej2-vue-charts";
const seriesData = [
{ x: "Food", y: 90, y1: 40, y2: 70, y3: 120 },
{ x: "Transport", y: 80, y1: 90, y2: 110, y3: 70 },
{ x: "Medical", y: 50, y1: 80, y2: 120, y3: 50 },
{ x: "Clothes", y: 70, y1: 30, y2: 60, y3: 180 },
{ x: "Personal Care", y: 30, y1: 80, y2: 80, y3: 30 },
{ x: "Books", y: 10, y1: 40, y2: 30, y3: 270 },
{ x: "Fitness", y: 100, y1: 30, y2: 70, y3: 40 },
{ x: "Electricity", y: 55, y1: 95, y2: 55, y3: 75 },
{ x: "Tax", y: 20, y1: 50, y2: 40, y3: 65 },
{ x: "Pet Care", y: 40, y1: 20, y2: 80, y3: 95 },
{ x: "Education", y: 45, y1: 15, y2: 45, y3: 195 },
{ x: "Entertainment", y: 75, y1: 45, y2: 65, y3: 115 }
];
const primaryXAxis = {
interval: 1,
valueType: 'Category'
};
const primaryYAxis = {
title: 'Expense',
interval: 100,
labelFormat: '${value}'
};
const chartArea = {
border: {
width: 0
}
};
const marker = {
visible: true
};
const tooltip = {
enable: true
};
provide('chart', [Category, Legend, Tooltip, StackingLineSeries]);
</script>
<style>
#container {
height: 350px;
}
</style>
<template>
<div id="app">
<ejs-chart id="chartcontainer" :primaryXAxis="primaryXAxis" :primaryYAxis="primaryYAxis" :tooltip="tooltip" :chartArea="chartArea">
<e-series-collection>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y" name="John" :marker="marker" fill='#ff4251'></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y1" name="Peter" :marker="marker" fill='#4C4C4C'></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y2" name="Steve" :marker="marker" fill='#794F1B'></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y3" name="Charle" :marker="marker" fill='#1a9a6f'></e-series>
</e-series-collection>
</ejs-chart>
</div>
</template>
<script>
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Category, Legend, Tooltip, StackingLineSeries } from "@syncfusion/ej2-vue-charts";
export default {
name: "App",
components: {
'ejs-chart': ChartComponent,
'e-series-collection': SeriesCollectionDirective,
'e-series': SeriesDirective
},
data() {
return {
seriesData: [
{ x: 'Food', y: 90, y1: 40, y2: 70, y3: 120 },
{ x: 'Transport', y: 80, y1: 90, y2: 110, y3: 70 },
{ x: 'Medical', y: 50, y1: 80, y2: 120, y3: 50 },
{ x: 'Clothes', y: 70, y1: 30, y2: 60, y3: 180 },
{ x: 'Personal Care', y: 30, y1: 80, y2: 80, y3: 30 },
{ x: 'Books', y: 10, y1: 40, y2: 30, y3: 270 },
{ x: 'Fitness', y: 100, y1: 30, y2: 70, y3: 40 },
{ x: 'Electricity', y: 55, y1: 95, y2: 55, y3: 75 },
{ x: 'Tax', y: 20, y1: 50, y2: 40, y3: 65 },
{ x: 'Pet Care', y: 40, y1: 20, y2: 80, y3: 95 },
{ x: 'Education', y: 45, y1: 15, y2: 45, y3: 195 },
{ x: 'Entertainment', y: 75, y1: 45, y2: 65, y3: 115 }
],
primaryXAxis: {
interval: 1,
valueType: 'Category'
},
primaryYAxis: {
title: 'Expense',
interval: 100,
labelFormat: '${value}'
},
chartArea: {
border: {
width: 0
}
},
marker: {
visible: true
},
tooltip: {
enable: true
}
};
},
provide: {
chart: [Category, Legend, Tooltip, StackingLineSeries]
}
};
</script>
<style>
#container {
height: 350px;
}
</style>
The fill property can be used to apply a gradient color to the stacked line series. By configuring this property with gradient values, you can create a visually appealing effect in which the color transitions smoothly from one shade to another.
<template>
<div id="app">
<ejs-chart id="chartcontainer" :primaryXAxis="primaryXAxis" :primaryYAxis="primaryYAxis" :tooltip="tooltip" :chartArea="chartArea">
<e-series-collection>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y" name="John" :marker="marker" fill='url(#gradient1)'></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y1" name="Peter" :marker="marker" fill='url(#gradient2)'></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y2" name="Steve" :marker="marker" fill='url(#gradient3)'></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y3" name="Charle" :marker="marker" fill='url(#gradient4)'></e-series>
</e-series-collection>
</ejs-chart>
</div>
</template>
<script setup>
import { provide } from "vue";
import { ChartComponent as EjsChart, SeriesCollectionDirective as ESeriesCollection, SeriesDirective as ESeries, Category, Legend, Tooltip, StackingLineSeries } from "@syncfusion/ej2-vue-charts";
const seriesData = [
{ x: "Food", y: 90, y1: 40, y2: 70, y3: 120 },
{ x: "Transport", y: 80, y1: 90, y2: 110, y3: 70 },
{ x: "Medical", y: 50, y1: 80, y2: 120, y3: 50 },
{ x: "Clothes", y: 70, y1: 30, y2: 60, y3: 180 },
{ x: "Personal Care", y: 30, y1: 80, y2: 80, y3: 30 },
{ x: "Books", y: 10, y1: 40, y2: 30, y3: 270 },
{ x: "Fitness", y: 100, y1: 30, y2: 70, y3: 40 },
{ x: "Electricity", y: 55, y1: 95, y2: 55, y3: 75 },
{ x: "Tax", y: 20, y1: 50, y2: 40, y3: 65 },
{ x: "Pet Care", y: 40, y1: 20, y2: 80, y3: 95 },
{ x: "Education", y: 45, y1: 15, y2: 45, y3: 195 },
{ x: "Entertainment", y: 75, y1: 45, y2: 65, y3: 115 }
];
const primaryXAxis = {
interval: 1,
valueType: 'Category'
};
const primaryYAxis = {
title: 'Expense',
interval: 100,
labelFormat: '${value}'
};
const chartArea = {
border: {
width: 0
}
};
const marker = {
visible: true
};
const tooltip = {
enable: true
};
provide('chart', [Category, Legend, Tooltip, StackingLineSeries]);
</script>
<style>
#container {
height: 350px;
}
</style>
<template>
<div id="app">
<ejs-chart id="chartcontainer" :primaryXAxis="primaryXAxis" :primaryYAxis="primaryYAxis" :tooltip="tooltip" :chartArea="chartArea">
<e-series-collection>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y" name="John" :marker="marker" fill='url(#gradient1)'></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y1" name="Peter" :marker="marker" fill='url(#gradient2)'></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y2" name="Steve" :marker="marker" fill='url(#gradient3)'></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y3" name="Charle" :marker="marker" fill='url(#gradient4)'></e-series>
</e-series-collection>
</ejs-chart>
</div>
</template>
<script>
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Category, Legend, Tooltip, StackingLineSeries } from "@syncfusion/ej2-vue-charts";
export default {
name: "App",
components: {
'ejs-chart': ChartComponent,
'e-series-collection': SeriesCollectionDirective,
'e-series': SeriesDirective
},
data() {
return {
seriesData: [
{ x: 'Food', y: 90, y1: 40, y2: 70, y3: 120 },
{ x: 'Transport', y: 80, y1: 90, y2: 110, y3: 70 },
{ x: 'Medical', y: 50, y1: 80, y2: 120, y3: 50 },
{ x: 'Clothes', y: 70, y1: 30, y2: 60, y3: 180 },
{ x: 'Personal Care', y: 30, y1: 80, y2: 80, y3: 30 },
{ x: 'Books', y: 10, y1: 40, y2: 30, y3: 270 },
{ x: 'Fitness', y: 100, y1: 30, y2: 70, y3: 40 },
{ x: 'Electricity', y: 55, y1: 95, y2: 55, y3: 75 },
{ x: 'Tax', y: 20, y1: 50, y2: 40, y3: 65 },
{ x: 'Pet Care', y: 40, y1: 20, y2: 80, y3: 95 },
{ x: 'Education', y: 45, y1: 15, y2: 45, y3: 195 },
{ x: 'Entertainment', y: 75, y1: 45, y2: 65, y3: 115 }
],
primaryXAxis: {
interval: 1,
valueType: 'Category'
},
primaryYAxis: {
title: 'Expense',
interval: 100,
labelFormat: '${value}'
},
chartArea: {
border: {
width: 0
}
},
marker: {
visible: true
},
tooltip: {
enable: true
}
};
},
provide: {
chart: [Category, Legend, Tooltip, StackingLineSeries]
}
};
</script>
<style>
#container {
height: 350px;
}
</style>
Opacity
The opacity property specifies the transparency level of the fill. Adjusting this property allows you to control how opaque or transparent the fill color of the series appears.
<template>
<div id="app">
<ejs-chart id="chartcontainer" :primaryXAxis="primaryXAxis" :primaryYAxis="primaryYAxis" :tooltip="tooltip" :chartArea="chartArea">
<e-series-collection>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y" name="John" :marker="marker" opacity=0.7></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y1" name="Peter" :marker="marker" opacity=0.7></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y2" name="Steve" :marker="marker" opacity=0.7></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y3" name="Charle" :marker="marker" opacity=0.7></e-series>
</e-series-collection>
</ejs-chart>
</div>
</template>
<script setup>
import { provide } from "vue";
import { ChartComponent as EjsChart, SeriesCollectionDirective as ESeriesCollection, SeriesDirective as ESeries, Category, Legend, Tooltip, StackingLineSeries } from "@syncfusion/ej2-vue-charts";
const seriesData = [
{ x: "Food", y: 90, y1: 40, y2: 70, y3: 120 },
{ x: "Transport", y: 80, y1: 90, y2: 110, y3: 70 },
{ x: "Medical", y: 50, y1: 80, y2: 120, y3: 50 },
{ x: "Clothes", y: 70, y1: 30, y2: 60, y3: 180 },
{ x: "Personal Care", y: 30, y1: 80, y2: 80, y3: 30 },
{ x: "Books", y: 10, y1: 40, y2: 30, y3: 270 },
{ x: "Fitness", y: 100, y1: 30, y2: 70, y3: 40 },
{ x: "Electricity", y: 55, y1: 95, y2: 55, y3: 75 },
{ x: "Tax", y: 20, y1: 50, y2: 40, y3: 65 },
{ x: "Pet Care", y: 40, y1: 20, y2: 80, y3: 95 },
{ x: "Education", y: 45, y1: 15, y2: 45, y3: 195 },
{ x: "Entertainment", y: 75, y1: 45, y2: 65, y3: 115 }
];
const primaryXAxis = {
interval: 1,
valueType: 'Category'
};
const primaryYAxis = {
title: 'Expense',
interval: 100,
labelFormat: '${value}'
};
const chartArea = {
border: {
width: 0
}
};
const marker = {
visible: true
};
const tooltip = {
enable: true
};
provide('chart', [Category, Legend, Tooltip, StackingLineSeries]);
</script>
<style>
#container {
height: 350px;
}
</style>
<template>
<div id="app">
<ejs-chart id="chartcontainer" :primaryXAxis="primaryXAxis" :primaryYAxis="primaryYAxis" :tooltip="tooltip" :chartArea="chartArea">
<e-series-collection>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y" name="John" :marker="marker" opacity=0.7></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y1" name="Peter" :marker="marker" opacity=0.7></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y2" name="Steve" :marker="marker" opacity=0.7></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y3" name="Charle" :marker="marker" opacity=0.7></e-series>
</e-series-collection>
</ejs-chart>
</div>
</template>
<script>
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Category, Legend, Tooltip, StackingLineSeries } from "@syncfusion/ej2-vue-charts";
export default {
name: "App",
components: {
'ejs-chart': ChartComponent,
'e-series-collection': SeriesCollectionDirective,
'e-series': SeriesDirective
},
data() {
return {
seriesData: [
{ x: 'Food', y: 90, y1: 40, y2: 70, y3: 120 },
{ x: 'Transport', y: 80, y1: 90, y2: 110, y3: 70 },
{ x: 'Medical', y: 50, y1: 80, y2: 120, y3: 50 },
{ x: 'Clothes', y: 70, y1: 30, y2: 60, y3: 180 },
{ x: 'Personal Care', y: 30, y1: 80, y2: 80, y3: 30 },
{ x: 'Books', y: 10, y1: 40, y2: 30, y3: 270 },
{ x: 'Fitness', y: 100, y1: 30, y2: 70, y3: 40 },
{ x: 'Electricity', y: 55, y1: 95, y2: 55, y3: 75 },
{ x: 'Tax', y: 20, y1: 50, y2: 40, y3: 65 },
{ x: 'Pet Care', y: 40, y1: 20, y2: 80, y3: 95 },
{ x: 'Education', y: 45, y1: 15, y2: 45, y3: 195 },
{ x: 'Entertainment', y: 75, y1: 45, y2: 65, y3: 115 }
],
primaryXAxis: {
interval: 1,
valueType: 'Category'
},
primaryYAxis: {
title: 'Expense',
interval: 100,
labelFormat: '${value}'
},
chartArea: {
border: {
width: 0
}
},
marker: {
visible: true
},
tooltip: {
enable: true
}
};
},
provide: {
chart: [Category, Legend, Tooltip, StackingLineSeries]
}
};
</script>
<style>
#container {
height: 350px;
}
</style>
Dash array
The dashArray property determines the pattern of dashes and gaps in the series.
<template>
<div id="app">
<ejs-chart id="chartcontainer" :primaryXAxis="primaryXAxis" :primaryYAxis="primaryYAxis" :tooltip="tooltip" :chartArea="chartArea">
<e-series-collection>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y" name="John" :marker="marker" dashArray='5,5'></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y1" name="Peter" :marker="marker" dashArray='5,5'></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y2" name="Steve" :marker="marker" dashArray='5,5'></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y3" name="Charle" :marker="marker" dashArray='5,5'></e-series>
</e-series-collection>
</ejs-chart>
</div>
</template>
<script setup>
import { provide } from "vue";
import { ChartComponent as EjsChart, SeriesCollectionDirective as ESeriesCollection, SeriesDirective as ESeries, Category, Legend, Tooltip, StackingLineSeries } from "@syncfusion/ej2-vue-charts";
const seriesData = [
{ x: "Food", y: 90, y1: 40, y2: 70, y3: 120 },
{ x: "Transport", y: 80, y1: 90, y2: 110, y3: 70 },
{ x: "Medical", y: 50, y1: 80, y2: 120, y3: 50 },
{ x: "Clothes", y: 70, y1: 30, y2: 60, y3: 180 },
{ x: "Personal Care", y: 30, y1: 80, y2: 80, y3: 30 },
{ x: "Books", y: 10, y1: 40, y2: 30, y3: 270 },
{ x: "Fitness", y: 100, y1: 30, y2: 70, y3: 40 },
{ x: "Electricity", y: 55, y1: 95, y2: 55, y3: 75 },
{ x: "Tax", y: 20, y1: 50, y2: 40, y3: 65 },
{ x: "Pet Care", y: 40, y1: 20, y2: 80, y3: 95 },
{ x: "Education", y: 45, y1: 15, y2: 45, y3: 195 },
{ x: "Entertainment", y: 75, y1: 45, y2: 65, y3: 115 }
];
const primaryXAxis = {
interval: 1,
valueType: 'Category'
};
const primaryYAxis = {
title: 'Expense',
interval: 100,
labelFormat: '${value}'
};
const chartArea = {
border: {
width: 0
}
};
const marker = {
visible: true
};
const tooltip = {
enable: true
};
provide('chart', [Category, Legend, Tooltip, StackingLineSeries]);
</script>
<style>
#container {
height: 350px;
}
</style>
<template>
<div id="app">
<ejs-chart id="chartcontainer" :primaryXAxis="primaryXAxis" :primaryYAxis="primaryYAxis" :tooltip="tooltip" :chartArea="chartArea">
<e-series-collection>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y" name="John" :marker="marker" dashArray='5,5'></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y1" name="Peter" :marker="marker" dashArray='5,5'></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y2" name="Steve" :marker="marker" dashArray='5,5'></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y3" name="Charle" :marker="marker" dashArray='5,5'></e-series>
</e-series-collection>
</ejs-chart>
</div>
</template>
<script>
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Category, Legend, Tooltip, StackingLineSeries } from "@syncfusion/ej2-vue-charts";
export default {
name: "App",
components: {
'ejs-chart': ChartComponent,
'e-series-collection': SeriesCollectionDirective,
'e-series': SeriesDirective
},
data() {
return {
seriesData: [
{ x: 'Food', y: 90, y1: 40, y2: 70, y3: 120 },
{ x: 'Transport', y: 80, y1: 90, y2: 110, y3: 70 },
{ x: 'Medical', y: 50, y1: 80, y2: 120, y3: 50 },
{ x: 'Clothes', y: 70, y1: 30, y2: 60, y3: 180 },
{ x: 'Personal Care', y: 30, y1: 80, y2: 80, y3: 30 },
{ x: 'Books', y: 10, y1: 40, y2: 30, y3: 270 },
{ x: 'Fitness', y: 100, y1: 30, y2: 70, y3: 40 },
{ x: 'Electricity', y: 55, y1: 95, y2: 55, y3: 75 },
{ x: 'Tax', y: 20, y1: 50, y2: 40, y3: 65 },
{ x: 'Pet Care', y: 40, y1: 20, y2: 80, y3: 95 },
{ x: 'Education', y: 45, y1: 15, y2: 45, y3: 195 },
{ x: 'Entertainment', y: 75, y1: 45, y2: 65, y3: 115 }
],
primaryXAxis: {
interval: 1,
valueType: 'Category'
},
primaryYAxis: {
title: 'Expense',
interval: 100,
labelFormat: '${value}'
},
chartArea: {
border: {
width: 0
}
},
marker: {
visible: true
},
tooltip: {
enable: true
}
};
},
provide: {
chart: [Category, Legend, Tooltip, StackingLineSeries]
}
};
</script>
<style>
#container {
height: 350px;
}
</style>
Width
The width property specifies the stroke width applied to the series.
<template>
<div id="app">
<ejs-chart id="chartcontainer" :primaryXAxis="primaryXAxis" :primaryYAxis="primaryYAxis" :tooltip="tooltip" :chartArea="chartArea">
<e-series-collection>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y" name="John" :marker="marker" width=2></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y1" name="Peter" :marker="marker" width=2></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y2" name="Steve" :marker="marker" width=2></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y3" name="Charle" :marker="marker" width=2></e-series>
</e-series-collection>
</ejs-chart>
</div>
</template>
<script setup>
import { provide } from "vue";
import { ChartComponent as EjsChart, SeriesCollectionDirective as ESeriesCollection, SeriesDirective as ESeries, Category, Legend, Tooltip, StackingLineSeries } from "@syncfusion/ej2-vue-charts";
const seriesData = [
{ x: "Food", y: 90, y1: 40, y2: 70, y3: 120 },
{ x: "Transport", y: 80, y1: 90, y2: 110, y3: 70 },
{ x: "Medical", y: 50, y1: 80, y2: 120, y3: 50 },
{ x: "Clothes", y: 70, y1: 30, y2: 60, y3: 180 },
{ x: "Personal Care", y: 30, y1: 80, y2: 80, y3: 30 },
{ x: "Books", y: 10, y1: 40, y2: 30, y3: 270 },
{ x: "Fitness", y: 100, y1: 30, y2: 70, y3: 40 },
{ x: "Electricity", y: 55, y1: 95, y2: 55, y3: 75 },
{ x: "Tax", y: 20, y1: 50, y2: 40, y3: 65 },
{ x: "Pet Care", y: 40, y1: 20, y2: 80, y3: 95 },
{ x: "Education", y: 45, y1: 15, y2: 45, y3: 195 },
{ x: "Entertainment", y: 75, y1: 45, y2: 65, y3: 115 }
];
const primaryXAxis = {
interval: 1,
valueType: 'Category'
};
const primaryYAxis = {
title: 'Expense',
interval: 100,
labelFormat: '${value}'
};
const chartArea = {
border: {
width: 0
}
};
const marker = {
visible: true
};
const tooltip = {
enable: true
};
provide('chart', [Category, Legend, Tooltip, StackingLineSeries]);
</script>
<style>
#container {
height: 350px;
}
</style>
<template>
<div id="app">
<ejs-chart id="chartcontainer" :primaryXAxis="primaryXAxis" :primaryYAxis="primaryYAxis" :tooltip="tooltip" :chartArea="chartArea">
<e-series-collection>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y" name="John" :marker="marker" width=2></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y1" name="Peter" :marker="marker" width=2></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y2" name="Steve" :marker="marker" width=2></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y3" name="Charle" :marker="marker" width=2></e-series>
</e-series-collection>
</ejs-chart>
</div>
</template>
<script>
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Category, Legend, Tooltip, StackingLineSeries } from "@syncfusion/ej2-vue-charts";
export default {
name: "App",
components: {
'ejs-chart': ChartComponent,
'e-series-collection': SeriesCollectionDirective,
'e-series': SeriesDirective
},
data() {
return {
seriesData: [
{ x: 'Food', y: 90, y1: 40, y2: 70, y3: 120 },
{ x: 'Transport', y: 80, y1: 90, y2: 110, y3: 70 },
{ x: 'Medical', y: 50, y1: 80, y2: 120, y3: 50 },
{ x: 'Clothes', y: 70, y1: 30, y2: 60, y3: 180 },
{ x: 'Personal Care', y: 30, y1: 80, y2: 80, y3: 30 },
{ x: 'Books', y: 10, y1: 40, y2: 30, y3: 270 },
{ x: 'Fitness', y: 100, y1: 30, y2: 70, y3: 40 },
{ x: 'Electricity', y: 55, y1: 95, y2: 55, y3: 75 },
{ x: 'Tax', y: 20, y1: 50, y2: 40, y3: 65 },
{ x: 'Pet Care', y: 40, y1: 20, y2: 80, y3: 95 },
{ x: 'Education', y: 45, y1: 15, y2: 45, y3: 195 },
{ x: 'Entertainment', y: 75, y1: 45, y2: 65, y3: 115 }
],
primaryXAxis: {
interval: 1,
valueType: 'Category'
},
primaryYAxis: {
title: 'Expense',
interval: 100,
labelFormat: '${value}'
},
chartArea: {
border: {
width: 0
}
},
marker: {
visible: true
},
tooltip: {
enable: true
}
};
},
provide: {
chart: [Category, Legend, Tooltip, StackingLineSeries]
}
};
</script>
<style>
#container {
height: 350px;
}
</style>
Empty points
Data points with null
or undefined
values are considered empty. Empty data points are ignored and not plotted on the chart.
Mode
Use the mode
property to define how empty or missing data points are handled in the series. The default mode for empty points is Gap
.
<template>
<div id="app">
<ejs-chart id="chartcontainer" :primaryXAxis="primaryXAxis" :primaryYAxis="primaryYAxis" :tooltip="tooltip" :chartArea="chartArea">
<e-series-collection>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y" name="John" :marker="marker" width=2 :emptyPointSettings='emptyPointSettings'></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y1" name="Peter" :marker="marker" width=2></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y2" name="Steve" :marker="marker" width=2 :emptyPointSettings='emptyPointSettings1'></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y3" name="Charle" :marker="marker" width=2></e-series>
</e-series-collection>
</ejs-chart>
</div>
</template>
<script setup>
import { provide } from "vue";
import { ChartComponent as EjsChart, SeriesCollectionDirective as ESeriesCollection, SeriesDirective as ESeries, Category, Legend, Tooltip, StackingLineSeries } from "@syncfusion/ej2-vue-charts";
const seriesData = [
{ x: "Food", y: 90, y1: 40, y2: 70, y3: 120 },
{ x: "Transport", y: 80, y1: 90, y2: 110, y3: 70 },
{ x: "Medical", y: 50, y1: 80, y2: 120, y3: 50 },
{ x: "Clothes", y: null, y1: 30, y2: 60, y3: 180 },
{ x: "Personal Care", y: 30, y1: 80, y2: 80, y3: 30 },
{ x: "Books", y: 10, y1: 40, y2: 30, y3: 270 },
{ x: "Fitness", y: 100, y1: 30, y2: 70, y3: 40 },
{ x: "Electricity", y: 55, y1: 95, y2: undefined, y3: 75 },
{ x: "Tax", y: 20, y1: 50, y2: 40, y3: 65 },
{ x: "Pet Care", y: 40, y1: 20, y2: 80, y3: 95 },
{ x: "Education", y: 45, y1: 15, y2: 45, y3: 195 },
{ x: "Entertainment", y: 75, y1: 45, y2: 65, y3: 115 }
];
const primaryXAxis = {
interval: 1,
valueType: 'Category'
};
const primaryYAxis = {
title: 'Expense',
interval: 100,
labelFormat: '${value}'
};
const chartArea = {
border: {
width: 0
}
};
const marker = {
visible: true,
width: 7,
height: 7,
isFilled: true
};
const tooltip = {
enable: true
};
const emptyPointSettings = {
mode: 'Average'
};
const emptyPointSettings1 = {
mode: 'Gap'
};
provide('chart', [Category, Legend, Tooltip, StackingLineSeries]);
</script>
<style>
#container {
height: 350px;
}
</style>
<template>
<div id="app">
<ejs-chart id="chartcontainer" :primaryXAxis="primaryXAxis" :primaryYAxis="primaryYAxis" :tooltip="tooltip" :chartArea="chartArea">
<e-series-collection>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y" name="John" :marker="marker" width=2 :emptyPointSettings='emptyPointSettings'></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y1" name="Peter" :marker="marker" width=2></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y2" name="Steve" :marker="marker" width=2 :emptyPointSettings='emptyPointSettings1'></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y3" name="Charle" :marker="marker" width=2></e-series>
</e-series-collection>
</ejs-chart>
</div>
</template>
<script>
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Category, Legend, Tooltip, StackingLineSeries } from "@syncfusion/ej2-vue-charts";
export default {
name: "App",
components: {
'ejs-chart': ChartComponent,
'e-series-collection': SeriesCollectionDirective,
'e-series': SeriesDirective
},
data() {
return {
seriesData: [
{ x: 'Food', y: 90, y1: 40, y2: 70, y3: 120 },
{ x: 'Transport', y: 80, y1: 90, y2: 110, y3: 70 },
{ x: 'Medical', y: 50, y1: 80, y2: 120, y3: 50 },
{ x: 'Clothes', y: null, y1: 30, y2: 60, y3: 180 },
{ x: 'Personal Care', y: 30, y1: 80, y2: 80, y3: 30 },
{ x: 'Books', y: 10, y1: 40, y2: 30, y3: 270 },
{ x: 'Fitness', y: 100, y1: 30, y2: 70, y3: 40 },
{ x: 'Electricity', y: 55, y1: 95, y2: undefined, y3: 75 },
{ x: 'Tax', y: 20, y1: 50, y2: 40, y3: 65 },
{ x: 'Pet Care', y: 40, y1: 20, y2: 80, y3: 95 },
{ x: 'Education', y: 45, y1: 15, y2: 45, y3: 195 },
{ x: 'Entertainment', y: 75, y1: 45, y2: 65, y3: 115 }
],
primaryXAxis: {
interval: 1,
valueType: 'Category'
},
primaryYAxis: {
title: 'Expense',
interval: 100,
labelFormat: '${value}'
},
chartArea: {
border: {
width: 0
}
},
marker: {
visible: true,
width: 7,
height: 7,
isFilled: true
},
tooltip: {
enable: true
},
emptyPointSettings: {
mode: 'Average'
},
emptyPointSettings1: {
mode: 'Gap'
}
};
},
provide: {
chart: [Category, Legend, Tooltip, StackingLineSeries]
}
};
</script>
<style>
#container {
height: 350px;
}
</style>
Fill
Use the fill
property to customize the fill color of empty points in the series.
<template>
<div id="app">
<ejs-chart id="chartcontainer" :primaryXAxis="primaryXAxis" :primaryYAxis="primaryYAxis" :tooltip="tooltip" :chartArea="chartArea">
<e-series-collection>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y" name="John" :marker="marker" width=2 :emptyPointSettings='emptyPointSettings'></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y1" name="Peter" :marker="marker" width=2></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y2" name="Steve" :marker="marker" width=2 :emptyPointSettings='emptyPointSettings1'></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y3" name="Charle" :marker="marker" width=2></e-series>
</e-series-collection>
</ejs-chart>
</div>
</template>
<script setup>
import { provide } from "vue";
import { ChartComponent as EjsChart, SeriesCollectionDirective as ESeriesCollection, SeriesDirective as ESeries, Category, Legend, Tooltip, StackingLineSeries } from "@syncfusion/ej2-vue-charts";
const seriesData = [
{ x: "Food", y: 90, y1: 40, y2: 70, y3: 120 },
{ x: "Transport", y: 80, y1: 90, y2: 110, y3: 70 },
{ x: "Medical", y: 50, y1: 80, y2: 120, y3: 50 },
{ x: "Clothes", y: null, y1: 30, y2: 60, y3: 180 },
{ x: "Personal Care", y: 30, y1: 80, y2: 80, y3: 30 },
{ x: "Books", y: 10, y1: 40, y2: 30, y3: 270 },
{ x: "Fitness", y: 100, y1: 30, y2: 70, y3: 40 },
{ x: "Electricity", y: 55, y1: 95, y2: undefined, y3: 75 },
{ x: "Tax", y: 20, y1: 50, y2: 40, y3: 65 },
{ x: "Pet Care", y: 40, y1: 20, y2: 80, y3: 95 },
{ x: "Education", y: 45, y1: 15, y2: 45, y3: 195 },
{ x: "Entertainment", y: 75, y1: 45, y2: 65, y3: 115 }
];
const primaryXAxis = {
interval: 1,
valueType: 'Category'
};
const primaryYAxis = {
title: 'Expense',
interval: 100,
labelFormat: '${value}'
};
const chartArea = {
border: {
width: 0
}
};
const marker = {
visible: true,
width: 7,
height: 7,
isFilled: true
};
const tooltip = {
enable: true
};
const emptyPointSettings = {
mode: 'Average',
fill: 'red'
};
const emptyPointSettings1 = {
mode: 'Gap'
};
provide('chart', [Category, Legend, Tooltip, StackingLineSeries]);
</script>
<style>
#container {
height: 350px;
}
</style>
<template>
<div id="app">
<ejs-chart id="chartcontainer" :primaryXAxis="primaryXAxis" :primaryYAxis="primaryYAxis" :tooltip="tooltip" :chartArea="chartArea">
<e-series-collection>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y" name="John" :marker="marker" width=2 :emptyPointSettings='emptyPointSettings'></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y1" name="Peter" :marker="marker" width=2></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y2" name="Steve" :marker="marker" width=2 :emptyPointSettings='emptyPointSettings1'></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y3" name="Charle" :marker="marker" width=2></e-series>
</e-series-collection>
</ejs-chart>
</div>
</template>
<script>
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Category, Legend, Tooltip, StackingLineSeries } from "@syncfusion/ej2-vue-charts";
export default {
name: "App",
components: {
'ejs-chart': ChartComponent,
'e-series-collection': SeriesCollectionDirective,
'e-series': SeriesDirective
},
data() {
return {
seriesData: [
{ x: 'Food', y: 90, y1: 40, y2: 70, y3: 120 },
{ x: 'Transport', y: 80, y1: 90, y2: 110, y3: 70 },
{ x: 'Medical', y: 50, y1: 80, y2: 120, y3: 50 },
{ x: 'Clothes', y: null, y1: 30, y2: 60, y3: 180 },
{ x: 'Personal Care', y: 30, y1: 80, y2: 80, y3: 30 },
{ x: 'Books', y: 10, y1: 40, y2: 30, y3: 270 },
{ x: 'Fitness', y: 100, y1: 30, y2: 70, y3: 40 },
{ x: 'Electricity', y: 55, y1: 95, y2: undefined, y3: 75 },
{ x: 'Tax', y: 20, y1: 50, y2: 40, y3: 65 },
{ x: 'Pet Care', y: 40, y1: 20, y2: 80, y3: 95 },
{ x: 'Education', y: 45, y1: 15, y2: 45, y3: 195 },
{ x: 'Entertainment', y: 75, y1: 45, y2: 65, y3: 115 }
],
primaryXAxis: {
interval: 1,
valueType: 'Category'
},
primaryYAxis: {
title: 'Expense',
interval: 100,
labelFormat: '${value}'
},
chartArea: {
border: {
width: 0
}
},
marker: {
visible: true,
width: 7,
height: 7,
isFilled: true
},
tooltip: {
enable: true
},
emptyPointSettings: {
mode: 'Average',
fill: 'red'
},
emptyPointSettings1: {
mode: 'Gap'
}
};
},
provide: {
chart: [Category, Legend, Tooltip, StackingLineSeries]
}
};
</script>
<style>
#container {
height: 350px;
}
</style>
Border
Use the border
property to customize the width and color of the border for empty points.
<template>
<div id="app">
<ejs-chart id="chartcontainer" :primaryXAxis="primaryXAxis" :primaryYAxis="primaryYAxis" :tooltip="tooltip" :chartArea="chartArea">
<e-series-collection>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y" name="John" :marker="marker" width=2 :emptyPointSettings='emptyPointSettings'></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y1" name="Peter" :marker="marker" width=2></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y2" name="Steve" :marker="marker" width=2 :emptyPointSettings='emptyPointSettings1'></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y3" name="Charle" :marker="marker" width=2></e-series>
</e-series-collection>
</ejs-chart>
</div>
</template>
<script setup>
import { provide } from "vue";
import { ChartComponent as EjsChart, SeriesCollectionDirective as ESeriesCollection, SeriesDirective as ESeries, Category, Legend, Tooltip, StackingLineSeries } from "@syncfusion/ej2-vue-charts";
const seriesData = [
{ x: "Food", y: 90, y1: 40, y2: 70, y3: 120 },
{ x: "Transport", y: 80, y1: 90, y2: 110, y3: 70 },
{ x: "Medical", y: 50, y1: 80, y2: 120, y3: 50 },
{ x: "Clothes", y: null, y1: 30, y2: 60, y3: 180 },
{ x: "Personal Care", y: 30, y1: 80, y2: 80, y3: 30 },
{ x: "Books", y: 10, y1: 40, y2: 30, y3: 270 },
{ x: "Fitness", y: 100, y1: 30, y2: 70, y3: 40 },
{ x: "Electricity", y: 55, y1: 95, y2: undefined, y3: 75 },
{ x: "Tax", y: 20, y1: 50, y2: 40, y3: 65 },
{ x: "Pet Care", y: 40, y1: 20, y2: 80, y3: 95 },
{ x: "Education", y: 45, y1: 15, y2: 45, y3: 195 },
{ x: "Entertainment", y: 75, y1: 45, y2: 65, y3: 115 }
];
const primaryXAxis = {
interval: 1,
valueType: 'Category'
};
const primaryYAxis = {
title: 'Expense',
interval: 100,
labelFormat: '${value}'
};
const chartArea = {
border: {
width: 0
}
};
const marker = {
visible: true,
width: 7,
height: 7,
isFilled: true
};
const tooltip = {
enable: true
};
const emptyPointSettings = {
mode: 'Average',
fill: 'red',
border: {
width: 2,
color: 'green'
}
};
const emptyPointSettings1 = {
mode: 'Gap'
};
provide('chart', [Category, Legend, Tooltip, StackingLineSeries]);
</script>
<style>
#container {
height: 350px;
}
</style>
<template>
<div id="app">
<ejs-chart id="chartcontainer" :primaryXAxis="primaryXAxis" :primaryYAxis="primaryYAxis" :tooltip="tooltip" :chartArea="chartArea">
<e-series-collection>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y" name="John" :marker="marker" width=2 :emptyPointSettings='emptyPointSettings'></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y1" name="Peter" :marker="marker" width=2></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y2" name="Steve" :marker="marker" width=2 :emptyPointSettings='emptyPointSettings1'></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y3" name="Charle" :marker="marker" width=2></e-series>
</e-series-collection>
</ejs-chart>
</div>
</template>
<script>
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Category, Legend, Tooltip, StackingLineSeries } from "@syncfusion/ej2-vue-charts";
export default {
name: "App",
components: {
'ejs-chart': ChartComponent,
'e-series-collection': SeriesCollectionDirective,
'e-series': SeriesDirective
},
data() {
return {
seriesData: [
{ x: 'Food', y: 90, y1: 40, y2: 70, y3: 120 },
{ x: 'Transport', y: 80, y1: 90, y2: 110, y3: 70 },
{ x: 'Medical', y: 50, y1: 80, y2: 120, y3: 50 },
{ x: 'Clothes', y: null, y1: 30, y2: 60, y3: 180 },
{ x: 'Personal Care', y: 30, y1: 80, y2: 80, y3: 30 },
{ x: 'Books', y: 10, y1: 40, y2: 30, y3: 270 },
{ x: 'Fitness', y: 100, y1: 30, y2: 70, y3: 40 },
{ x: 'Electricity', y: 55, y1: 95, y2: undefined, y3: 75 },
{ x: 'Tax', y: 20, y1: 50, y2: 40, y3: 65 },
{ x: 'Pet Care', y: 40, y1: 20, y2: 80, y3: 95 },
{ x: 'Education', y: 45, y1: 15, y2: 45, y3: 195 },
{ x: 'Entertainment', y: 75, y1: 45, y2: 65, y3: 115 }
],
primaryXAxis: {
interval: 1,
valueType: 'Category'
},
primaryYAxis: {
title: 'Expense',
interval: 100,
labelFormat: '${value}'
},
chartArea: {
border: {
width: 0
}
},
marker: {
visible: true,
width: 7,
height: 7,
isFilled: true
},
tooltip: {
enable: true
},
emptyPointSettings: {
mode: 'Average',
fill: 'red',
border: {
width: 2,
color: 'green'
}
},
emptyPointSettings1: {
mode: 'Gap'
}
};
},
provide: {
chart: [Category, Legend, Tooltip, StackingLineSeries]
}
};
</script>
<style>
#container {
height: 350px;
}
</style>
Stack labels
The stack labels in stacked charts display cumulative total values for stack segments directly using data labels. If a stacked point has negative values, the stack labels are displayed below the point.
<template>
<div id="app">
<ejs-chart id="chartcontainer" :primaryXAxis="primaryXAxis" :primaryYAxis="primaryYAxis" :tooltip="tooltip" :chartArea="chartArea" :stackLabels = 'stackLabels'>
<e-series-collection>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y" name="John" :marker="marker"></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y1" name="Peter" :marker="marker"></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y2" name="Steve" :marker="marker"></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y3" name="Charle" :marker="marker"></e-series>
</e-series-collection>
</ejs-chart>
</div>
</template>
<script setup>
import { provide } from "vue";
import { ChartComponent as EjsChart, SeriesCollectionDirective as ESeriesCollection, SeriesDirective as ESeries, Category, Legend, Tooltip, StackingLineSeries, DataLabel } from "@syncfusion/ej2-vue-charts";
const seriesData = [
{ x: "Food", y: 90, y1: 40, y2: 70, y3: 120 },
{ x: "Transport", y: 80, y1: 90, y2: 110, y3: 70 },
{ x: "Medical", y: 50, y1: 80, y2: 120, y3: 50 },
{ x: "Clothes", y: 70, y1: 30, y2: 60, y3: 180 },
{ x: "Personal Care", y: 30, y1: 80, y2: 80, y3: 30 },
{ x: "Books", y: 10, y1: 40, y2: 30, y3: 270 },
{ x: "Fitness", y: 100, y1: 30, y2: 70, y3: 40 },
{ x: "Electricity", y: 55, y1: 95, y2: 55, y3: 75 },
{ x: "Tax", y: 20, y1: 50, y2: 40, y3: 65 },
{ x: "Pet Care", y: 40, y1: 20, y2: 80, y3: 95 },
{ x: "Education", y: 45, y1: 15, y2: 45, y3: 195 },
{ x: "Entertainment", y: 75, y1: 45, y2: 65, y3: 115 }
];
const primaryXAxis = {
interval: 1,
valueType: 'Category'
};
const primaryYAxis = {
title: 'Expense',
interval: 100,
labelFormat: '${value}'
};
const chartArea = {
border: {
width: 0
}
};
const marker = {dataLabel : {visible : true}};
const stackLabels = { visible: true };
const tooltip = {
enable: true
};
provide('chart', [Category, Legend, Tooltip, StackingLineSeries, DataLabel]);
</script>
<style>
#container {
height: 350px;
}
</style>
<template>
<div id="app">
<ejs-chart id="chartcontainer" :primaryXAxis="primaryXAxis" :primaryYAxis="primaryYAxis" :tooltip="tooltip" :chartArea="chartArea" :stackLabels = 'stackLabels'>
<e-series-collection>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y" name="John" :marker="marker"></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y1" name="Peter" :marker="marker"></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y2" name="Steve" :marker="marker"></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y3" name="Charle" :marker="marker"></e-series>
</e-series-collection>
</ejs-chart>
</div>
</template>
<script>
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Category, Legend, Tooltip, StackingLineSeries,DataLabel } from "@syncfusion/ej2-vue-charts";
export default {
name: "App",
components: {
'ejs-chart': ChartComponent,
'e-series-collection': SeriesCollectionDirective,
'e-series': SeriesDirective
},
data() {
return {
seriesData: [
{ x: 'Food', y: 90, y1: 40, y2: 70, y3: 120 },
{ x: 'Transport', y: 80, y1: 90, y2: 110, y3: 70 },
{ x: 'Medical', y: 50, y1: 80, y2: 120, y3: 50 },
{ x: 'Clothes', y: 70, y1: 30, y2: 60, y3: 180 },
{ x: 'Personal Care', y: 30, y1: 80, y2: 80, y3: 30 },
{ x: 'Books', y: 10, y1: 40, y2: 30, y3: 270 },
{ x: 'Fitness', y: 100, y1: 30, y2: 70, y3: 40 },
{ x: 'Electricity', y: 55, y1: 95, y2: 55, y3: 75 },
{ x: 'Tax', y: 20, y1: 50, y2: 40, y3: 65 },
{ x: 'Pet Care', y: 40, y1: 20, y2: 80, y3: 95 },
{ x: 'Education', y: 45, y1: 15, y2: 45, y3: 195 },
{ x: 'Entertainment', y: 75, y1: 45, y2: 65, y3: 115 }
],
primaryXAxis: {
interval: 1,
valueType: 'Category'
},
primaryYAxis: {
title: 'Expense',
interval: 100,
labelFormat: '${value}'
},
chartArea: {
border: {
width: 0
}
},
marker:{dataLabel : {visible : true}},
stackLabels: { visible: true },
tooltip: {
enable: true
}
};
},
provide: {
chart: [Category, Legend, Tooltip, StackingLineSeries, DataLabel]
}
};
</script>
<style>
#container {
height: 350px;
}
</style>
Stack labels customization
Stack labels have various properties for customization to enhance the visual based on your requirements:
-
visible
- Specifies whether stack labels are visible. Setting to true will display the labels. Default is false. -
fill
- Defines the background color of the stack labels. Accepts valid CSS color strings (hex, RGBA, etc.). Default is transparent. -
format
- Formats the text displayed in the stack labels. Supports placeholders like {value}. Default is null. -
angle
- Specifies the rotation angle for stack labels in degrees. Default is 0. -
rx
- Defines the rounded corner radius along the X-axis (horizontal direction) for the stack label background. Default is 5. -
ry
- Defines the rounded corner radius along the Y-axis (vertical direction) for the stack label background. Default is 5. -
margin
- Configures the margin around the stack label (left, right, top, and bottom). -
border
- Configures the appearance of the stack label’s border. -
font
- Customizes the stack label text, including font size, color, style, weight, and family.
<template>
<div id="app">
<ejs-chart id="chartcontainer" :primaryXAxis="primaryXAxis" :primaryYAxis="primaryYAxis" :tooltip="tooltip" :chartArea="chartArea" :stackLabels = 'stackLabels'>
<e-series-collection>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y" name="John" :marker="marker"></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y1" name="Peter" :marker="marker"></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y2" name="Steve" :marker="marker"></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y3" name="Charle" :marker="marker"></e-series>
</e-series-collection>
</ejs-chart>
</div>
</template>
<script setup>
import { provide } from "vue";
import { ChartComponent as EjsChart, SeriesCollectionDirective as ESeriesCollection, SeriesDirective as ESeries, Category, Legend, Tooltip, StackingLineSeries, DataLabel } from "@syncfusion/ej2-vue-charts";
const seriesData = [
{ x: "Food", y: 90, y1: 40, y2: 70, y3: 120 },
{ x: "Transport", y: 80, y1: 90, y2: 110, y3: 70 },
{ x: "Medical", y: 50, y1: 80, y2: 120, y3: 50 },
{ x: "Clothes", y: 70, y1: 30, y2: 60, y3: 180 },
{ x: "Personal Care", y: 30, y1: 80, y2: 80, y3: 30 },
{ x: "Books", y: 10, y1: 40, y2: 30, y3: 270 },
{ x: "Fitness", y: 100, y1: 30, y2: 70, y3: 40 },
{ x: "Electricity", y: 55, y1: 95, y2: 55, y3: 75 },
{ x: "Tax", y: 20, y1: 50, y2: 40, y3: 65 },
{ x: "Pet Care", y: 40, y1: 20, y2: 80, y3: 95 },
{ x: "Education", y: 45, y1: 15, y2: 45, y3: 195 },
{ x: "Entertainment", y: 75, y1: 45, y2: 65, y3: 115 }
];
const primaryXAxis = {
interval: 1,
valueType: 'Category'
};
const primaryYAxis = {
title: 'Expense',
interval: 100,
labelFormat: '${value}'
};
const chartArea = {
border: {
width: 0
}
};
const marker = {dataLabel : {visible : true}};
const stackLabels = { visible: true, fill: 'rgba(0, 123, 255, 0.5)', format: '{value}', angle: 45, rx: 10, ry: 10, margin: { left: 10, right: 10, top: 10, bottom: 10 }, border: { width: 2, color: '#000' }, font: { size: '14px', color: '#fff', weight: 'bold', family: 'Arial', textAlignment: 'Left' } };
const tooltip = {
enable: true
};
provide('chart', [Category, Legend, Tooltip, StackingLineSeries, DataLabel]);
</script>
<style>
#container {
height: 350px;
}
</style>
<template>
<div id="app">
<ejs-chart id="chartcontainer" :primaryXAxis="primaryXAxis" :primaryYAxis="primaryYAxis" :tooltip="tooltip" :chartArea="chartArea" :stackLabels = 'stackLabels'>
<e-series-collection>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y" name="John" :marker="marker"></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y1" name="Peter" :marker="marker"></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y2" name="Steve" :marker="marker"></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y3" name="Charle" :marker="marker"></e-series>
</e-series-collection>
</ejs-chart>
</div>
</template>
<script>
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Category, Legend, Tooltip, StackingLineSeries,DataLabel } from "@syncfusion/ej2-vue-charts";
export default {
name: "App",
components: {
'ejs-chart': ChartComponent,
'e-series-collection': SeriesCollectionDirective,
'e-series': SeriesDirective
},
data() {
return {
seriesData: [
{ x: 'Food', y: 90, y1: 40, y2: 70, y3: 120 },
{ x: 'Transport', y: 80, y1: 90, y2: 110, y3: 70 },
{ x: 'Medical', y: 50, y1: 80, y2: 120, y3: 50 },
{ x: 'Clothes', y: 70, y1: 30, y2: 60, y3: 180 },
{ x: 'Personal Care', y: 30, y1: 80, y2: 80, y3: 30 },
{ x: 'Books', y: 10, y1: 40, y2: 30, y3: 270 },
{ x: 'Fitness', y: 100, y1: 30, y2: 70, y3: 40 },
{ x: 'Electricity', y: 55, y1: 95, y2: 55, y3: 75 },
{ x: 'Tax', y: 20, y1: 50, y2: 40, y3: 65 },
{ x: 'Pet Care', y: 40, y1: 20, y2: 80, y3: 95 },
{ x: 'Education', y: 45, y1: 15, y2: 45, y3: 195 },
{ x: 'Entertainment', y: 75, y1: 45, y2: 65, y3: 115 }
],
primaryXAxis: {
interval: 1,
valueType: 'Category'
},
primaryYAxis: {
title: 'Expense',
interval: 100,
labelFormat: '${value}'
},
chartArea: {
border: {
width: 0
}
},
marker:{dataLabel : {visible : true}},
stackLabels: { visible: true, fill: 'rgba(0, 123, 255, 0.5)', format: '{value}', angle: 45, rx: 10, ry: 10, margin: { left: 10, right: 10, top: 10, bottom: 10 }, border: { width: 2, color: '#000' }, font: { size: '14px', color: '#fff', weight: 'bold', family: 'Arial', textAlignment: 'Left' } },
tooltip: {
enable: true
}
};
},
provide: {
chart: [Category, Legend, Tooltip, StackingLineSeries, DataLabel]
}
};
</script>
<style>
#container {
height: 350px;
}
</style>
Events
Series render
The seriesRender
event allows you to customize series properties, such as data, fill, and name, before they are rendered on the chart.
<template>
<div id="app">
<ejs-chart id="chartcontainer" :primaryXAxis="primaryXAxis" :primaryYAxis="primaryYAxis"
:tooltip="tooltip" :chartArea="chartArea" :seriesRender='seriesRender'>
<e-series-collection>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y" name="John" :marker="marker"></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y1" name="Peter" :marker="marker"></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y2" name="Steve" :marker="marker"></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y3" name="Charle" :marker="marker"></e-series>
</e-series-collection>
</ejs-chart>
</div>
</template>
<script setup>
import { provide } from "vue";
import { ChartComponent as EjsChart, SeriesCollectionDirective as ESeriesCollection, SeriesDirective as ESeries, Category, Legend, Tooltip, StackingLineSeries } from "@syncfusion/ej2-vue-charts";
const seriesData = [
{ x: "Food", y: 90, y1: 40, y2: 70, y3: 120 },
{ x: "Transport", y: 80, y1: 90, y2: 110, y3: 70 },
{ x: "Medical", y: 50, y1: 80, y2: 120, y3: 50 },
{ x: "Clothes", y: 70, y1: 30, y2: 60, y3: 180 },
{ x: "Personal Care", y: 30, y1: 80, y2: 80, y3: 30 },
{ x: "Books", y: 10, y1: 40, y2: 30, y3: 270 },
{ x: "Fitness", y: 100, y1: 30, y2: 70, y3: 40 },
{ x: "Electricity", y: 55, y1: 95, y2: 55, y3: 75 },
{ x: "Tax", y: 20, y1: 50, y2: 40, y3: 65 },
{ x: "Pet Care", y: 40, y1: 20, y2: 80, y3: 95 },
{ x: "Education", y: 45, y1: 15, y2: 45, y3: 195 },
{ x: "Entertainment", y: 75, y1: 45, y2: 65, y3: 115 }
];
const primaryXAxis = {
interval: 1,
valueType: 'Category'
};
const primaryYAxis = {
title: 'Expense',
interval: 100,
labelFormat: '${value}'
};
const chartArea = {
border: {
width: 0
}
};
const marker = {
visible: true
};
const tooltip = {
enable: true
};
provide('chart', [Category, Legend, Tooltip, StackingLineSeries]);
const seriesRender = function (args) {
if (args.series.index === 0) {
args.fill = '#ff4251';
}
else if (args.series.index === 1) {
args.fill = '#4C4C4C';
}
else if (args.series.index === 2) {
args.fill = '#794F1B';
}
else if (args.series.index === 3) {
args.fill = '#1a9a6f';
}
};
</script>
<style>
#container {
height: 350px;
}
</style>
<template>
<div id="app">
<ejs-chart id="chartcontainer" :primaryXAxis="primaryXAxis" :primaryYAxis="primaryYAxis"
:tooltip="tooltip" :chartArea="chartArea" :seriesRender='seriesRender'>
<e-series-collection>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y" name="John" :marker="marker"></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y1" name="Peter" :marker="marker"></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y2" name="Steve" :marker="marker"></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y3" name="Charle" :marker="marker"></e-series>
</e-series-collection>
</ejs-chart>
</div>
</template>
<script>
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Category, Legend, Tooltip, StackingLineSeries } from "@syncfusion/ej2-vue-charts";
export default {
name: "App",
components: {
'ejs-chart': ChartComponent,
'e-series-collection': SeriesCollectionDirective,
'e-series': SeriesDirective
},
data() {
return {
seriesData: [
{ x: 'Food', y: 90, y1: 40, y2: 70, y3: 120 },
{ x: 'Transport', y: 80, y1: 90, y2: 110, y3: 70 },
{ x: 'Medical', y: 50, y1: 80, y2: 120, y3: 50 },
{ x: 'Clothes', y: 70, y1: 30, y2: 60, y3: 180 },
{ x: 'Personal Care', y: 30, y1: 80, y2: 80, y3: 30 },
{ x: 'Books', y: 10, y1: 40, y2: 30, y3: 270 },
{ x: 'Fitness', y: 100, y1: 30, y2: 70, y3: 40 },
{ x: 'Electricity', y: 55, y1: 95, y2: 55, y3: 75 },
{ x: 'Tax', y: 20, y1: 50, y2: 40, y3: 65 },
{ x: 'Pet Care', y: 40, y1: 20, y2: 80, y3: 95 },
{ x: 'Education', y: 45, y1: 15, y2: 45, y3: 195 },
{ x: 'Entertainment', y: 75, y1: 45, y2: 65, y3: 115 }
],
primaryXAxis: {
interval: 1,
valueType: 'Category'
},
primaryYAxis: {
title: 'Expense',
interval: 100,
labelFormat: '${value}'
},
chartArea: {
border: {
width: 0
}
},
marker: {
visible: true
},
tooltip: {
enable: true
}
};
},
provide: {
chart: [Category, Legend, Tooltip, StackingLineSeries]
},
methods: {
seriesRender: function (args) {
if (args.series.index === 0) {
args.fill = '#ff4251';
}
else if (args.series.index === 1) {
args.fill = '#4C4C4C';
}
else if (args.series.index === 2) {
args.fill = '#794F1B';
}
else if (args.series.index === 3) {
args.fill = '#1a9a6f';
}
}
}
};
</script>
<style>
#container {
height: 350px;
}
</style>
Point render
The pointRender
event allows you to customize each data point before it is rendered on the chart.
<template>
<div id="app">
<ejs-chart id="chartcontainer" :primaryXAxis="primaryXAxis" :primaryYAxis="primaryYAxis"
:tooltip="tooltip" :chartArea="chartArea" :pointRender='pointRender'>
<e-series-collection>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y" name="John" :marker="marker"></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y1" name="Peter" :marker="marker"></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y2" name="Steve" :marker="marker"></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y3" name="Charle" :marker="marker"></e-series>
</e-series-collection>
</ejs-chart>
</div>
</template>
<script setup>
import { provide } from "vue";
import { ChartComponent as EjsChart, SeriesCollectionDirective as ESeriesCollection, SeriesDirective as ESeries, Category, Legend, Tooltip, StackingLineSeries } from "@syncfusion/ej2-vue-charts";
const seriesData = [
{ x: "Food", y: 90, y1: 40, y2: 70, y3: 120 },
{ x: "Transport", y: 80, y1: 90, y2: 110, y3: 70 },
{ x: "Medical", y: 50, y1: 80, y2: 120, y3: 50 },
{ x: "Clothes", y: 70, y1: 30, y2: 60, y3: 180 },
{ x: "Personal Care", y: 30, y1: 80, y2: 80, y3: 30 },
{ x: "Books", y: 10, y1: 40, y2: 30, y3: 270 },
{ x: "Fitness", y: 100, y1: 30, y2: 70, y3: 40 },
{ x: "Electricity", y: 55, y1: 95, y2: 55, y3: 75 },
{ x: "Tax", y: 20, y1: 50, y2: 40, y3: 65 },
{ x: "Pet Care", y: 40, y1: 20, y2: 80, y3: 95 },
{ x: "Education", y: 45, y1: 15, y2: 45, y3: 195 },
{ x: "Entertainment", y: 75, y1: 45, y2: 65, y3: 115 }
];
const primaryXAxis = {
interval: 1,
valueType: 'Category'
};
const primaryYAxis = {
title: 'Expense',
interval: 100,
labelFormat: '${value}'
};
const chartArea = {
border: {
width: 0
}
};
const marker = {
visible: true
};
const tooltip = {
enable: true
};
provide('chart', [Category, Legend, Tooltip, StackingLineSeries]);
const pointRender = function (args) {
if (args.point.y < 100) {
args.fill = '#ff6347';
}
else {
args.fill = '#009cb8';
}
};
</script>
<style>
#container {
height: 350px;
}
</style>
<template>
<div id="app">
<ejs-chart id="chartcontainer" :primaryXAxis="primaryXAxis" :primaryYAxis="primaryYAxis"
:tooltip="tooltip" :chartArea="chartArea" :pointRender='pointRender'>
<e-series-collection>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y" name="John" :marker="marker"></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y1" name="Peter" :marker="marker"></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y2" name="Steve" :marker="marker"></e-series>
<e-series :dataSource="seriesData" type="StackingLine" xName="x" yName="y3" name="Charle" :marker="marker"></e-series>
</e-series-collection>
</ejs-chart>
</div>
</template>
<script>
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Category, Legend, Tooltip, StackingLineSeries } from "@syncfusion/ej2-vue-charts";
export default {
name: "App",
components: {
'ejs-chart': ChartComponent,
'e-series-collection': SeriesCollectionDirective,
'e-series': SeriesDirective
},
data() {
return {
seriesData: [
{ x: 'Food', y: 90, y1: 40, y2: 70, y3: 120 },
{ x: 'Transport', y: 80, y1: 90, y2: 110, y3: 70 },
{ x: 'Medical', y: 50, y1: 80, y2: 120, y3: 50 },
{ x: 'Clothes', y: 70, y1: 30, y2: 60, y3: 180 },
{ x: 'Personal Care', y: 30, y1: 80, y2: 80, y3: 30 },
{ x: 'Books', y: 10, y1: 40, y2: 30, y3: 270 },
{ x: 'Fitness', y: 100, y1: 30, y2: 70, y3: 40 },
{ x: 'Electricity', y: 55, y1: 95, y2: 55, y3: 75 },
{ x: 'Tax', y: 20, y1: 50, y2: 40, y3: 65 },
{ x: 'Pet Care', y: 40, y1: 20, y2: 80, y3: 95 },
{ x: 'Education', y: 45, y1: 15, y2: 45, y3: 195 },
{ x: 'Entertainment', y: 75, y1: 45, y2: 65, y3: 115 }
],
primaryXAxis: {
interval: 1,
valueType: 'Category'
},
primaryYAxis: {
title: 'Expense',
interval: 100,
labelFormat: '${value}'
},
chartArea: {
border: {
width: 0
}
},
marker: {
visible: true
},
tooltip: {
enable: true
}
};
},
provide: {
chart: [Category, Legend, Tooltip, StackingLineSeries]
},
methods: {
pointRender: function (args) {
if (args.point.y < 100) {
args.fill = '#ff6347';
}
else {
args.fill = '#009cb8';
}
}
}
};
</script>
<style>
#container {
height: 350px;
}
</style>