Candle Chart in React Chart
Candle
The Candle series, similar to the Hilo Open Close series, is used to represent the low, high, open, and closing prices over time. It is commonly used in financial charts to visualize stock price movements.
To render a candle 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
typeasCandlein your chart configuration. This indicates that the data should be represented as a candle chart, providing a detailed view of stock price fluctuations by displaying the high, low, open, and close values for each time period. -
Inject the CandleSeries module: Inject the
CandleSeriesmodule into the chart’sservicesusing<Inject services={...} />. The samples below also injectCategoryso the x-axis renders month labels correctly. Inject additional modules such asTooltip,Crosshair, orZoomif your scenario requires them. -
Provide high, low, open, and close values: The
Candleseries requires five fields (x, high, low, open, and close) to accurately display the stock’s high, low, open, and close prices. Ensure that your data source includes these fields to create a detailed representation of stock price movements over time.
import * as React from "react";
import * as ReactDOM from "react-dom/client";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Category, CandleSeries } from '@syncfusion/ej2-react-charts';
import { chartData } from './datasource';
function App() {
const primaryxAxis = { title: 'Date', valueType: 'Category', majorGridLines: { width: 0 } };
const primaryyAxis = { title: 'Price in Dollar', minimum: 100, maximum: 200, interval: 20 };
const style = { textAlign: "center" };
return <ChartComponent id='charts' style={style} primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} title='Shirpur Gold Refinery Share Price'>
<Inject services={[CandleSeries, Category]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={chartData} xName='x' name='SHIRPUR-G' type='Candle' low='low' high='high' open='open' close='close'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>;
}
;
export default App;
const root = ReactDOM.createRoot(document.getElementById('charts'));
root.render(<App />);import * as React from "react";
import * as ReactDOM from "react-dom/client";
import type { AxisModel } from "@syncfusion/ej2-react-charts";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Category, CandleSeries }
from '@syncfusion/ej2-react-charts';
import { chartData } from './datasource';
function App() {
const primaryxAxis: AxisModel = { title: 'Date', valueType: 'Category', majorGridLines: { width: 0 } };
const primaryyAxis: AxisModel = { title: 'Price in Dollar', minimum: 100, maximum: 200, interval: 20 };
const style: any = { textAlign: "center" };
return <ChartComponent id='charts' style={style}
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Shirpur Gold Refinery Share Price'>
<Inject services={[CandleSeries, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={chartData} xName='x' name='SHIRPUR-G' type='Candle' low='low'
high='high' open='open' close='close'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
const root = ReactDOM.createRoot(document.getElementById('charts') as HTMLElement);
root.render(<App />);export let chartData = [
{ x: 'Jan', open: 120, high: 160, low: 100, close: 140 },
{ x: 'Feb', open: 150, high: 190, low: 130, close: 170 },
{ x: 'Mar', open: 130, high: 170, low: 110, close: 150 },
{ x: 'Apr', open: 160, high: 180, low: 120, close: 140 },
{ x: 'May', open: 150, high: 170, low: 110, close: 130 }
];export let chartData: Object[] = [
{ x: 'Jan', open: 120, high: 160, low: 100, close: 140 },
{ x: 'Feb', open: 150, high: 190, low: 130, close: 170 },
{ x: 'Mar', open: 130, high: 170, low: 110, close: 150 },
{ x: 'Apr', open: 160, high: 180, low: 120, close: 140 },
{ x: 'May', open: 150, high: 170, low: 110, close: 130 }
];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, low, open and close properties.
import * as React from "react";
import * as ReactDOM from "react-dom/client";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Category, CandleSeries } from '@syncfusion/ej2-react-charts';
import { chartData } from './datasource';
function App() {
const primaryxAxis = { title: 'Date', valueType: 'Category', majorGridLines: { width: 0 } };
const primaryyAxis = { title: 'Price in Dollar', minimum: 100, maximum: 200, interval: 20 };
const style = { textAlign: "center" };
return <ChartComponent id='charts' style={style} primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} title='Shirpur Gold Refinery Share Price'>
<Inject services={[CandleSeries, Category]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={chartData} xName='x' name='SHIRPUR-G' type='Candle' low='low' high='high' open='open' close='close'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>;
}
;
export default App;
const root = ReactDOM.createRoot(document.getElementById('charts'));
root.render(<App />);import * as React from "react";
import * as ReactDOM from "react-dom/client";
import type { AxisModel } from "@syncfusion/ej2-react-charts";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Category, CandleSeries }
from '@syncfusion/ej2-react-charts';
import { chartData } from './datasource';
function App() {
const primaryxAxis: AxisModel = { title: 'Date', valueType: 'Category', majorGridLines: { width: 0 } };
const primaryyAxis: AxisModel = { title: 'Price in Dollar', minimum: 100, maximum: 200, interval: 20 };
const style: any = { textAlign: "center" };
return <ChartComponent id='charts' style={style}
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Shirpur Gold Refinery Share Price'>
<Inject services={[CandleSeries, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={chartData} xName='x' name='SHIRPUR-G' type='Candle' low='low'
high='high' open='open' close='close'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
const root = ReactDOM.createRoot(document.getElementById('charts') as HTMLElement);
root.render(<App />);export let chartData = [
{ x: 'Jan', open: 120, high: 160, low: 100, close: 140 },
{ x: 'Feb', open: 150, high: 190, low: 130, close: 170 },
{ x: 'Mar', open: 130, high: 170, low: 110, close: 150 },
{ x: 'Apr', open: 160, high: 180, low: 120, close: 140 },
{ x: 'May', open: 150, high: 170, low: 110, close: 130 }
];export let chartData: Object[] = [
{ x: 'Jan', open: 120, high: 160, low: 100, close: 140 },
{ x: 'Feb', open: 150, high: 190, low: 130, close: 170 },
{ x: 'Mar', open: 130, high: 170, low: 110, close: 150 },
{ x: 'Apr', open: 160, high: 180, low: 120, close: 140 },
{ x: 'May', open: 150, high: 170, low: 110, close: 130 }
];Hollow candles
Hollow candles in candle charts allow you to visually compare the current price with the previous price by coloring them differently. This is the default rendering mode (when enableSolidCandles is false). The candles are filled or left hollow based on the following criteria:
| States | Description |
| Filled | Candlesticks are filled when the close value is less than the open value, indicating a price drop. |
| Unfilled | Candlesticks are unfilled when the close value is greater than the open value, indicating a price rise. |
The candle color is determined by comparing the current closing value with the previous closing value. In hollow-candle mode, the candle body is filled or hollow based on the relationship between its own opening and closing values, as described in the table above.
By default, the bullFillColor is set to red and the bearFillColor is set to green.
To customize the colors, set the bullFillColor and bearFillColor properties on the series.
Solid candles
The enableSolidCandles property is used to enable or disable solid candles. By default, it is set to false (hollow candles). When set to true, the fill color of each candle is determined by its opening and closing values:
- The
bearFillColoris applied when the opening value is less than the closing value (price rose during the period). - The
bullFillColoris applied when the opening value is greater than the closing value (price fell during the period).
import * as React from "react";
import * as ReactDOM from "react-dom/client";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Category, CandleSeries } from '@syncfusion/ej2-react-charts';
import { chartData } from './datasource';
function App() {
const primaryxAxis = { title: 'Date', valueType: 'Category', majorGridLines: { width: 0 } };
const primaryyAxis = { title: 'Price in Dollar', minimum: 100, maximum: 200, interval: 20 };
const style = { textAlign: "center" };
return <ChartComponent id='charts' style={style} primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} title='Shirpur Gold Refinery Share Price'>
<Inject services={[CandleSeries, Category]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={chartData} xName='x' name='SHIRPUR-G' type='Candle' low='low' high='high' open='open' close='close' enableSolidCandles={true} bearFillColor='#e56590' bullFillColor='#f8b883'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>;
}
;
export default App;
const root = ReactDOM.createRoot(document.getElementById('charts'));
root.render(<App />);import * as React from "react";
import * as ReactDOM from "react-dom/client";
import type { AxisModel } from "@syncfusion/ej2-react-charts";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Category, CandleSeries }
from '@syncfusion/ej2-react-charts';
import { chartData } from './datasource';
function App() {
const primaryxAxis: AxisModel = { title: 'Date', valueType: 'Category', majorGridLines: { width: 0 } };
const primaryyAxis: AxisModel = { title: 'Price in Dollar', minimum: 100, maximum: 200, interval: 20 };
const style: any = { textAlign: "center" };
return <ChartComponent id='charts' style={style}
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Shirpur Gold Refinery Share Price'>
<Inject services={[CandleSeries, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={chartData} xName='x' name='SHIRPUR-G' type='Candle' low='low'
high='high' open='open' close='close' enableSolidCandles={true} bearFillColor='#e56590' bullFillColor='#f8b883'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
const root = ReactDOM.createRoot(document.getElementById('charts') as HTMLElement);
root.render(<App />);export let chartData = [
{ x: 'Jan', open: 120, high: 160, low: 100, close: 140 },
{ x: 'Feb', open: 150, high: 190, low: 130, close: 170 },
{ x: 'Mar', open: 130, high: 170, low: 110, close: 150 },
{ x: 'Apr', open: 160, high: 180, low: 120, close: 140 },
{ x: 'May', open: 150, high: 170, low: 110, close: 130 }
];export let chartData: Object[] = [
{ x: 'Jan', open: 120, high: 160, low: 100, close: 140 },
{ x: 'Feb', open: 150, high: 190, low: 130, close: 170 },
{ x: 'Mar', open: 130, high: 170, low: 110, close: 150 },
{ x: 'Apr', open: 160, high: 180, low: 120, close: 140 },
{ x: 'May', open: 150, high: 170, low: 110, close: 130 }
];Empty points
Data points with null, undefined, or NaN values are considered empty. By default (Gap mode), empty data points leave a gap and are not plotted on the chart. The behavior can be customized using the mode and fill properties of emptyPointSettings.
Mode
Use the mode property to control handling of empty points. Available modes are Gap (leave a break, the default), Drop (ignores the empty point during rendering), Zero (plot as zero), and Average (plot as the average of neighboring points).
import * as React from "react";
import * as ReactDOM from "react-dom/client";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Category, CandleSeries } from '@syncfusion/ej2-react-charts';
import { chartData } from './datasource';
function App() {
const primaryxAxis = { title: 'Date', valueType: 'Category', majorGridLines: { width: 0 } };
const primaryyAxis = { title: 'Price in Dollar', minimum: 100, maximum: 200, interval: 20 };
const style = { textAlign: "center" };
const emptyPoint = { mode: 'Average' }
return <ChartComponent id='charts' style={style} primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} title='Shirpur Gold Refinery Share Price'>
<Inject services={[CandleSeries, Category]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={chartData} xName='x' name='SHIRPUR-G' emptyPointSettings={emptyPoint} type='Candle' low='low' high='high' open='open' close='close' bearFillColor='#e56590' bullFillColor='#f8b883'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>;
}
;
export default App;
const root = ReactDOM.createRoot(document.getElementById('charts'));
root.render(<App />);import * as React from "react";
import * as ReactDOM from "react-dom/client";
import type { AxisModel } from "@syncfusion/ej2-react-charts";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Category, CandleSeries }
from '@syncfusion/ej2-react-charts';
import { chartData } from './datasource';
function App() {
const primaryxAxis: AxisModel = { title: 'Date', valueType: 'Category', majorGridLines: { width: 0 } };
const primaryyAxis: AxisModel = { title: 'Price in Dollar', minimum: 100, maximum: 200, interval: 20 };
const style: any = { textAlign: "center" };
const emptyPoint: object = { mode: 'Average' }
return <ChartComponent id='charts' style={style}
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Shirpur Gold Refinery Share Price'>
<Inject services={[CandleSeries, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={chartData} xName='x' name='SHIRPUR-G' type='Candle' low='low'
high='high' open='open' close='close' emptyPointSettings={emptyPoint} bearFillColor='#e56590' bullFillColor='#f8b883'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
const root = ReactDOM.createRoot(document.getElementById('charts') as HTMLElement);
root.render(<App />);export let chartData = [
{ x: 'Jan', open: 120, high: 160, low: 100, close: 140 },
{ x: 'Feb', open: 150, high: 190, low: 130, close: 170 },
{ x: 'Mar', open: null, high: 170, low: 110, close: 150 },
{ x: 'Apr', open: 160, high: 180, low: 120, close: 140 },
{ x: 'May', open: 150, high: 170, low: 110, close: 130 }
];export let chartData: Object[] = [
{ x: 'Jan', open: 120, high: 160, low: 100, close: 140 },
{ x: 'Feb', open: 150, high: 190, low: 130, close: 170 },
{ x: 'Mar', open: null, high: 170, low: 110, close: 150 },
{ x: 'Apr', open: 160, high: 180, low: 120, close: 140 },
{ x: 'May', open: 150, high: 170, low: 110, close: 130 }
];Fill
Use the fill property to set the fill color for the empty candle. In the following sample, the empty candle is rendered in blue and its open value is computed using Average mode.
import * as React from "react";
import * as ReactDOM from "react-dom/client";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Category, CandleSeries } from '@syncfusion/ej2-react-charts';
import { chartData } from './datasource';
function App() {
const primaryxAxis = { title: 'Date', valueType: 'Category', majorGridLines: { width: 0 } };
const primaryyAxis = { title: 'Price in Dollar', minimum: 100, maximum: 200, interval: 20 };
const style = { textAlign: "center" };
const emptyPoint = { mode: 'Average', fill: 'blue' }
return <ChartComponent id='charts' style={style} primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} title='Shirpur Gold Refinery Share Price'>
<Inject services={[CandleSeries, Category]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={chartData} xName='x' name='SHIRPUR-G' emptyPointSettings={emptyPoint} type='Candle' low='low' high='high' open='open' close='close' bearFillColor='#e56590' bullFillColor='#f8b883'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>;
}
;
export default App;
const root = ReactDOM.createRoot(document.getElementById('charts'));
root.render(<App />);import * as React from "react";
import * as ReactDOM from "react-dom/client";
import type { AxisModel } from "@syncfusion/ej2-react-charts";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Category, CandleSeries }
from '@syncfusion/ej2-react-charts';
import { chartData } from './datasource';
function App() {
const primaryxAxis: AxisModel = { title: 'Date', valueType: 'Category', majorGridLines: { width: 0 } };
const primaryyAxis: AxisModel = { title: 'Price in Dollar', minimum: 100, maximum: 200, interval: 20 };
const style: any = { textAlign: "center" };
const emptyPoint: object = { mode: 'Average', fill: 'blue' }
return <ChartComponent id='charts' style={style}
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Shirpur Gold Refinery Share Price'>
<Inject services={[CandleSeries, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={chartData} xName='x' name='SHIRPUR-G' type='Candle' low='low'
high='high' open='open' close='close' emptyPointSettings={emptyPoint} bearFillColor='#e56590' bullFillColor='#f8b883'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
const root = ReactDOM.createRoot(document.getElementById('charts') as HTMLElement);
root.render(<App />);export let chartData = [
{ x: 'Jan', open: 120, high: 160, low: 100, close: 140 },
{ x: 'Feb', open: 150, high: 190, low: 130, close: 170 },
{ x: 'Mar', open: null, high: 170, low: 110, close: 150 },
{ x: 'Apr', open: 160, high: 180, low: 120, close: 140 },
{ x: 'May', open: 150, high: 170, low: 110, close: 130 }
];export let chartData: Object[] = [
{ x: 'Jan', open: 120, high: 160, low: 100, close: 140 },
{ x: 'Feb', open: 150, high: 190, low: 130, close: 170 },
{ x: 'Mar', open: null, high: 170, low: 110, close: 150 },
{ x: 'Apr', open: 160, high: 180, low: 120, close: 140 },
{ x: 'May', open: 150, high: 170, low: 110, close: 130 }
];Events
Series render
The seriesRender event fires before each series is rendered. Use its event arguments to modify the series data, fill, or name dynamically before rendering.
import * as React from "react";
import * as ReactDOM from "react-dom/client";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Category, CandleSeries } from '@syncfusion/ej2-react-charts';
import { chartData } from './datasource';
function App() {
const primaryxAxis = { title: 'Date', valueType: 'Category', majorGridLines: { width: 0 } };
const primaryyAxis = { title: 'Price in Dollar', minimum: 100, maximum: 200, interval: 20 };
const style = { textAlign: "center" };
const seriesRender = (args) => {
args.series.bearFillColor = '#ff6347';
args.series.bullFillColor = '#009cb8';
};
return <ChartComponent id='charts' style={style} primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} seriesRender={seriesRender} title='Shirpur Gold Refinery Share Price'>
<Inject services={[CandleSeries, Category]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={chartData} xName='x' name='SHIRPUR-G' type='Candle' low='low' high='high' open='open' close='close' bearFillColor='#e56590' bullFillColor='#f8b883'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>;
}
;
export default App;
const root = ReactDOM.createRoot(document.getElementById('charts'));
root.render(<App />);import * as React from "react";
import * as ReactDOM from "react-dom/client";
import type { AxisModel, ISeriesRenderEventArgs } from "@syncfusion/ej2-react-charts";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Category, CandleSeries }
from '@syncfusion/ej2-react-charts';
import type { EmitType } from '@syncfusion/ej2-base';
import { chartData } from './datasource';
function App() {
const primaryxAxis: AxisModel = { title: 'Date', valueType: 'Category', majorGridLines: { width: 0 } };
const primaryyAxis: AxisModel = { title: 'Price in Dollar', minimum: 100, maximum: 200, interval: 20 };
const style: any = { textAlign: "center" };
const seriesRender: EmitType<ISeriesRenderEventArgs> = (args: ISeriesRenderEventArgs): void => {
args.series.bearFillColor = '#ff6347';
args.series.bullFillColor = '#009cb8';
};
return <ChartComponent id='charts' style={style}
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Shirpur Gold Refinery Share Price' seriesRender={seriesRender}>
<Inject services={[CandleSeries, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={chartData} xName='x' name='SHIRPUR-G' type='Candle' low='low'
high='high' open='open' close='close' bearFillColor='#e56590' bullFillColor='#f8b883'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
const root = ReactDOM.createRoot(document.getElementById('charts') as HTMLElement);
root.render(<App />);export let chartData = [
{ x: 'Jan', open: 120, high: 160, low: 100, close: 140 },
{ x: 'Feb', open: 150, high: 190, low: 130, close: 170 },
{ x: 'Mar', open: null, high: 170, low: 110, close: 150 },
{ x: 'Apr', open: 160, high: 180, low: 120, close: 140 },
{ x: 'May', open: 150, high: 170, low: 110, close: 130 }
];export let chartData: Object[] = [
{ x: 'Jan', open: 120, high: 160, low: 100, close: 140 },
{ x: 'Feb', open: 150, high: 190, low: 130, close: 170 },
{ x: 'Mar', open: null, high: 170, low: 110, close: 150 },
{ x: 'Apr', open: 160, high: 180, low: 120, close: 140 },
{ x: 'May', open: 150, high: 170, low: 110, close: 130 }
];Point render
The pointRender event provides a hook to customize each data point (for example, marker shape, border, or fill) before it is drawn. Use this to apply per-point styling rules or conditional formatting.
import * as React from "react";
import * as ReactDOM from "react-dom/client";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Category, CandleSeries } from '@syncfusion/ej2-react-charts';
import { chartData } from './datasource';
function App() {
const primaryxAxis = { title: 'Date', valueType: 'Category', majorGridLines: { width: 0 } };
const primaryyAxis = { title: 'Price in Dollar', minimum: 100, maximum: 200, interval: 20 };
const style = { textAlign: "center" };
const pointRender = (args) => {
if (args.point.index % 2 !== 0) {
args.fill = '#ff6347';
}
else {
args.fill = '#009cb8';
}
};
return <ChartComponent id='charts' style={style} primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} pointRender={pointRender} title='Shirpur Gold Refinery Share Price'>
<Inject services={[CandleSeries, Category]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={chartData} xName='x' name='SHIRPUR-G' type='Candle' low='low' high='high' open='open' close='close' bearFillColor='#e56590' bullFillColor='#f8b883'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>;
}
;
export default App;
const root = ReactDOM.createRoot(document.getElementById('charts'));
root.render(<App />);import * as React from "react";
import * as ReactDOM from "react-dom/client";
import type { AxisModel, IPointRenderEventArgs } from "@syncfusion/ej2-react-charts";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Category, CandleSeries }
from '@syncfusion/ej2-react-charts';
import type { EmitType } from '@syncfusion/ej2-base';
import { chartData } from './datasource';
function App() {
const primaryxAxis: AxisModel = { title: 'Date', valueType: 'Category', majorGridLines: { width: 0 } };
const primaryyAxis: AxisModel = { title: 'Price in Dollar', minimum: 100, maximum: 200, interval: 20 };
const style: any = { textAlign: "center" };
const pointRender: EmitType<IPointRenderEventArgs> = (args: IPointRenderEventArgs): void => {
if (args.point.index % 2 !== 0) {
args.fill = '#ff6347';
}
else {
args.fill = '#009cb8';
}
};
return <ChartComponent id='charts' style={style}
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Shirpur Gold Refinery Share Price' pointRender={pointRender}>
<Inject services={[CandleSeries, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={chartData} xName='x' name='SHIRPUR-G' type='Candle' low='low'
high='high' open='open' close='close' bearFillColor='#e56590' bullFillColor='#f8b883'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
const root = ReactDOM.createRoot(document.getElementById('charts') as HTMLElement);
root.render(<App />);export let chartData = [
{ x: 'Jan', open: 120, high: 160, low: 100, close: 140 },
{ x: 'Feb', open: 150, high: 190, low: 130, close: 170 },
{ x: 'Mar', open: null, high: 170, low: 110, close: 150 },
{ x: 'Apr', open: 160, high: 180, low: 120, close: 140 },
{ x: 'May', open: 150, high: 170, low: 110, close: 130 }
];export let chartData: Object[] = [
{ x: 'Jan', open: 120, high: 160, low: 100, close: 140 },
{ x: 'Feb', open: 150, high: 190, low: 130, close: 170 },
{ x: 'Mar', open: null, high: 170, low: 110, close: 150 },
{ x: 'Apr', open: 160, high: 180, low: 120, close: 140 },
{ x: 'May', open: 150, high: 170, low: 110, close: 130 }
];