Telerik Forums
UI for Silverlight Forum
11 answers
157 views
I'm creating the columns in a RadGridView by code:

this.radGridView.Columns.Add(new SparkLineColumn()
                                                            {
                                                                UniqueName = column.ColumnName,
                                                                Header = CommonTranslations.ResourceManager.GetString(column.LabelKey),
                                                                DataMemberBinding = new Binding(string.Format(BINDING_STRING, index)),
                                                                Width = column.Width,
                                                                IsSortable = column.IsSortable,
                                                                IsFilterable = column.IsFilterable
                                                            }
                                                        );            

And I have the class:

public class SparkLineColumn : GridViewDataColumn
{

        public override FrameworkElement CreateCellElement(GridViewCell cell, object dataItem)
        {
            line = new RadLinearSparkline();

            Random r = new Random();
            List<double> myData = new List<double>();

            for (int i = 0; i < 20; i++)
            {
                myData.Add(r.Next(0, 100));
            }
            line.ItemsSource = myData;

            return line;
        }
}

But the RadGridView columns doesn't show the graph,
I can show Buttons and RadChart, but SparkLine......

I have been testing with
q2 2012
        q1 2013

Thanks

Danail Vasilev
Telerik team
 answered on 29 Jul 2014
8 answers
126 views

    Hi, I want to have RadTimeBar with different kind of content. So I have the following xaml (part of the user control):

<telerik:RadTimeBar Margin="3" x:Name="Timebar"
                           IsEnabled="{Binding IsTimeSelectionEnabled}"
                           Grid.Row="1"  VerticalAlignment="Top"
                           Height="90"
                           HorizontalAlignment="Stretch"                           
                           PeriodStart="{Binding PeriodStart, Mode=TwoWay}"
                           PeriodEnd="{Binding PeriodEnd, Mode=TwoWay}"
                           VisiblePeriodStart="{Binding VisiblePeriodStart, Mode=TwoWay}"
                           VisiblePeriodEnd="{Binding VisiblePeriodEnd, Mode=TwoWay}"
                           SelectionStart="{Binding SelectionStart, Mode=TwoWay}"
                           SelectionEnd="{Binding SelectionEnd, Mode=TwoWay}"
                           >
 
           <i:Interaction.Triggers>
               <i:EventTrigger EventName="SelectionChanged">
                   <i:InvokeCommandAction Command="{Binding ApplyPeriodCommand}"/>
               </i:EventTrigger>
           </i:Interaction.Triggers>
           <telerik:RadTimeBar.Intervals>
               <telerik:MonthInterval />
               <telerik:WeekInterval />
               <telerik:DayInterval />
               <telerik:HourInterval/>
           </telerik:RadTimeBar.Intervals>
 
      
       </telerik:RadTimeBar>



The content is set as follows in the code behind:

public FrameworkElement TimeBarContent
       {
           get { return this.Timebar.Content as FrameworkElement; }
           set
           {
               this.Timebar.Content = value;        
           }
       }
 
       public TimeLineControl()
       {
           InitializeComponent();
           this.DataContextChanged += TimeLineControl_DataContextChanged;
       }
 
       void TimeLineControl_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
       {
           if (this.TimeBarContent == null) return;
           var timeLineViewModel = e.NewValue as TimeLineViewModel;
           if (timeLineViewModel != null)
               this.TimeBarContent.DataContext = timeLineViewModel.TimeBarContentDataContext;
       }



The SparkLine control, which is set as content of time line is:

<UserControl x:Class="Wave.Platform.PortalFramework.Infrastructure.Controls.Views.SparkLineControl"
             xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.DataVisualization"
             xmlns:viewModels="clr-namespace:Wave.Platform.PortalFramework.Infrastructure.Controls.ViewModels"
             mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">
 
    <d:DesignData.DataContext>
        <viewModels:SparklineControlViewModel/>
    </d:DesignData.DataContext>
 
    <telerik:RadColumnSparkline Name="SparkLine" ItemsSource="{Binding SparklineData}"
                                                    Margin="0,0,0,5"
                                                    ColumnWidthPercent="0.8"
                                                    XValuePath="Moment"
                                                    YValuePath="Value"      
                                                    MaxYValue="{Binding Maximum}"
                                                    AutoRange="False" />
</UserControl>




The view model of the sparkline is as follows

[Export]
   [PartCreationPolicy(CreationPolicy.NonShared)]
   public class SparklineControlViewModel : NotificationObject, ITimeBarContentDataContext
   {
       private double _maximum;
       public double Maximum
       {
           get { return _maximum; }
           private set
           {
               _maximum = value;
               RaisePropertyChanged(()=>this.Maximum);
           }
       }
 
       private TimeSpan _groupingTimeSpan;
       public TimeSpan GroupingTimeSpan
       {
           get { return _groupingTimeSpan; }
           set
           {
               _groupingTimeSpan = value;
               RaisePropertyChanged(() => this.GroupingTimeSpan);
           }
       }
 
       private ObservableCollection<ColumnSparklineVM> _sparklineData = new ObservableCollection<ColumnSparklineVM>();
       public ObservableCollection<ColumnSparklineVM> SparklineData
       {
           get { return _sparklineData; }
           private set
           {
               _sparklineData = value;
               RaisePropertyChanged(()=>this.SparklineData);
           }
       }
 
       public SparklineControlViewModel()
       {
            
       }
 
       public void SetData(IEnumerable<IDataWithMoment> data)
       {
           this.SparklineData.Clear();
           var dataWithMoments = data as IList<IDataWithMoment> ?? data.ToList();
           if (!dataWithMoments.Any()) return;
           var groupedTimes = dataWithMoments.GroupBy(dt => dt.Moment.Ticks/this.GroupingTimeSpan.Ticks);
           this.SparklineData = groupedTimes.Select(g => new ColumnSparklineVM() { Moment = new DateTime(g.Key * GroupingTimeSpan.Ticks), Value = g.Count() }).ToObservable();
           SetMaximum();
       }
 
       public void SetData(IEnumerable<ColumnSparklineVM> data)
       {
           this.SparklineData = data.ToObservable();
           SetMaximum();
       }
 
       private void SetMaximum()
       {
           this.Maximum = Math.Max(Maximum, SparklineData.Max(s => s.Value));
       }
 
   }
 
   public class ColumnSparklineVM : NotificationObject
   {
       private double _value;
       public double Value
       {
           get { return _value; }
           set
           {
               _value = value;
               RaisePropertyChanged(()=>this.Value);
           }
       }
 
       private DateTime _moment;
       public DateTime Moment
       {
           get { return _moment; }
           set
           {
               _moment = value;
               RaisePropertyChanged(()=>this.Moment);
           }
       }
   }
 
   public interface IDataWithMoment
   {
       DateTime Moment { get; }
   }


Add some test data are inserted this way:

if (SparklineControlViewModel != null)
            {
                for (int i = 0; i < 1000; i++)
                {
                    ReportsBasic.Add(new DetailedReportBasic(){FirstLogicCause = new LogicCause(){ActivatedUtc = DateTime.Now.AddMinutes(-i)}});
                }
                SparklineControlViewModel.SetData(this.ReportsBasic);
            }


The TimeSpan of is set to One hour , wo when grouped the passed data to SetData() method create 17 SparklineData objects with moments - 17 hours which are added to the ItemsSource of the SparkLine control. However the columns drawn seems to be with completely different timestamps as you can see on the attached screen shot - the 17 columns spread for several days each...

Please tell me what am I missing? I guess it is some king syncronisation between the sparkline and the timebar, but no such is needed in some of the samples I can see in the telerik demos...  

Thank you in advance for your help!

Pavel R. Pavlov
Telerik team
 answered on 02 Jun 2014
5 answers
108 views
Hello,
I was having detail iussue on large adta with timebar & radchart... using RadLinearSparkLines I achieve a better deep detail.
I wish to know if it's possible to add 2 horizontal lines for a limit and a warning as I was doing with annotations in radchart.


Thanks
Martin Ivanov
Telerik team
 answered on 28 Apr 2014
4 answers
150 views
Hi,

 I am trying to use customised theme for sparkline chart using the telerik approach.I am able to cusomise the slider by following the steps specified in the link http://www.telerik.com/help/silverlight/common-styling-apperance-themes-custom-theme-project-telerik-approach.html

but dont know why sparkline chart is not getting reflected with the customised theme.

Any help will be much appreciated
Peshito
Telerik team
 answered on 26 Aug 2013
5 answers
62 views
Hello,
I've encountered a strange behaviour when using RadLinearSparkline inside a RadTimeBar. The sparkline displays correctly until I change RadTimeBars VisiblePeriodEnd or VisiblePeriodStart. In the beginning the sparkline scales well but somewhere around half visibleperiod the sparkline disapperas but not the high and low points.

See the following link for example: https://dl.dropbox.com/u/435313/sparkline.png

Anyone knows why?

Regards, Clas Ericson
Clas Ericson
Top achievements
Rank 2
 answered on 09 Oct 2012
1 answer
53 views
Hi,

I have a RadLinearSparkLine control within a DataGridTemplateColumn of my DataGrid. After I scroll, the markers on the RadLinearSparkline seem to jump around to random spots (please see attached screenshots). How do I prevent this from happening?

  <sdk:DataGridTemplateColumn Width="Auto" MinWidth="100" CanUserReorder="False" CanUserResize="True" CanUserSort="False">
          <sdk:DataGridTemplateColumn.CellTemplate>
            <DataTemplate>
                <telerik:RadLinearSparkline MinWidth="90" Height="20" Margin="5,4"
                                            ItemsSource="{Binding Uptake}"
                                            ShowMarkers="True" LineStroke="{Binding UptakeBrush}"
                                            AutoRange="False" MinYValue="0">
                </telerik:RadLinearSparkline>
            </DataTemplate>
          </sdk:DataGridTemplateColumn.CellTemplate>
        </sdk:DataGridTemplateColumn>

Kind regards,
Chris
Yavor
Telerik team
 answered on 09 Jul 2012
2 answers
129 views
Hi,

Is the following possible:

I'd like to add multiple horizontal RadLinearSparkLines to my RadTimeBar.
The width of each line is determined by an end date and a start date on the X-axis.
The Y-axis is only used to position the different RadLinearSparkLines 
When you zoom in or out in the RadTimeBar, the RadLinearSparkLines should grow/shrink accordingly (keeping them between the end date and start date).

Possible or not?

Greetings,
Ben


Tsvetie
Telerik team
 answered on 18 Jun 2012
1 answer
29 views
I have searched and could not find a demo/how to for taking a single table, generate entity, add domain service, add sparkline and add a RadDomainDataSource to set x and y value paths. I would think this could be done...but have not found anything. Any help would be greatly appreciated!
Best regards,
Hank
Yavor
Telerik team
 answered on 21 May 2012
1 answer
56 views
Hello,

I'm interested to know if anybody has encountered the following error when adjusting the selected dates on a RadTimeBar that contains a RadSparkLine?

{System.NullReferenceException: Object reference not set to an instance of an object.
at Telerik.Windows.Controls.Sparklines.DataPointsCollectionView.OnItemPropertyChanged(Object sender, PropertyChangedEventArgs e)}

I have yet to determine the exact scenario that causes the problem but will post more if I find it.
Vladimir Milev
Telerik team
 answered on 19 Jan 2012
1 answer
50 views
Hi , 
 We are using Q1 2011 version of RAD silver light controls.
 
We used this COntrol inside the Timebar control and provide the required Data as

Time Bar - Period start and End date(Jan-1-2009 to Jan-1-2012)
Time Bar - VisiblePeriod start and End date(Jan-1-2009 to Jan-1-2012)


Provided the item source for RadColumnSparkline List of Name and Value for binding for all the dates from Start to end. 
eg. My values will be 0 or 1 , so i have set 1 to First of every month(Jan , Feb etc for all the 3 yrs) and rest of the values as 0. 
I.e [Only one day in month will be having the value as 1 all the others will be zero]

But in the initial load , the column sparkline is not visible, with the same data if i zoom in then the sparkline is visible.
Also if i set 1 to 2nd of every month , then the same is visible?

Is it because of the older version we are using.



Thanks 
B.Balaji
Yavor
Telerik team
 answered on 12 Dec 2011
Top users last month
horváth
Top achievements
Rank 2
Iron
Iron
Steve
Top achievements
Rank 2
Iron
Erkki
Top achievements
Rank 1
Iron
Mark
Top achievements
Rank 2
Iron
Iron
Veteran
Jakub
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?