Candle in ASP.NET Core Charts Component
26 Feb 20247 minutes to read
To get started with the ASP.NET Core Candle charts, you can check on this video:
Candle
Candle series are 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
.
<ejs-chart id="container" width="60%">
<e-chart-primaryxaxis valueType="Category"></e-chart-primaryxaxis>
<e-series-collection>
<e-series dataSource="ViewBag.dataSource" xName="x" high="high" low="low" open="open" close="close"
type="@Syncfusion.EJ2.Charts.ChartSeriesType.Candle">
</e-series>
</e-series-collection>
</ejs-chart>
public ActionResult Index()
{
List<Data> chartData = new List<Data>
{
new Data{ x= "Jan", open= 120, high= 160, low= 100, close= 140 },
new Data{ x= "Feb", open= 150, high= 190, low= 130, close= 170 },
new Data{ x= "Mar", open= 130, high= 170, low= 110, close= 150 },
new Data{ x= "Apr", open= 160, high= 180, low= 120, close= 140 },
new Data{ x= "May", open= 150, high= 170, low= 110, close= 130 }
};
ViewBag.dataSource = chartData;
return View();
}
public class Data
{
public string x;
public double y;
public double high;
public double low;
public double open;
public double close;
}
Hollow Candles
Candle charts allow to visually compare the current price with previous price by customizing the appearance.
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.
Solid Candles
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.
<ejs-chart id="container" width="60%">
<e-chart-primaryxaxis valueType="Category"></e-chart-primaryxaxis>
<e-series-collection>
<e-series dataSource="ViewBag.dataSource" xName="x" high="high" low="low" open="open" close="close"
type="@Syncfusion.EJ2.Charts.ChartSeriesType.Candle" bearFillColor="#e56590" bullFillColor="#f8b883"
enableSolidCandles="true">
</e-series>
</e-series-collection>
</ejs-chart>
public ActionResult Index()
{
List<Data> chartData = new List<Data>
{
new Data{ x= "Jan", open= 120, high= 160, low= 100, close= 140 },
new Data{ x= "Feb", open= 150, high= 190, low= 130, close= 170 },
new Data{ x= "Mar", open= 130, high= 170, low= 110, close= 150 },
new Data{ x= "Apr", open= 160, high= 180, low= 120, close= 140 },
new Data{ x= "May", open= 150, high= 170, low= 110, close= 130 }
};
ViewBag.dataSource = chartData;
return View();
}
public class Data
{
public string x;
public double y;
public double high;
public double low;
public double open;
public double close;
}