Waterfall in React Chart component
14 Oct 202424 minutes to read
Waterfall chart
To render a waterfall
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
asWaterfall
in your chart configuration. This indicates that the data should be represented as a waterfall chart, which helps illustrate the cumulative effect of sequentially introduced positive and negative values. -
Inject the WaterfallSeries module: Inject
WaterfallSeries
module into theservices
. This step is essential, as it ensures that the necessary functionalities for rendering waterfall series are available in your chart. -
Configure intermediate and cumulative sums: Use the
intermediateSumIndexes
property property to represent intermediate sum values, and thesumIndexes
property to represent cumulative sum values.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Legend, Category, Tooltip, DataLabel, Zoom, Crosshair, WaterfallSeries } from '@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const primaryxAxis = { valueType: 'Category', majorGridLines: { width: 0 }, plotOffset: 20 };
const primaryyAxis = { minimum: 0, maximum: 5000, interval: 1000, majorGridLines: { width: 0 }, title: 'Expenditure' };
const marker = { dataLabel: { visible: true, font: { color: '#ffffff' } } };
const connector = { color: '#5F6A6A', width: 2 };
const tooltip = { enable: true, shared: false };
const legendSettings = { visible: false };
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} tooltip={tooltip} legendSettings={legendSettings} title='Company Revenue and Profit'>
<Inject services={[WaterfallSeries, Category, Tooltip, Zoom, Crosshair, Legend, DataLabel]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' yName='y' name='USA' type='Waterfall' intermediateSumIndexes={[4]} sumIndexes={[7]} marker={marker} connector={connector} columnWidth={0.9} negativeFillColor='#e56590'>
</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,TooltipSettingsModel,LegendSettingsModel,
Legend, Category, Tooltip, DataLabel, Zoom, Crosshair, WaterfallSeries, Selection}
from'@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const primaryxAxis: AxisModel = { valueType: 'Category', majorGridLines: { width: 0 }, plotOffset: 20 };
const primaryyAxis: AxisModel = { minimum: 0, maximum: 5000, interval: 1000, majorGridLines: { width: 0 }, title: 'Expenditure' };
const marker = { dataLabel: { visible: true, font: { color: '#ffffff' } } };
const connector = { color: '#5F6A6A', width: 2 };
const tooltip: TooltipSettingsModel = { enable: true, shared: false };
const legendSettings: LegendSettingsModel = { visible: false };
return <ChartComponent id='charts'
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
tooltip={tooltip}
legendSettings={legendSettings}
title='Company Revenue and Profit'>
<Inject services={[WaterfallSeries, Category, Tooltip, Zoom, Crosshair, Legend, DataLabel]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' yName='y' name='USA' type='Waterfall' intermediateSumIndexes={[4]}
sumIndexes={[7]} marker={marker} connector={connector} columnWidth={0.9}
negativeFillColor='#e56590'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
export let data = [
{ x: 'Income', y: 4711 },
{ x: 'Sales', y: -1015 },
{ x: 'Development', y: -688 },
{ x: 'Revenue', y: 1030 },
{ x: 'Balance' },
{ x: 'Expense', y: -361 },
{ x: 'Tax', y: -695 },
{ x: 'Net Profit' }
];
export let data: Object[] = [
{ x: 'Income', y: 4711 },
{ x: 'Sales', y: -1015 },
{ x: 'Development', y: -688 },
{ x: 'Revenue', y: 1030 },
{ x: 'Balance' },
{ x: 'Expense', y: -361 },
{ x: 'Tax', y: -695 },
{ x: 'Net Profit' }
];
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, Legend, Category, Tooltip, DataLabel, Zoom, Crosshair, WaterfallSeries } from '@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const primaryxAxis = { valueType: 'Category', majorGridLines: { width: 0 }, plotOffset: 20 };
const primaryyAxis = { minimum: 0, maximum: 5000, interval: 1000, majorGridLines: { width: 0 }, title: 'Expenditure' };
const marker = { dataLabel: { visible: true, font: { color: '#ffffff' } } };
const connector = { color: '#5F6A6A', width: 2 };
const tooltip = { enable: true, shared: false };
const legendSettings = { visible: false };
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} tooltip={tooltip} legendSettings={legendSettings} title='Company Revenue and Profit'>
<Inject services={[WaterfallSeries, Category, Tooltip, Zoom, Crosshair, Legend, DataLabel]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' yName='y' name='USA' type='Waterfall' intermediateSumIndexes={[4]} sumIndexes={[7]} marker={marker} connector={connector} columnWidth={0.9} negativeFillColor='#e56590'>
</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,TooltipSettingsModel,LegendSettingsModel,
Legend, Category, Tooltip, DataLabel, Zoom, Crosshair, WaterfallSeries, Selection}
from'@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const primaryxAxis: AxisModel = { valueType: 'Category', majorGridLines: { width: 0 }, plotOffset: 20 };
const primaryyAxis: AxisModel = { minimum: 0, maximum: 5000, interval: 1000, majorGridLines: { width: 0 }, title: 'Expenditure' };
const marker = { dataLabel: { visible: true, font: { color: '#ffffff' } } };
const connector = { color: '#5F6A6A', width: 2 };
const tooltip: TooltipSettingsModel = { enable: true, shared: false };
const legendSettings: LegendSettingsModel = { visible: false };
return <ChartComponent id='charts'
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
tooltip={tooltip}
legendSettings={legendSettings}
title='Company Revenue and Profit'>
<Inject services={[WaterfallSeries, Category, Tooltip, Zoom, Crosshair, Legend, DataLabel]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' yName='y' name='USA' type='Waterfall' intermediateSumIndexes={[4]}
sumIndexes={[7]} marker={marker} connector={connector} columnWidth={0.9}
negativeFillColor='#e56590'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
export let data = [
{ x: 'Income', y: 4711 },
{ x: 'Sales', y: -1015 },
{ x: 'Development', y: -688 },
{ x: 'Revenue', y: 1030 },
{ x: 'Balance' },
{ x: 'Expense', y: -361 },
{ x: 'Tax', y: -695 },
{ x: 'Net Profit' }
];
export let data: Object[] = [
{ x: 'Income', y: 4711 },
{ x: 'Sales', y: -1015 },
{ x: 'Development', y: -688 },
{ x: 'Revenue', y: 1030 },
{ x: 'Balance' },
{ x: 'Expense', y: -361 },
{ x: 'Tax', y: -695 },
{ x: 'Net Profit' }
];
Series customization
In waterfall charts, you can customize the appearance of different types of data changes using specific properties. The negativeFillColor
property is used to specify the color for negative changes, which helps visually distinguish decreases in the data. Similarly, the summaryFillColor
property is used to define the color for summary changes. By default, the negativeFillColor
is set to green, indicating decreases, while the summaryFillColor
is set to black, marking summary or total values.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Legend, Category, Tooltip, DataLabel, Zoom, Crosshair, WaterfallSeries } from '@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const primaryxAxis = { crossesAt: 15 };
const primaryyAxis = { crossesAt: 5 };
const marker = { dataLabel: { visible: true, font: { color: '#ffffff' } } };
const connector = { color: '#5F6A6A', width: 2 };
const tooltip = { enable: true, shared: false };
const legendSettings = { visible: false };
return <ChartComponent id='charts' primaryXAxis={{ valueType: 'Category', majorGridLines: { width: 0 }, plotOffset: 20 }} primaryYAxis={{ minimum: 0, maximum: 5000, interval: 1000, majorGridLines: { width: 0 }, title: 'Expenditure' }} tooltip={tooltip} legendSettings={legendSettings} title='Company Revenue and Profit'>
<Inject services={[WaterfallSeries, Category, Tooltip, Zoom, Crosshair, Legend, DataLabel]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' yName='y' name='USA' type='Waterfall' intermediateSumIndexes={[4]} sumIndexes={[7]} marker={marker} connector={connector} columnWidth={0.9} summaryFillColor='#e56590' negativeFillColor='#f8b883'>
</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,TooltipSettingsModel,LegendSettingsModel,
Legend, Category, Tooltip, DataLabel, Zoom, Crosshair, WaterfallSeries, Selection}
from'@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const primaryxAxis: AxisModel = { crossesAt: 15 };
const primaryyAxis: AxisModel = { crossesAt: 5 };
const marker = { dataLabel: { visible: true, font: { color: '#ffffff' } } };
const connector = { color: '#5F6A6A', width: 2 };
const tooltip: TooltipSettingsModel = { enable: true, shared: false };
const legendSettings: LegendSettingsModel = { visible: false };
return <ChartComponent id='charts'
primaryXAxis={{ valueType: 'Category', majorGridLines: { width: 0 }, plotOffset: 20 }}
primaryYAxis={{ minimum: 0, maximum: 5000, interval: 1000, majorGridLines: { width: 0 }, title: 'Expenditure' }}
tooltip={tooltip}
legendSettings={legendSettings}
title='Company Revenue and Profit'>
<Inject services={[WaterfallSeries, Category, Tooltip, Zoom, Crosshair, Legend, DataLabel]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' yName='y' name='USA' type='Waterfall' intermediateSumIndexes={[4]}
sumIndexes={[7]} marker={marker} connector={connector} columnWidth={0.9}
summaryFillColor='#e56590' negativeFillColor='#f8b883'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
export let data = [
{ x: 'Income', y: 4711 },
{ x: 'Sales', y: -1015 },
{ x: 'Development', y: -688 },
{ x: 'Revenue', y: 1030 },
{ x: 'Balance' },
{ x: 'Expense', y: -361 },
{ x: 'Tax', y: -695 },
{ x: 'Net Profit' }
];
export let data: Object[] = [
{ x: 'Income', y: 4711 },
{ x: 'Sales', y: -1015 },
{ x: 'Development', y: -688 },
{ x: 'Revenue', y: 1030 },
{ x: 'Balance' },
{ x: 'Expense', y: -361 },
{ x: 'Tax', y: -695 },
{ x: 'Net Profit' }
];
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, Legend, Category, Tooltip, DataLabel, Zoom, Crosshair, WaterfallSeries } from '@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const primaryxAxis = { crossesAt: 15 };
const primaryyAxis = { crossesAt: 5 };
const marker = { dataLabel: { visible: true, font: { color: '#ffffff' } } };
const connector = { color: '#5F6A6A', width: 2 };
const tooltip = { enable: true, shared: false };
const legendSettings = { visible: false };
const emptyPoint = { mode: 'Average' };
return <ChartComponent id='charts' primaryXAxis={{ valueType: 'Category', majorGridLines: { width: 0 }, plotOffset: 20 }} primaryYAxis={{ minimum: 0, maximum: 5000, interval: 1000, majorGridLines: { width: 0 }, title: 'Expenditure' }} tooltip={tooltip} legendSettings={legendSettings} title='Company Revenue and Profit'>
<Inject services={[WaterfallSeries, Category, Tooltip, Zoom, Crosshair, Legend, DataLabel]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' yName='y' name='USA' type='Waterfall' emptyPointSettings={emptyPoint} intermediateSumIndexes={[4]} sumIndexes={[7]} marker={marker} connector={connector} columnWidth={0.9}>
</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,TooltipSettingsModel,LegendSettingsModel,
Legend, Category, Tooltip, DataLabel, Zoom, Crosshair, WaterfallSeries, Selection}
from'@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const primaryxAxis: AxisModel = { crossesAt: 15 };
const primaryyAxis: AxisModel = { crossesAt: 5 };
const marker = { dataLabel: { visible: true, font: { color: '#ffffff' } } };
const connector = { color: '#5F6A6A', width: 2 };
const tooltip: TooltipSettingsModel = { enable: true, shared: false };
const legendSettings: LegendSettingsModel = { visible: false };
const emptyPoint: object = { mode: 'Average' };
return <ChartComponent id='charts'
primaryXAxis={{ valueType: 'Category', majorGridLines: { width: 0 }, plotOffset: 20 }}
primaryYAxis={{ minimum: 0, maximum: 5000, interval: 1000, majorGridLines: { width: 0 }, title: 'Expenditure' }}
tooltip={tooltip}
legendSettings={legendSettings}
title='Company Revenue and Profit'>
<Inject services={[WaterfallSeries, Category, Tooltip, Zoom, Crosshair, Legend, DataLabel]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' yName='y' emptyPointSettings={emptyPoint} name='USA' type='Waterfall' intermediateSumIndexes={[4]}
sumIndexes={[7]} marker={marker} connector={connector} columnWidth={0.9}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
export let data = [
{ x: 'Income', y: 4711 },
{ x: 'Sales', y: -1015 },
{ x: 'Development', y: -688 },
{ x: 'Revenue', y: null },
{ x: 'Balance' },
{ x: 'Administrative', y: -780 },
{ x: 'Expense', y: -361 },
{ x: 'Tax', y: -695 },
{ x: 'Net Profit' }
];
export let data: Object[] = [
{ x: 'Income', y: 4711 },
{ x: 'Sales', y: -1015 },
{ x: 'Development', y: -688 },
{ x: 'Revenue', y: null },
{ x: 'Balance' },
{ x: 'Administrative', y: -780 },
{ x: 'Expense', y: -361 },
{ x: 'Tax', y: -695 },
{ x: 'Net Profit' }
];
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, Legend, Category, Tooltip, DataLabel, Zoom, Crosshair, WaterfallSeries } from '@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const primaryxAxis = { crossesAt: 15 };
const primaryyAxis = { crossesAt: 5 };
const marker = { dataLabel: { visible: true, font: { color: '#ffffff' } } };
const connector = { color: '#5F6A6A', width: 2 };
const tooltip = { enable: true, shared: false };
const legendSettings = { visible: false };
const emptyPoint = { mode: 'Average', fill: 'red' };
return <ChartComponent id='charts' primaryXAxis={{ valueType: 'Category', majorGridLines: { width: 0 }, plotOffset: 20 }} primaryYAxis={{ minimum: 0, maximum: 5000, interval: 1000, majorGridLines: { width: 0 }, title: 'Expenditure' }} tooltip={tooltip} legendSettings={legendSettings} title='Company Revenue and Profit'>
<Inject services={[WaterfallSeries, Category, Tooltip, Zoom, Crosshair, Legend, DataLabel]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' yName='y' name='USA' type='Waterfall' emptyPointSettings={emptyPoint} intermediateSumIndexes={[4]} sumIndexes={[7]} marker={marker} connector={connector} columnWidth={0.9}>
</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,TooltipSettingsModel,LegendSettingsModel,
Legend, Category, Tooltip, DataLabel, Zoom, Crosshair, WaterfallSeries, Selection}
from'@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const primaryxAxis: AxisModel = { crossesAt: 15 };
const primaryyAxis: AxisModel = { crossesAt: 5 };
const marker = { dataLabel: { visible: true, font: { color: '#ffffff' } } };
const connector = { color: '#5F6A6A', width: 2 };
const tooltip: TooltipSettingsModel = { enable: true, shared: false };
const legendSettings: LegendSettingsModel = { visible: false };
const emptyPoint: object = { mode: 'Average', fill: 'red' };
return <ChartComponent id='charts'
primaryXAxis={{ valueType: 'Category', majorGridLines: { width: 0 }, plotOffset: 20 }}
primaryYAxis={{ minimum: 0, maximum: 5000, interval: 1000, majorGridLines: { width: 0 }, title: 'Expenditure' }}
tooltip={tooltip}
legendSettings={legendSettings}
title='Company Revenue and Profit'>
<Inject services={[WaterfallSeries, Category, Tooltip, Zoom, Crosshair, Legend, DataLabel]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' yName='y' emptyPointSettings={emptyPoint} name='USA' type='Waterfall' intermediateSumIndexes={[4]}
sumIndexes={[7]} marker={marker} connector={connector} columnWidth={0.9}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
export let data = [
{ x: 'Income', y: 4711 },
{ x: 'Sales', y: -1015 },
{ x: 'Development', y: -688 },
{ x: 'Revenue', y: null },
{ x: 'Balance' },
{ x: 'Administrative', y: -780 },
{ x: 'Expense', y: -361 },
{ x: 'Tax', y: -695 },
{ x: 'Net Profit' }
];
export let data: Object[] = [
{ x: 'Income', y: 4711 },
{ x: 'Sales', y: -1015 },
{ x: 'Development', y: -688 },
{ x: 'Revenue', y: null },
{ x: 'Balance' },
{ x: 'Administrative', y: -780 },
{ x: 'Expense', y: -361 },
{ x: 'Tax', y: -695 },
{ x: 'Net Profit' }
];
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, Legend, Category, Tooltip, DataLabel, Zoom, Crosshair, WaterfallSeries } from '@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const primaryxAxis = { crossesAt: 15 };
const primaryyAxis = { crossesAt: 5 };
const marker = { dataLabel: { visible: true, font: { color: '#ffffff' } } };
const connector = { color: '#5F6A6A', width: 2 };
const tooltip = { enable: true, shared: false };
const legendSettings = { visible: false };
const emptyPoint = { mode: 'Average', fill: 'red', border: {width: 1.5, color: 'green'} };
return <ChartComponent id='charts' primaryXAxis={{ valueType: 'Category', majorGridLines: { width: 0 }, plotOffset: 20 }} primaryYAxis={{ minimum: 0, maximum: 5000, interval: 1000, majorGridLines: { width: 0 }, title: 'Expenditure' }} tooltip={tooltip} legendSettings={legendSettings} title='Company Revenue and Profit'>
<Inject services={[WaterfallSeries, Category, Tooltip, Zoom, Crosshair, Legend, DataLabel]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' yName='y' name='USA' type='Waterfall' emptyPointSettings={emptyPoint} intermediateSumIndexes={[4]} sumIndexes={[7]} marker={marker} connector={connector} columnWidth={0.9}>
</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,TooltipSettingsModel,LegendSettingsModel,
Legend, Category, Tooltip, DataLabel, Zoom, Crosshair, WaterfallSeries, Selection}
from'@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const primaryxAxis: AxisModel = { crossesAt: 15 };
const primaryyAxis: AxisModel = { crossesAt: 5 };
const marker = { dataLabel: { visible: true, font: { color: '#ffffff' } } };
const connector = { color: '#5F6A6A', width: 2 };
const tooltip: TooltipSettingsModel = { enable: true, shared: false };
const legendSettings: LegendSettingsModel = { visible: false };
const emptyPoint: object = { mode: 'Average', fill: 'red', border: {width: 1.5, color: 'green'} };
return <ChartComponent id='charts'
primaryXAxis={{ valueType: 'Category', majorGridLines: { width: 0 }, plotOffset: 20 }}
primaryYAxis={{ minimum: 0, maximum: 5000, interval: 1000, majorGridLines: { width: 0 }, title: 'Expenditure' }}
tooltip={tooltip}
legendSettings={legendSettings}
title='Company Revenue and Profit'>
<Inject services={[WaterfallSeries, Category, Tooltip, Zoom, Crosshair, Legend, DataLabel]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' yName='y' emptyPointSettings={emptyPoint} name='USA' type='Waterfall' intermediateSumIndexes={[4]}
sumIndexes={[7]} marker={marker} connector={connector} columnWidth={0.9}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
export let data = [
{ x: 'Income', y: 4711 },
{ x: 'Sales', y: -1015 },
{ x: 'Development', y: -688 },
{ x: 'Revenue', y: null },
{ x: 'Balance' },
{ x: 'Administrative', y: -780 },
{ x: 'Expense', y: -361 },
{ x: 'Tax', y: -695 },
{ x: 'Net Profit' }
];
export let data: Object[] = [
{ x: 'Income', y: 4711 },
{ x: 'Sales', y: -1015 },
{ x: 'Development', y: -688 },
{ x: 'Revenue', y: null },
{ x: 'Balance' },
{ x: 'Administrative', y: -780 },
{ x: 'Expense', y: -361 },
{ x: 'Tax', y: -695 },
{ x: 'Net Profit' }
];
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, Legend, Category, Tooltip, DataLabel, Zoom, Crosshair, WaterfallSeries } from '@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const primaryxAxis = { crossesAt: 15 };
const primaryyAxis = { crossesAt: 5 };
const marker = { dataLabel: { visible: true, font: { color: '#ffffff' } } };
const connector = { color: '#5F6A6A', width: 2 };
const tooltip = { enable: true, shared: false };
const legendSettings = { visible: false };
const seriesRender = (args) => {
args.fill = '#ff6347';
args.series.negativeFillColor = '#ff6347';
args.series.summaryFillColor = '#ff6347';
};
return <ChartComponent id='charts' seriesRender={seriesRender} primaryXAxis={{ valueType: 'Category', majorGridLines: { width: 0 }, plotOffset: 20 }} primaryYAxis={{ minimum: 0, maximum: 5000, interval: 1000, majorGridLines: { width: 0 }, title: 'Expenditure' }} tooltip={tooltip} legendSettings={legendSettings} title='Company Revenue and Profit'>
<Inject services={[WaterfallSeries, Category, Tooltip, Zoom, Crosshair, Legend, DataLabel]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' yName='y' name='USA' type='Waterfall' intermediateSumIndexes={[4]} sumIndexes={[7]} marker={marker} connector={connector} columnWidth={0.9}>
</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,TooltipSettingsModel,LegendSettingsModel,
Legend, Category, Tooltip, DataLabel, Zoom, Crosshair, WaterfallSeries, ISeriesRenderEventArgs}
from'@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const primaryxAxis: AxisModel = { crossesAt: 15 };
const primaryyAxis: AxisModel = { crossesAt: 5 };
const marker = { dataLabel: { visible: true, font: { color: '#ffffff' } } };
const connector = { color: '#5F6A6A', width: 2 };
const tooltip: TooltipSettingsModel = { enable: true, shared: false };
const legendSettings: LegendSettingsModel = { visible: false };
const seriesRender = (args: ISeriesRenderEventArgs) => {
args.fill = '#ff6347';
args.series.negativeFillColor = '#ff6347';
args.series.summaryFillColor = '#ff6347';
};
return <ChartComponent id='charts'
primaryXAxis={{ valueType: 'Category', majorGridLines: { width: 0 }, plotOffset: 20 }}
primaryYAxis={{ minimum: 0, maximum: 5000, interval: 1000, majorGridLines: { width: 0 }, title: 'Expenditure' }}
tooltip={tooltip}
legendSettings={legendSettings}
title='Company Revenue and Profit'
seriesRender={seriesRender}>
<Inject services={[WaterfallSeries, Category, Tooltip, Zoom, Crosshair, Legend, DataLabel]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' yName='y' name='USA' type='Waterfall' intermediateSumIndexes={[4]}
sumIndexes={[7]} marker={marker} connector={connector} columnWidth={0.9}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
export let data = [
{ x: 'Income', y: 4711 },
{ x: 'Sales', y: -1015 },
{ x: 'Development', y: -688 },
{ x: 'Revenue', y: 1030 },
{ x: 'Balance' },
{ x: 'Expense', y: -361 },
{ x: 'Tax', y: -695 },
{ x: 'Net Profit' }
];
export let data: Object[] = [
{ x: 'Income', y: 4711 },
{ x: 'Sales', y: -1015 },
{ x: 'Development', y: -688 },
{ x: 'Revenue', y: 1030 },
{ x: 'Balance' },
{ x: 'Expense', y: -361 },
{ x: 'Tax', y: -695 },
{ x: 'Net Profit' }
];
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, Legend, Category, Tooltip, DataLabel, Zoom, Crosshair, WaterfallSeries } from '@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const primaryxAxis = { crossesAt: 15 };
const primaryyAxis = { crossesAt: 5 };
const marker = { dataLabel: { visible: true, font: { color: '#ffffff' } } };
const connector = { color: '#5F6A6A', width: 2 };
const tooltip = { enable: true, shared: false };
const legendSettings = { visible: false };
const pointRender = (args) => {
if (args.point.index % 2 !== 0) {
args.fill = '#ff6347';
}
else {
args.fill = '#009cb8';
}
};
return <ChartComponent id='charts' pointRender={pointRender} primaryXAxis={{ valueType: 'Category', majorGridLines: { width: 0 }, plotOffset: 20 }} primaryYAxis={{ minimum: 0, maximum: 5000, interval: 1000, majorGridLines: { width: 0 }, title: 'Expenditure' }} tooltip={tooltip} legendSettings={legendSettings} title='Company Revenue and Profit'>
<Inject services={[WaterfallSeries, Category, Tooltip, Zoom, Crosshair, Legend, DataLabel]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' yName='y' name='USA' type='Waterfall' intermediateSumIndexes={[4]} sumIndexes={[7]} marker={marker} connector={connector} columnWidth={0.9}>
</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,TooltipSettingsModel,LegendSettingsModel,
Legend, Category, Tooltip, DataLabel, Zoom, Crosshair, WaterfallSeries, IPointRenderEventArgs}
from'@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const primaryxAxis: AxisModel = { crossesAt: 15 };
const primaryyAxis: AxisModel = { crossesAt: 5 };
const marker = { dataLabel: { visible: true, font: { color: '#ffffff' } } };
const connector = { color: '#5F6A6A', width: 2 };
const tooltip: TooltipSettingsModel = { enable: true, shared: false };
const legendSettings: LegendSettingsModel = { visible: false };
const pointRender = (args: IPointRenderEventArgs) => {
if (args.point.index % 2 !== 0) {
args.fill = '#ff6347';
}
else {
args.fill = '#009cb8';
}
};
return <ChartComponent id='charts'
primaryXAxis={{ valueType: 'Category', majorGridLines: { width: 0 }, plotOffset: 20 }}
primaryYAxis={{ minimum: 0, maximum: 5000, interval: 1000, majorGridLines: { width: 0 }, title: 'Expenditure' }}
tooltip={tooltip}
legendSettings={legendSettings}
title='Company Revenue and Profit'
pointRender={pointRender}>
<Inject services={[WaterfallSeries, Category, Tooltip, Zoom, Crosshair, Legend, DataLabel]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' yName='y' name='USA' type='Waterfall' intermediateSumIndexes={[4]}
sumIndexes={[7]} marker={marker} connector={connector} columnWidth={0.9}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
export let data = [
{ x: 'Income', y: 4711 },
{ x: 'Sales', y: -1015 },
{ x: 'Development', y: -688 },
{ x: 'Revenue', y: 1030 },
{ x: 'Balance' },
{ x: 'Expense', y: -361 },
{ x: 'Tax', y: -695 },
{ x: 'Net Profit' }
];
export let data: Object[] = [
{ x: 'Income', y: 4711 },
{ x: 'Sales', y: -1015 },
{ x: 'Development', y: -688 },
{ x: 'Revenue', y: 1030 },
{ x: 'Balance' },
{ x: 'Expense', y: -361 },
{ x: 'Tax', y: -695 },
{ x: 'Net Profit' }
];