Trying to force scatter chart to be square

3 posts, 0 answers
  1. andre king
    andre king avatar
    9 posts
    Member since:
    Sep 2009

    Posted 10 Nov 2010 Link to this post

    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. andre king
    andre king avatar
    9 posts
    Member since:
    Sep 2009

    Posted 11 Nov 2010 Link to this post

    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;
        }
    }
  3. Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 15 Nov 2010 Link to this post

    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
Back to Top