Range Selector Label Formatting

3 posts, 0 answers
  1. Craig
    Craig avatar
    4 posts
    Member since:
    Oct 2010

    Posted 27 Jan 2014 Link to this post

    I have just started using the Range Selector linked to a Chart View with a Date Time Categorical axis. My issue is that I cannot seem to find the formatting setting for the date label in the Range Selector. 

    Can you please help?
  2. Craig
    Craig avatar
    4 posts
    Member since:
    Oct 2010

    Posted 27 Jan 2014 in reply to Craig Link to this post

    Also, how do I synchronise the palette between the Chart View and the Range Selector?
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 30 Jan 2014 Link to this post

    Hi Craig,

    Thank you for writing. 

    You can use the LabelInitializing event of the AssociatedElement to access and format the labels:
    ((RangeSelectorViewElement)radRangeSelector1.RangeSelectorElement.AssociatedElement).LabelInitializing += new LabelInitializingEventHandler(RangeSelectorViewElement_LabelInitializing);
     
    private void RangeSelectorViewElement_LabelInitializing(object sender, LabelInitializingEventArgs e)
    {
        DateTime date = DateTime.Parse(e.LabelElement.Text);
        e.LabelElement.Text = string.Format("{0:MM yyyy}", date);
        e.LabelElement.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
        e.LabelElement.AngleTransform = 45;
    }

    As to the palette, here is how to access the chart element in RadRangeSelector and set its palette. The best place to do that is the Form.Load event:
    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
     
        RangeSelectorViewElement rangeChart = ((RangeSelectorViewElement)radRangeSelector1.RangeSelectorElement.AssociatedElement);
        rangeChart.View.Series[0].Palette = KnownPalette.Metro.GlobalEntries[0];
    }

    I hope this helps. 

    Regards,
    Stefan
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - APPLICATION ANALYTICS for WINFORMS.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top