This is a migrated thread and some comments may be shown as answers.

Trying to force scatter chart to be square

2 Answers 45 Views
Chart
This is a migrated thread and some comments may be shown as answers.
andre king
Top achievements
Rank 1
andre king asked on 10 Nov 2010, 10:55 PM
Hi,
I need to maintain a 1:1 ratio between the screen size of the x and y axiis of the scatter chart.
I tried Pete Brown's general approach (http://10rem.net/blog/2009/01/09/creating-a-silverlight-control-that-stays-square) of extending RadChart and overriding the Measure and Arrange methods but the chart did not render properly (I also tried dropping it as content in his SquareContainer and got the same result). This would also make the entire chart square - I only want the chartarea to be square.
Do you have any suggestions?
thanks for your time,
andre

2 Answers, 1 is accepted

Sort by
0
andre king
Top achievements
Rank 1
answered on 11 Nov 2010, 06:35 PM

This is what I came up with so far. It does what I need. Please comment if there is a better way.
Thanks,
a

public class MyRadChart: RadChart
{
    public MyRadChart()
    {
        this.DefaultView.ChartArea.LayoutUpdated += new EventHandler(ChartArea_LayoutUpdated);            
    }
    void ChartArea_LayoutUpdated(object sender, EventArgs e)
    {
        double dim = Math.Min(this.ActualHeight, this.ActualWidth);
        this.DefaultView.ChartArea.Height = dim;
        this.DefaultView.ChartArea.Width = dim;
    }
}
0
Yavor
Telerik team
answered on 15 Nov 2010, 11:01 AM
Hello andre,

The approach which you have chosen is a good one, and the code seems optimal.
You can safely use it in your application.

Kind regards,
Yavor
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Chart
Asked by
andre king
Top achievements
Rank 1
Answers by
andre king
Top achievements
Rank 1
Yavor
Telerik team
Share this question
or