Skip to content

Commit 10cd42f

Browse files
KB BotTsvetomir-Hr
authored andcommitted
Added new kb article chart-remove-excess-whitespace
1 parent 6ec129a commit 10cd42f

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
---
2+
title: How to Reduce the Excessive WhiteSpace Around the Chart
3+
description: Learn how to adjust the padding and legend position of a Chart and remove unnecessary whitespace.
4+
type: how-to
5+
page_title: How to Reduce the Excessive WhiteSpace Around the Chart
6+
slug: chart-kb-remove-excess-whitespace
7+
tags: chart, padding
8+
res_type: kb
9+
ticketid: 1663179, 1559824
10+
---
11+
12+
## Environment
13+
14+
<table>
15+
<tbody>
16+
<tr>
17+
<td>Product</td>
18+
<td>Chart for Blazor</td>
19+
</tr>
20+
</tbody>
21+
</table>
22+
23+
## Description
24+
25+
This KB article answers the following questions:
26+
27+
- How to adjust the padding of a Chart in Blazor?
28+
- How to reduce whitespace around the Chart that is within a Telerik Card?
29+
- How to make the Chart more compact?
30+
31+
## Solution
32+
33+
To reduce the whitespace around a Chart, use the `Padding` parameter of the ChartSeries.
34+
35+
````CSHTML
36+
<TelerikCard Width="330px">
37+
<CardHeader>
38+
<CardTitle>Simple Pie Chart</CardTitle>
39+
</CardHeader>
40+
<CardBody>
41+
<TelerikChart Height="300px">
42+
<ChartSeriesItems>
43+
<ChartSeries Type="ChartSeriesType.Pie"
44+
Data="@pieData"
45+
Field="@nameof(MyPieChartModel.SegmentValue)"
46+
CategoryField="@nameof(MyPieChartModel.SegmentName)"
47+
Padding="5">
48+
</ChartSeries>
49+
</ChartSeriesItems>
50+
<ChartLegend Position="ChartLegendPosition.Bottom" Width="300">
51+
</ChartLegend>
52+
</TelerikChart>
53+
</CardBody>
54+
</TelerikCard>
55+
56+
@code {
57+
58+
private List<MyPieChartModel> pieData = new List<MyPieChartModel>
59+
{
60+
new MyPieChartModel
61+
{
62+
SegmentName = "Product 1",
63+
SegmentValue = 2
64+
},
65+
new MyPieChartModel
66+
{
67+
SegmentName = "Product 2",
68+
SegmentValue = 3
69+
},
70+
new MyPieChartModel
71+
{
72+
SegmentName = "Product 3",
73+
SegmentValue = 4
74+
}
75+
};
76+
public class MyPieChartModel
77+
{
78+
public string SegmentName { get; set; }
79+
public double SegmentValue { get; set; }
80+
}
81+
}
82+
````
83+
84+
## See Also
85+
86+
- [ChartSeries API Documentation](https://docs.telerik.com/blazor-ui/api/telerik.blazor.components.chartseries)
87+
- [Chart for Blazor Overview]({%slug components/chart/overview%})

0 commit comments

Comments
 (0)