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

RadChart with Bar not Calling Item Style Delegate

1 Answer 44 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Jeremy
Top achievements
Rank 1
Jeremy asked on 10 Jun 2010, 03:46 PM
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!

1 Answer, 1 is accepted

Sort by
0
Dwight
Telerik team
answered on 15 Jun 2010, 02:42 PM
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.
Tags
Chart
Asked by
Jeremy
Top achievements
Rank 1
Answers by
Dwight
Telerik team
Share this question
or