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

Axis multiplier

3 Answers 66 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Alan
Top achievements
Rank 1
Alan asked on 16 Aug 2019, 03:49 PM

Hello,

I have a spline series on a cartesian graph, the y values can vary from -750000 to 1000000. I would like to display the labels as multiples of .0001 to save some screen space. I can't see a property to do it.

Thanks.

Alan

3 Answers, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 19 Aug 2019, 08:32 AM

Hello Alan,

If you use LinearAxis, you can try its MajorStep property. It allows you to define an interval between the generated ticks on the axis. For example, if you have a minimum of 0 on the axis and maximum of 10, a major step of 2, will generate ticks on 0, 2, 4, 6, 8 and 10.

Additionally, you can check the LogarithmicAxis and see if this would help.

If those suggestions are not helpful may I ask you send me a drawing of the expected result with the range you mentioned (-750000 and 1000000)?

Regards, Martin Ivanov
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Alan
Top achievements
Rank 1
answered on 19 Aug 2019, 03:08 PM

Hello,

MajorStep isn't what I'm looking for. Right now my graph looks like Graph1. I want it to look more like Graph2.

Thanks!

Alan

 

 

 

0
Martin Ivanov
Telerik team
answered on 20 Aug 2019, 09:43 AM

Hello Alan,

Thank you for the attached images. I think I understand your case better now.

To achieve this, you can use a couple of approaches. The first one is to alter your data before pass it to the chart. Instead, of populating the data points with values that range between -750000 and 1000000, you can multiply the values beforehand and provide values between 75 and 100.

The second approach is to use a custom template for the labels. You can do this via the LabelTemplate property of the axis. This way you can define a TextBlock element, bind it to the default label, and use an IValueConverter to return the multiplied value. Here is an example in code:

<telerik:LinearAxis.LabelTemplate>
	<DataTemplate>
		<TextBlock Text="{Binding Converter={StaticResource LabelConverter}}" />
	</DataTemplate>
</telerik:LinearAxis.LabelTemplate>

public class LabelConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var labelValue = double.Parse(value.ToString());
            return labelValue * 0.0001;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

Regards, Martin Ivanov
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
ChartView
Asked by
Alan
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Alan
Top achievements
Rank 1
Share this question
or