Basic Bars
Razor
@page "/Bars/Basic"
@using LiveChartsCore.SkiaSharpView.Blazor
@using LiveChartsCore;
@using LiveChartsCore.SkiaSharpView;
@using LiveChartsCore.SkiaSharpView.Painting;
@using SkiaSharp;
<CartesianChart
Series="@series"
XAxes="@xAxes"
LegendPosition="LiveChartsCore.Measure.LegendPosition.Right">
</CartesianChart>
@code {
private static double[] maryValues = new double[] { 2, 5, 4 };
private static double[] anaValues = new double[] { 3, 1, 6 };
private static string[] labels = new string[] { "Category 1", "Category 2", "Category 3" };
private ISeries[] series = new ISeries[]
{
new ColumnSeries<double> { Name = "Mary", Values = maryValues },
new ColumnSeries<double> { Name = "Ana", Values = anaValues }
};
private Axis[] xAxes = new Axis[]
{
new Axis
{
Labels = labels,
LabelsRotation = 0,
SeparatorsPaint = new SolidColorPaint(new SKColor(200, 200, 200)),
SeparatorsAtCenter = false,
TicksPaint = new SolidColorPaint(new SKColor(35, 35, 35)),
TicksAtCenter = true,
MinStep = 1,
ForceStepToMin = true
}
};
}
Articles you might also find useful: