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

How to customer different colors of series labels foreground.

1 Answer 79 Views
Chart
This is a migrated thread and some comments may be shown as answers.
John kang
Top achievements
Rank 2
John kang asked on 21 Jan 2014, 02:25 AM

hello...
I used RadChart of Bar Series..
I want to display different Series Label Text Foreground Color from own's Bar Color with transparent background.
How can I solve this... please advice to me...

attached files are before and after screen.

bellow code is source
----------------------------------------------------------
<chart:RadChart Grid.Row="0"
                                                x:Name="RadChart1"
                                                BorderThickness="0"
                                                ItemsSource="{Binding DFChartList}"
                                                SeriesMappings="{Binding DFSeriesMappings2}"
                                                LegendStyle="{StaticResource ChartLegendStyle}"
                                                Margin="10,-7,15,0"
                                                MinWidth="350" MinHeight="0" Height="240">
                                        <chart:RadChart.DefaultView>
                                        <charting:ChartDefaultView ChartLegendPosition="Bottom">
                                            <charting:ChartDefaultView.ChartArea>
                                                <charting:ChartArea LegendName="ChartLegend1" EnableAnimations="False" EnableTransitionAnimations="True"
                                                                    TransitionControlStyle="{StaticResource TransitionControlStyle}" LabelFormatBehavior="None">
                                                    <charting:ChartArea.AxisY>
                                                        <charting:AxisY AutoRange="False" MinValue="0" MaxValue="{Binding DFMaxValue}" Step="{Binding DFStepValue}"
                                                                           MinorTicksVisibility="Visible" MajorTicksVisibility="Visible" />
                                                    </charting:ChartArea.AxisY>
                                                </charting:ChartArea>
                                            </charting:ChartDefaultView.ChartArea>
                                            <charting:ChartDefaultView.ChartLegend>
                                                <charting:ChartLegend BorderThickness="0" Header="" x:Name="ChartLegend1" />
                                            </charting:ChartDefaultView.ChartLegend>
                                        </charting:ChartDefaultView>
                                    </chart:RadChart.DefaultView>
                                </chart:RadChart>
----------------------------------------------------------
XElement rootElement = e.Result;

                foreach (XElement rowEle in rootElement.Descendants("row"))
                {
                    String strCreateDate = rowEle.Attribute("createDate") != null ? rowEle.Attribute("createDate").Value : String.Empty;
                    DateTime dtCreateDate = new DateTime();
                    DateTime.TryParse(strCreateDate, out dtCreateDate);
                    strCreateDate = dtCreateDate.ToString("MM/dd");

                    ChartM StatAPIAnalChartM = new ChartM();
                    StatAPIAnalChartM.CreateDate = strCreateDate;
                    StatAPIAnalChartM.Type = "StaticAPIanalysis";
                    StatAPIAnalChartM.Count = 0;
                    StatAPIAnalChartM.ChartColor = new SolidColorBrush(Color.FromArgb(255, 106, 228, 92));

                    ChartM AppContReviewChartM = new ChartM();
                    AppContReviewChartM.CreateDate = strCreateDate;
                    AppContReviewChartM.Type = "Appl.ContentReview";
                    AppContReviewChartM.Count = 0;
                    AppContReviewChartM.ChartColor = new SolidColorBrush(Color.FromArgb(255, 119, 158, 232));

                    ChartM DynAPIAnalChartM = new ChartM();
                    DynAPIAnalChartM.CreateDate = strCreateDate;
                    DynAPIAnalChartM.Type = "DynamicAPIanalysis";
                    DynAPIAnalChartM.Count = 0;
                    DynAPIAnalChartM.ChartColor = new SolidColorBrush(Color.FromArgb(255, 242, 84, 144));

                    ChartM OthersChartM = new ChartM();
                    OthersChartM.CreateDate = strCreateDate;
                    OthersChartM.Type = "Others";
                    OthersChartM.Count = 0;
                    OthersChartM.ChartColor = new SolidColorBrush(Color.FromArgb(255, 148, 0, 211));

                    ChartM FncTestChartM = new ChartM();
                    FncTestChartM.CreateDate = strCreateDate;
                    FncTestChartM.Type = "FunctionalTest";
                    FncTestChartM.Count = 0;
                    FncTestChartM.ChartColor = new SolidColorBrush(Color.FromArgb(255, 170, 128, 0));
                    .
                    .
                    .
                    }

                    
                    this.DFChartList.Add(StatAPIAnalChartM);
                    this.DFChartList.Add(AppContReviewChartM);
                    this.DFChartList.Add(DynAPIAnalChartM);
                    this.DFChartList.Add(OthersChartM);
                    this.DFChartList.Add(FncTestChartM);

                    BindDFChart();
                }

----------------------------------------------------------
public void BindDFChart()
        {
            Style itemLabelStyle1 = new Style { TargetType = typeof(SeriesItemLabel) };
            itemLabelStyle1.Setters.Add(new Setter(SeriesItemLabel.ForegroundProperty, new SolidColorBrush(Color.FromArgb(255, 106, 228, 92))));
            itemLabelStyle1.Setters.Add(new Setter(SeriesItemLabel.FontWeightProperty, FontWeights.Bold));
            itemLabelStyle1.Setters.Add(new Setter { Property = SeriesItemLabel.FontWeightProperty, Value = FontWeights.Bold });
            itemLabelStyle1.Setters.Add(new Setter { Property = SeriesItemLabel.FillProperty, Value = new SolidColorBrush(Colors.Transparent) });

            BarSeriesDefinition definition1 = new BarSeriesDefinition();
            definition1.ShowItemToolTips = true;
            definition1.ShowItemLabels = true;
            definition1.LabelSettings.LabelDisplayMode = LabelDisplayMode.Outside;
            definition1.SeriesItemLabelStyle = itemLabelStyle1;

            SeriesMapping mapping1 = new SeriesMapping();
            mapping1.SeriesDefinition = definition1;
            mapping1.GroupingSettings.GroupDescriptors.Add(new ChartGroupDescriptor("Type"));
            mapping1.ItemMappings.Add(new ItemMapping("Count", DataPointMember.YValue));
            mapping1.ItemMappings.Add(new ItemMapping("CreateDate", DataPointMember.XCategory));

 

            SeriesMappingCollection mappings = new SeriesMappingCollection();
            mappings.Add(mapping1);
            this.DFSeriesMappings2 = mappings;
        }
----------------------------------------------------------

1 Answer, 1 is accepted

Sort by
0
Evgenia
Telerik team
answered on 24 Jan 2014, 09:22 AM
Hello Jun,

In the attached project I have replaced the Appearance API setters in the code behind with a declaration of StyleBuilderData object instance that holds the necessary colors and mappings in the UserControl.Resources (the key should be "StyleBuilderData" so the control can pick the correct resource up). If you use only line series definitions in your application, you can remove all commented lines, because they are necessary for other series. 

The main idea is that most of our themes [except the Expression Dark one] have White fill for the point marks, that cannot be changed through the PaletteBrushes functionality. That is why in the styles that overwrite the default ones I have changed the PointMarkStyle to use the main color for its fill: 

<telerik:StyleMappingCollection x:Key="PointMarkStyle">
    <telerik:StyleMapping Property="Stroke" SourceKey="main" />
    <telerik:StyleMapping Property="Fill" SourceKey="main" />
</telerik:StyleMappingCollection>

The main color is the one that can be modified  when using a custom palette.

I hope this helps.

Regards,
Evgenia
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
Chart
Asked by
John kang
Top achievements
Rank 2
Answers by
Evgenia
Telerik team
Share this question
or