- Scatter charts
- Binding data with series
- Series customization
- Empty points
- Events
- See also
Contact Support
Scatter Chart in Vue Component
14 Oct 202424 minutes to read
Scatter charts
To render a scatter 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
asScatter
in your chart configuration. This indicates that the data should be displayed as individual points scattered across the chart. -
Inject the ScatterSeries module: Use the
provide: { chart: [ScatterSeries]}
method to inject theScatterSeries
module into your chart. This step is essential, as it ensures that the necessary functionalities for rendering the scatter series are available in your chart.
<template>
<div id="app">
<ejs-chart id="container" :primaryXAxis='primaryXAxis' :primaryYAxis='primaryYAxis' :title='title'>
<e-series-collection>
<e-series :dataSource='seriesData1' type='Scatter' xName='x' yName='y' name='Male' :marker='marker'>
</e-series>
<e-series :dataSource='seriesData2' type='Scatter' xName='x' yName='y' name='Female' :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, ScatterSeries, Legend } from "@syncfusion/ej2-vue-charts";
let series1 = [];
let series2 = [];
let point1;
let value = 80;
let value1 = 70;
let i;
for (i = 1; i < 50; i++) {
if (Math.random() > 0.5) {
value += Math.random();
} else {
value -= Math.random();
}
value = value < 60 ? 60 : value > 90 ? 90 : value;
point1 = { x: 120 + (i / 2), y: value.toFixed(1) };
series1.push(point1);
}
for (i = 1; i < 50; i++) {
if (Math.random() > 0.5) {
value1 += Math.random();
} else {
value1 -= Math.random();
}
value1 = value1 < 60 ? 60 : value1 > 90 ? 90 : value1;
point1 = { x: 120 + (i / 2), y: value1.toFixed(1) };
series2.push(point1);
}
const seriesData1 = series1;
const seriesData2 = series2;
const primaryXAxis = {
title: 'Height (cm)',
minimum: 120, maximum: 180,
edgeLabelPlacement: 'Shift',
labelFormat: '{value}cm'
};
const primaryYAxis = {
title: 'Weight (kg)',
minimum: 60, maximum: 90,
labelFormat: '{value}kg',
rangePadding: 'None'
};
const title = 'Height Vs Weight';
const marker = { width: 10, height: 10 };
provide('chart', [ScatterSeries, Legend]);
</script>
<style>
#container {
height: 350px;
}
</style>
<template>
<div id="app">
<ejs-chart id="container" :primaryXAxis='primaryXAxis' :primaryYAxis='primaryYAxis' :title='title'>
<e-series-collection>
<e-series :dataSource='seriesData1' type='Scatter' xName='x' yName='y' name='Male' :marker='marker'> </e-series>
<e-series :dataSource='seriesData2' type='Scatter' xName='x' yName='y' name='Female' :marker='marker'> </e-series>
</e-series-collection>
</ejs-chart>
</div>
</template>
<script>
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, ScatterSeries, Legend } from "@syncfusion/ej2-vue-charts";
let series1 = [];
let series2 = [];
let point1;
let value = 80;
let value1 = 70;
let i;
for (i = 1; i < 120; i++) {
if (Math.random() > 0.5) {
value += Math.random();
} else {
value -= Math.random();
}
value = value < 60 ? 60 : value > 90 ? 90 : value;
point1 = { x: 120 + (i / 2), y: value.toFixed(1) };
series1.push(point1);
}
for (i = 1; i < 120; i++) {
if (Math.random() > 0.5) {
value1 += Math.random();
} else {
value1 -= Math.random();
}
value1 = value1 < 60 ? 60 : value1 > 90 ? 90 : value1;
point1 = { x: 120 + (i / 2), y: value1.toFixed(1) };
series2.push(point1);
}
export default {
name: "App",
components: {
'ejs-chart': ChartComponent,
'e-series-collection': SeriesCollectionDirective,
'e-series': SeriesDirective
},
data() {
return {
seriesData1: series1,
seriesData2: series2,
primaryXAxis: {
title: 'Height (cm)',
minimum: 120, maximum: 180,
edgeLabelPlacement: 'Shift',
labelFormat: '{value}cm'
},
primaryYAxis:
{
title: 'Weight (kg)',
minimum: 60, maximum: 90,
labelFormat: '{value}kg',
rangePadding: 'None'
},
title: 'Height Vs Weight',
marker: { width: 10, height: 10 }
};
},
provide: {
chart: [ScatterSeries, Legend]
}
};
</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="container" :primaryXAxis='primaryXAxis' :primaryYAxis='primaryYAxis' :title='title'>
<e-series-collection>
<e-series :dataSource='seriesData1' type='Scatter' xName='x' yName='y' name='Male' :marker='marker'>
</e-series>
<e-series :dataSource='seriesData2' type='Scatter' xName='x' yName='y' name='Female' :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, ScatterSeries, Legend } from "@syncfusion/ej2-vue-charts";
let series1 = [];
let series2 = [];
let point1;
let value = 80;
let value1 = 70;
let i;
for (i = 1; i < 50; i++) {
if (Math.random() > 0.5) {
value += Math.random();
} else {
value -= Math.random();
}
value = value < 60 ? 60 : value > 90 ? 90 : value;
point1 = { x: 120 + (i / 2), y: value.toFixed(1) };
series1.push(point1);
}
for (i = 1; i < 50; i++) {
if (Math.random() > 0.5) {
value1 += Math.random();
} else {
value1 -= Math.random();
}
value1 = value1 < 60 ? 60 : value1 > 90 ? 90 : value1;
point1 = { x: 120 + (i / 2), y: value1.toFixed(1) };
series2.push(point1);
}
const seriesData1 = series1;
const seriesData2 = series2;
const primaryXAxis = {
title: 'Height (cm)',
minimum: 120, maximum: 180,
edgeLabelPlacement: 'Shift',
labelFormat: '{value}cm'
};
const primaryYAxis = {
title: 'Weight (kg)',
minimum: 60, maximum: 90,
labelFormat: '{value}kg',
rangePadding: 'None'
};
const title = 'Height Vs Weight';
const marker = { width: 10, height: 10 };
provide('chart', [ScatterSeries, Legend]);
</script>
<style>
#container {
height: 350px;
}
</style>
<template>
<div id="app">
<ejs-chart id="container" :primaryXAxis='primaryXAxis' :primaryYAxis='primaryYAxis' :title='title'>
<e-series-collection>
<e-series :dataSource='seriesData1' type='Scatter' xName='x' yName='y' name='Male' :marker='marker'> </e-series>
<e-series :dataSource='seriesData2' type='Scatter' xName='x' yName='y' name='Female' :marker='marker'> </e-series>
</e-series-collection>
</ejs-chart>
</div>
</template>
<script>
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, ScatterSeries, Legend } from "@syncfusion/ej2-vue-charts";
let series1 = [];
let series2 = [];
let point1;
let value = 80;
let value1 = 70;
let i;
for (i = 1; i < 120; i++) {
if (Math.random() > 0.5) {
value += Math.random();
} else {
value -= Math.random();
}
value = value < 60 ? 60 : value > 90 ? 90 : value;
point1 = { x: 120 + (i / 2), y: value.toFixed(1) };
series1.push(point1);
}
for (i = 1; i < 120; i++) {
if (Math.random() > 0.5) {
value1 += Math.random();
} else {
value1 -= Math.random();
}
value1 = value1 < 60 ? 60 : value1 > 90 ? 90 : value1;
point1 = { x: 120 + (i / 2), y: value1.toFixed(1) };
series2.push(point1);
}
export default {
name: "App",
components: {
'ejs-chart': ChartComponent,
'e-series-collection': SeriesCollectionDirective,
'e-series': SeriesDirective
},
data() {
return {
seriesData1: series1,
seriesData2: series2,
primaryXAxis: {
title: 'Height (cm)',
minimum: 120, maximum: 180,
edgeLabelPlacement: 'Shift',
labelFormat: '{value}cm'
},
primaryYAxis:
{
title: 'Weight (kg)',
minimum: 60, maximum: 90,
labelFormat: '{value}kg',
rangePadding: 'None'
},
title: 'Height Vs Weight',
marker: { width: 10, height: 10 }
};
},
provide: {
chart: [ScatterSeries, Legend]
}
};
</script>
<style>
#container {
height: 350px;
}
</style>
Series customization
The following properties can be used to customize the scatter
series.
Fill
The fill property determines the color applied to the series.
<template>
<div id="app">
<ejs-chart id="container" :primaryXAxis='primaryXAxis' :primaryYAxis='primaryYAxis' :title='title'>
<e-series-collection>
<e-series :dataSource='seriesData1' type='Scatter' xName='x' yName='y' name='Male' :marker='marker'>
</e-series>
<e-series :dataSource='seriesData2' type='Scatter' xName='x' yName='y' name='Female' :marker='marker1' fill='red'>
</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, ScatterSeries, Legend } from "@syncfusion/ej2-vue-charts";
let series1 = [];
let series2 = [];
let point1;
let value = 80;
let value1 = 70;
let i;
for (i = 1; i < 50; i++) {
if (Math.random() > 0.5) {
value += Math.random();
} else {
value -= Math.random();
}
value = value < 60 ? 60 : value > 90 ? 90 : value;
point1 = { x: 120 + (i / 2), y: value.toFixed(1) };
series1.push(point1);
}
for (i = 1; i < 50; i++) {
if (Math.random() > 0.5) {
value1 += Math.random();
} else {
value1 -= Math.random();
}
value1 = value1 < 60 ? 60 : value1 > 90 ? 90 : value1;
point1 = { x: 120 + (i / 2), y: value1.toFixed(1) };
series2.push(point1);
}
const seriesData1 = series1;
const seriesData2 = series2;
const primaryXAxis = {
title: 'Height (cm)',
minimum: 120, maximum: 180,
edgeLabelPlacement: 'Shift',
labelFormat: '{value}cm'
};
const primaryYAxis = {
title: 'Weight (kg)',
minimum: 60, maximum: 90,
labelFormat: '{value}kg',
rangePadding: 'None'
};
const title = 'Height Vs Weight';
const marker = { width: 5, height: 5 };
const marker1 = { width: 3, height: 3 };
provide('chart', [ScatterSeries, Legend]);
</script>
<style>
#container {
height: 350px;
}
</style>
<template>
<div id="app">
<ejs-chart id="container" :primaryXAxis='primaryXAxis' :primaryYAxis='primaryYAxis' :title='title'>
<e-series-collection>
<e-series :dataSource='seriesData1' type='Scatter' xName='x' yName='y' name='Male' :marker='marker'> </e-series>
<e-series :dataSource='seriesData2' type='Scatter' xName='x' yName='y' name='Female' :marker='marker1' fill='red'> </e-series>
</e-series-collection>
</ejs-chart>
</div>
</template>
<script>
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, ScatterSeries, Legend } from "@syncfusion/ej2-vue-charts";
let series1 = [];
let series2 = [];
let point1;
let value = 80;
let value1 = 70;
let i;
for (i = 1; i < 120; i++) {
if (Math.random() > 0.5) {
value += Math.random();
} else {
value -= Math.random();
}
value = value < 60 ? 60 : value > 90 ? 90 : value;
point1 = { x: 120 + (i / 2), y: value.toFixed(1) };
series1.push(point1);
}
for (i = 1; i < 120; i++) {
if (Math.random() > 0.5) {
value1 += Math.random();
} else {
value1 -= Math.random();
}
value1 = value1 < 60 ? 60 : value1 > 90 ? 90 : value1;
point1 = { x: 120 + (i / 2), y: value1.toFixed(1) };
series2.push(point1);
}
export default {
name: "App",
components: {
'ejs-chart': ChartComponent,
'e-series-collection': SeriesCollectionDirective,
'e-series': SeriesDirective
},
data() {
return {
seriesData1: series1,
seriesData2: series2,
primaryXAxis: {
title: 'Height (cm)',
minimum: 120, maximum: 180,
edgeLabelPlacement: 'Shift',
labelFormat: '{value}cm'
},
primaryYAxis:
{
title: 'Weight (kg)',
minimum: 60, maximum: 90,
labelFormat: '{value}kg',
rangePadding: 'None'
},
title: 'Height Vs Weight',
marker: { width: 5, height: 5 },
marker1: { width: 3, height: 3 }
};
},
provide: {
chart: [ScatterSeries, Legend]
}
};
</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="container" :primaryXAxis='primaryXAxis' :primaryYAxis='primaryYAxis' :title='title'>
<e-series-collection>
<e-series :dataSource='seriesData1' type='Scatter' xName='x' yName='y' name='Male' :marker='marker' opacity=0.7>
</e-series>
<e-series :dataSource='seriesData2' type='Scatter' xName='x' yName='y' name='Female' :marker='marker1' fill='red' 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, ScatterSeries, Legend } from "@syncfusion/ej2-vue-charts";
let series1 = [];
let series2 = [];
let point1;
let value = 80;
let value1 = 70;
let i;
for (i = 1; i < 50; i++) {
if (Math.random() > 0.5) {
value += Math.random();
} else {
value -= Math.random();
}
value = value < 60 ? 60 : value > 90 ? 90 : value;
point1 = { x: 120 + (i / 2), y: value.toFixed(1) };
series1.push(point1);
}
for (i = 1; i < 50; i++) {
if (Math.random() > 0.5) {
value1 += Math.random();
} else {
value1 -= Math.random();
}
value1 = value1 < 60 ? 60 : value1 > 90 ? 90 : value1;
point1 = { x: 120 + (i / 2), y: value1.toFixed(1) };
series2.push(point1);
}
const seriesData1 = series1;
const seriesData2 = series2;
const primaryXAxis = {
title: 'Height (cm)',
minimum: 120, maximum: 180,
edgeLabelPlacement: 'Shift',
labelFormat: '{value}cm'
};
const primaryYAxis = {
title: 'Weight (kg)',
minimum: 60, maximum: 90,
labelFormat: '{value}kg',
rangePadding: 'None'
};
const title = 'Height Vs Weight';
const marker = { width: 5, height: 5 };
const marker1 = { width: 3, height: 3 };
provide('chart', [ScatterSeries, Legend]);
</script>
<style>
#container {
height: 350px;
}
</style>
<template>
<div id="app">
<ejs-chart id="container" :primaryXAxis='primaryXAxis' :primaryYAxis='primaryYAxis' :title='title'>
<e-series-collection>
<e-series :dataSource='seriesData1' type='Scatter' xName='x' yName='y' name='Male' :marker='marker' opacity=0.7> </e-series>
<e-series :dataSource='seriesData2' type='Scatter' xName='x' yName='y' name='Female' :marker='marker1' fill='red' opacity=0.7> </e-series>
</e-series-collection>
</ejs-chart>
</div>
</template>
<script>
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, ScatterSeries, Legend } from "@syncfusion/ej2-vue-charts";
let series1 = [];
let series2 = [];
let point1;
let value = 80;
let value1 = 70;
let i;
for (i = 1; i < 120; i++) {
if (Math.random() > 0.5) {
value += Math.random();
} else {
value -= Math.random();
}
value = value < 60 ? 60 : value > 90 ? 90 : value;
point1 = { x: 120 + (i / 2), y: value.toFixed(1) };
series1.push(point1);
}
for (i = 1; i < 120; i++) {
if (Math.random() > 0.5) {
value1 += Math.random();
} else {
value1 -= Math.random();
}
value1 = value1 < 60 ? 60 : value1 > 90 ? 90 : value1;
point1 = { x: 120 + (i / 2), y: value1.toFixed(1) };
series2.push(point1);
}
export default {
name: "App",
components: {
'ejs-chart': ChartComponent,
'e-series-collection': SeriesCollectionDirective,
'e-series': SeriesDirective
},
data() {
return {
seriesData1: series1,
seriesData2: series2,
primaryXAxis: {
title: 'Height (cm)',
minimum: 120, maximum: 180,
edgeLabelPlacement: 'Shift',
labelFormat: '{value}cm'
},
primaryYAxis:
{
title: 'Weight (kg)',
minimum: 60, maximum: 90,
labelFormat: '{value}kg',
rangePadding: 'None'
},
title: 'Height Vs Weight',
marker: { width: 5, height: 5 },
marker1: { width: 3, height: 3 }
};
},
provide: {
chart: [ScatterSeries, Legend]
}
};
</script>
<style>
#container {
height: 350px;
}
</style>
Shape
The shape property allows you to customize the appearance of the markers by specifying different shapes.
<template>
<div id="app">
<ejs-chart id="container" :primaryXAxis='primaryXAxis' :primaryYAxis='primaryYAxis' :title='title'>
<e-series-collection>
<e-series :dataSource='seriesData1' type='Scatter' xName='x' yName='y' name='Male' :marker='marker' opacity=0.7>
</e-series>
<e-series :dataSource='seriesData2' type='Scatter' xName='x' yName='y' name='Female' :marker='marker1' fill='red' 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, ScatterSeries, Legend } from "@syncfusion/ej2-vue-charts";
let series1 = [];
let series2 = [];
let point1;
let value = 80;
let value1 = 70;
let i;
for (i = 1; i < 50; i++) {
if (Math.random() > 0.5) {
value += Math.random();
} else {
value -= Math.random();
}
value = value < 60 ? 60 : value > 90 ? 90 : value;
point1 = { x: 120 + (i / 2), y: value.toFixed(1) };
series1.push(point1);
}
for (i = 1; i < 50; i++) {
if (Math.random() > 0.5) {
value1 += Math.random();
} else {
value1 -= Math.random();
}
value1 = value1 < 60 ? 60 : value1 > 90 ? 90 : value1;
point1 = { x: 120 + (i / 2), y: value1.toFixed(1) };
series2.push(point1);
}
const seriesData1 = series1;
const seriesData2 = series2;
const primaryXAxis = {
title: 'Height (cm)',
minimum: 120, maximum: 180,
edgeLabelPlacement: 'Shift',
labelFormat: '{value}cm'
};
const primaryYAxis = {
title: 'Weight (kg)',
minimum: 60, maximum: 90,
labelFormat: '{value}kg',
rangePadding: 'None'
};
const title = 'Height Vs Weight';
const marker = { width: 5, height: 5, shape: 'Triangle' };
const marker1 = { width: 3, height: 3, shape: 'Square' };
provide('chart', [ScatterSeries, Legend]);
</script>
<style>
#container {
height: 350px;
}
</style>
<template>
<div id="app">
<ejs-chart id="container" :primaryXAxis='primaryXAxis' :primaryYAxis='primaryYAxis' :title='title'>
<e-series-collection>
<e-series :dataSource='seriesData1' type='Scatter' xName='x' yName='y' name='Male' :marker='marker' opacity=0.7> </e-series>
<e-series :dataSource='seriesData2' type='Scatter' xName='x' yName='y' name='Female' :marker='marker1' fill='red' opacity=0.7> </e-series>
</e-series-collection>
</ejs-chart>
</div>
</template>
<script>
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, ScatterSeries, Legend } from "@syncfusion/ej2-vue-charts";
let series1 = [];
let series2 = [];
let point1;
let value = 80;
let value1 = 70;
let i;
for (i = 1; i < 120; i++) {
if (Math.random() > 0.5) {
value += Math.random();
} else {
value -= Math.random();
}
value = value < 60 ? 60 : value > 90 ? 90 : value;
point1 = { x: 120 + (i / 2), y: value.toFixed(1) };
series1.push(point1);
}
for (i = 1; i < 120; i++) {
if (Math.random() > 0.5) {
value1 += Math.random();
} else {
value1 -= Math.random();
}
value1 = value1 < 60 ? 60 : value1 > 90 ? 90 : value1;
point1 = { x: 120 + (i / 2), y: value1.toFixed(1) };
series2.push(point1);
}
export default {
name: "App",
components: {
'ejs-chart': ChartComponent,
'e-series-collection': SeriesCollectionDirective,
'e-series': SeriesDirective
},
data() {
return {
seriesData1: series1,
seriesData2: series2,
primaryXAxis: {
title: 'Height (cm)',
minimum: 120, maximum: 180,
edgeLabelPlacement: 'Shift',
labelFormat: '{value}cm'
},
primaryYAxis:
{
title: 'Weight (kg)',
minimum: 60, maximum: 90,
labelFormat: '{value}kg',
rangePadding: 'None'
},
title: 'Height Vs Weight',
marker: { width: 5, height: 5, shape: 'Triangle' },
marker1: { width: 3, height: 3, shape: 'Square' }
};
},
provide: {
chart: [ScatterSeries, Legend]
}
};
</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="container" :primaryXAxis='primaryXAxis' :primaryYAxis='primaryYAxis' :title='title'>
<e-series-collection>
<e-series :dataSource='seriesData' type='Scatter' xName='x' yName='y' :marker='marker' :emptyPointSettings='emptyPointSettings'>
</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, ScatterSeries } from "@syncfusion/ej2-vue-charts";
const seriesData = [
{ x: 1, y: 15 }, { x: 2, y: 25 }, { x: 3, y: 35 }, { x: 4, y: null },
{ x: 5, y: 55 }, { x: 6, y: 60 }, { x: 7, y: 65 }, { x: 8, y: 70 },
{ x: 9, y: 75 }, { x: 10, y: 80 }, { x: 11, y: undefined }, { x: 12, y: 90 },
{ x: 13, y: 92 }, { x: 14, y: 94 }, { x: 15, y: 96 }, { x: 16, y: null },
{ x: 17, y: 98 }, { x: 18, y: 99 }, { x: 19, y: 100 }, { x: 20, y: 100 }
];
const primaryXAxis = {
minimum: 0,
maximum: 21,
interval: 3,
majorGridLines: { width: 0 },
title: 'Study Hours (Per Week)'
};
const primaryYAxis = {
title: 'Test Scores (%)',
minimum: 0,
maximum: 120,
interval: 20,
labelFormat: '{value}%'
};
const title = 'Relationship Between Study Hours and Test Scores';
const marker = {
visible: false,
width: 10,
height: 10,
shape: 'Circle'
};
const emptyPointSettings = {
mode: 'Zero'
};
provide('chart', [ScatterSeries]);
</script>
<style>
#container {
height: 350px;
}
</style>
<template>
<div id="app">
<ejs-chart id="container" :primaryXAxis='primaryXAxis' :primaryYAxis='primaryYAxis' :title='title'>
<e-series-collection>
<e-series :dataSource='seriesData' type='Scatter' xName='x' yName='y' :marker='marker' :emptyPointSettings='emptyPointSettings'> </e-series>
</e-series-collection>
</ejs-chart>
</div>
</template>
<script>
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, ScatterSeries } from "@syncfusion/ej2-vue-charts";
export default {
name: "App",
components: {
'ejs-chart': ChartComponent,
'e-series-collection': SeriesCollectionDirective,
'e-series': SeriesDirective
},
data() {
return {
seriesData: [
{ x: 1, y: 15 }, { x: 2, y: 25 }, { x: 3, y: 35 }, { x: 4, y: null },
{ x: 5, y: 55 }, { x: 6, y: 60 }, { x: 7, y: 65 }, { x: 8, y: 70 },
{ x: 9, y: 75 }, { x: 10, y: 80 }, { x: 11, y: undefined }, { x: 12, y: 90 },
{ x: 13, y: 92 }, { x: 14, y: 94 }, { x: 15, y: 96 }, { x: 16, y: null },
{ x: 17, y: 98 }, { x: 18, y: 99 }, { x: 19, y: 100 }, { x: 20, y: 100 }
],
primaryXAxis: {
minimum: 0,
maximum: 21,
interval: 3,
majorGridLines: { width: 0 },
title: 'Study Hours (Per Week)'
},
primaryYAxis:
{
title: 'Test Scores (%)',
minimum: 0,
maximum: 120,
interval: 20,
labelFormat: '{value}%'
},
title: 'Relationship Between Study Hours and Test Scores',
marker: {
visible: false,
width: 10,
height: 10,
shape: 'Circle'
},
emptyPointSettings: {
mode: 'Zero'
}
};
},
provide: {
chart: [ScatterSeries]
}
};
</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="container" :primaryXAxis='primaryXAxis' :primaryYAxis='primaryYAxis' :title='title'>
<e-series-collection>
<e-series :dataSource='seriesData' type='Scatter' xName='x' yName='y' :marker='marker' :emptyPointSettings='emptyPointSettings'>
</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, ScatterSeries } from "@syncfusion/ej2-vue-charts";
const seriesData = [
{ x: 1, y: 15 }, { x: 2, y: 25 }, { x: 3, y: 35 }, { x: 4, y: null },
{ x: 5, y: 55 }, { x: 6, y: 60 }, { x: 7, y: 65 }, { x: 8, y: 70 },
{ x: 9, y: 75 }, { x: 10, y: 80 }, { x: 11, y: undefined }, { x: 12, y: 90 },
{ x: 13, y: 92 }, { x: 14, y: 94 }, { x: 15, y: 96 }, { x: 16, y: null },
{ x: 17, y: 98 }, { x: 18, y: 99 }, { x: 19, y: 100 }, { x: 20, y: 100 }
];
const primaryXAxis = {
minimum: 0,
maximum: 21,
interval: 3,
majorGridLines: { width: 0 },
title: 'Study Hours (Per Week)'
};
const primaryYAxis = {
title: 'Test Scores (%)',
minimum: 0,
maximum: 120,
interval: 20,
labelFormat: '{value}%'
};
const title = 'Relationship Between Study Hours and Test Scores';
const marker = {
visible: false,
width: 10,
height: 10,
shape: 'Circle'
};
const emptyPointSettings = {
mode: 'Average',
fill: 'red'
};
provide('chart', [ScatterSeries]);
</script>
<style>
#container {
height: 350px;
}
</style>
<template>
<div id="app">
<ejs-chart id="container" :primaryXAxis='primaryXAxis' :primaryYAxis='primaryYAxis' :title='title'>
<e-series-collection>
<e-series :dataSource='seriesData' type='Scatter' xName='x' yName='y' :marker='marker' :emptyPointSettings='emptyPointSettings'> </e-series>
</e-series-collection>
</ejs-chart>
</div>
</template>
<script>
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, ScatterSeries } from "@syncfusion/ej2-vue-charts";
export default {
name: "App",
components: {
'ejs-chart': ChartComponent,
'e-series-collection': SeriesCollectionDirective,
'e-series': SeriesDirective
},
data() {
return {
seriesData: [
{ x: 1, y: 15 }, { x: 2, y: 25 }, { x: 3, y: 35 }, { x: 4, y: null },
{ x: 5, y: 55 }, { x: 6, y: 60 }, { x: 7, y: 65 }, { x: 8, y: 70 },
{ x: 9, y: 75 }, { x: 10, y: 80 }, { x: 11, y: undefined }, { x: 12, y: 90 },
{ x: 13, y: 92 }, { x: 14, y: 94 }, { x: 15, y: 96 }, { x: 16, y: null },
{ x: 17, y: 98 }, { x: 18, y: 99 }, { x: 19, y: 100 }, { x: 20, y: 100 }
],
primaryXAxis: {
minimum: 0,
maximum: 21,
interval: 3,
majorGridLines: { width: 0 },
title: 'Study Hours (Per Week)'
},
primaryYAxis:
{
title: 'Test Scores (%)',
minimum: 0,
maximum: 120,
interval: 20,
labelFormat: '{value}%'
},
title: 'Relationship Between Study Hours and Test Scores',
marker: {
visible: false,
width: 10,
height: 10,
shape: 'Circle'
},
emptyPointSettings: {
mode: 'Average',
fill: 'red'
}
};
},
provide: {
chart: [ScatterSeries]
}
};
</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="container" :primaryXAxis='primaryXAxis' :primaryYAxis='primaryYAxis' :title='title'>
<e-series-collection>
<e-series :dataSource='seriesData' type='Scatter' xName='x' yName='y' :marker='marker' :emptyPointSettings='emptyPointSettings'>
</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, ScatterSeries } from "@syncfusion/ej2-vue-charts";
const seriesData = [
{ x: 1, y: 15 }, { x: 2, y: 25 }, { x: 3, y: 35 }, { x: 4, y: null },
{ x: 5, y: 55 }, { x: 6, y: 60 }, { x: 7, y: 65 }, { x: 8, y: 70 },
{ x: 9, y: 75 }, { x: 10, y: 80 }, { x: 11, y: undefined }, { x: 12, y: 90 },
{ x: 13, y: 92 }, { x: 14, y: 94 }, { x: 15, y: 96 }, { x: 16, y: null },
{ x: 17, y: 98 }, { x: 18, y: 99 }, { x: 19, y: 100 }, { x: 20, y: 100 }
];
const primaryXAxis = {
minimum: 0,
maximum: 21,
interval: 3,
majorGridLines: { width: 0 },
title: 'Study Hours (Per Week)'
};
const primaryYAxis = {
title: 'Test Scores (%)',
minimum: 0,
maximum: 120,
interval: 20,
labelFormat: '{value}%'
};
const title = 'Relationship Between Study Hours and Test Scores';
const marker = {
visible: false,
width: 10,
height: 10,
shape: 'Circle'
};
const emptyPointSettings = {
mode: 'Average',
fill: 'red',
border: { width: 2, color: 'green' }
};
provide('chart', [ScatterSeries]);
</script>
<style>
#container {
height: 350px;
}
</style>
<template>
<div id="app">
<ejs-chart id="container" :primaryXAxis='primaryXAxis' :primaryYAxis='primaryYAxis' :title='title'>
<e-series-collection>
<e-series :dataSource='seriesData' type='Scatter' xName='x' yName='y' :marker='marker' :emptyPointSettings='emptyPointSettings'> </e-series>
</e-series-collection>
</ejs-chart>
</div>
</template>
<script>
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, ScatterSeries } from "@syncfusion/ej2-vue-charts";
export default {
name: "App",
components: {
'ejs-chart': ChartComponent,
'e-series-collection': SeriesCollectionDirective,
'e-series': SeriesDirective
},
data() {
return {
seriesData: [
{ x: 1, y: 15 }, { x: 2, y: 25 }, { x: 3, y: 35 }, { x: 4, y: null },
{ x: 5, y: 55 }, { x: 6, y: 60 }, { x: 7, y: 65 }, { x: 8, y: 70 },
{ x: 9, y: 75 }, { x: 10, y: 80 }, { x: 11, y: undefined }, { x: 12, y: 90 },
{ x: 13, y: 92 }, { x: 14, y: 94 }, { x: 15, y: 96 }, { x: 16, y: null },
{ x: 17, y: 98 }, { x: 18, y: 99 }, { x: 19, y: 100 }, { x: 20, y: 100 }
],
primaryXAxis: {
minimum: 0,
maximum: 21,
interval: 3,
majorGridLines: { width: 0 },
title: 'Study Hours (Per Week)'
},
primaryYAxis:
{
title: 'Test Scores (%)',
minimum: 0,
maximum: 120,
interval: 20,
labelFormat: '{value}%'
},
title: 'Relationship Between Study Hours and Test Scores',
marker: {
visible: false,
width: 10,
height: 10,
shape: 'Circle'
},
emptyPointSettings: {
mode: 'Average',
fill: 'red',
border: { width: 2, color: 'green' }
}
};
},
provide: {
chart: [ScatterSeries]
}
};
</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="container" :primaryXAxis='primaryXAxis' :primaryYAxis='primaryYAxis' :title='title' :seriesRender='seriesRender'>
<e-series-collection>
<e-series :dataSource='seriesData' type='Scatter' xName='x' yName='y' :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, ScatterSeries } from "@syncfusion/ej2-vue-charts";
const seriesData = [
{ x: 1, y: 15 }, { x: 2, y: 25 }, { x: 3, y: 35 }, { x: 4, y: 45 },
{ x: 5, y: 55 }, { x: 6, y: 60 }, { x: 7, y: 65 }, { x: 8, y: 70 },
{ x: 9, y: 75 }, { x: 10, y: 80 }, { x: 11, y: 85 }, { x: 12, y: 90 },
{ x: 13, y: 92 }, { x: 14, y: 94 }, { x: 15, y: 96 }, { x: 16, y: 97 },
{ x: 17, y: 98 }, { x: 18, y: 99 }, { x: 19, y: 100 }, { x: 20, y: 100 }
];
const primaryXAxis = {
minimum: 0,
maximum: 21,
interval: 3,
majorGridLines: { width: 0 },
title: 'Study Hours (Per Week)'
};
const primaryYAxis = {
title: 'Test Scores (%)',
minimum: 0,
maximum: 120,
interval: 20,
labelFormat: '{value}%'
};
const title = 'Relationship Between Study Hours and Test Scores';
const marker = {
visible: false,
width: 10,
height: 10,
shape: 'Circle'
};
provide('chart', [ScatterSeries]);
const seriesRender = function (args) {
args.fill = '#ff6347';
};
</script>
<style>
#container {
height: 350px;
}
</style>
<template>
<div id="app">
<ejs-chart id="container" :primaryXAxis='primaryXAxis' :primaryYAxis='primaryYAxis' :title='title' :seriesRender='seriesRender'>
<e-series-collection>
<e-series :dataSource='seriesData' type='Scatter' xName='x' yName='y' :marker='marker'> </e-series>
</e-series-collection>
</ejs-chart>
</div>
</template>
<script>
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, ScatterSeries } from "@syncfusion/ej2-vue-charts";
export default {
name: "App",
components: {
'ejs-chart': ChartComponent,
'e-series-collection': SeriesCollectionDirective,
'e-series': SeriesDirective
},
data() {
return {
seriesData: [
{ x: 1, y: 15 }, { x: 2, y: 25 }, { x: 3, y: 35 }, { x: 4, y: 45 },
{ x: 5, y: 55 }, { x: 6, y: 60 }, { x: 7, y: 65 }, { x: 8, y: 70 },
{ x: 9, y: 75 }, { x: 10, y: 80 }, { x: 11, y: 85 }, { x: 12, y: 90 },
{ x: 13, y: 92 }, { x: 14, y: 94 }, { x: 15, y: 96 }, { x: 16, y: 97 },
{ x: 17, y: 98 }, { x: 18, y: 99 }, { x: 19, y: 100 }, { x: 20, y: 100 }
],
primaryXAxis: {
minimum: 0,
maximum: 21,
interval: 3,
majorGridLines: { width: 0 },
title: 'Study Hours (Per Week)'
},
primaryYAxis:
{
title: 'Test Scores (%)',
minimum: 0,
maximum: 120,
interval: 20,
labelFormat: '{value}%'
},
title: 'Relationship Between Study Hours and Test Scores',
marker: {
visible: false,
width: 10,
height: 10,
shape: 'Circle'
},
};
},
provide: {
chart: [ScatterSeries]
},
methods: {
seriesRender: function (args) {
args.fill = '#ff6347';
}
}
};
</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="container" :primaryXAxis='primaryXAxis' :primaryYAxis='primaryYAxis' :title='title' :pointRender='pointRender'>
<e-series-collection>
<e-series :dataSource='seriesData' type='Scatter' xName='x' yName='y' :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, ScatterSeries } from "@syncfusion/ej2-vue-charts";
const seriesData = [
{ x: 1, y: 15 }, { x: 2, y: 25 }, { x: 3, y: 35 }, { x: 4, y: 45 },
{ x: 5, y: 55 }, { x: 6, y: 60 }, { x: 7, y: 65 }, { x: 8, y: 70 },
{ x: 9, y: 75 }, { x: 10, y: 80 }, { x: 11, y: 85 }, { x: 12, y: 90 },
{ x: 13, y: 92 }, { x: 14, y: 94 }, { x: 15, y: 96 }, { x: 16, y: 97 },
{ x: 17, y: 98 }, { x: 18, y: 99 }, { x: 19, y: 100 }, { x: 20, y: 100 }
];
const primaryXAxis = {
minimum: 0,
maximum: 21,
interval: 3,
majorGridLines: { width: 0 },
title: 'Study Hours (Per Week)'
};
const primaryYAxis = {
title: 'Test Scores (%)',
minimum: 0,
maximum: 120,
interval: 20,
labelFormat: '{value}%'
};
const title = 'Relationship Between Study Hours and Test Scores';
const marker = {
visible: false,
width: 10,
height: 10,
shape: 'Circle'
};
provide('chart', [ScatterSeries]);
const pointRender= function (args) {
if (args.point.index % 2 !== 0) {
args.fill = '#ff6347';
}
else {
args.fill = '#009cb8';
}
};
</script>
<style>
#container {
height: 350px;
}
</style>
<template>
<div id="app">
<ejs-chart id="container" :primaryXAxis='primaryXAxis' :primaryYAxis='primaryYAxis' :title='title' :pointRender='pointRender'>
<e-series-collection>
<e-series :dataSource='seriesData' type='Scatter' xName='x' yName='y' :marker='marker'> </e-series>
</e-series-collection>
</ejs-chart>
</div>
</template>
<script>
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, ScatterSeries } from "@syncfusion/ej2-vue-charts";
export default {
name: "App",
components: {
'ejs-chart': ChartComponent,
'e-series-collection': SeriesCollectionDirective,
'e-series': SeriesDirective
},
data() {
return {
seriesData: [
{ x: 1, y: 15 }, { x: 2, y: 25 }, { x: 3, y: 35 }, { x: 4, y: 45 },
{ x: 5, y: 55 }, { x: 6, y: 60 }, { x: 7, y: 65 }, { x: 8, y: 70 },
{ x: 9, y: 75 }, { x: 10, y: 80 }, { x: 11, y: 85 }, { x: 12, y: 90 },
{ x: 13, y: 92 }, { x: 14, y: 94 }, { x: 15, y: 96 }, { x: 16, y: 97 },
{ x: 17, y: 98 }, { x: 18, y: 99 }, { x: 19, y: 100 }, { x: 20, y: 100 }
],
primaryXAxis: {
minimum: 0,
maximum: 21,
interval: 3,
majorGridLines: { width: 0 },
title: 'Study Hours (Per Week)'
},
primaryYAxis:
{
title: 'Test Scores (%)',
minimum: 0,
maximum: 120,
interval: 20,
labelFormat: '{value}%'
},
title: 'Relationship Between Study Hours and Test Scores',
marker: {
visible: false,
width: 10,
height: 10,
shape: 'Circle'
},
};
},
provide: {
chart: [ScatterSeries]
},
methods: {
pointRender: function (args) {
if (args.point.index % 2 !== 0) {
args.fill = '#ff6347';
}
else {
args.fill = '#009cb8';
}
}
}
};
</script>
<style>
#container {
height: 350px;
}
</style>