views:

816

answers:

1

Hy,

I have a chart,wich is created in runtime,this could be Line, Bar or Pie type.

Basically what i want is to have more contrast on the lines on the chart,this means i should use different colors on the lines.

For Bar chart i use the StylePalette property to set wich colors will used in the chart,and it's working fine,but for Line it has no effect.

As a Line chart i tried this: For the line i want to use lets say 2 colors.

    Style style = new Style(typeof(Control));
     Setter st = new Setter(Control.ForegroundProperty, new SolidColorBrush(Colors.Red));
     style.Setters.Add(st);
     Style style2 = new Style(typeof(Control));
Setter st2 = new Setter(Control.ForegroundProperty, new SolidColorBrush(Colors.Green));
                style2.Setters.Add(st2);

                StylePalette palette = new StylePalette();
                palette.Add(style);
                palette.Add(style2);

                m_oChart.StylePalette = palette;

And this in the xaml file:

<chartingToolkit:Chart x:Name="m_oChart" Style="{StaticResource ChartStyleLegendBottom}" d:IsHidden="True">
                    <chartingToolkit:Chart.StylePalette>
                        <visualizationToolkit:StylePalette>
                            <Style TargetType="Control">
                                <Setter Property="Background" Value="Gray"/>
                            </Style>
                            <Style TargetType="Control">
                                <Setter Property="Background" Value="Black"/>
                            </Style>
                        </visualizationToolkit:StylePalette>
                    </chartingToolkit:Chart.StylePalette>
                </chartingToolkit:Chart>

Note that i tried for Background and Foreground propertys too both on the xaml and codebehind side.

I've done this according to this link:

http://forums.silverlight.net/forums/t/58894.aspx

Basically what i want is to have more contrast on the lines on the chart,this means i should use different colors on the lines. I use this example to demonstrate the problem i'm facing in this particular situation.

Does somebody have this problem? Did somebody have any solution for that?

A: 

The problem was i had a style wich overrited the Background color of the lines. The solution was to set all the style from code behind.

Style style = new Style(typeof(Control));
                        style.Setters.Add(new Setter(Control.BackgroundProperty, new SolidColorBrush(oColors[colors])));
                        style.Setters.Add(new Setter(Control.HeightProperty, 5));
                        style.Setters.Add(new Setter(Control.WidthProperty, 5));
                        series.DataPointStyle = style;
Sad0w1nL1ght