Microcharts
Microcharts copied to clipboard
[Question] How Can I add Text In the Center Of the Dount Chart?
Is there a way to allow adding Text inside the chart beside the ones on the right side
here is the chart I have
and the example I'm using please note I'm using QuestPDF with Microcharts
var entries = new[]
{
new ChartEntry(7)
{
Label = "Available Limit",
ValueLabel = "7000",
Color = SKColor.Parse("#1976D2"), // Blue
ValueLabelColor = SKColor.Parse("#1976D2")
},
new ChartEntry(2)
{
Label = "Closing Balance",
ValueLabel = "2000",
Color = SKColor.Parse("#689F38"), // Light Green
ValueLabelColor = SKColor.Parse("#689F38")
},
new ChartEntry(1)
{
Label = "Installments Deferred",
ValueLabel = "1000",
Color = SKColor.Parse("#FFC107"), // Yellow
ValueLabelColor = SKColor.Parse("#FFC107")
},
new ChartEntry(3)
{
Label = "Overdue",
ValueLabel = "3000",
Color = SKColor.Parse("#F44336"), // Red
ValueLabelColor = SKColor.Parse("#F44336")
}
};
Document.Create(container =>
{
container.Page(page =>
{
page
.Content()
.Column(column =>
{
var titleStyle = TextStyle
.Default
.FontSize(20)
.SemiBold()
.FontColor(Colors.Blue.Medium);
column
.Item()
.Height(450)
.Width(560)
.Border(1)
.Canvas((canvas, size) =>
{
var chart = new DonutChart
{
Entries = entries,
AnimationProgress = 0,
Margin = 20,
LabelTextSize = 15,
IsAnimated = false,
AnimationDuration = default,
HoleRadius = 0.6f,
LabelMode = LabelMode.RightOnly,
GraphPosition = GraphPosition.AutoFill
};
chart.Draw(canvas, (int)size.Width, (int)size.Height);
});
});
});
}).ShowInPreviewer();