Pareto in React Chart component
17 Oct 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. -
Inject the necessary modules: inject
ParetoSeries
ColumnSeries
andLineSeries
module. This step is essential, as it ensures that the necessary functionalities for rendering pareto series are available in your chart.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, ParetoSeries, ColumnSeries, LineSeries, Legend, Category, Tooltip, DataLabel } from '@syncfusion/ej2-react-charts';
import { chartData } from './datasource';
function App() {
const primaryxAxis = { title: 'Defects', valueType: 'Category' };
const primaryyAxis = { title: 'Frequency', minimum: 0, maximum: 150, interval: 30 };
const tooltipsettings = { enable: true };
const marker = { visible: true, width: 10, height: 10 };
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} tooltip={tooltipsettings} title='Defect vs Frequency'>
<Inject services={[ColumnSeries, LineSeries, ParetoSeries, Legend, Tooltip, Category, DataLabel]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={chartData} xName='x' yName='y' name='Defect' type='Pareto' marker={marker}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>;
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
import * as React from "react";
import * as ReactDOM from "react-dom";
import {
AxisModel, ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, ChartTheme,LegendSettingsModel,TooltipSettingsModel,ParetoSeries,ColumnSeries,LineSeries,
Legend, Category, Tooltip, ILoadedEventArgs, DataLabel
} from '@syncfusion/ej2-react-charts';
import { chartData } from './datasource';
function App() {
const primaryxAxis: AxisModel= { title: 'Defects', valueType: 'Category' } ;
const primaryyAxis: AxisModel= { title: 'Frequency', minimum: 0, maximum: 150,interval: 30 } ;
const tooltipsettings: TooltipSettingsModel={ enable: true };
const marker={ visible: true, width: 10, height: 10};
return <ChartComponent id='charts'
primaryXAxis={ primaryxAxis }
primaryYAxis={ primaryyAxis }
tooltip={ tooltipsettings }
title='Defect vs Frequency'>
<Inject services={[ColumnSeries, LineSeries, ParetoSeries, Legend, Tooltip, Category, DataLabel]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={chartData} xName='x' yName='y' name='Defect' type='Pareto'
marker={ marker }>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
export let chartData = [
{ x: 'Traffic', y: 56 },
{ x: 'Child Care', y: 44.8 },
{ x: 'Transport', y: 27.2 },
{ x: 'Weather', y: 19.6 },
{ x: 'Emergency', y: 6.6 }
];
export let chartData: Object[] = [
{ x: 'Traffic', y: 56 },
{ x: 'Child Care', y: 44.8 },
{ x: 'Transport', y: 27.2 },
{ x: 'Weather', y: 19.6 },
{ x: 'Emergency', y: 6.6 }
];
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.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, ParetoSeries, ColumnSeries, LineSeries, Legend, Category, Tooltip, DataLabel } from '@syncfusion/ej2-react-charts';
import { chartData } from './datasource';
function App() {
const primaryxAxis = { title: 'Defects', valueType: 'Category' };
const primaryyAxis = { title: 'Frequency', minimum: 0, maximum: 150, interval: 30 };
const tooltipsettings = { enable: true };
const marker = { visible: true, width: 10, height: 10 };
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} tooltip={tooltipsettings} title='Defect vs Frequency'>
<Inject services={[ColumnSeries, LineSeries, ParetoSeries, Legend, Tooltip, Category, DataLabel]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={chartData} xName='x' yName='y' name='Defect' type='Pareto' marker={marker}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>;
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
import * as React from "react";
import * as ReactDOM from "react-dom";
import {
AxisModel, ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, ChartTheme,LegendSettingsModel,TooltipSettingsModel,ParetoSeries,ColumnSeries,LineSeries,
Legend, Category, Tooltip, ILoadedEventArgs, DataLabel
} from '@syncfusion/ej2-react-charts';
import { chartData } from './datasource';
function App() {
const primaryxAxis: AxisModel= { title: 'Defects', valueType: 'Category' } ;
const primaryyAxis: AxisModel= { title: 'Frequency', minimum: 0, maximum: 150,interval: 30 } ;
const tooltipsettings: TooltipSettingsModel={ enable: true };
const marker={ visible: true, width: 10, height: 10};
return <ChartComponent id='charts'
primaryXAxis={ primaryxAxis }
primaryYAxis={ primaryyAxis }
tooltip={ tooltipsettings }
title='Defect vs Frequency'>
<Inject services={[ColumnSeries, LineSeries, ParetoSeries, Legend, Tooltip, Category, DataLabel]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={chartData} xName='x' yName='y' name='Defect' type='Pareto'
marker={ marker }>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
export let chartData = [
{ x: 'Traffic', y: 56 },
{ x: 'Child Care', y: 44.8 },
{ x: 'Transport', y: 27.2 },
{ x: 'Weather', y: 19.6 },
{ x: 'Emergency', y: 6.6 }
];
export let chartData: Object[] = [
{ x: 'Traffic', y: 56 },
{ x: 'Child Care', y: 44.8 },
{ x: 'Transport', y: 27.2 },
{ x: 'Weather', y: 19.6 },
{ x: 'Emergency', y: 6.6 }
];
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.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, ParetoSeries, ColumnSeries, LineSeries, Legend, Category, Tooltip, DataLabel } from '@syncfusion/ej2-react-charts';
import { chartData } from './datasource';
function App() {
const primaryxAxis = { title: 'Defects', valueType: 'Category' };
const primaryyAxis = { title: 'Frequency', minimum: 0, maximum: 150, interval: 30 };
const tooltipsettings = { enable: true };
const marker = { visible: true, width: 10, height: 10 };
const paretoOptions = {
fill: 'red'
}
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} tooltip={tooltipsettings} title='Defect vs Frequency'>
<Inject services={[ColumnSeries, LineSeries, ParetoSeries, Legend, Tooltip, Category, DataLabel]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={chartData} xName='x' yName='y' name='Defect' type='Pareto' marker={marker} paretoOptions={paretoOptions}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>;
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
import * as React from "react";
import * as ReactDOM from "react-dom";
import {
AxisModel, ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, ChartTheme,LegendSettingsModel,TooltipSettingsModel,ParetoSeries,ColumnSeries,LineSeries,
Legend, Category, Tooltip, ILoadedEventArgs, DataLabel
} from '@syncfusion/ej2-react-charts';
import { chartData } from './datasource';
function App() {
const primaryxAxis: AxisModel= { title: 'Defects', valueType: 'Category' } ;
const primaryyAxis: AxisModel= { title: 'Frequency', minimum: 0, maximum: 150,interval: 30 } ;
const tooltipsettings: TooltipSettingsModel={ enable: true };
const marker={ visible: true, width: 10, height: 10};
const paretoOptions: object = {
fill: 'red'
};
return <ChartComponent id='charts'
primaryXAxis={ primaryxAxis }
primaryYAxis={ primaryyAxis }
tooltip={ tooltipsettings }
title='Defect vs Frequency'>
<Inject services={[ColumnSeries, LineSeries, ParetoSeries, Legend, Tooltip, Category, DataLabel]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={chartData} xName='x' yName='y' name='Defect' type='Pareto'
marker={ marker } paretoOptions={paretoOptions}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
export let chartData = [
{ 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 }
];
export let chartData: Object[] = [
{ 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 }
];
Width
Use the width
property to control the thickness of the line for the pareto series, which affects its visual weight on the chart.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, ParetoSeries, ColumnSeries, LineSeries, Legend, Category, Tooltip, DataLabel } from '@syncfusion/ej2-react-charts';
import { chartData } from './datasource';
function App() {
const primaryxAxis = { title: 'Defects', valueType: 'Category' };
const primaryyAxis = { title: 'Frequency', minimum: 0, maximum: 150, interval: 30 };
const tooltipsettings = { enable: true };
const marker = { visible: true, width: 10, height: 10 };
const paretoOptions = {
width: 4
}
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} tooltip={tooltipsettings} title='Defect vs Frequency'>
<Inject services={[ColumnSeries, LineSeries, ParetoSeries, Legend, Tooltip, Category, DataLabel]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={chartData} xName='x' yName='y' name='Defect' type='Pareto' marker={marker} paretoOptions={paretoOptions}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>;
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
import * as React from "react";
import * as ReactDOM from "react-dom";
import {
AxisModel, ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, ChartTheme,LegendSettingsModel,TooltipSettingsModel,ParetoSeries,ColumnSeries,LineSeries,
Legend, Category, Tooltip, ILoadedEventArgs, DataLabel
} from '@syncfusion/ej2-react-charts';
import { chartData } from './datasource';
function App() {
const primaryxAxis: AxisModel= { title: 'Defects', valueType: 'Category' } ;
const primaryyAxis: AxisModel= { title: 'Frequency', minimum: 0, maximum: 150,interval: 30 } ;
const tooltipsettings: TooltipSettingsModel={ enable: true };
const marker={ visible: true, width: 10, height: 10};
const paretoOptions: object = {
width: 4
};
return <ChartComponent id='charts'
primaryXAxis={ primaryxAxis }
primaryYAxis={ primaryyAxis }
tooltip={ tooltipsettings }
title='Defect vs Frequency'>
<Inject services={[ColumnSeries, LineSeries, ParetoSeries, Legend, Tooltip, Category, DataLabel]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={chartData} xName='x' yName='y' name='Defect' type='Pareto'
marker={ marker } paretoOptions={paretoOptions}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
export let chartData = [
{ 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 }
];
export let chartData: Object[] = [
{ 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 }
];
Dash array
The dashArray property determines the pattern of dashes and gaps in the pareto line series.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, ParetoSeries, ColumnSeries, LineSeries, Legend, Category, Tooltip, DataLabel } from '@syncfusion/ej2-react-charts';
import { chartData } from './datasource';
function App() {
const primaryxAxis = { title: 'Defects', valueType: 'Category' };
const primaryyAxis = { title: 'Frequency', minimum: 0, maximum: 150, interval: 30 };
const tooltipsettings = { enable: true };
const marker = { visible: true, width: 10, height: 10 };
const paretoOptions = {
fill: 'red', dashArray: '5'
}
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} tooltip={tooltipsettings} title='Defect vs Frequency'>
<Inject services={[ColumnSeries, LineSeries, ParetoSeries, Legend, Tooltip, Category, DataLabel]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={chartData} xName='x' yName='y' name='Defect' type='Pareto' marker={marker} paretoOptions={paretoOptions}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>;
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
import * as React from "react";
import * as ReactDOM from "react-dom";
import {
AxisModel, ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, ChartTheme,LegendSettingsModel,TooltipSettingsModel,ParetoSeries,ColumnSeries,LineSeries,
Legend, Category, Tooltip, ILoadedEventArgs, DataLabel
} from '@syncfusion/ej2-react-charts';
import { chartData } from './datasource';
function App() {
const primaryxAxis: AxisModel= { title: 'Defects', valueType: 'Category' } ;
const primaryyAxis: AxisModel= { title: 'Frequency', minimum: 0, maximum: 150,interval: 30 } ;
const tooltipsettings: TooltipSettingsModel={ enable: true };
const marker={ visible: true, width: 10, height: 10};
const paretoOptions: object = {
fill: 'red', dashArray: '5'
};
return <ChartComponent id='charts'
primaryXAxis={ primaryxAxis }
primaryYAxis={ primaryyAxis }
tooltip={ tooltipsettings }
title='Defect vs Frequency'>
<Inject services={[ColumnSeries, LineSeries, ParetoSeries, Legend, Tooltip, Category, DataLabel]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={chartData} xName='x' yName='y' name='Defect' type='Pareto'
marker={ marker } paretoOptions={paretoOptions}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
export let chartData = [
{ 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 }
];
export let chartData: Object[] = [
{ 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 }
];
Marker
Use the marker
property to display and customize markers for individual points in a pareto line.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, ParetoSeries, ColumnSeries, LineSeries, Legend, Category, Tooltip, DataLabel } from '@syncfusion/ej2-react-charts';
import { chartData } from './datasource';
function App() {
const primaryxAxis = { title: 'Defects', valueType: 'Category' };
const primaryyAxis = { title: 'Frequency', minimum: 0, maximum: 150, interval: 30 };
const tooltipsettings = { enable: true };
const marker = { visible: true, width: 10, height: 10 };
const paretoOptions = {
marker: { visible: true, width: 10, height: 10 },
}
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} tooltip={tooltipsettings} title='Defect vs Frequency'>
<Inject services={[ColumnSeries, LineSeries, ParetoSeries, Legend, Tooltip, Category, DataLabel]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={chartData} xName='x' yName='y' name='Defect' type='Pareto' marker={marker} paretoOptions={paretoOptions}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>;
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
import * as React from "react";
import * as ReactDOM from "react-dom";
import {
AxisModel, ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, ChartTheme,LegendSettingsModel,TooltipSettingsModel,ParetoSeries,ColumnSeries,LineSeries,
Legend, Category, Tooltip, ILoadedEventArgs, DataLabel
} from '@syncfusion/ej2-react-charts';
import { chartData } from './datasource';
function App() {
const primaryxAxis: AxisModel= { title: 'Defects', valueType: 'Category' } ;
const primaryyAxis: AxisModel= { title: 'Frequency', minimum: 0, maximum: 150,interval: 30 } ;
const tooltipsettings: TooltipSettingsModel={ enable: true };
const marker={ visible: true, width: 10, height: 10};
const paretoOptions: object = {
marker: { visible: true, width: 10, height: 10 },
};
return <ChartComponent id='charts'
primaryXAxis={ primaryxAxis }
primaryYAxis={ primaryyAxis }
tooltip={ tooltipsettings }
title='Defect vs Frequency'>
<Inject services={[ColumnSeries, LineSeries, ParetoSeries, Legend, Tooltip, Category, DataLabel]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={chartData} xName='x' yName='y' name='Defect' type='Pareto'
marker={ marker } paretoOptions={paretoOptions}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
export let chartData = [
{ 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 }
];
export let chartData: Object[] = [
{ 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 }
];
Show axis
Use the showAxis
property to show or hide the secondary axis for the pareto series.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, ParetoSeries, ColumnSeries, LineSeries, Legend, Category, Tooltip, DataLabel } from '@syncfusion/ej2-react-charts';
import { chartData } from './datasource';
function App() {
const primaryxAxis = { title: 'Defects', valueType: 'Category' };
const primaryyAxis = { title: 'Frequency', minimum: 0, maximum: 150, interval: 30 };
const tooltipsettings = { enable: true };
const marker = { visible: true, width: 10, height: 10 };
const paretoOptions = {
marker: { visible: true, width: 10, height: 10 }, showAxis: false
}
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} tooltip={tooltipsettings} title='Defect vs Frequency'>
<Inject services={[ColumnSeries, LineSeries, ParetoSeries, Legend, Tooltip, Category, DataLabel]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={chartData} xName='x' yName='y' name='Defect' type='Pareto' marker={marker} paretoOptions={paretoOptions}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>;
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
import * as React from "react";
import * as ReactDOM from "react-dom";
import {
AxisModel, ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, ChartTheme,LegendSettingsModel,TooltipSettingsModel,ParetoSeries,ColumnSeries,LineSeries,
Legend, Category, Tooltip, ILoadedEventArgs, DataLabel
} from '@syncfusion/ej2-react-charts';
import { chartData } from './datasource';
function App() {
const primaryxAxis: AxisModel= { title: 'Defects', valueType: 'Category' } ;
const primaryyAxis: AxisModel= { title: 'Frequency', minimum: 0, maximum: 150,interval: 30 } ;
const tooltipsettings: TooltipSettingsModel={ enable: true };
const marker={ visible: true, width: 10, height: 10};
const paretoOptions: object = {
marker: { visible: true, width: 10, height: 10 }, showAxis: false
};
return <ChartComponent id='charts'
primaryXAxis={ primaryxAxis }
primaryYAxis={ primaryyAxis }
tooltip={ tooltipsettings }
title='Defect vs Frequency'>
<Inject services={[ColumnSeries, LineSeries, ParetoSeries, Legend, Tooltip, Category, DataLabel]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={chartData} xName='x' yName='y' name='Defect' type='Pareto'
marker={ marker } paretoOptions={paretoOptions}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
export let chartData = [
{ 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 }
];
export let chartData: Object[] = [
{ 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 }
];
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
.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, ParetoSeries, ColumnSeries, LineSeries, Legend, Category, Tooltip, DataLabel } from '@syncfusion/ej2-react-charts';
import { chartData } from './datasource';
function App() {
const primaryxAxis = { title: 'Defects', valueType: 'Category' };
const primaryyAxis = { title: 'Frequency', minimum: 0, maximum: 150, interval: 30 };
const tooltipsettings = { enable: true };
const marker = { visible: true, width: 10, height: 10 };
const paretoOptions = {
marker: { visible: true, width: 10, height: 10 }, showAxis: false
}
const emptyPoint = { mode: 'Gap' };
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} tooltip={tooltipsettings} title='Defect vs Frequency'>
<Inject services={[ColumnSeries, LineSeries, ParetoSeries, Legend, Tooltip, Category, DataLabel]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={chartData} xName='x' yName='y' name='Defect' type='Pareto' marker={marker} paretoOptions={paretoOptions} emptyPointSettings={emptyPoint}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>;
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
import * as React from "react";
import * as ReactDOM from "react-dom";
import {
AxisModel, ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, ChartTheme,LegendSettingsModel,TooltipSettingsModel,ParetoSeries,ColumnSeries,LineSeries,
Legend, Category, Tooltip, ILoadedEventArgs, DataLabel
} from '@syncfusion/ej2-react-charts';
import { chartData } from './datasource';
function App() {
const primaryxAxis: AxisModel= { title: 'Defects', valueType: 'Category' } ;
const primaryyAxis: AxisModel= { title: 'Frequency', minimum: 0, maximum: 150,interval: 30 } ;
const tooltipsettings: TooltipSettingsModel={ enable: true };
const marker={ visible: true, width: 10, height: 10};
const paretoOptions: object = {
marker: { visible: true, width: 10, height: 10 }, showAxis: false
};
const emptyPoint: object = { mode: 'Gap' };
return <ChartComponent id='charts'
primaryXAxis={ primaryxAxis }
primaryYAxis={ primaryyAxis }
tooltip={ tooltipsettings }
title='Defect vs Frequency'>
<Inject services={[ColumnSeries, LineSeries, ParetoSeries, Legend, Tooltip, Category, DataLabel]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={chartData} xName='x' yName='y' name='Defect' type='Pareto'
marker={ marker } paretoOptions={paretoOptions} emptyPointSettings={emptyPoint}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
export let chartData = [
{ 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 }
];
export let chartData: Object[] = [
{ 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 }
];
Fill
Use the fill
property to customize the fill color of empty points in the series.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, ParetoSeries, ColumnSeries, LineSeries, Legend, Category, Tooltip, DataLabel } from '@syncfusion/ej2-react-charts';
import { chartData } from './datasource';
function App() {
const primaryxAxis = { title: 'Defects', valueType: 'Category' };
const primaryyAxis = { title: 'Frequency', minimum: 0, maximum: 150, interval: 30 };
const tooltipsettings = { enable: true };
const marker = { visible: true, width: 10, height: 10 };
const paretoOptions = {
marker: { visible: true, width: 10, height: 10 }, showAxis: false
}
const emptyPoint = { mode: 'Average', fill: 'red' };
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} tooltip={tooltipsettings} title='Defect vs Frequency'>
<Inject services={[ColumnSeries, LineSeries, ParetoSeries, Legend, Tooltip, Category, DataLabel]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={chartData} xName='x' yName='y' name='Defect' type='Pareto' marker={marker} paretoOptions={paretoOptions} emptyPointSettings={emptyPoint}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>;
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
import * as React from "react";
import * as ReactDOM from "react-dom";
import {
AxisModel, ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, ChartTheme,LegendSettingsModel,TooltipSettingsModel,ParetoSeries,ColumnSeries,LineSeries,
Legend, Category, Tooltip, ILoadedEventArgs, DataLabel
} from '@syncfusion/ej2-react-charts';
import { chartData } from './datasource';
function App() {
const primaryxAxis: AxisModel= { title: 'Defects', valueType: 'Category' } ;
const primaryyAxis: AxisModel= { title: 'Frequency', minimum: 0, maximum: 150,interval: 30 } ;
const tooltipsettings: TooltipSettingsModel={ enable: true };
const marker={ visible: true, width: 10, height: 10};
const paretoOptions: object = {
marker: { visible: true, width: 10, height: 10 }, showAxis: false
};
const emptyPoint: object = { mode: 'Average', fill: 'red' };
return <ChartComponent id='charts'
primaryXAxis={ primaryxAxis }
primaryYAxis={ primaryyAxis }
tooltip={ tooltipsettings }
title='Defect vs Frequency'>
<Inject services={[ColumnSeries, LineSeries, ParetoSeries, Legend, Tooltip, Category, DataLabel]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={chartData} xName='x' yName='y' name='Defect' type='Pareto'
marker={ marker } paretoOptions={paretoOptions} emptyPointSettings={emptyPoint}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
export let chartData = [
{ 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 }
];
export let chartData: Object[] = [
{ 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 }
];
Border
Use the border
property to customize the width and color of the border for empty points.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, ParetoSeries, ColumnSeries, LineSeries, Legend, Category, Tooltip, DataLabel } from '@syncfusion/ej2-react-charts';
import { chartData } from './datasource';
function App() {
const primaryxAxis = { title: 'Defects', valueType: 'Category' };
const primaryyAxis = { title: 'Frequency', minimum: 0, maximum: 150, interval: 30 };
const tooltipsettings = { enable: true };
const marker = { visible: true, width: 10, height: 10 };
const paretoOptions = {
marker: { visible: true, width: 10, height: 10 }, showAxis: false
}
const emptyPoint = { mode: 'Average', fill: 'red', border: { width: 2, color: 'green' } };
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} tooltip={tooltipsettings} title='Defect vs Frequency'>
<Inject services={[ColumnSeries, LineSeries, ParetoSeries, Legend, Tooltip, Category, DataLabel]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={chartData} xName='x' yName='y' name='Defect' type='Pareto' marker={marker} paretoOptions={paretoOptions} emptyPointSettings={emptyPoint}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>;
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
import * as React from "react";
import * as ReactDOM from "react-dom";
import {
AxisModel, ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, ChartTheme,LegendSettingsModel,TooltipSettingsModel,ParetoSeries,ColumnSeries,LineSeries,
Legend, Category, Tooltip, ILoadedEventArgs, DataLabel
} from '@syncfusion/ej2-react-charts';
import { chartData } from './datasource';
function App() {
const primaryxAxis: AxisModel= { title: 'Defects', valueType: 'Category' } ;
const primaryyAxis: AxisModel= { title: 'Frequency', minimum: 0, maximum: 150,interval: 30 } ;
const tooltipsettings: TooltipSettingsModel={ enable: true };
const marker={ visible: true, width: 10, height: 10};
const paretoOptions: object = {
marker: { visible: true, width: 10, height: 10 }, showAxis: false
};
const emptyPoint: object = { mode: 'Average', fill: 'red', border: { width: 2, color: 'green' } };
return <ChartComponent id='charts'
primaryXAxis={ primaryxAxis }
primaryYAxis={ primaryyAxis }
tooltip={ tooltipsettings }
title='Defect vs Frequency'>
<Inject services={[ColumnSeries, LineSeries, ParetoSeries, Legend, Tooltip, Category, DataLabel]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={chartData} xName='x' yName='y' name='Defect' type='Pareto'
marker={ marker } paretoOptions={paretoOptions} emptyPointSettings={emptyPoint}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
export let chartData = [
{ 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 }
];
export let chartData: Object[] = [
{ 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 }
];
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.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, ParetoSeries, ColumnSeries, LineSeries, Legend, Category, Tooltip, DataLabel } from '@syncfusion/ej2-react-charts';
import { chartData } from './datasource';
function App() {
const primaryxAxis = { title: 'Defects', valueType: 'Category' };
const primaryyAxis = { title: 'Frequency', minimum: 0, maximum: 150, interval: 30 };
const tooltipsettings = { enable: true };
const marker = { visible: true, width: 10, height: 10 };
const paretoOptions = {
marker: { visible: true, width: 10, height: 10 }, showAxis: false
}
const seriesRender = (args) => {
args.fill = '#ff6347';
};
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} tooltip={tooltipsettings} title='Defect vs Frequency' seriesRender={seriesRender}>
<Inject services={[ColumnSeries, LineSeries, ParetoSeries, Legend, Tooltip, Category, DataLabel]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={chartData} xName='x' yName='y' name='Defect' type='Pareto' marker={marker} paretoOptions={paretoOptions}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>;
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
import * as React from "react";
import * as ReactDOM from "react-dom";
import {
AxisModel, ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, ChartTheme,LegendSettingsModel,TooltipSettingsModel,ParetoSeries,ColumnSeries,LineSeries,
Legend, Category, Tooltip, ILoadedEventArgs, DataLabel, ISeriesRenderEventArgs
} from '@syncfusion/ej2-react-charts';
import { EmitType } from '@syncfusion/ej2-base';
import { chartData } from './datasource';
function App() {
const primaryxAxis: AxisModel= { title: 'Defects', valueType: 'Category' } ;
const primaryyAxis: AxisModel= { title: 'Frequency', minimum: 0, maximum: 150,interval: 30 } ;
const tooltipsettings: TooltipSettingsModel={ enable: true };
const marker={ visible: true, width: 10, height: 10};
const paretoOptions: object = {
marker: { visible: true, width: 10, height: 10 }, showAxis: false
};
const seriesRender: EmitType<ISeriesRenderEventArgs> = (args: ISeriesRenderEventArgs): void => {
args.fill = '#ff6347';
};
return <ChartComponent id='charts'
primaryXAxis={ primaryxAxis }
primaryYAxis={ primaryyAxis }
tooltip={ tooltipsettings }
title='Defect vs Frequency' seriesRender={seriesRender}>
<Inject services={[ColumnSeries, LineSeries, ParetoSeries, Legend, Tooltip, Category, DataLabel]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={chartData} xName='x' yName='y' name='Defect' type='Pareto'
marker={ marker } paretoOptions={paretoOptions}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
export let chartData = [
{ x: 'Button Defect', y: 23 },
{ x: 'Pocket Defect', y: 16 },
{ x: 'Collar Defect', y: 4 },
{ x: 'Cuff Defect', y: 7 },
{ x: 'Sleeve Defect', y: 6 },
{ x: 'Other Defect', y: 2 },
{ x: 'Stitching Defect', y: 5 },
{ x: 'Zipper Defect', y: 3 },
{ x: 'Fabric Defect', y: 9 }
];
export let chartData: Object[] = [
{ x: 'Button Defect', y: 23 },
{ x: 'Pocket Defect', y: 16 },
{ x: 'Collar Defect', y: 4 },
{ x: 'Cuff Defect', y: 7 },
{ x: 'Sleeve Defect', y: 6 },
{ x: 'Other Defect', y: 2 },
{ x: 'Stitching Defect', y: 5 },
{ x: 'Zipper Defect', y: 3 },
{ x: 'Fabric Defect', y: 9 }
];
Point render
The pointRender
event allows you to customize each data point before it is rendered on the chart.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, ParetoSeries, ColumnSeries, LineSeries, Legend, Category, Tooltip, DataLabel } from '@syncfusion/ej2-react-charts';
import { chartData } from './datasource';
function App() {
const primaryxAxis = { title: 'Defects', valueType: 'Category' };
const primaryyAxis = { title: 'Frequency', minimum: 0, maximum: 150, interval: 30 };
const tooltipsettings = { enable: true };
const marker = { visible: true, width: 10, height: 10 };
const paretoOptions = {
marker: { visible: true, width: 10, height: 10 }, showAxis: false
}
const pointRender = (args) => {
if (args.point.index % 2 !== 0) {
args.fill = '#ff6347';
}
else {
args.fill = '#009cb8';
}
};
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} tooltip={tooltipsettings} title='Defect vs Frequency' pointRender={pointRender}>
<Inject services={[ColumnSeries, LineSeries, ParetoSeries, Legend, Tooltip, Category, DataLabel]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={chartData} xName='x' yName='y' name='Defect' type='Pareto' marker={marker} paretoOptions={paretoOptions}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>;
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
import * as React from "react";
import * as ReactDOM from "react-dom";
import {
AxisModel, ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, ChartTheme,LegendSettingsModel,TooltipSettingsModel,ParetoSeries,ColumnSeries,LineSeries,
Legend, Category, Tooltip, ILoadedEventArgs, DataLabel, IPointRenderEventArgs
} from '@syncfusion/ej2-react-charts';
import { EmitType } from '@syncfusion/ej2-base';
import { chartData } from './datasource';
function App() {
const primaryxAxis: AxisModel= { title: 'Defects', valueType: 'Category' } ;
const primaryyAxis: AxisModel= { title: 'Frequency', minimum: 0, maximum: 150,interval: 30 } ;
const tooltipsettings: TooltipSettingsModel={ enable: true };
const marker={ visible: true, width: 10, height: 10};
const paretoOptions: object = {
marker: { visible: true, width: 10, height: 10 }, showAxis: false
};
const pointRender: EmitType<IPointRenderEventArgs> = (args: IPointRenderEventArgs): void => {
if (args.point.index % 2 !== 0) {
args.fill = '#ff6347';
}
else {
args.fill = '#009cb8';
}
};
return <ChartComponent id='charts'
primaryXAxis={ primaryxAxis }
primaryYAxis={ primaryyAxis }
tooltip={ tooltipsettings }
title='Defect vs Frequency' pointRender={pointRender}>
<Inject services={[ColumnSeries, LineSeries, ParetoSeries, Legend, Tooltip, Category, DataLabel]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={chartData} xName='x' yName='y' name='Defect' type='Pareto'
marker={ marker } paretoOptions={paretoOptions}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
export let chartData = [
{ x: 'Button Defect', y: 23 },
{ x: 'Pocket Defect', y: 16 },
{ x: 'Collar Defect', y: 4 },
{ x: 'Cuff Defect', y: 7 },
{ x: 'Sleeve Defect', y: 6 },
{ x: 'Other Defect', y: 2 },
{ x: 'Stitching Defect', y: 5 },
{ x: 'Zipper Defect', y: 3 },
{ x: 'Fabric Defect', y: 9 }
];
export let chartData: Object[] = [
{ x: 'Button Defect', y: 23 },
{ x: 'Pocket Defect', y: 16 },
{ x: 'Collar Defect', y: 4 },
{ x: 'Cuff Defect', y: 7 },
{ x: 'Sleeve Defect', y: 6 },
{ x: 'Other Defect', y: 2 },
{ x: 'Stitching Defect', y: 5 },
{ x: 'Zipper Defect', y: 3 },
{ x: 'Fabric Defect', y: 9 }
];