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

Time Bar binding to contained data

3 Answers 75 Views
TimeBar
This is a migrated thread and some comments may be shown as answers.
Eric
Top achievements
Rank 1
Eric asked on 17 Jul 2012, 12:53 AM
Hello,

I have a sparkline in a time bar, and I am looking to match the x values of the sparkline with the times of the timebar.  Currently, the first item in the sparkline is always shown at the start of the timebar, no matter if the times match or not.  Is there a way I can do this?

Thanks,
Eric

3 Answers, 1 is accepted

Sort by
0
Rosko
Telerik team
answered on 18 Jul 2012, 07:21 AM
Hi Eric,

To achieve the desired effect you need to set two properties: timeBar1.PeriodStart and timeBar1.PeriodEnd. For the first one, you have to set the same DateTime which comes in first in the ItemsSource of the SparkLine. For the other one, the last DateTime from the ItemsSource of the SparkLine. If the generic collection is sorted you can do something similar to the one in the code snippet below. I hope this helps.

timeBar1.PeriodStart = list.First().Date;
timeBar1.PeriodEnd = list.Last().Date;


Greetings,
Rosko
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Eric
Top achievements
Rank 1
answered on 18 Jul 2012, 04:47 PM
Hello,

What if I wanted to have two sparklines showing, one that occours from 10:00AM to 3:00PM and one from 11:00AM to 2:00PM, and I wanted to have them appear in the correct locations?  Or, for example, I wanted some white space on the side of the sparkline so it's easier to zoom in to the edges of the sparkline.

Thanks,
Eric
0
Rosko
Telerik team
answered on 19 Jul 2012, 07:56 AM
Hello Eric,

All of this can be achieved.

To have two SparkLines which do not start from different places in a TimeBar you need to set these three properties of SparkLine: AutoRange, MinXValue, MaxXValue.
sparkLine2.AutoRange = false;
sparkLine2.MinXValue = timeBar2.PeriodStart.Ticks;
sparkLine2.MaxXValue = timeBar2.PeriodEnd.Ticks;

To have some space on the sides, you need to extend the PeriodStart and PeriodEnd.
timeBar1.PeriodStart = list1.First().Date.AddDays(-0.1);
timeBar1.PeriodEnd = list1.Last().Date.AddDays(0.1);

You can see the attached sample project, where the desired behavior is demonstrated. I hope this meets your requirements.

Regards,
Rosko
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
TimeBar
Asked by
Eric
Top achievements
Rank 1
Answers by
Rosko
Telerik team
Eric
Top achievements
Rank 1
Share this question
or