Skip to content

Commit 90384a5

Browse files
added section about fixed plotarea size
1 parent e05b061 commit 90384a5

File tree

3 files changed

+68
-2
lines changed

3 files changed

+68
-2
lines changed

controls/htmlchart/troubleshooting/common-issues.md

Lines changed: 68 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ This help article lists the most common issues one can face when using the **Rad
1717
1. [ XAxis labels are cluttered or overlapping. ](#xaxis-labels-are-cluttered-or-overlapping)
1818
1. [ YAxis is not rescaled in a stock chart when changing the selection range. ](#yaxis-is-not-rescaled-in-a-stock-chart-when-changing-the-selection-range)
1919
1. [ There is a redundant space between pie or donut chart and its legend. ](#there-is-a-redundant-space-between-pie-or-donut-chart-and-its-legend)
20+
1. [ PlotArea is Shrunk by the Legend / PlotArea Dimensions Depend on the Legend Size.](#plotarea-is-shrunk-by-the-legend--plotarea-dimensions-depend-on-the-legend-size)
2021
1. [ RadHtmlChart cannot be bound to a data source that has special characters in its field names. ](#radhtmlchart-cannot-be-bound-to-a-data-source-that-has-special-characters-in-its-field-names)
2122
1. [Chart with display: none does not show itself](#chart-with-display-none-does-not-show-itself)
2223

@@ -165,14 +166,79 @@ Solution: You can either offset the legend (see an example in the [ADD legend po
165166
</telerik:RadHtmlChart>
166167
````
167168

169+
## PlotArea is Shrunk by the Legend / PlotArea Dimensions Depend on the Legend Size
170+
171+
Generally, the size of the chart's elements including the PlotArea is dynamic, so that that all the elements can fit in with the chart's wrapper size. This, however, may leads to the following issues:
172+
173+
* Longer legend names will shrunk the PlotArea dimensions.
174+
175+
* Charts with similar dimensions and series but different legend size (e.g., the length of the legend items varies) will have different PlotArea size.
176+
177+
>caption Figure 2: Compare two charts with similar dimensions but different PlotArea size.
178+
179+
![htmlchart-troubleshooting-common-issues-plotarea-varying-size](images/htmlchart-troubleshooting-common-issues-plotarea-varying-size.png)
180+
181+
You can resolve these issue as follows:
182+
183+
1. Set enough margin between the PlotArea and the legend via the [PlotArea.Appearance.TextStyle.Margin property]({%slug htmlchart/appearance-and-styling/labels-and-titles-font-settings%}#setting-text-styles-for-titles-and-labels).
184+
185+
1. Define a custom position for the legend via the [Legend.Appearance.Position, OffsetX and OffsetY properties]({%slug htmlchart/appearance-and-styling/legend-settings%}#position-and-alignment).
186+
187+
>caption Figure 3: Compare two charts with similar size of their PlotArea and wrapper element.
188+
189+
![htmlchart-troubleshooting-common-issues-plotarea-fixed-size](images/htmlchart-troubleshooting-common-issues-plotarea-fixed-size.png)
190+
191+
>caption Example 3: Set a custom position for the legend in order to get a fixed PlotArea size.
192+
193+
````ASP.NET
194+
<telerik:RadHtmlChart runat="server" ID="PieChart1" Transitions="true" Width="750px" Height="400px">
195+
<Legend>
196+
<Appearance Position="Custom" OffsetX="450" OffsetY="150"></Appearance>
197+
</Legend>
198+
<PlotArea>
199+
<Appearance>
200+
<TextStyle Margin="0 250 0 0" />
201+
</Appearance>
202+
<Series>
203+
<telerik:PieSeries StartAngle="90">
204+
<SeriesItems>
205+
<telerik:PieSeriesItem BackgroundColor="#9de219" Exploded="true" Name="Asia" Y="18.3" />
206+
<telerik:PieSeriesItem BackgroundColor="#90cc38" Exploded="false" Name="Europe" Y="35.8" />
207+
<telerik:PieSeriesItem BackgroundColor="#068c35" Exploded="false" Name="Latin America America Americaaaaaaaa" Y="38.3" />
208+
</SeriesItems>
209+
</telerik:PieSeries>
210+
</Series>
211+
</PlotArea>
212+
</telerik:RadHtmlChart>
213+
<telerik:RadHtmlChart runat="server" ID="RadHtmlChart1" Transitions="true" Width="750px" Height="400px">
214+
<Legend>
215+
<Appearance Position="Custom" OffsetX="450" OffsetY="150"></Appearance>
216+
</Legend>
217+
<PlotArea>
218+
<Appearance>
219+
<TextStyle Margin="0 250 0 0" />
220+
</Appearance>
221+
<Series>
222+
<telerik:PieSeries StartAngle="90">
223+
<SeriesItems>
224+
<telerik:PieSeriesItem BackgroundColor="#9de219" Exploded="true" Name="Asia" Y="18.3" />
225+
<telerik:PieSeriesItem BackgroundColor="#90cc38" Exploded="false" Name="Europe" Y="35.8" />
226+
<telerik:PieSeriesItem BackgroundColor="#068c35" Exploded="false" Name="Latin America" Y="38.3" />
227+
</SeriesItems>
228+
</telerik:PieSeries>
229+
</Series>
230+
</PlotArea>
231+
</telerik:RadHtmlChart>
232+
````
233+
168234
## RadHtmlChart Cannot be Bound to a Data Source that Has Special Characters in Its Field Names
169235

170236
Solution: Special characters in data source field names are escaped by surrounding the name with quotes and brackets (see **Example 3**).
171237

172238
>caution There are invalid characters in data source field names which cannot be escaped like "(", ")", "[", "]", ".", "/", "\". More information is available in the [Datacolumn name illegal character](https://social.msdn.microsoft.com/Forums/en-US/e2a88f75-da11-49db-8ec8-ef3007a66d28/datacolumn-name-illegal-character) forum post.
173239
174240

175-
>caption Example 3: Escaping special characters in field names by surrounding the name with quotes and brackets.
241+
>caption Example 4: Escaping special characters in field names by surrounding the name with quotes and brackets.
176242
177243
````ASP.NET
178244
<telerik:RadHtmlChart runat="server" ID="ColumnChart" Width="600px" Height="400px">
@@ -233,7 +299,7 @@ This happens because the hidden container does not let the control evaluate its
233299

234300
To resolve this, call its `repaint` client-side method so the chart will redraw itself.
235301

236-
>caption Example 4: Showing an initially hidden chart.
302+
>caption Example 5: Showing an initially hidden chart.
237303
238304
````ASP.NET
239305
<script>
42 KB
Loading
38.1 KB
Loading

0 commit comments

Comments
 (0)