Example of Polar RangeColumn in ASP.NET Core Charts Control
This sample shows minimum and maximum temperature variations in polar and radar charts using a range column series.
${x}
Low : ${low}°C
High : ${high}°C
Low : ${low}°C
High : ${high}°C
@Html.UiChart(new UiChartOptions
{
Id = "polarRangeColumnChart",
Title = "Temperatures of Germany",
Data = (IEnumerable<object>)ViewData["ChartPoints"],
Tooltip = new UiChartTooltip { Enable = true, Template = "#tipPolarRangeColumn" },
Legend = new UiChartLegend { Visible = false },
PrimaryXAxis = new UiChartAxis { ValueType = UiChartValueType.Category, Interval = 1 },
PrimaryYAxis = new UiChartAxis { LabelFormat = "{value}", Interval = 5, Minimum = 0, Maximum = 15 },
Series = new List<UiChartSeries>
{
new UiChartSeries { Type = UiChartSeriesType.Polar, Width = 2, XName = "Month", Name = "Germany", DrawType = UiChartDrawType.RangeColumn, High = "MaxTemp", Low = "MinTemp", ShowDataLabel = true }
}
})
<template id="tipPolarRangeColumn"><b>${x}</b> <br> Low : <b>${low}°C</b> <br> High : <b>${high}°C</b></template>
@Html.UiChart(new UiChartOptions
{
Id = "polarRangeColumnChart",
Title = "Temperatures of Germany",
Data = (IEnumerable<object>)ViewData["ChartPoints"],
Tooltip = new UiChartTooltip { Enable = true, Template = "#tipPolarRangeColumn" },
Legend = new UiChartLegend { Visible = false },
PrimaryXAxis = new UiChartAxis { ValueType = UiChartValueType.Category, Interval = 1 },
PrimaryYAxis = new UiChartAxis { LabelFormat = "{value}", Interval = 5, Minimum = 0, Maximum = 15 },
Series = new List<UiChartSeries>
{
new UiChartSeries { Type = UiChartSeriesType.Polar, Width = 2, XName = "Month", Name = "Germany", DrawType = UiChartDrawType.RangeColumn, High = "MaxTemp", Low = "MinTemp", ShowDataLabel = 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/PolarRangeColumn.cshtml; it draws what ViewData holds.
public ActionResult PolarRangeColumn()
{
List<PolarRangeColumnData> ChartPoints = new List<PolarRangeColumnData>
{
new PolarRangeColumnData { Month = "Jan", MinTemp = 2, MaxTemp = 7 },
new PolarRangeColumnData { Month = "Feb", MinTemp = 3, MaxTemp = 7 },
new PolarRangeColumnData { Month = "Mar", MinTemp = 3, MaxTemp = 7 },
new PolarRangeColumnData { Month = "Apr", MinTemp = 4, MaxTemp = 9 },
new PolarRangeColumnData { Month = "May", MinTemp = 6, MaxTemp = 11 },
new PolarRangeColumnData { Month = "June", MinTemp = 8,MaxTemp = 14 }
};
ViewData["ChartPoints"] = ChartPoints;
ViewData["data"] = new string[] { "Polar", "Radar" };
return View();
}
public class PolarRangeColumnData
{
public string Month { get; set; }
public double MinTemp { get; set; }
public double MaxTemp { get; set; }
}
}
}
@* 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. *@
In this example, you can see how to render and configure polar and radar charts with a range column series. Switching between polar and radar series can be done using Series Type in the property panel.
Tooltip is enabled in this example. To see the tooltip in action, hover over a point or tap on a point in touch-enabled devices.