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

Polar Chart, labeled degrees

1 Answer 14 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 04 Feb 2016, 10:14 PM

I need to make a polar chart that is not labeled 0 to360 but 0 to 180 and 0 to -150.  Any ideas on how I might do this?

I included an image of what I need in case it is not clear.

1 Answer, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 08 Feb 2016, 02:25 PM
Hi Mark,

The polar chart doesn't support such behavior. In order to achieve the desired result you can use the following approach:
  • Use GenericDataPointBinding<T> for the AngleBinding of the series. In its ValueSelector you can convert the negative values to positive ones in the range between 181 and 359 degrees. For example, -60 should become 300 and -150 should be 210.
  • Use a LabelTemplate and an IValueConverter to display the labels with the negative values. Basically, if the value in the label is bigger then 180, make the calculations and return a negative value. An example:
    <telerik:NumericRadialAxis>
        <telerik:NumericRadialAxis.LabelTemplate>
            <DataTemplate>
                <TextBlock Text="{Binding Converter={StaticResource angleConverter}}" />
            </DataTemplate>
        </telerik:NumericRadialAxis.LabelTemplate>
    </telerik:NumericRadialAxis>

    public class AngleConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var angle = (double)value;     
            return angle > 180 ?  -(360 - angle) : angle;
        }
     
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

I hope this information is useful.

Regards,
Martin
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
ChartView
Asked by
Mark
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Share this question
or