BlazorBasics.Charts
1.0.2
See the version list below for details.
dotnet add package BlazorBasics.Charts --version 1.0.2
NuGet\Install-Package BlazorBasics.Charts -Version 1.0.2
<PackageReference Include="BlazorBasics.Charts" Version="1.0.2" />
<PackageVersion Include="BlazorBasics.Charts" Version="1.0.2" />
<PackageReference Include="BlazorBasics.Charts" />
paket add BlazorBasics.Charts --version 1.0.2
#r "nuget: BlazorBasics.Charts, 1.0.2"
#:package BlazorBasics.Charts@1.0.2
#addin nuget:?package=BlazorBasics.Charts&version=1.0.2
#tool nuget:?package=BlazorBasics.Charts&version=1.0.2
Description
Create charts simples from data. You can create a Pie Chart, Columns Chart or Bar Chart.
How to use simple way
Import the name space adding to _Imports.razor this line:
@using BlazorBasics.Charts
Pie Chart
Example about Pie Chart. Values can't be more than 100% about total values.
<PieChartComponent DataSource=GetPieSegments />
@code {
Task<IReadOnlyList<ChartSegment>> GetPieSegments()
{
IReadOnlyList<ChartSegment> segments = new();
...
return Task.FromResult(segments);
}
}
Also you can set some parameters
public class PieChartParams
{
public PieChartParams(int width = 150, int height = 150,
double saturation = 100.0, double luminosity = 50.0, int separationOffset = 30,
double delayTime = 0, string title = "",
IEnumerable<ChartColor> chartColours = null)
{
Width = width;
Height = height;
Saturation = saturation;
Luminosity = luminosity;
SeparationOffset = separationOffset;
DelayTime = delayTime;
Title = title;
ChartColors = new(chartColours ?? ChartColourHelper
.InitializeColours(256, separationOffset));
}
public int Width { get; init; }
public int Height { get; init; }
public double Saturation { get; init; }
public double Luminosity { get; init; }
public double DelayTime { get; init; }
public int SeparationOffset { get; init; }
public string Title { get; init; }
public List<ChartColor> ChartColors { get; set; }
public int MaxColours => ChartColors.Count;
}
Then you can do that
<PieChartComponent DataSource=GetPieSegments Parameters=PieParams />
@code {
PieChartParams PieParams = new PieChartParams(title: "Totals");
Task<IReadOnlyList<ChartSegment>> GetPieSegments()
{
IReadOnlyList<ChartSegment> segments = new();
...
return Task.FromResult(segments);
}
}
Column or Bar Chart
Example about Column or Bar Chart.
<ColumnChartComponent Topics=Totals />
@code {
IEnumerable<ChartSegment> Totals;
protected override void OnInitialized()
{
Totals =
[
new ChartSegment
{
Value = "1",
Name = "Total Requests"
},
...
];
}
}
Also you can set some parameters
public class ColumnsBarChartParams
{
public ColumnsBarChartParams(string backgroundColour = "#D3D3D3", int thickness = 20, int dimension = 100,
bool showValues = true,
IEnumerable<ChartColor> chartColours = null)
{
BackgroundColour = backgroundColour;
Thickness = thickness;
Dimension = dimension;
ShowValues = showValues;
ChartColors = new(chartColours ?? ChartColourHelper
.InitializeColours(256, 30));
}
public string BackgroundColour { get; init; }
public int Thickness { get; init; }
public int Dimension { get; init; }
public bool ShowValues { get; init; }
public List<ChartColor> ChartColors { get; set; }
public int MaxColours => ChartColors.Count;
}
Then you can do that
<BarChartComponent Topics=Totals Parameters=BarParams />
@code {
ColumnsBarChartParams BarParams = new ColumnsBarChartParams();
IEnumerable<ChartSegment> Totals;
protected override void OnInitialized()
{
Totals =
[
new ChartSegment
{
Value = "1",
Name = "Total Requests"
},
...
];
}
}
Personalize Charts
All chart automatic set the colours depending in how many items have the data. But also you can personalize colours in the charts using the property ChartColours.
@code {
ColumnsBarChartParams BarParams = new ColumnsBarChartParams();
List<ChartColor> ChartColours =
[
new("#2E3092"),
new("#00AEEF"),
new("#EDF5FF"),
new("#2E78E8"),
new("#0C5FBA"),
new("#D1E7FF"),
new("#03B15E"),
new("#E6FFEA"),
new("#CEEED3"),
new("#F98316"),
new("#FFF2DA"),
new("#FFD8B1"),
new("#D94D4D"),
new("#FFE7E7"),
new("#FFCFCF")
];
protected override void OnInitialized()
{
BarParams = new ColumnsBarChartParams(chartColours: ChartColours);
// or BarParams.ChartColors = ChartColours;
}
}
This is aplicable for Pie Chart, Column Chart and Bar Chart. Color can be rgb(0,0,0), HEX #000000 or hsl(1,80,40).
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Microsoft.AspNetCore.Components.Web (>= 8.0.10)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
1.2.13 | 185 | 8/30/2025 |
1.2.12 | 337 | 7/21/2025 |
1.2.11 | 159 | 7/7/2025 |
1.1.10 | 331 | 6/11/2025 |
1.1.9 | 169 | 6/2/2025 |
1.1.8 | 183 | 4/2/2025 |
1.1.7 | 159 | 3/21/2025 |
1.1.6 | 157 | 3/14/2025 |
1.1.5 | 182 | 3/12/2025 |
1.1.4 | 200 | 11/18/2024 |
1.0.3 | 157 | 10/15/2024 |
1.0.2 | 130 | 10/13/2024 |
1.0.1 | 120 | 10/10/2024 |
1.0.0 | 122 | 10/10/2024 |
Fixed small bug in PieChart when reorder code always use synamic colour. Now can use personalized colours.