Line Chart in C#
Draw line charts in C# as self-contained SVG with TerraFluent.Chart.Reporting. One AddLine call, 18 themes, no JavaScript and no browser. MIT licensed.
Line Chart
Single-series animated line chart with monthly visitors data.
When to use a line chart
Reach for it when
- A continuous measure sampled at even intervals, where the reader's question is "which way is it going?"
- Comparing the shape of two to five series that share one unit and a similar range.
- Long category runs — a line stays readable at 50 points where columns turn into a picket fence.
Use something else when
- Categories with no inherent order. Connecting Belgium to Denmark implies a trend that does not exist; use a column or bar chart.
- A single data point per category, where the line's slope is the only thing drawn and it carries no meaning.
- Series whose ranges differ by an order of magnitude — put the smaller one on a secondary axis or use a log scale, or it flatlines against the axis.
Line Chart in C#
Lifted verbatim from the chart types reference, so it compiles against the shipped API. See the API reference for every overload and the exact data types each series method accepts.
string svg = ChartBuilder.Create()
.Title("Monthly Website Visitors")
.Subtitle("Jan – Dec 2025")
.Size(700, 420)
.XAxis("Month",
"Jan","Feb","Mar","Apr","May","Jun",
"Jul","Aug","Sep","Oct","Nov","Dec")
.YAxis("Visitors", min: 0)
.AsAnimated()
.Series(s => s
.AddLine("Visitors", new double[]
{ 12400, 14800, 16200, 18500, 21000, 19800,
22300, 25100, 23700, 20400, 17900, 15600 }))
.RenderToSvg();Install
dotnet add package TerraFluent.Chart.Reporting
- MIT licensed — free for commercial use, no chart limits, no watermarks.
- Zero dependencies — nothing but the .NET base class library.
- netstandard2.0 through net10.0 — .NET Framework 4.6.1+, .NET Core 2.0+, and every modern release.
- Output is one SVG string — embed it in HTML, a PDF, or a Word document.