Financial Charts
28 Feb 202222 minutes to read
Financial charts are used to illustrate the movements in the price of a financial instrument over time.
Chart supports the following financial series
Hilo
Hilo Series illustrates the price movements in stock using the high and low values. To render a Hilo series, use series Type
as Hilo
.
Hilo series requires 3 fields (x, high and low) to show the high and low price in the stock.
<script src="chart/series/hilo/financial-data.js"></script>
@Html.EJS().Chart("container").Series(series =>
{
series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Hilo).XName("x").High("high").Low("low").Close("close").Open("Open").DataSource("returnValue").Name("Apple Inc").Add();
}).PrimaryXAxis(px => px.ValueType(Syncfusion.EJ2.Charts.ValueType.DateTime).MajorGridLines(ViewBag.majorGridLines).CrosshairTooltip(ViewBag.crosshairTooltip)
).ChartArea(area => area.Border(ViewBag.ChartBorder)).Crosshair(cr => cr.Enable(true).LineType(Syncfusion.EJ2.Charts.LineType.Vertical).Line(ViewBag.line)).Load("load").LegendSettings(lg => lg.Visible(false)).Tooltip(tt => tt.Enable(true).Shared(true)).Title("AAPL Historical").Load("load").Render()
<script>
var dataSource = window.chartData;
var date1 = new Date('2017-01-01');
var returnValue = dataSource.filter(filterValue);
function filterValue(value) {
return value.x >= date1;
}
</script>
public ActionResult Index()
{
List<Data> chartData = new List<Data>
{
new Data{ x= "Jan", low= 87, high= 200 },
new Data{ x= "Feb", low= 45, high= 135 },
new Data{ x= "Mar", low= 19, high= 85 },
new Data{ x= "Apr", low= 31, high= 108 },
new Data{ x= "May", low= 27, high= 80 },
new Data{ x= "June",low= 84, high= 130 },
new Data{ x= "Jul", low= 77, high=150 },
new Data{ x= "Aug", low= 54, high= 125 },
new Data{ x= "Sep", low= 60, high= 155 },
new Data{ x= "Oct", low= 60, high= 180 },
new Data{ x= "Nov", low= 88, high= 180 },
new Data{ x= "Dec", low= 84, high= 230 }
};
ViewBag.dataSource = chartData;
return View();
}
public class Data
{
public string x;
public double y;
public double high;
public double low;
}
High Low Open Close
HiloOpenClose series is used to represent the low, high, open and closing values over time. To render a HiloOpenClose series, use series Type
as HiloOpenClose
.
HiloOpenClose series requires 5 fields (x, high, low, open and close) to show the high, low, open and close price values in the stock.
<script src="chart/series/hilo/financial-data.js"></script>
@Html.EJS().Chart("container").Series(series =>
{
series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.HiloOpenClose).XName("x").High("high").Low("low").Close("close").Open("open").DataSource("returnValue").Name("Warmest").Add();
}).PrimaryXAxis(px => px.ValueType(Syncfusion.EJ2.Charts.ValueType.DateTime).MajorGridLines(ViewBag.majorGridLines).CrosshairTooltip(ViewBag.crosshairTooltip)
).PrimaryYAxis(py => py.Minimum(100).Maximum(180).Interval(20).MajorTickLines(ViewBag.majorTickLines).LineStyle(ViewBag.lineStyle).Title("Price").LabelFormat("${value}")
).ChartArea(area => area.Border(ViewBag.ChartBorder)).Crosshair(cr => cr.Enable(true).Line(ViewBag.line).LineType(Syncfusion.EJ2.Charts.LineType.Vertical)).Load("load").LegendSettings(lg => lg.Visible(false)).Tooltip(tt => tt.Enable(true).Shared(true)).Title("AAPL Historical").Load("load").Render()
<script>
var dataSource = window.chartData;
var date1 = new Date('2017-01-01');
var returnValue = dataSource.filter(filterValue);
function filterValue(value) {
return value.x >= date1;
}
</script>
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;
}
Customization of HiloOpenClose Series
In HiloOpenClose series, BullFillColor
is used to fill the segment when the open value is greater than the close value and BearFillColor
is used to fill the segment when the open value is less than the close value.
By default, bullFillColor is set as red and bearFillColor is set as green.
<script src="chart/series/hilo/financial-data.js"></script>
@Html.EJS().Chart("container").Series(series =>
{
series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.HiloOpenClose)
.XName("x").High("high").Low("low")
.Close("close")
.Open("open")
.DataSource("returnValue")
.BearFillColor("#2ecd71")
.BullFillColor("#e74c3d")
.Name("Warmest").Add();
}).PrimaryXAxis(px => px.ValueType(Syncfusion.EJ2.Charts.ValueType.DateTime).MajorGridLines(ViewBag.majorGridLines).CrosshairTooltip(ViewBag.crosshairTooltip)
).PrimaryYAxis(py => py.Minimum(100).Maximum(180).Interval(20).MajorTickLines(ViewBag.majorTickLines).LineStyle(ViewBag.lineStyle).Title("Price").LabelFormat("${value}")
).ChartArea(area => area.Border(ViewBag.ChartBorder)).Crosshair(cr => cr.Enable(true).Line(ViewBag.line).LineType(Syncfusion.EJ2.Charts.LineType.Vertical)).Load("load").LegendSettings(lg => lg.Visible(false)).Tooltip(tt => tt.Enable(true).Shared(true)).Title("AAPL Historical").Load("load").Render()
}
<script>
var dataSource = window.chartData;
var date1 = new Date('2017-01-01');
var returnValue = dataSource.filter(filterValue);
function filterValue(value) {
return value.x >= date1;
}
</script>
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;
}
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
.
<script src="chart/series/hilo/financial-data.js"></script>
@Html.EJS().Chart("container").Rows(rows =>
{
rows.Height("30%").Add();
rows.Height("70%").Add();
}).Axes(ax =>
{
ax.Name("secondary").
OpposedPosition(true).
Minimum(100).
Maximum(180).
RowIndex(1).
PlotOffset(30).
Title("Price").LabelFormat("${value}").
Interval(20).MajorTickLines(ViewBag.majorTickLines).LineStyle(ViewBag.lineStyle).Add();
}
).Series(series =>
{
series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Column).XName("x").YName("volume").Name("Volume").DataSource("returnValue").Add();
series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Candle).XName("x").High("high").Low("low").Close("close").Open("open").DataSource("returnValue").YAxisName("secondary").Name("Apple Inc").Add();
}).PrimaryXAxis(px => px.ValueType(Syncfusion.EJ2.Charts.ValueType.DateTime).MajorGridLines(ViewBag.majorGridLines).CrosshairTooltip(ViewBag.crosshairTooltip)
).PrimaryYAxis(py => py.Minimum(500000000).Maximum(130000000).ValueType(Syncfusion.EJ2.Charts.ValueType.Logarithmic).OpposedPosition(true).Title("Volume").LineStyle(ViewBag.lineStyle)
).Crosshair(cr => cr.Enable(true).LineType(Syncfusion.EJ2.Charts.LineType.Vertical)).ChartArea(area => area.Border(ViewBag.ChartBorder)).LegendSettings(lg => lg.Visible(true)).Tooltip(tt => tt.Enable(true).Shared(true)).Title("AAPL Historical").Width("60%").Load("load").Render()
}
<script>
var dataSource = window.chartData;
var date1 = new Date('2017-01-01');
var returnValue = dataSource.filter(filterValue);
function filterValue(value) {
return value.x >= date1;
}
</script>
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
BnableSolidCandles
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.
<script src="chart/series/hilo/financial-data.js"></script>
@Html.EJS().Chart("container").Rows(rows =>
{
rows.Height("30%").Add();
rows.Height("70%").Add();
}).Axes(ax =>
{
ax.Name("secondary").
OpposedPosition(true).
Minimum(100).
Maximum(180).
RowIndex(1).
PlotOffset(30).
Title("Price").LabelFormat("${value}").
Interval(20).MajorTickLines(ViewBag.majorTickLines).LineStyle(ViewBag.lineStyle).Add();
}
).Series(series =>
{
series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Column)
.XName("x").YName("volume")
.Name("Volume")
.DataSource("returnValue").Add();
series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Candle)
.XName("x").High("high")
.Low("low")
.Close("close")
.Open("open")
.BearFillColor("#2ecd71")
.BullFillColor("#e74c3d")
.DataSource("returnValue")
.YAxisName("secondary")
.Name("Apple Inc").Add();
}).PrimaryXAxis(px => px.ValueType(Syncfusion.EJ2.Charts.ValueType.DateTime).MajorGridLines(ViewBag.majorGridLines).CrosshairTooltip(ViewBag.crosshairTooltip)
).PrimaryYAxis(py => py.Minimum(500000000).Maximum(130000000).ValueType(Syncfusion.EJ2.Charts.ValueType.Logarithmic).OpposedPosition(true).Title("Volume").LineStyle(ViewBag.lineStyle)
).Crosshair(cr => cr.Enable(true).LineType(Syncfusion.EJ2.Charts.LineType.Vertical)).ChartArea(area => area.Border(ViewBag.ChartBorder)).LegendSettings(lg => lg.Visible(true)).Tooltip(tt => tt.Enable(true).Shared(true)).Title("AAPL Historical").Width("60%").Load("load").Render()
<script>
var dataSource = window.chartData;
var date1 = new Date('2017-01-01');
var returnValue = dataSource.filter(filterValue);
function filterValue(value) {
return value.x >= date1;
}
</script>
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;
}