I have RadChart in my application. In X axis there is description & Y axis it displays only positive value related that description. I have set height & width of RadChart. Currently there is only 15 different types of description in X-axis & some value is related to that description. Now my problem is that, Value of x axis is dynamic so that when it increases, related number displays in Y-axis gets overlapped.
How to solve this problem? Is there any way to set height & width dynamically based on number of record?
5 Answers, 1 is accepted
In short, no, there is no way to set the Width and Height of the chart, relative to the number of items in the x and y axes. I can suggest two things in your case:
- You can use the LabelAppearance settings to rotate the labels of the axes.
- You can calculate the Width and Height values for the chart dynamically, based on the generated number of axis items. You can use the PrePaint event of the chart to do this.
All the best,
Tsvetie
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>
Just a quick followup. Regarding my first suggestion - please refer to this online demo, it will give a quick overview of the label rotation feature.
Regards,
Tsvetie
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>
Dim
plotAreaHeight
As
Integer
= XItemCount * 25
plotAreaHeight += RadChart1.Chart.Appearance.Dimensions.Margins.Top.Value
plotAreaHeight += RadChart1.Chart.Appearance.Dimensions.Margins.Bottom.Value
plotAreaHeight += RadChart1.Chart.Appearance.Dimensions.Paddings.Top.Value
plotAreaHeight += RadChart1.Chart.Appearance.Dimensions.Paddings.Bottom.Value
plotAreaHeight += RadChart1.Chart.ChartTitle.Appearance.Dimensions.Margins.Top.Value
plotAreaHeight += RadChart1.Chart.ChartTitle.Appearance.Dimensions.Margins.Bottom.Value
plotAreaHeight += RadChart1.Chart.ChartTitle.Appearance.Dimensions.Paddings.Top.Value
plotAreaHeight += RadChart1.Chart.ChartTitle.Appearance.Dimensions.Paddings.Bottom.Value
plotAreaHeight += RadChart1.Chart.PlotArea.Appearance.Dimensions.Margins.Top.Value
plotAreaHeight += RadChart1.Chart.PlotArea.Appearance.Dimensions.Margins.Bottom.Value
plotAreaHeight += RadChart1.Chart.PlotArea.Appearance.Dimensions.Paddings.Top.Value
plotAreaHeight += RadChart1.Chart.PlotArea.Appearance.Dimensions.Paddings.Bottom.Value
plotAreaHeight += RadChart1.Chart.ChartTitle.Appearance.Dimensions.Height.Value
RadChart1.Height = Unit.Pixel(plotAreaHeight)
Attached is a sample output:
Indeed, you are correct. You can use the PrePaint event to get the calculated margin, padding and title height values, but you cannot change the height of the chart control at this point in the lifecycle. You can use the DataBound or PreRender events to change the height of the chart, based on the number of items. However, please note, at this point the margin, padding and title height values are not calculated yet. You can use a fixed value for these and calculate the height of the chart based on that fixed value and the number of items in the chart.
Regards,Tsvetie
Telerik
I have created a thread asking for help on this matter here:
http://www.telerik.com/community/forums/aspnet-ajax/chart/controlling-the-chart-appearance.aspx