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

Style of a point

5 Answers 55 Views
RangeSelector
This is a migrated thread and some comments may be shown as answers.
Peter
Top achievements
Rank 1
Peter asked on 07 Feb 2015, 10:53 PM
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

5 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 10 Feb 2015, 04:36 PM
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.

 
0
Peter
Top achievements
Rank 1
answered on 10 Feb 2015, 11:32 PM
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");
        }
    }
}


0
Dimitar
Telerik team
answered on 11 Feb 2015, 04:51 PM
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.

 
0
Peter
Top achievements
Rank 1
answered on 12 Feb 2015, 08:48 PM
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
0
Accepted
Dimitar
Telerik team
answered on 16 Feb 2015, 02:52 PM
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.

 
Tags
RangeSelector
Asked by
Peter
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Peter
Top achievements
Rank 1
Share this question
or