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

Axis advice

5 Answers 58 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
Iron
Iron
David asked on 13 Mar 2017, 04:38 PM

We're currently using RadHorizontalDataAxis for a media-scrubber-like application like so.

1.<telerik:RadHorizontalDataAxis x:Name="FrameAxis" Grid.Row="0" Panel.ZIndex="1"
2.                     Stroke="DarkRed" Foreground="Gray" SizeChanged="FrameAxis_SizeChanged"
3.                     Minimum="{Binding Path=FirstValue, Source={x:Static local:MyEditorViewModel.Instance}, Mode=OneWay}"
4.                     Maximum="{Binding Path=Duration, Source={x:Static local:MyEditorViewModel.Instance}, Mode=OneWay}"   />

 

The result looks like the attached image.  The mess at the end is because there is a tick mark at 12 and then at 12.00000048877 (the Duration, and a correct value).

1) I'd like the axis to be smarter about ticks marks near the end.  In this sample, either only showing 12 or only showing 12.00000048877 would be desirable, but not both.  It looks like ChartView.LinearAxis has a SmartLabelsMode property that can do what we want.  However, is LinearAxis usable in a loose fashion, that is, without a ChartView?  Basic attempts to use it by itself weren't successful.

1) For application-specific purposes, I'd like to have some different stops at the ends.  I'd like to see "Start" at the beginning, then 0 followed by some number of other autogenerated ticks, followed by "End" at the end.  So, in the example, I'd like to see axis labels of "Start, "0", "4", "8", "12", and "End".  This seems like a mixture of categorical labels and smart/data-driven labels.  Any options for this?

1) Is there a better axis we should be using?

 

We don't particularly need a ChartView, but I ask this here since ChartView seems to be where all the axes fall.  If there's a better forum in which to ask, please let me know.

 

5 Answers, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 16 Mar 2017, 03:03 PM
Hi David,

Thank you for contacting us.

We weren't able to reproduce the described behavior in your first question. That is why we would ask you to send us isolated project from your application reproducing it so we can further investigate it directly on our side.

As for your second question about RadHorizontalDataAxis showing a mixture of categorical labels is not supported by the control. Basically, this is a numeric axis and can't be customized to show a mixture of categorical labels.

As for your last question, we would ask you to elaborate more on your scenario. What are you trying to visualize/show/display in the application so we can give you a proper suggestion?

Regards,
Dinko
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
David
Top achievements
Rank 1
Iron
Iron
answered on 20 Mar 2017, 10:09 PM

Hi Dinko,

Thanks for the reply!

In regards to an example for RadHorizontalDataAxis, please see the attached project (Note:  I was unable to attach a zip file of the visual-studio project.  How can I provide you with an example?).  Note that in the middle of the string "12.123456789", there is some visual clutter in about the middle of the text.  That is the tick mark at 12.

In regards to my last question, here's my example:  say I desire an axis to cover a data range of 0 to 12.123456789, for instance.  The axis will be displayed horizontally.  I want to display a tick mark on the far left of the axis with the word "Start".  I want to display a tick mark on the far right of the axis with the word "End".  I'd like to axis to be clever enough to place tick marks with numbers at some reasonable collection of number, say, 0, 4, 8, and 12.  I'm less concerned about exactly which numbers it picks than that I can put "Start" on the left and "End" on the right.  I want "Start" separate from "0" and "End" separate from whatever the rightmost tick mark might be.  I would like to limit the axis to tick marks and displayed numbers only at whole-number values.  Can you recommend a control for this, please?

 

0
David
Top achievements
Rank 1
Iron
Iron
answered on 20 Mar 2017, 10:11 PM
Also, we are using a moderately old library version, 2015.1.406.40.
0
David
Top achievements
Rank 1
Iron
Iron
answered on 21 Mar 2017, 10:05 PM

here's the simple xaml that shows the first issue

 

<Window x:Class="RadHorizontalDataAxis.MainWindow"
        xmlns:local="clr-namespace:RadHorizontalDataAxis"
        Title="MainWindow" Height="350" Width="525">
    <Grid Margin="60">
        <telerik:RadHorizontalDataAxis x:Name="FrameAxis"
                                       Stroke="DarkRed" Foreground="Gray"
                                       Minimum="0"
                                       Maximum="12.123456789"
                                       />
    </Grid>
</Window>
0
Martin Ivanov
Telerik team
answered on 23 Mar 2017, 04:15 PM
Hello David,

I think the RadChartView axes would be most convenient for your case. However, they cannot be used separately from the chart. So, to use them you should also declare a chart and populate it with data.

About the RadHorizontalDataAxis control, I checked your code and I reproduce the reported behavior. This appears because the calculation of the step between the ticks is not very precise. And if you have some floating number set as Maximum, the step might be calculated so that it is not very convenient. 

In your case, the automatically calculated step is 4. So, a tick will be placed on each value multiple of 4. Those are 0, 4, 8, 12. According to the step the next value should be 16, but the maximum is 12.123456789. In this case, the axis will draw the last tick at its maximum. This is why you see two ticks that are very close in position.

In order to resolve this you can manually calculate the step and set it to the Step property the RadHorizontalDataAxis control. For example:
double range = FrameAxis.Maximum - FrameAxis.Minimum;
int desiredTicksCount = 5;
double step = range / desiredTicksCount;
FrameAxis.Step = step;

About extending both ends of the axis with string values, as Dinko mentioned, this is not supported. However, you can achieve such visualization using some custom code. For example, you can draw custom line with a Path element that is placed on both sides of the data axis control. 

Additionally, if you send a drawing of the end result which you are expecting (the axis along the related data) I can think if there is another control that could be more suitable for your case.

Regards,
Martin
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
ChartView
Asked by
David
Top achievements
Rank 1
Iron
Iron
Answers by
Dinko | Tech Support Engineer
Telerik team
David
Top achievements
Rank 1
Iron
Iron
Martin Ivanov
Telerik team
Share this question
or