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

RadChart Problem: Layout cycle detected. Layout could not complete.

3 Answers 26 Views
Chart
This is a migrated thread and some comments may be shown as answers.
NSP
Top achievements
Rank 1
NSP asked on 20 Mar 2014, 09:38 AM
Hi telerik,
Please help me solve this problem.
In my Silverlight 4 project, I have the exception "Layout cycle detected"
with different types of diagrams on large data.
For example the LineSeriesDefinition chart  throw the exeption on large data (300 items) . I have updated telerik dlls to the latest version of Silverlight 4, but it not help.
I can send a test project, if necessary.
Thanks for your replies

3 Answers, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 25 Mar 2014, 09:51 AM
Hi Ulf,

Note that the RadChart has many known issue and limitations. This is why we decide to create new charting components with better implementation and performance. The new RadChartView covers most of the features from the RadChart excluding the bubble series(which can be recreated with custom style) and all 3D series. You can read more about the differences between the controls in the RadChart vs. RadChartView help article. Generally I recommend using the chart view components instead the old chart. Please give it a try and let me know if you have any difficulties with your implementation.

Regards,
Martin
Telerik
 

Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

 
0
NSP
Top achievements
Rank 1
answered on 07 Apr 2014, 10:51 AM
Thank you Martin
Update to silverlight 5 solved the problem for the Chart control, but there was a problem with Telerik.Windows.Controls.DataTemplateSelector. In the new version Telerik.Windows.Controls.DataTemplateSelector is not inherited from DependencyObject. This code not build :
 
xaml.cs:
    public class HighlightDayTemplateSelector : Telerik.Windows.Controls.DataTemplateSelector
    {
        private static void OnAppointmentsSourceChanged(DependencyObject dp, DependencyPropertyChangedEventArgs e)
        {
        }

        public DataTemplate DayWithEventsTemplate
        {
            get { return (DataTemplate)GetValue(DayWithEventsTemplateProperty); }
            set { SetValue(DayWithEventsTemplateProperty, value); }
        }

        // Using a DependencyProperty as the backing store for DayWithEventsTemplate.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty DayWithEventsTemplateProperty =
            DependencyProperty.Register("DayWithEventsTemplate", typeof(DataTemplate), typeof(HighlightDayTemplateSelector), new PropertyMetadata(null));

        
        public DataTemplate EventlessDayTemplate
        {
            get { return (DataTemplate)GetValue(EventlessDayTemplateProperty); }
            set { SetValue(EventlessDayTemplateProperty, value); }
        }

        // Using a DependencyProperty as the backing store for EventlessDayTemplate.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty EventlessDayTemplateProperty =
            DependencyProperty.Register("EventlessDayTemplate", typeof(DataTemplate), typeof(HighlightDayTemplateSelector), new PropertyMetadata(null));



        public IEnumerable AppointmentsSource
        {
            get { return (IEnumerable)GetValue(AppointmentsSourceProperty); }
            set { SetValue(AppointmentsSourceProperty, value); }
        }

        // Using a DependencyProperty as the backing store for AppointmentsSource.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty AppointmentsSourceProperty =
            DependencyProperty.Register("AppointmentsSource", typeof(IEnumerable), typeof(HighlightDayTemplateSelector), new PropertyMetadata(null, OnAppointmentsSourceChanged));


        private static bool AreSameDays(DateTime dayA, DateTime dayB)
        {
            return
                dayA.Year == dayB.Year &&
                dayA.Month == dayB.Month &&
                dayA.Day == dayB.Day;
        }

        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {            
            Telerik.Windows.Controls.Calendar.CalendarButtonContent buttonContent = item as Telerik.Windows.Controls.Calendar.CalendarButtonContent;
            if (buttonContent != null && AppointmentsSource != null)
            {
                if (AppointmentsSource.OfType<IAppointment>().FirstOrDefault(t => AreSameDays(buttonContent.Date, t.Start)) != null)
                {
                    return DayWithEventsTemplate;
                }
            }

            return EventlessDayTemplate;
        }
    }
xaml:
 <telerik:RadCalendar.DayTemplateSelector>
                <views:HighlightDayTemplateSelector
                    AppointmentsSource="{Binding ReportRows}"                    
                    >
                    <views:HighlightDayTemplateSelector.DayWithEventsTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding}" FontWeight="Bold"/>
                        </DataTemplate>
                    </views:HighlightDayTemplateSelector.DayWithEventsTemplate>
                    <views:HighlightDayTemplateSelector.EventlessDayTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding}"/>
                        </DataTemplate>
                    </views:HighlightDayTemplateSelector.EventlessDayTemplate>
                </views:HighlightDayTemplateSelector>
            </telerik:RadCalendar.DayTemplateSelector>


What class should inherit HighlightDayTemplateSelector?


0
Martin Ivanov
Telerik team
answered on 10 Apr 2014, 11:01 AM
Hi Ulf,

Indeed, the DataTemplateSelector does not derive from the DependencyObject class and you cannot create dependency properties in it.

However, I can offer you an approach that you can use to achieve your requirement. In general, instead of defining dependency properties in your selector, you can create a helper class with attached properties. Then you can set the properties of your template selector in the OnPropertyChange callbacks of the attached properties.
public class TemplateSelectorParameters : DependencyObject
{
    .........
 
    public static readonly DependencyProperty AppointmentsSourceProperty =
        DependencyProperty.RegisterAttached(
        "AppointmentsSource",
        typeof(IEnumerable),
        typeof(TemplateSelectorParameters),
        new PropertyMetadata(null, OnAppointmentsSourcePropertyChanged));
 
    private static void OnAppointmentsSourcePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
    {
        RadCalendar calendar = (RadCalendar)d;
        HighlightDayTemplateSelector selector = (HighlightDayTemplateSelector)calendar.DayTemplateSelector;
        selector.AppointmentsSource = (IEnumerable)e.NewValue;
    }
}
<telerik:RadCalendar Name="calendar"local:TemplateSelectorParameters.AppointmentsSource="{Binding}" />

For your convenience I attached a sample project that demonstrates this approach. Please give it a try and let me know if it works for you.

Regards,
Martin
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Chart
Asked by
NSP
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
NSP
Top achievements
Rank 1
Share this question
or