Range Area in React Chart component
14 Dec 202424 minutes to read
Range Area
To render a range area 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
asRangeArea
in your chart configuration. This indicates that the data should be represented as a range area chart, which is ideal for visualizing a range of values for each data point. This type of chart is particularly useful for displaying data that has a range between a minimum and maximum value, such as temperature ranges, stock price ranges, or any other type of data that varies within a specific interval. -
Inject the RangeAreaSeries module: Inject
RangeAreaSeries
module into theservices
. This step is essential, as it ensures that the necessary functionalities for rendering range area series are available in your chart. -
Provide high and low values: The
RangeArea
series requires two y-values for each data point, you need to specify both the high and low values. The high value represents the maximum range, while the low value represents the minimum range for each data point. These values define the upper and lower boundaries of the area for each point on the chart.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Legend, Category, Tooltip, DataLabel, RangeAreaSeries } from '@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const marker = { visible: true, width: 10, height: 10, border: { width: 2, color: '#F8AB1D' } };
return <ChartComponent id='charts'>
<Inject services={[RangeAreaSeries, Legend, Tooltip, DataLabel, Category]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' high='high' low='low' width={3} name='India' type='RangeArea' 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 { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Legend, Category, Tooltip, DataLabel, Zoom, Crosshair, RangeAreaSeries, Selection}
from'@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const marker = { visible: true, width: 10, height: 10, border: { width: 2, color: '#F8AB1D' } };
return <ChartComponent id='charts'>
<Inject services={[RangeAreaSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' high='high' low='low' width={3}
name='India' type='RangeArea'
marker={marker}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
export let data = [
{ x: 2005, y: 28, high: 18, low: 44 },
{ x: 2006, y: 25, high: 20, low: 40 },
{ x: 2007, y: 26, high: 22, low: 36 },
{ x: 2008, y: 27, high: 24, low: 32 },
{ x: 2009, y: 32, high: 26, low: 28 },
{ x: 2010, y: 35, high: 28, low: 24 },
{ x: 2011, y: 30, high: 30, low: 20 }
];
export let data: Object[] = [
{ x: 2005, y: 28, high: 18, low: 44 },
{ x: 2006, y: 25, high: 20, low: 40 },
{ x: 2007, y: 26, high: 22, low: 36 },
{ x: 2008, y: 27, high: 24, low: 32 },
{ x: 2009, y: 32, high: 26, low: 28 },
{ x: 2010, y: 35, high: 28, low: 24 },
{ x: 2011, y: 30, high: 30, low: 20 }
];
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
, high
, and low
properties.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Legend, Category, Tooltip, DataLabel, RangeAreaSeries } from '@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const marker = { visible: true, width: 10, height: 10, border: { width: 2, color: '#F8AB1D' } };
return <ChartComponent id='charts'>
<Inject services={[RangeAreaSeries, Legend, Tooltip, DataLabel, Category]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' high='high' low='low' width={3} name='India' type='RangeArea' 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 { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Legend, Category, Tooltip, DataLabel, Zoom, Crosshair, RangeAreaSeries, Selection}
from'@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const marker = { visible: true, width: 10, height: 10, border: { width: 2, color: '#F8AB1D' } };
return <ChartComponent id='charts'>
<Inject services={[RangeAreaSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' high='high' low='low' width={3}
name='India' type='RangeArea'
marker={marker}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
export let data = [
{ x: 2005, y: 28, high: 18, low: 44 },
{ x: 2006, y: 25, high: 20, low: 40 },
{ x: 2007, y: 26, high: 22, low: 36 },
{ x: 2008, y: 27, high: 24, low: 32 },
{ x: 2009, y: 32, high: 26, low: 28 },
{ x: 2010, y: 35, high: 28, low: 24 },
{ x: 2011, y: 30, high: 30, low: 20 }
];
export let data: Object[] = [
{ x: 2005, y: 28, high: 18, low: 44 },
{ x: 2006, y: 25, high: 20, low: 40 },
{ x: 2007, y: 26, high: 22, low: 36 },
{ x: 2008, y: 27, high: 24, low: 32 },
{ x: 2009, y: 32, high: 26, low: 28 },
{ x: 2010, y: 35, high: 28, low: 24 },
{ x: 2011, y: 30, high: 30, low: 20 }
];
Series customization
The following properties can be used to customize the range area
series.
Fill
The fill property determines the color applied to the series.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Legend, Category, Tooltip, DataLabel, RangeAreaSeries } from '@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
return <ChartComponent id='charts'>
<Inject services={[RangeAreaSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' high='low' low='high' fill='yellow'
type='RangeArea'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Legend, Category, Tooltip, DataLabel, Zoom, Crosshair, RangeAreaSeries, Selection}
from'@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
return <ChartComponent id='charts'>
<Inject services={[RangeAreaSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' high='low' low='high' fill='yellow'
type='RangeArea'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
export let data = [
{ x: 2005, y: 28, high: 18, low: 44 },
{ x: 2006, y: 25, high: 20, low: 40 },
{ x: 2007, y: 26, high: 22, low: 36 },
{ x: 2008, y: 27, high: 24, low: 32 },
{ x: 2009, y: 32, high: 26, low: 28 },
{ x: 2010, y: 35, high: 28, low: 24 },
{ x: 2011, y: 30, high: 30, low: 20 }
];
export let data: Object[] = [
{ x: 2005, y: 28, high: 18, low: 44 },
{ x: 2006, y: 25, high: 20, low: 40 },
{ x: 2007, y: 26, high: 22, low: 36 },
{ x: 2008, y: 27, high: 24, low: 32 },
{ x: 2009, y: 32, high: 26, low: 28 },
{ x: 2010, y: 35, high: 28, low: 24 },
{ x: 2011, y: 30, high: 30, low: 20 }
];
The fill property can be used to apply a gradient color to the range area series. By configuring this property with gradient values, you can create a visually appealing effect in which the color transitions smoothly from one shade to another.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Legend, Category, Tooltip, DataLabel, RangeAreaSeries } from '@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
return <ChartComponent id='charts'>
<Inject services={[RangeAreaSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' high='low' low='high' fill='url(#gradient)'
type='RangeArea'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Legend, Category, Tooltip, DataLabel, Zoom, Crosshair, RangeAreaSeries, Selection}
from'@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
return <ChartComponent id='charts'>
<Inject services={[RangeAreaSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' high='low' low='high' fill='url(#gradient)'
type='RangeArea'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
export let data = [
{ x: 2005, y: 28, high: 18, low: 44 },
{ x: 2006, y: 25, high: 20, low: 40 },
{ x: 2007, y: 26, high: 22, low: 36 },
{ x: 2008, y: 27, high: 24, low: 32 },
{ x: 2009, y: 32, high: 26, low: 28 },
{ x: 2010, y: 35, high: 28, low: 24 },
{ x: 2011, y: 30, high: 30, low: 20 }
];
export let data: Object[] = [
{ x: 2005, y: 28, high: 18, low: 44 },
{ x: 2006, y: 25, high: 20, low: 40 },
{ x: 2007, y: 26, high: 22, low: 36 },
{ x: 2008, y: 27, high: 24, low: 32 },
{ x: 2009, y: 32, high: 26, low: 28 },
{ x: 2010, y: 35, high: 28, low: 24 },
{ x: 2011, y: 30, high: 30, low: 20 }
];
Opacity
The opacity property specifies the transparency level of the fill. Adjusting this property allows you to control how opaque or transparent the fill color of the series appears.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Legend, Category, Tooltip, DataLabel, RangeAreaSeries } from '@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
return <ChartComponent id='charts'>
<Inject services={[RangeAreaSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' high='low' low='high' opacity={0.5}
type='RangeArea'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Legend, Category, Tooltip, DataLabel, Zoom, Crosshair, RangeAreaSeries, Selection}
from'@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
return <ChartComponent id='charts'>
<Inject services={[RangeAreaSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' high='low' low='high' opacity={0.5}
type='RangeArea'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
export let data = [
{ x: 2005, y: 28, high: 18, low: 44 },
{ x: 2006, y: 25, high: 20, low: 40 },
{ x: 2007, y: 26, high: 22, low: 36 },
{ x: 2008, y: 27, high: 24, low: 32 },
{ x: 2009, y: 32, high: 26, low: 28 },
{ x: 2010, y: 35, high: 28, low: 24 },
{ x: 2011, y: 30, high: 30, low: 20 }
];
export let data: Object[] = [
{ x: 2005, y: 28, high: 18, low: 44 },
{ x: 2006, y: 25, high: 20, low: 40 },
{ x: 2007, y: 26, high: 22, low: 36 },
{ x: 2008, y: 27, high: 24, low: 32 },
{ x: 2009, y: 32, high: 26, low: 28 },
{ x: 2010, y: 35, high: 28, low: 24 },
{ x: 2011, y: 30, high: 30, low: 20 }
];
Border
Use the border property to customize the width, color and dasharray of the series border.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Category, RangeAreaSeries } from '@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const border = { width: 2, color: 'red', dashArray: '5,5' };
const primaryXAxis = {
valueType: 'Category',
title: 'Month',
edgeLabelPlacement: 'Shift',
majorGridLines: { width: 0 }
};
const primaryYAxis = {
title: 'Temperature',
labelFormat: '{value}˚C',
lineStyle: { width: 0 },
minimum: 0,
maximum: 30,
majorTickLines: { width: 0 }
};
return <ChartComponent id='charts' primaryXAxis={primaryXAxis} primaryYAxis={primaryYAxis} title='Monthly Temperature Range'>
<Inject services={[RangeAreaSeries, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' high='low' low='high' type='RangeArea' border={border}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, AxisModel, BorderModel, Category, RangeAreaSeries } from '@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const border: BorderModel = { width: 2, color: 'red', dashArray: '5,5' };
const primaryXAxis: AxisModel = {
valueType: 'Category',
title: 'Month',
edgeLabelPlacement: 'Shift',
majorGridLines: { width: 0 }
};
const primaryYAxis: AxisModel = {
title: 'Temperature',
labelFormat: '{value}˚C',
lineStyle: { width: 0 },
minimum: 0,
maximum: 30,
majorTickLines: { width: 0 }
};
return <ChartComponent id='charts' primaryXAxis={primaryXAxis} primaryYAxis={primaryYAxis} title='Monthly Temperature Range'>
<Inject services={[RangeAreaSeries, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' high='low' low='high' type='RangeArea' border={border}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
export let data = [
{ x: 'Jan', high: 14, low: 4 },
{ x: 'Feb', high: 17, low: 7 },
{ x: 'Mar', high: 20, low: 10 },
{ x: 'Apr', high: 22, low: 12 },
{ x: 'May', high: 20, low: 10 },
{ x: 'Jun', high: 17, low: 7 },
{ x: 'Jul', high: 15, low: 5 },
{ x: 'Aug', high: 17, low: 7 },
{ x: 'Sep', high: 20, low: 10 },
{ x: 'Oct', high: 22, low: 12 },
{ x: 'Nov', high: 20, low: 10 },
{ x: 'Dec', high: 17, low: 7 }
];
export let data: Object[] = [
{ x: 'Jan', high: 14, low: 4 },
{ x: 'Feb', high: 17, low: 7 },
{ x: 'Mar', high: 20, low: 10 },
{ x: 'Apr', high: 22, low: 12 },
{ x: 'May', high: 20, low: 10 },
{ x: 'Jun', high: 17, low: 7 },
{ x: 'Jul', high: 15, low: 5 },
{ x: 'Aug', high: 17, low: 7 },
{ x: 'Sep', high: 20, low: 10 },
{ x: 'Oct', high: 22, low: 12 },
{ x: 'Nov', high: 20, low: 10 },
{ x: 'Dec', high: 17, low: 7 }
];
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, RangeAreaSeries } from '@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const emptyPoint = { mode: 'Gap' };
return <ChartComponent id='charts'>
<Inject services={[RangeAreaSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' high='low' low='high' emptyPointSettings={emptyPoint}
type='RangeArea'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Legend, Category, Tooltip, DataLabel, Zoom, Crosshair, RangeAreaSeries, Selection}
from'@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const emptyPoint: object = { mode: 'Gap' };
return <ChartComponent id='charts'>
<Inject services={[RangeAreaSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' high='low' low='high' emptyPointSettings={emptyPoint}
type='RangeArea'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
export let data = [
{ x: 2005, y: 28, high: 18, low: 44 },
{ x: 2006, y: 25, high: 20, low: 40 },
{ x: 2007, y: 26, high: 22, low: 36 },
{ x: 2008, y: 27, high: 24, low: null },
{ x: 2009, y: 32, high: 26, low: 28 },
{ x: 2010, y: 35, high: 28, low: 24 },
{ x: 2011, y: 30, high: 30, low: 20 },
];
export let data: Object[] = [
{ x: 2005, y: 28, high: 18, low: 44 },
{ x: 2006, y: 25, high: 20, low: 40 },
{ x: 2007, y: 26, high: 22, low: 36 },
{ x: 2008, y: 27, high: 24, low: null },
{ x: 2009, y: 32, high: 26, low: 28 },
{ x: 2010, y: 35, high: 28, low: 24 },
{ x: 2011, y: 30, high: 30, low: 20 },
];
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, RangeAreaSeries } from '@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const emptyPoint = { mode: 'Average', fill: 'red' };
const marker = { visible: true };
return <ChartComponent id='charts'>
<Inject services={[RangeAreaSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' high='low' low='high' emptyPointSettings={emptyPoint} marker={marker}
type='RangeArea'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Legend, Category, Tooltip, DataLabel, Zoom, Crosshair, RangeAreaSeries, Selection}
from'@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const emptyPoint: object = { mode: 'Average', fill: 'red' };
const marker: object = { visible: true };
return <ChartComponent id='charts'>
<Inject services={[RangeAreaSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' high='low' low='high' emptyPointSettings={emptyPoint} marker={marker}
type='RangeArea'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
export let data = [
{ x: 2005, y: 28, high: 18, low: 44 },
{ x: 2006, y: 25, high: 20, low: 40 },
{ x: 2007, y: 26, high: 22, low: 36 },
{ x: 2008, y: 27, high: 24, low: null },
{ x: 2009, y: 32, high: 26, low: 28 },
{ x: 2010, y: 35, high: 28, low: 24 },
{ x: 2011, y: 30, high: 30, low: 20 },
];
export let data: Object[] = [
{ x: 2005, y: 28, high: 18, low: 44 },
{ x: 2006, y: 25, high: 20, low: 40 },
{ x: 2007, y: 26, high: 22, low: 36 },
{ x: 2008, y: 27, high: 24, low: null },
{ x: 2009, y: 32, high: 26, low: 28 },
{ x: 2010, y: 35, high: 28, low: 24 },
{ x: 2011, y: 30, high: 30, low: 20 },
];
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, RangeAreaSeries } from '@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const emptyPoint = { mode: 'Average', fill: 'red', border: { width: 1.5, fill: 'green' } };
const marker = { visible: true };
return <ChartComponent id='charts'>
<Inject services={[RangeAreaSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' high='low' low='high' emptyPointSettings={emptyPoint} marker={marker}
type='RangeArea'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Legend, Category, Tooltip, DataLabel, Zoom, Crosshair, RangeAreaSeries, Selection}
from'@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const emptyPoint: object = { mode: 'Average', fill: 'red', border: { width: 1.5, fill: 'green' } };
const marker: object = { visible: true };
return <ChartComponent id='charts'>
<Inject services={[RangeAreaSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' high='low' low='high' emptyPointSettings={emptyPoint} marker={marker}
type='RangeArea'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
export let data = [
{ x: 2005, y: 28, high: 18, low: 44 },
{ x: 2006, y: 25, high: 20, low: 40 },
{ x: 2007, y: 26, high: 22, low: 36 },
{ x: 2008, y: 27, high: 24, low: null },
{ x: 2009, y: 32, high: 26, low: 28 },
{ x: 2010, y: 35, high: 28, low: 24 },
{ x: 2011, y: 30, high: 30, low: 20 },
];
export let data: Object[] = [
{ x: 2005, y: 28, high: 18, low: 44 },
{ x: 2006, y: 25, high: 20, low: 40 },
{ x: 2007, y: 26, high: 22, low: 36 },
{ x: 2008, y: 27, high: 24, low: null },
{ x: 2009, y: 32, high: 26, low: 28 },
{ x: 2010, y: 35, high: 28, low: 24 },
{ x: 2011, y: 30, high: 30, low: 20 },
];
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, RangeAreaSeries } from '@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const seriesRender = (args) => {
args.fill = '#ff6347';
}
return <ChartComponent id='charts' seriesRender={seriesRender}>
<Inject services={[RangeAreaSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' high='low' low='high'
type='RangeArea'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Legend, Category, Tooltip, DataLabel, Zoom, Crosshair, RangeAreaSeries, ISeriesRenderEventArgs}
from'@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const seriesRender = (args: ISeriesRenderEventArgs) => {
args.fill = '#ff6347';
}
return <ChartComponent id='charts' seriesRender={seriesRender}>
<Inject services={[RangeAreaSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' high='low' low='high'
type='RangeArea'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
export let data = [
{ x: 2005, y: 28, high: 18, low: 44 },
{ x: 2006, y: 25, high: 20, low: 40 },
{ x: 2007, y: 26, high: 22, low: 36 },
{ x: 2008, y: 27, high: 24, low: 32 },
{ x: 2009, y: 32, high: 26, low: 28 },
{ x: 2010, y: 35, high: 28, low: 24 },
{ x: 2011, y: 30, high: 30, low: 20 },
];
export let data: Object[] = [
{ x: 2005, y: 28, high: 18, low: 44 },
{ x: 2006, y: 25, high: 20, low: 40 },
{ x: 2007, y: 26, high: 22, low: 36 },
{ x: 2008, y: 27, high: 24, low: 32 },
{ x: 2009, y: 32, high: 26, low: 28 },
{ x: 2010, y: 35, high: 28, low: 24 },
{ x: 2011, y: 30, high: 30, low: 20 },
];
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, RangeAreaSeries } from '@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const pointRender = (args) => {
if (args.point.index % 2 !== 0) {
args.fill = '#ff6347';
}
else {
args.fill = '#009cb8';
}
}
return <ChartComponent id='charts' pointRender={pointRender}>
<Inject services={[RangeAreaSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' high='low' low='high' marker=
type='RangeArea'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Legend, Category, Tooltip, DataLabel, Zoom, Crosshair, RangeAreaSeries, IPointRenderEventArgs}
from'@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const pointRender = (args: IPointRenderEventArgs) => {
if (args.point.index % 2 !== 0) {
args.fill = '#ff6347';
}
else {
args.fill = '#009cb8';
}
}
return <ChartComponent id='charts' pointRender={pointRender}>
<Inject services={[RangeAreaSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' high='low' low='high' marker=
type='RangeArea'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
export let data = [
{ x: 2005, y: 28, high: 18, low: 44 },
{ x: 2006, y: 25, high: 20, low: 40 },
{ x: 2007, y: 26, high: 22, low: 36 },
{ x: 2008, y: 27, high: 24, low: 32 },
{ x: 2009, y: 32, high: 26, low: 28 },
{ x: 2010, y: 35, high: 28, low: 24 },
{ x: 2011, y: 30, high: 30, low: 20 },
];
export let data: Object[] = [
{ x: 2005, y: 28, high: 18, low: 44 },
{ x: 2006, y: 25, high: 20, low: 40 },
{ x: 2007, y: 26, high: 22, low: 36 },
{ x: 2008, y: 27, high: 24, low: 32 },
{ x: 2009, y: 32, high: 26, low: 28 },
{ x: 2010, y: 35, high: 28, low: 24 },
{ x: 2011, y: 30, high: 30, low: 20 },
];