Example of Hilo in ASP.NET Core Charts Control
This Hilo Chart example shows the high and low price of a share on each trading day as a vertical line.
@* The chart's settings are in the view; the data they read (ViewData) is set in the controller action (see the controller tab). *@
@Html.UiChart(new UiChartOptions
{
Id = "hiloChart",
Data = (IEnumerable<object>)ViewData["ChartData"],
Height = "340px",
PrimaryXAxis = new UiChartAxis { LabelRotation = -45 },
PrimaryYAxis = new UiChartAxis { LabelFormat = "C0", Minimum = 90, Maximum = 135 },
Series = new List<UiChartSeries>
{
new UiChartSeries { Type = UiChartSeriesType.Hilo, XName = "Day", High = "High", Low = "Low", Name = "Hilo" }
}
})
@Html.UiChart(new UiChartOptions
{
Id = "hiloChart",
Data = (IEnumerable<object>)ViewData["ChartData"],
Height = "340px",
PrimaryXAxis = new UiChartAxis { LabelRotation = -45 },
PrimaryYAxis = new UiChartAxis { LabelFormat = "C0", Minimum = 90, Maximum = 135 },
Series = new List<UiChartSeries>
{
new UiChartSeries { Type = UiChartSeriesType.Hilo, XName = "Day", High = "High", Low = "Low", Name = "Hilo" }
}
})
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using Lumen.UI.Mvc;
namespace YourApp.Controllers
{
public class ChartController : Controller
{
// The page is Views/Chart/HiloChart.cshtml; it draws what ViewData holds.
public ActionResult HiloChart()
{
ViewData["ChartData"] = StockPrices();
return View();
}
/// <summary>One trading day: the rows of the Hilo, Hilo Open Close and Candle samples.</summary>
public class StockData
{
public DateTime Date { get; set; }
public double Open { get; set; }
public double High { get; set; }
public double Low { get; set; }
public double Close { get; set; }
}
private static List<StockData> StockPrices()
{
var list = new List<StockData>();
double close = 100;
double[] moves = { 4, -3, 6, 5, -4, 7, -2, 3, -5, 6, 4, -3, 2, 5 };
for (int i = 0; i < moves.Length; i++)
{
DateTime day = new DateTime(2026, 3, 2).AddDays(i + (i / 5) * 2); // weekdays only
double open = close + (i % 3 == 0 ? -1 : 1);
close = open + moves[i];
list.Add(new StockData
{
Date = day,
Open = open,
Close = close,
High = Math.Max(open, close) + 2 + i % 3,
Low = Math.Min(open, close) - 2 - i % 2
});
}
return list;
}
}
}
@* Program.cs *@
builder.Services.AddControllersWithViews().AddLumenUIJson();
builder.Services.AddLumenUI();
// ...
app.UseLumenUI();
@* Views/_ViewImports.cshtml *@
@using Lumen.UI.Mvc
@addTagHelper *, Lumen.UI.Core
@* Views/Shared/_Layout.cshtml *@
<head>
@Html.UiStyles()
<link rel="stylesheet" href="~/css/site.css" />
</head>
<body>
@RenderBody()
@Html.UiScripts()
@await RenderSectionAsync("scripts", required: false)
</body>
@* Charts with a DataUrl: @Html.AntiForgeryToken() on the page and [HttpPost, ValidateJsonAntiForgeryToken] on the action. *@
Hilo: a line from the low to the high of each day.