Example of Strip Line Recurrence in ASP.NET Core Charts Control
This example repeats a strip line at a fixed distance, to mark the weekends of a daily chart.
@* 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 = "stripRepeatChart",
Data = (IEnumerable<object>)ViewData["ChartData"],
Height = "380px",
Title = "Visitors per day",
PrimaryXAxis = new UiChartAxis
{
ValueType = UiChartValueType.DateTime,
LabelFormat = "dd MMM",
StripLines = new List<UiChartStripLine>
{
new UiChartStripLine { Start = new DateTime(2026, 3, 7), Size = 2, RepeatEvery = 7, RepeatUntil = new DateTime(2026, 3, 29), Color = "#c4314b", Opacity = 0.12, Text = "Weekend" }
}
},
PrimaryYAxis = new UiChartAxis
{
LabelFormat = "N0",
Minimum = 0,
Maximum = 30000,
StripLines = new List<UiChartStripLine>
{
new UiChartStripLine { Start = 10000, RepeatEvery = 10000, RepeatUntil = 30000, DashArray = "4,4", Color = "#7f56d9" }
}
},
Series = new List<UiChartSeries>
{
new UiChartSeries { Type = UiChartSeriesType.Line, XName = "Day", YName = "Visitors", Name = "Visitors", ShowMarker = true }
}
})
@Html.UiChart(new UiChartOptions
{
Id = "stripRepeatChart",
Data = (IEnumerable<object>)ViewData["ChartData"],
Height = "380px",
Title = "Visitors per day",
PrimaryXAxis = new UiChartAxis
{
ValueType = UiChartValueType.DateTime,
LabelFormat = "dd MMM",
StripLines = new List<UiChartStripLine>
{
new UiChartStripLine { Start = new DateTime(2026, 3, 7), Size = 2, RepeatEvery = 7, RepeatUntil = new DateTime(2026, 3, 29), Color = "#c4314b", Opacity = 0.12, Text = "Weekend" }
}
},
PrimaryYAxis = new UiChartAxis
{
LabelFormat = "N0",
Minimum = 0,
Maximum = 30000,
StripLines = new List<UiChartStripLine>
{
new UiChartStripLine { Start = 10000, RepeatEvery = 10000, RepeatUntil = 30000, DashArray = "4,4", Color = "#7f56d9" }
}
},
Series = new List<UiChartSeries>
{
new UiChartSeries { Type = UiChartSeriesType.Line, XName = "Day", YName = "Visitors", Name = "Visitors", ShowMarker = true }
}
})
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/StripLineRecurrence.cshtml; it draws what ViewData holds.
public ActionResult StripLineRecurrence()
{
ViewData["ChartData"] = Enumerable.Range(0, 28).Select(i => new { Day = new DateTime(2026, 3, 2).AddDays(i), Visitors = 18000 + (i * 7919 % 9000) + (i % 7 >= 5 ? -6000 : 0) }).ToList();
return View();
}
}
}
@* 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. *@
A strip line with RepeatEvery is drawn again at a fixed distance: here a band of two days every seven days (the weekends), and a line at every 10,000 on the Y axis. RepeatUntil stops the repeats; without it they run to the axis' Maximum.