Pare to Chart in EJ2 JavaScript control
20 Sep 202424 minutes to read
Pareto
Pareto charts are used to find the cumulative values of data in different categories. It is a combination of Column
and Line
series, where the initial values are represented by the column chart and the cumulative values are represented by the line chart.
To render a pareto
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
asPareto
in your chart configuration. This indicates that the data should be represented as a pareto chart, will use a combination of column and line series.
/**
* Sample for Pareto chart
*/
var paretoData = [
{ x: 'Button Defect', y: 23 },
{ x: 'Pocket Defect', y: 16 },
{ x: 'Coller Defect', y: 10 },
{ x: 'Cuff Defect', y: 7 },
{ x: 'Sleeve Defect', y: 6 },
{ x: 'Other Defect', y: 2 }
];
var chart = new ej.charts.Chart({
//Initializing Primary X Axis
primaryXAxis: {
interval: 1,
valueType: 'Category',
majorGridLines: { width: 0 }, minorGridLines: { width: 0 },
majorTickLines: { width: 0 }, minorTickLines: { width: 0 },
lineStyle: { width: 0 }, labelIntersectAction: 'Rotate45'
},
//Initializing Primary Y Axis
primaryYAxis:
{
title: 'Frequency of Occurence',
minimum: 0,
maximum: 25,
interval: 5,
lineStyle: { width: 0 },
majorTickLines: { width: 0 }, majorGridLines: { width: 1 },
minorGridLines: { width: 1 }, minorTickLines: { width: 0 }
},
chartArea: {
border: {
width: 0
}
},
//Initializing Chart Series
series: [
{
type: 'Pareto',
dataSource: paretoData,
xName: 'x', yName: 'y', name: 'Defect', width: 2,
paretoOptions: {
marker: { visible: true, isFilled: true, width: 7, height: 7 },
width: 2
}
}
],
//Initializing Chart title
title: 'Pareto chart - Defects in Shirts',
legendSettings: { visible: true },
//Initializing User Interaction
tooltip: {
enable: true,
shared: true
}
});
chart.appendTo('#element');
<!DOCTYPE html>
<html lang="en">
<head>
<title>EJ2 Animation</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Typescript UI Controls">
<meta name="author" content="Syncfusion">
<link href="index.css" rel="stylesheet">
<script src="https://cdn.syncfusion.com/ej2/27.2.2/dist/ej2.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if (ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body>
</html>
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.
/**
* Sample for Pareto chart
*/
var paretoData = [
{ x: 'Button Defect', y: 23 },
{ x: 'Pocket Defect', y: 16 },
{ x: 'Coller Defect', y: 10 },
{ x: 'Cuff Defect', y: 7 },
{ x: 'Sleeve Defect', y: 6 },
{ x: 'Other Defect', y: 2 }
];
var chart = new ej.charts.Chart({
//Initializing Primary X Axis
primaryXAxis: {
interval: 1,
valueType: 'Category',
majorGridLines: { width: 0 }, minorGridLines: { width: 0 },
majorTickLines: { width: 0 }, minorTickLines: { width: 0 },
lineStyle: { width: 0 }, labelIntersectAction: 'Rotate45'
},
//Initializing Primary Y Axis
primaryYAxis:
{
title: 'Frequency of Occurence',
minimum: 0,
maximum: 25,
interval: 5,
lineStyle: { width: 0 },
majorTickLines: { width: 0 }, majorGridLines: { width: 1 },
minorGridLines: { width: 1 }, minorTickLines: { width: 0 }
},
chartArea: {
border: {
width: 0
}
},
//Initializing Chart Series
series: [
{
type: 'Pareto',
dataSource: paretoData,
xName: 'x', yName: 'y', name: 'Defect', width: 2,
paretoOptions: {
marker: { visible: true, isFilled: true, width: 7, height: 7 },
width: 2
}
}
],
//Initializing Chart title
title: 'Pareto chart - Defects in Shirts',
legendSettings: { visible: true },
//Initializing User Interaction
tooltip: {
enable: true,
shared: true
}
});
chart.appendTo('#element');
<!DOCTYPE html>
<html lang="en">
<head>
<title>EJ2 Animation</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Typescript UI Controls">
<meta name="author" content="Syncfusion">
<link href="index.css" rel="stylesheet">
<script src="https://cdn.syncfusion.com/ej2/27.2.2/dist/ej2.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if (ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body>
</html>
Pareto customization
Fill
Use the fill
property to apply a color to the pareto line. By default, a color based on the theme is used.
/**
* Sample for Pareto chart
*/
var paretoData = [
{ x: 'Button Defect', y: 23 },
{ x: 'Pocket Defect', y: 16 },
{ x: 'Collar Defect', y: 10 },
{ x: 'Cuff Defect', y: 7 },
{ x: 'Sleeve Defect', y: 6 },
{ x: 'Other Defect', y: 2 }
];
var chart = new ej.charts.Chart({
//Initializing Primary X Axis
primaryXAxis: {
interval: 1,
valueType: 'Category',
majorGridLines: { width: 0 }, minorGridLines: { width: 0 },
majorTickLines: { width: 0 }, minorTickLines: { width: 0 },
lineStyle: { width: 0 }, labelIntersectAction: 'Rotate45'
},
//Initializing Primary Y Axis
primaryYAxis:
{
title: 'Frequency of Occurence',
minimum: 0,
maximum: 25,
interval: 5,
lineStyle: { width: 0 },
majorTickLines: { width: 0 }, majorGridLines: { width: 1 },
minorGridLines: { width: 1 }, minorTickLines: { width: 0 }
},
chartArea: {
border: {
width: 0
}
},
//Initializing Chart Series
series: [
{
type: 'Pareto',
dataSource: [
{ x: 'Button Defect', y: 23 }, { x: 'Pocket Defect', y: 16 },
{ x: 'Collar Defect', y: 10 }, { x: 'Cuff Defect', y: 7 },
{ x: 'Sleeve Defect', y: 6 }, { x: 'Other Defect', y: 2 }
],
xName: 'x', yName: 'y', name: 'Defect', width: 2, opacity: 0.75, columnWidth: 0.4,
paretoOptions: {
fill: '#F7523F'
},
cornerRadius: { topLeft: ej.base.Browser.isDevice ? 4 : 6, topRight: ej.base.Browser.isDevice ? 4 : 6 }
}
],
//Initializing Chart title
title: 'Defects in Shirts',
legendSettings: { visible: true, enableHighlight: true },
//Initializing User Interaction
tooltip: {
enable: true,
shared: true,
format: '${series.name} : <b>${point.y}</b>'
}
});
chart.appendTo('#element');
<!DOCTYPE html>
<html lang="en">
<head>
<title>EJ2 Animation</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Typescript UI Controls">
<meta name="author" content="Syncfusion">
<link href="index.css" rel="stylesheet">
<script src="https://cdn.syncfusion.com/ej2/27.2.2/dist/ej2.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if (ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body>
</html>
Width
Use the width
property to control the thickness of the line for the pareto series, which affects its visual weight on the chart.
/**
* Sample for Pareto chart
*/
var paretoData = [
{ x: 'Button Defect', y: 23 },
{ x: 'Pocket Defect', y: 16 },
{ x: 'Collar Defect', y: 10 },
{ x: 'Cuff Defect', y: 7 },
{ x: 'Sleeve Defect', y: 6 },
{ x: 'Other Defect', y: 2 }
];
var chart = new ej.charts.Chart({
//Initializing Primary X Axis
primaryXAxis: {
interval: 1,
valueType: 'Category',
majorGridLines: { width: 0 }, minorGridLines: { width: 0 },
majorTickLines: { width: 0 }, minorTickLines: { width: 0 },
lineStyle: { width: 0 }, labelIntersectAction: 'Rotate45'
},
//Initializing Primary Y Axis
primaryYAxis:
{
title: 'Frequency of Occurence',
minimum: 0,
maximum: 25,
interval: 5,
lineStyle: { width: 0 },
majorTickLines: { width: 0 }, majorGridLines: { width: 1 },
minorGridLines: { width: 1 }, minorTickLines: { width: 0 }
},
chartArea: {
border: {
width: 0
}
},
//Initializing Chart Series
series: [
{
type: 'Pareto',
dataSource: [
{ x: 'Button Defect', y: 23 }, { x: 'Pocket Defect', y: 16 },
{ x: 'Collar Defect', y: 10 }, { x: 'Cuff Defect', y: 7 },
{ x: 'Sleeve Defect', y: 6 }, { x: 'Other Defect', y: 2 }
],
xName: 'x', yName: 'y', name: 'Defect', width: 2, opacity: 0.75, columnWidth: 0.4,
paretoOptions: {
fill: '#F7523F',
width: 2
},
cornerRadius: { topLeft: ej.base.Browser.isDevice ? 4 : 6, topRight: ej.base.Browser.isDevice ? 4 : 6 }
}
],
//Initializing Chart title
title: 'Defects in Shirts',
legendSettings: { visible: true, enableHighlight: true },
//Initializing User Interaction
tooltip: {
enable: true,
shared: true,
format: '${series.name} : <b>${point.y}</b>'
}
});
chart.appendTo('#element');
<!DOCTYPE html>
<html lang="en">
<head>
<title>EJ2 Animation</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Typescript UI Controls">
<meta name="author" content="Syncfusion">
<link href="index.css" rel="stylesheet">
<script src="https://cdn.syncfusion.com/ej2/27.2.2/dist/ej2.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if (ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body>
</html>
Dash array
The dashArray property determines the pattern of dashes and gaps in the pareto line series.
/**
* Sample for Pareto chart
*/
var paretoData = [
{ x: 'Button Defect', y: 23 },
{ x: 'Pocket Defect', y: 16 },
{ x: 'Collar Defect', y: 10 },
{ x: 'Cuff Defect', y: 7 },
{ x: 'Sleeve Defect', y: 6 },
{ x: 'Other Defect', y: 2 }
];
var chart = new ej.charts.Chart({
//Initializing Primary X Axis
primaryXAxis: {
interval: 1,
valueType: 'Category',
majorGridLines: { width: 0 }, minorGridLines: { width: 0 },
majorTickLines: { width: 0 }, minorTickLines: { width: 0 },
lineStyle: { width: 0 }, labelIntersectAction: 'Rotate45'
},
//Initializing Primary Y Axis
primaryYAxis:
{
title: 'Frequency of Occurence',
minimum: 0,
maximum: 25,
interval: 5,
lineStyle: { width: 0 },
majorTickLines: { width: 0 }, majorGridLines: { width: 1 },
minorGridLines: { width: 1 }, minorTickLines: { width: 0 }
},
chartArea: {
border: {
width: 0
}
},
//Initializing Chart Series
series: [
{
type: 'Pareto',
dataSource: [
{ x: 'Button Defect', y: 23 }, { x: 'Pocket Defect', y: 16 },
{ x: 'Collar Defect', y: 10 }, { x: 'Cuff Defect', y: 7 },
{ x: 'Sleeve Defect', y: 6 }, { x: 'Other Defect', y: 2 }
],
xName: 'x', yName: 'y', name: 'Defect', width: 2, opacity: 0.75, columnWidth: 0.4,
paretoOptions: {
fill: '#F7523F',
width: 2,
dashArray: '3,3'
},
cornerRadius: { topLeft: ej.base.Browser.isDevice ? 4 : 6, topRight: ej.base.Browser.isDevice ? 4 : 6 }
}
],
//Initializing Chart title
title: 'Defects in Shirts',
legendSettings: { visible: true, enableHighlight: true },
//Initializing User Interaction
tooltip: {
enable: true,
shared: true,
format: '${series.name} : <b>${point.y}</b>'
}
});
chart.appendTo('#element');
<!DOCTYPE html>
<html lang="en">
<head>
<title>EJ2 Animation</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Typescript UI Controls">
<meta name="author" content="Syncfusion">
<link href="index.css" rel="stylesheet">
<script src="https://cdn.syncfusion.com/ej2/27.2.2/dist/ej2.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if (ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body>
</html>
Marker
Use the marker
property to display and customize markers for individual points in a pareto line.
/**
* Sample for Pareto chart
*/
var paretoData = [
{ x: 'Button Defect', y: 23 },
{ x: 'Pocket Defect', y: 16 },
{ x: 'Collar Defect', y: 10 },
{ x: 'Cuff Defect', y: 7 },
{ x: 'Sleeve Defect', y: 6 },
{ x: 'Other Defect', y: 2 }
];
var chart = new ej.charts.Chart({
//Initializing Primary X Axis
primaryXAxis: {
interval: 1,
valueType: 'Category',
majorGridLines: { width: 0 }, minorGridLines: { width: 0 },
majorTickLines: { width: 0 }, minorTickLines: { width: 0 },
lineStyle: { width: 0 }, labelIntersectAction: 'Rotate45'
},
//Initializing Primary Y Axis
primaryYAxis:
{
title: 'Frequency of Occurence',
minimum: 0,
maximum: 25,
interval: 5,
lineStyle: { width: 0 },
majorTickLines: { width: 0 }, majorGridLines: { width: 1 },
minorGridLines: { width: 1 }, minorTickLines: { width: 0 }
},
chartArea: {
border: {
width: 0
}
},
//Initializing Chart Series
series: [
{
type: 'Pareto',
dataSource: [
{ x: 'Button Defect', y: 23 }, { x: 'Pocket Defect', y: 16 },
{ x: 'Collar Defect', y: 10 }, { x: 'Cuff Defect', y: 7 },
{ x: 'Sleeve Defect', y: 6 }, { x: 'Other Defect', y: 2 }
],
xName: 'x', yName: 'y', name: 'Defect', width: 2, opacity: 0.75, columnWidth: 0.4,
paretoOptions: {
marker: { visible: true, isFilled: true, width: 7, height: 7 },
fill: '#F7523F',
width: 2
},
cornerRadius: { topLeft: ej.base.Browser.isDevice ? 4 : 6, topRight: ej.base.Browser.isDevice ? 4 : 6 }
}
],
//Initializing Chart title
title: 'Defects in Shirts',
legendSettings: { visible: true, enableHighlight: true },
//Initializing User Interaction
tooltip: {
enable: true,
shared: true,
format: '${series.name} : <b>${point.y}</b>'
}
});
chart.appendTo('#element');
<!DOCTYPE html>
<html lang="en">
<head>
<title>EJ2 Animation</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Typescript UI Controls">
<meta name="author" content="Syncfusion">
<link href="index.css" rel="stylesheet">
<script src="https://cdn.syncfusion.com/ej2/27.2.2/dist/ej2.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if (ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body>
</html>
Show axis
Use the showAxis
property to show or hide the secondary axis for the pareto series.
/**
* Sample for Pareto chart
*/
var paretoData = [
{ x: 'Button Defect', y: 23 },
{ x: 'Pocket Defect', y: 16 },
{ x: 'Collar Defect', y: 10 },
{ x: 'Cuff Defect', y: 7 },
{ x: 'Sleeve Defect', y: 6 },
{ x: 'Other Defect', y: 2 }
];
var chart = new ej.charts.Chart({
//Initializing Primary X Axis
primaryXAxis: {
interval: 1,
valueType: 'Category',
majorGridLines: { width: 0 }, minorGridLines: { width: 0 },
majorTickLines: { width: 0 }, minorTickLines: { width: 0 },
lineStyle: { width: 0 }, labelIntersectAction: 'Rotate45'
},
//Initializing Primary Y Axis
primaryYAxis:
{
title: 'Frequency of Occurence',
minimum: 0,
maximum: 25,
interval: 5,
lineStyle: { width: 0 },
majorTickLines: { width: 0 }, majorGridLines: { width: 1 },
minorGridLines: { width: 1 }, minorTickLines: { width: 0 }
},
chartArea: {
border: {
width: 0
}
},
//Initializing Chart Series
series: [
{
type: 'Pareto',
dataSource: paretoData,
xName: 'x', yName: 'y', name: 'Defect', width: 2, opacity: 0.75, columnWidth: 0.4,
paretoOptions: {
marker: { visible: true, isFilled: true, width: 7, height: 7 },
fill: '#F7523F',
width: 2,
showAxis: false
},
cornerRadius: { topLeft: ej.base.Browser.isDevice ? 4 : 6, topRight: ej.base.Browser.isDevice ? 4 : 6 }
}
],
//Initializing Chart title
title: 'Defects in Shirts',
legendSettings: { visible: true, enableHighlight: true },
//Initializing User Interaction
tooltip: {
enable: true,
shared: true,
format: '${series.name} : <b>${point.y}</b>'
}
});
chart.appendTo('#element');
<!DOCTYPE html>
<html lang="en">
<head>
<title>EJ2 Animation</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Typescript UI Controls">
<meta name="author" content="Syncfusion">
<link href="index.css" rel="stylesheet">
<script src="https://cdn.syncfusion.com/ej2/27.2.2/dist/ej2.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if (ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body>
</html>
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
.
/**
* Sample for Pareto chart
*/
var paretoData = [
{ x: 'Button Defect', y: 23 },
{ x: 'Pocket Defect', y: 16 },
{ x: 'Collar Defect', y: null },
{ x: 'Cuff Defect', y: 7 },
{ x: 'Sleeve Defect', y: 6 },
{ x: 'Other Defect', y: 2 },
{ x: 'Stitching Defect', y: null },
{ x: 'Zipper Defect', y: 3 },
{ x: 'Fabric Defect', y: 9 }
];
var chart = new ej.charts.Chart({
//Initializing Primary X Axis
primaryXAxis: {
interval: 1,
valueType: 'Category',
majorGridLines: { width: 0 }, minorGridLines: { width: 0 },
majorTickLines: { width: 0 }, minorTickLines: { width: 0 },
lineStyle: { width: 0 }, labelIntersectAction: 'Rotate45'
},
//Initializing Primary Y Axis
primaryYAxis:
{
title: 'Frequency of Occurence',
minimum: 0,
maximum: 25,
interval: 5,
lineStyle: { width: 0 },
majorTickLines: { width: 0 }, majorGridLines: { width: 1 },
minorGridLines: { width: 1 }, minorTickLines: { width: 0 }
},
chartArea: {
border: {
width: 0
}
},
//Initializing Chart Series
series: [
{
type: 'Pareto',
dataSource: paretoData,
xName: 'x', yName: 'y', name: 'Defect', width: 2, opacity: 0.75, columnWidth: 0.4,
paretoOptions: {
marker: { visible: true, isFilled: true, width: 7, height: 7 },
fill: '#F7523F',
width: 2
},
cornerRadius: { topLeft: ej.base.Browser.isDevice ? 4 : 6, topRight: ej.base.Browser.isDevice ? 4 : 6 },
emptyPointSettings: {
mode: 'Average'
}
}
],
//Initializing Chart title
title: 'Defects in Shirts',
legendSettings: { visible: true, enableHighlight: true },
//Initializing User Interaction
tooltip: {
enable: true,
shared: true,
format: '${series.name} : <b>${point.y}</b>'
}
});
chart.appendTo('#element');
<!DOCTYPE html>
<html lang="en">
<head>
<title>EJ2 Animation</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Typescript UI Controls">
<meta name="author" content="Syncfusion">
<link href="index.css" rel="stylesheet">
<script src="https://cdn.syncfusion.com/ej2/27.2.2/dist/ej2.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if (ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body>
</html>
Fill
Use the fill
property to customize the fill color of empty points in the series.
/**
* Sample for Pareto chart
*/
var paretoData = [
{ x: 'Button Defect', y: 23 },
{ x: 'Pocket Defect', y: 16 },
{ x: 'Collar Defect', y: null },
{ x: 'Cuff Defect', y: 7 },
{ x: 'Sleeve Defect', y: 6 },
{ x: 'Other Defect', y: 2 },
{ x: 'Stitching Defect', y: null },
{ x: 'Zipper Defect', y: 3 },
{ x: 'Fabric Defect', y: 9 }
];
var chart = new ej.charts.Chart({
//Initializing Primary X Axis
primaryXAxis: {
interval: 1,
valueType: 'Category',
majorGridLines: { width: 0 }, minorGridLines: { width: 0 },
majorTickLines: { width: 0 }, minorTickLines: { width: 0 },
lineStyle: { width: 0 }, labelIntersectAction: 'Rotate45'
},
//Initializing Primary Y Axis
primaryYAxis:
{
title: 'Frequency of Occurence',
minimum: 0,
maximum: 25,
interval: 5,
lineStyle: { width: 0 },
majorTickLines: { width: 0 }, majorGridLines: { width: 1 },
minorGridLines: { width: 1 }, minorTickLines: { width: 0 }
},
chartArea: {
border: {
width: 0
}
},
//Initializing Chart Series
series: [
{
type: 'Pareto',
dataSource: paretoData,
xName: 'x', yName: 'y', name: 'Defect', width: 2, opacity: 0.75, columnWidth: 0.4,
paretoOptions: {
marker: { visible: true, isFilled: true, width: 7, height: 7 },
fill: '#F7523F',
width: 2
},
cornerRadius: { topLeft: ej.base.Browser.isDevice ? 4 : 6, topRight: ej.base.Browser.isDevice ? 4 : 6 },
emptyPointSettings: {
mode: 'Average',
fill: 'red'
}
}
],
//Initializing Chart title
title: 'Defects in Shirts',
legendSettings: { visible: true, enableHighlight: true },
//Initializing User Interaction
tooltip: {
enable: true,
shared: true,
format: '${series.name} : <b>${point.y}</b>'
}
});
chart.appendTo('#element');
<!DOCTYPE html>
<html lang="en">
<head>
<title>EJ2 Animation</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Typescript UI Controls">
<meta name="author" content="Syncfusion">
<link href="index.css" rel="stylesheet">
<script src="https://cdn.syncfusion.com/ej2/27.2.2/dist/ej2.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if (ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body>
</html>
Border
Use the border
property to customize the width and color of the border for empty points.
/**
* Sample for Pareto chart
*/
var paretoData = [
{ x: 'Button Defect', y: 23 },
{ x: 'Pocket Defect', y: 16 },
{ x: 'Collar Defect', y: null },
{ x: 'Cuff Defect', y: 7 },
{ x: 'Sleeve Defect', y: 6 },
{ x: 'Other Defect', y: 2 },
{ x: 'Stitching Defect', y: null },
{ x: 'Zipper Defect', y: 3 },
{ x: 'Fabric Defect', y: 9 }
];
var chart = new ej.charts.Chart({
//Initializing Primary X Axis
primaryXAxis: {
interval: 1,
valueType: 'Category',
majorGridLines: { width: 0 }, minorGridLines: { width: 0 },
majorTickLines: { width: 0 }, minorTickLines: { width: 0 },
lineStyle: { width: 0 }, labelIntersectAction: 'Rotate45'
},
//Initializing Primary Y Axis
primaryYAxis:
{
title: 'Frequency of Occurence',
minimum: 0,
maximum: 25,
interval: 5,
lineStyle: { width: 0 },
majorTickLines: { width: 0 }, majorGridLines: { width: 1 },
minorGridLines: { width: 1 }, minorTickLines: { width: 0 }
},
chartArea: {
border: {
width: 0
}
},
//Initializing Chart Series
series: [
{
type: 'Pareto',
dataSource: paretoData,
xName: 'x', yName: 'y', name: 'Defect', width: 2, opacity: 0.75, columnWidth: 0.4,
paretoOptions: {
marker: { visible: true, isFilled: true, width: 7, height: 7 },
fill: '#F7523F',
width: 2
},
cornerRadius: { topLeft: ej.base.Browser.isDevice ? 4 : 6, topRight: ej.base.Browser.isDevice ? 4 : 6 },
emptyPointSettings: {
mode: 'Average',
fill: 'red',
border: { width: 2, color: 'green' }
}
}
],
//Initializing Chart title
title: 'Defects in Shirts',
legendSettings: { visible: true, enableHighlight: true },
//Initializing User Interaction
tooltip: {
enable: true,
shared: true,
format: '${series.name} : <b>${point.y}</b>'
}
});
chart.appendTo('#element');
<!DOCTYPE html>
<html lang="en">
<head>
<title>EJ2 Animation</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Typescript UI Controls">
<meta name="author" content="Syncfusion">
<link href="index.css" rel="stylesheet">
<script src="https://cdn.syncfusion.com/ej2/27.2.2/dist/ej2.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if (ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body>
</html>
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.
/**
* Sample for Pareto chart
*/
var paretoData = [
{ x: 'Button Defect', y: 23 },
{ x: 'Pocket Defect', y: 16 },
{ x: 'Coller Defect', y: 10 },
{ x: 'Cuff Defect', y: 7 },
{ x: 'Sleeve Defect', y: 6 },
{ x: 'Other Defect', y: 2 }
];
var chart = new ej.charts.Chart({
//Initializing Primary X Axis
primaryXAxis: {
interval: 1,
valueType: 'Category',
majorGridLines: { width: 0 }, minorGridLines: { width: 0 },
majorTickLines: { width: 0 }, minorTickLines: { width: 0 },
lineStyle: { width: 0 }, labelIntersectAction: 'Rotate45'
},
//Initializing Primary Y Axis
primaryYAxis:
{
title: 'Frequency of Occurence',
minimum: 0,
maximum: 25,
interval: 5,
lineStyle: { width: 0 },
majorTickLines: { width: 0 }, majorGridLines: { width: 1 },
minorGridLines: { width: 1 }, minorTickLines: { width: 0 }
},
chartArea: {
border: {
width: 0
}
},
//Initializing Chart Series
series: [
{
type: 'Pareto',
dataSource: paretoData,
xName: 'x', yName: 'y', name: 'Defect', width: 2,
paretoOptions: {
marker: { visible: true, isFilled: true, width: 7, height: 7 },
width: 2
}
}
],
//Initializing Chart title
title: 'Pareto chart - Defects in Shirts',
legendSettings: { visible: true },
//Initializing User Interaction
tooltip: {
enable: true,
shared: true
},
seriesRender: function (args) {
args.fill = 'green';
}
});
chart.appendTo('#element');
<!DOCTYPE html>
<html lang="en">
<head>
<title>EJ2 Animation</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Typescript UI Controls">
<meta name="author" content="Syncfusion">
<link href="index.css" rel="stylesheet">
<script src="https://cdn.syncfusion.com/ej2/27.2.2/dist/ej2.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if (ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body>
</html>
Point render
The pointRender
event allows you to customize each data point before it is rendered on the chart.
/**
* Sample for Pareto chart
*/
var paretoData = [
{ x: 'Button Defect', y: 23 },
{ x: 'Pocket Defect', y: 16 },
{ x: 'Coller Defect', y: 10 },
{ x: 'Cuff Defect', y: 7 },
{ x: 'Sleeve Defect', y: 6 },
{ x: 'Other Defect', y: 2 }
];
var chart = new ej.charts.Chart({
//Initializing Primary X Axis
primaryXAxis: {
interval: 1,
valueType: 'Category',
majorGridLines: { width: 0 }, minorGridLines: { width: 0 },
majorTickLines: { width: 0 }, minorTickLines: { width: 0 },
lineStyle: { width: 0 }, labelIntersectAction: 'Rotate45'
},
//Initializing Primary Y Axis
primaryYAxis:
{
title: 'Frequency of Occurence',
minimum: 0,
maximum: 25,
interval: 5,
lineStyle: { width: 0 },
majorTickLines: { width: 0 }, majorGridLines: { width: 1 },
minorGridLines: { width: 1 }, minorTickLines: { width: 0 }
},
chartArea: {
border: {
width: 0
}
},
//Initializing Chart Series
series: [
{
type: 'Pareto',
dataSource: paretoData,
xName: 'x', yName: 'y', name: 'Defect', width: 2,
paretoOptions: {
marker: { visible: true, isFilled: true, width: 7, height: 7 },
width: 2
}
}
],
//Initializing Chart title
title: 'Pareto chart - Defects in Shirts',
legendSettings: { visible: true },
//Initializing User Interaction
tooltip: {
enable: true,
shared: true
},
pointRender: function (args) {
if (args.point.index % 2 !== 0) {
args.fill = '#ff6347';
}
else {
args.fill = '#009cb8';
}
}
});
chart.appendTo('#element');
<!DOCTYPE html>
<html lang="en">
<head>
<title>EJ2 Animation</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Typescript UI Controls">
<meta name="author" content="Syncfusion">
<link href="index.css" rel="stylesheet">
<script src="https://cdn.syncfusion.com/ej2/27.2.2/dist/ej2.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if (ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body>
</html>