Style of a point

6 posts, 1 answers
  1. Peter
    Peter avatar
    6 posts
    Member since:
    Aug 2013

    Posted 07 Feb 2015 Link to this post

    Hi,

    I would like to control the style of a point of the RangeSelector when the AssociatedControl is a ChartView.

    There's an example available how to do this on a regular ChartView (at http://www.telerik.com/forums/scatter-points-with-different-color-symbol-and-size), but I can't get this to work on a ChartView in a RangeSelector.

    In have tried for example to implement an event with:
    RangeSelectorViewElement rangeChartElement = ((RangeSelectorViewElement)this.radRangeSelector1.RangeSelectorElement.AssociatedElement);
    rangeChartElement.LabelFormatting += this.rangeChartElement_LabelFormatting;

    but it isn't being called (and I made sure ShowLabels = true).

    Could you please help me?

    Regards,

    Peter
  2. Dimitar
    Admin
    Dimitar avatar
    1404 posts

    Posted 10 Feb 2015 Link to this post

    Hi Peter,

    Thank you for writing.

    After the chart is associated with the range selector the series are recreated and you need to set the ShowLabels property again:
    radRangeSelector1.AssociatedControl = radChartView1;
     
    var rangeChart = radRangeSelector1.RangeSelectorElement.AssociatedElement as RangeSelectorViewElement;
    rangeChart.LabelFormatting += View_LabelFormatting;
    foreach (var item in rangeChart.View.Series)
    {
        item.ShowLabels = true;
    }

    I hope this helps. Should you have any other questions do not hesitate to ask.
     
    Regards,
    Dimitar
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Peter
    Peter avatar
    6 posts
    Member since:
    Aug 2013

    Posted 10 Feb 2015 in reply to Dimitar Link to this post

    Hi Dimitar,

    Thanks for your response.

    When I apply your code, the method View_LabelFormatting never gets called.

    To make sure I'm not causing this myself I also tried this in the ExamplesCSVS2010 solution on both FirstLook and MSFTStocks example (see code below). Am I still missing something or am I running into an issue?

    namespace Telerik.Examples.WinControls.RangeSelector.FirstLook
    {
        public partial class Form1 : ExamplesForm
        {
            public Form1()
            {
                InitializeComponent();

                (this.radRangeSlider1.RangeSelectorElement.AssociatedElement as RangeSelectorViewElement).ScalesPosition = ViewPosition.BottomRight;

                this.radChartView1.View.Margin = new Padding(0);
                var rangeChart = radRangeSlider1.RangeSelectorElement.AssociatedElement as RangeSelectorViewElement;
                rangeChart.LabelFormatting += View_LabelFormatting;
                foreach (var item in rangeChart.View.Series)
                {
                    item.ShowLabels = true;
                }
            }

            private void View_LabelFormatting(object sender, ChartViewLabelFormattingEventArgs e)
            {
                MessageBox.Show("This should popup for every datapoint");
            }
        }
    }


  5. Dimitar
    Admin
    Dimitar avatar
    1404 posts

    Posted 11 Feb 2015 Link to this post

    Hello Peter,

    Thank you for writing back.

    This works fine on my side. I have attached a small sample project where you can see that the points are displayed.

    I hope this helps.

    Regards,
    Dimitar
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  6. Peter
    Peter avatar
    6 posts
    Member since:
    Aug 2013

    Posted 12 Feb 2015 in reply to Dimitar Link to this post

    Thanks Dimitar,

    Your example works indeed. I'm sorry to bother you again, but I still having a problem to get it working in my "specific" situation.

    In my case I initialize the series, add them to ChartView and assign the Chart to the AssociatedControl of the RangeSelector.

    Why doesn't the LabelFormatting work if assigned directly after initializing the series and RangeSelector?

    If I move the assignment of LabelFormatting in your example to the Form constructor the event never gets called.

    Kind regards,

    Peter
  7. Answer
    Dimitar
    Admin
    Dimitar avatar
    1404 posts

    Posted 16 Feb 2015 Link to this post

    Hello Peter,

    Thank you for writing back.

    You must subscribe to the event after the AssociatedControl property of the range selector is set because when this property is set the RangeSelectorViewElement and the series in the range selector will be recreated (new instances for these objects will be created). This will reset any existing subscriptions or properties. This is why you should use the approach I have given you.

    I hope this information helps. 

    Regards,
    Dimitar
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top
UI for WinForms is Visual Studio 2017 Ready