Example of Rounded Corner in ASP.NET Core Charts Control
This sample demonstrates the global usage share of operating systems across all platforms in 2024 using a donut chart with rounded corners.
${x}
Operating System Usage: ${y}%
Operating System Usage: ${y}%
@Html.UiChart(new UiChartOptions
{
Id = "roundedDonutChart",
Title = "Global Operating System Usage Share - 2024",
SubTitle = "Source: wikipedia.org",
Data = (IEnumerable<object>)ViewData["ChartPoints"],
Tooltip = new UiChartTooltip { Enable = true, EnableHighlight = true, Template = "#tipPieRoundedCorner" },
Legend = new UiChartLegend { Visible = false },
Series = new List<UiChartSeries>
{
new UiChartSeries { Type = UiChartSeriesType.Doughnut, XName = "X", YName = "Y", Name = "Project", InnerRadius = "50%", StartAngle = 120, ShowDataLabel = true, DataLabelTemplate = "${Text}", DataLabelPosition = UiChartLabelPosition.Outside, CornerRadius = 8 }
}
})
<template id="tipPieRoundedCorner"><b>${x}</b><br>Operating System Usage: <b>${y}%</b></template>
@Html.UiChart(new UiChartOptions
{
Id = "roundedDonutChart",
Title = "Global Operating System Usage Share - 2024",
SubTitle = "Source: wikipedia.org",
Data = (IEnumerable<object>)ViewData["ChartPoints"],
Tooltip = new UiChartTooltip { Enable = true, EnableHighlight = true, Template = "#tipPieRoundedCorner" },
Legend = new UiChartLegend { Visible = false },
Series = new List<UiChartSeries>
{
new UiChartSeries { Type = UiChartSeriesType.Doughnut, XName = "X", YName = "Y", Name = "Project", InnerRadius = "50%", StartAngle = 120, ShowDataLabel = true, DataLabelTemplate = "${Text}", DataLabelPosition = UiChartLabelPosition.Outside, CornerRadius = 8 }
}
})
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/PieRoundedCorner.cshtml; it draws what ViewData holds.
public ActionResult PieRoundedCorner()
{
List<CornerRadiusChartData> ChartPoints = new List<CornerRadiusChartData>
{
new CornerRadiusChartData { X = "Android", Y = 45.49, Text = "Android: 45.49%" },
new CornerRadiusChartData { X = "Windows", Y = 25.35, Text = "Windows: 25.35%" },
new CornerRadiusChartData { X = "iOS", Y = 18.26, Text = "iOS: 18.26%" },
new CornerRadiusChartData { X = "macOS", Y = 5.06, Text = "macOS: 5.06%" },
new CornerRadiusChartData { X = "Linux", Y = 1.48, Text = "Linux: 1.48%" },
new CornerRadiusChartData { X = "Others", Y = 4.36, Text = "Others: 4.36%" }
};
ViewData["ChartPoints"] = ChartPoints;
return View();
}
public class CornerRadiusChartData
{
public string X { get; set; }
public double Y { get; set; }
public string Text { 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 a donut chart with customized corners for each slice. By specifying a value for BorderRadius, you can create rounded corners for each slice, giving the chart a modern and polished look.
Tooltips are enabled in this example. To see the tooltips in action, hover over a slice or tap on it on touch-enabled devices.