I am trying to figure out how to style a LineSeriesDefinition with a dotted line but using a custom defined palette
The palette is setup in code like this in code behind:
I've create a style like this:
and a lineseriesdefinition like:
The probem now is that the line doesn't take the color of my defined palette.
With a bar style it seems to work though definig a style like:
The palette is setup in code like this in code behind:
BrushCollection paletteColors = new BrushCollection(); paletteColors.Add(new SolidColorBrush(ColorPaletteBase.HexStringToColor("#44BBBBBB"))); paletteColors.Add(new SolidColorBrush(ColorPaletteBase.HexStringToColor("#44555555"))); paletteColors.Add(new SolidColorBrush(ColorPaletteBase.HexStringToColor("#FF329C8E"))); paletteColors.Add(new SolidColorBrush(ColorPaletteBase.HexStringToColor("#FF309A8C"))); paletteColors.Add(new SolidColorBrush(ColorPaletteBase.HexStringToColor("#FFFDD20F"))); paletteColors.Add(new SolidColorBrush(ColorPaletteBase.HexStringToColor("#FFFBD00D"))); paletteColors.Add(new SolidColorBrush(ColorPaletteBase.HexStringToColor("#FFAE1F25"))); paletteColors.Add(new SolidColorBrush(ColorPaletteBase.HexStringToColor("#FFAC1D23"))); foreach (Brush item in paletteColors) { DataChart.PaletteBrushes.Add(item); }
I've create a style like this:
<Style x:Name="DottedLineStyle" TargetType="charting:SelfDrawingSeries"> <Setter Property="BorderLineStyle"> <Setter.Value> <Style TargetType="Path"> <Setter Property="StrokeDashArray" Value="1" /> <Setter Property="StrokeThickness" Value="3" /> </Style> </Setter.Value> </Setter> </Style>
and a lineseriesdefinition like:
<charting:SeriesMapping LegendLabel="NetSales"> <charting:SeriesMapping.SeriesDefinition> <charting:LineSeriesDefinition AxisName="Secondary" SeriesStyle="{StaticResource DottedLineStyle}" ShowItemLabels="False" ShowItemToolTips="True" ItemToolTipFormat="Net Sales Week: #XCAT Value: #Y{F2}"/> </charting:SeriesMapping.SeriesDefinition> <charting:ItemMapping DataPointMember="YValue" FieldName="NetSales" /> <charting:ItemMapping DataPointMember="XCategory" FieldName="YearMonth" /> </charting:SeriesMapping>
The probem now is that the line doesn't take the color of my defined palette.
With a bar style it seems to work though definig a style like:
<Style x:Key="FlatBarStyle" TargetType="charting:Bar"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="charting:Bar"> <Canvas> <Rectangle x:Name="PART_DefiningGeometry" Height="{TemplateBinding ItemActualHeight}" Width="{TemplateBinding ItemActualWidth}" RadiusX="0" RadiusY="0" Style="{TemplateBinding ItemStyle}" /> </Canvas> </ControlTemplate> </Setter.Value> </Setter> </Style>