Candle series is similar to Hilo Open Close series, are used to represent the low,
high, open and closing price over time. To render a candle series, use series type
as Candle
and inject CandleSeries
module using Chart.Inject(CandleSeries)
method.
import { Chart, CandleSeries, Category, DateTime } from '@syncfusion/ej2-charts';
Chart.Inject(CandleSeries, Category, DateTime);
let chartData: any[] = [
{ 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 }
];
let chart: Chart = new Chart({
primaryXAxis: {
valueType: 'Category',
},
series:[
{
dataSource: chartData,
xName: 'x', open: 'open', close: 'close', high: 'high', low: 'low',
// Series type as candle series
type: 'Candle'
}
],
}, '#element');
<!DOCTYPE html>
<html lang="en">
<head>
<title>EJ2 Animation</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Typescript UI Controls" />
<meta name="author" content="Syncfusion" />
<link href="index.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container'>
<div id='element'></div>
</div>
</body>
</html>
Candle charts allow to visually compare the current price with previous price by coloring them.
Candles are filled/left as hollow based on the following criteria.
States | Description |
Filled | candle sticks are filled when the close value is lesser than the open value |
Unfilled | candle sticks are unfilled when the close value is greater than the open value |
The color of the candle will be defined by comparing with previous values. Bear color will be applied when the current closing value is greater than the previous closing value. Bull color will be applied when the current closing value is less than the previous closing value.
By default, bullFillColor is set as red and bearFillColor is set as green.
enableSolidCandles
is used to enable/disable the solid candles.
By default is set to be false.
The fill color of the candle will be defined by its opening and closing values.
bearFillColor
will be applied when the opening value is less than the closing value.
bullFillColor
will be applied when the opening value is greater than closing value.
import { Chart, CandleSeries, Category, DateTime } from '@syncfusion/ej2-charts';
import { hocData } from './datasource.ts';
Chart.Inject(CandleSeries, Category, DateTime);
let chart: Chart = new Chart({
primaryXAxis: {
valueType: 'Category',
},
series:[
{
dataSource: hocData,
xName: 'x', open: 'open', close: 'close', high: 'high', low: 'low',
bearFillColor: '#e56590',
bullFillColor: '#f8b883',
// Series type as candle series
type: 'Candle'
}
],
title: 'Shirpur Gold Refinery Share Price'
}, '#element');
<!DOCTYPE html>
<html lang="en">
<head>
<title>EJ2 Animation</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Typescript UI Controls" />
<meta name="author" content="Syncfusion" />
<link href="index.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container'>
<div id='element'></div>
</div>
</body>
</html>