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

DateContinuousAxis Grid Labels

3 Answers 86 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
KA
Top achievements
Rank 1
KA asked on 29 Aug 2015, 03:43 PM

Hi

I would like to ask if there is an easy solution to create a grid on the x-axis of a datecontinuous axis.

e.g. every x second/minute/hour depending on the total timespan shown in the chart there will be a tick/grid line. independent if there exist a value for that specific datetime

 thanks for your help!

 

3 Answers, 1 is accepted

Sort by
0
Anna
Telerik team
answered on 01 Sep 2015, 12:23 PM
Hi Kumar,

You can check out the article on CartesianChartGrid and PolarChartGrid which has information and samples on how to include a grid into your plot area.

The default behavior of the DateTimeContinuous axis is to include ticks at even intervals independent of whether there exist a corresponding value in the view models for this date or not. If you would like to control this interval, you can use the MajorStep and the MajorStepUnit properties of the axis. For example if you would like to have a gridline/tick for each month, your xaml would look like this:

<telerik:DateTimeContinuousAxis LabelFitMode="MultiLine" MajorStepUnit="Month" MajorStep="1" LabelFormat="MMM yyyy"/>

I hope this helps.

Regards,
Anna
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
0
KA
Top achievements
Rank 1
answered on 05 Sep 2015, 10:10 AM

Hi Anna,

 thanks for your post

 I have a timebar connected to a chartview. ​Depending on the selected timespan in  the timebar the chartview is updated. The timebar can display up to years of sensordata which interval in 500 milliseconds. The data is sampled with chartdatasource. It is also possible to zoom into the timebar, which leads to more detailed representation of the data.

Now i would like to

1) always show a minimum count of labels

2) add annotations which show the timespan between the axis-ticks and if possible time elapsed after visiblerange.min

 

thanks

KA

 

I found a similar approach at here but there the

 

0
Petar Marchev
Telerik team
answered on 09 Sep 2015, 08:09 AM
Hello Kumar,


1) always show a minimum count of labels

As Anna explained earlier, you can use the MajorStepUnit and MajorStep properties of the axis. When you make a selection in the timebar, you need to take a look at the selected range and decide whether the step unit should be days, months, years or else. In the method in which you decide the step unit and the step, you can include logic so that a minimum number of labels is shown. For example if the selected range is 2.5 years and you require at least 5 labels, you should not use Year because it would leave you with two labels, you can use either Quarter or Month step unit.

2) add annotations which show the timespan between the axis-ticks and if possible time elapsed after visiblerange.min
I am a little unsure where you want to add this annotation. You can use the Annotations property of the chart if you need to add chart annotations. The chart annotations are usually some visuals in the plot area which emphasize data and so are data dependent. What you seem to need is not such an annotation, because it is not related to specific data.

You shouldn't have any problems with the content of this annotation - since you manually set the step unit and step, you know what is the distance between two ticks.

Regards,
Petar Marchev
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
KA
Top achievements
Rank 1
Answers by
Anna
Telerik team
KA
Top achievements
Rank 1
Petar Marchev
Telerik team
Share this question
or