RadChart with Bar not Calling Item Style Delegate

2 posts, 0 answers
  1. Jeremy
    Jeremy avatar
    3 posts
    Member since:
    Jul 2012

    Posted 10 Jun 2010 Link to this post

    I'm trying to style a stacked bar panel and running into some problems. The definition of the panel looks like this:

    <Controls:RadChart              
                x:Name="StatusChart"   
                HorizontalAlignment="Stretch"   
                HorizontalContentAlignment="Stretch"   
                ItemsSource="{Binding StatusCounts}">   
                <Controls:RadChart.DefaultView> 
                    <Charting:ChartDefaultView> 
                        <Charting:ChartDefaultView.ChartLegend> 
                            <Charting:ChartLegend Visibility="Collapsed"/>  
                        </Charting:ChartDefaultView.ChartLegend>    
                        <Charting:ChartDefaultView.ChartArea> 
                            <Charting:ChartArea  
                                EnableStripLinesAnimation="True" 
                                EnableAnimations="True" 
                                ItemWidthPercent="90"                              
                                HorizontalAlignment="Stretch"   
                                HorizontalContentAlignment="Stretch"/>  
                        </Charting:ChartDefaultView.ChartArea> 
                    </Charting:ChartDefaultView> 
                </Controls:RadChart.DefaultView> 
                <Controls:RadChart.SeriesMappings> 
                    <Charting:SeriesMapping> 
                        <Charting:SeriesMapping.SeriesDefinition> 
                            <Charting:Bar3DSeriesDefinition ShowItemLabels="True"/>  
                        </Charting:SeriesMapping.SeriesDefinition> 
                        <Charting:SeriesMapping.ItemMappings> 
                            <Charting:ItemMapping FieldName="Count" DataPointMember="YValue"/>  
                            <Charting:ItemMapping FieldName="StatusDescription" DataPointMember="XCategory"/>  
                        </Charting:SeriesMapping.ItemMappings> 
                    </Charting:SeriesMapping> 
                </Controls:RadChart.SeriesMappings> 
            </Controls:RadChart> 

    The StatusCounts is a IEnumerable<T> where T is an object that has the Count and StatusDescription fields. In the code behind, I do this:

    public StatusChartControl()  
            {  
                InitializeComponent();  
                StatusChart.CreateItemStyleDelegate = CreateItemStyle;  
            } 

    And then:

    public Style CreateItemStyle(Control control, Style baseStyle, DataPoint dataPoint, DataSeries dataSeries)  
    {  
        if (control is ChartLegendItem || dataPoint == null)  
        {  
            return baseStyle;  
        }  
                  
        // Create a new style, do not use the one that is provided as parameter.  
        var newStyle = new Style(baseStyle.TargetType) {BasedOn = baseStyle};  
     
        var brush = ((StatusCount) dataPoint.DataItem).Region.AsBrush();  
                  
        if (control is BaseChartItem2D)  
            newStyle.Setters.Add(new Setter(Shape.FillProperty, brush));  
     
        if (control is SeriesItemLabel)  
            newStyle.Setters.Add(new Setter(SeriesItemLabel.FillProperty, brush));  
     
        return newStyle;  
    }         

    The problem is ... the create item style is never called! I set a breakpoint and it never fires. The chart is rendering fine, I see axis labels and lables on the items, etc, but I never get the create item style delegate to fire so I can colorize the data items. Help!
  2. Dwight
    Admin
    Dwight avatar
    475 posts

    Posted 15 Jun 2010 Link to this post

    Hello Jeremy,

    The 3D chart does not support styling as this mechanism is available only for regular WPF/Silverlight controls (i.e. 2D scenarios).

    We plan on refactoring the whole WPF/Silverlight 3D chart in order to bring it to parity with the 2D chart.

    Best,
    Joshua
    the Telerik team

    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 Public Issue Tracking system and vote to affect the priority of the items.
Back to Top