Hi,
xamDataChart StackedColumnSeries repeat color palette after stacking 5 series in one column. We need unique color palette for each series. Is there any setting that i need to turn it on? I'm using InfragisticsWPF4.Controls.Charts.XamDataChart.v11.2.
Thanks,
-Lily
Hello,
I have been looking into your question and I can suggest you use the Brushes Property of the XamDataChart, which is a collection with Brushes and the chart uses these colors for the series like e.g. :
Red
Yellow
Violet
blue
Green
Orange
Pink
YellowGreen
Here you can read more about it:
http://help.infragistics.com/NetAdvantage/Silverlight/2012.1/CLR4.0/?page=InfragisticsSL5.Controls.Charts.XamDataChart.v12.1~Infragistics.Controls.Charts.XamDataChart~Brushes.html
Also you can use the Series’ Brush Property, which set the color to the specific Series. Here you can find more information:
http://help.infragistics.com/NetAdvantage/Silverlight/2012.1/CLR4.0/?page=InfragisticsSL5.Controls.Charts.XamDataChart.v12.1~Infragistics.Controls.Charts.Series~Brush.html
Feel free to write me if you need any further assistance on this matter.
Yanko,
AutoGenerateSeries="True" for StackedColumnSeries in my WPF application, so the brush for each series is automatically set by XamDataChart, not in my code. The issue is that the color is repeating itself after stacking 5 series.
I'm using InfragisticsWPF4.Controls.Charts.XamDataChart.v11.2. The complete sample code is posted below:
1. MainWindow.xaml
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:ig="http://schemas.infragistics.com/xaml" xmlns:TilesTest="clr-namespace:TilesTest" x:Class="TilesTest.MainWindow" Title="MainWindow" Height="350" Width="525" mc:Ignorable="d"> <Window.Resources> <TilesTest:SeriesData x:Key="SD"/> <!--Here i chnaged the ItemsSource to a StaticResource I also chnaged the DataSource structure, you can see the code behind--> <ig:GroupBy x:Key="grouped" ItemsSource="{Binding Source={StaticResource SD},Path=DataPoints}" GroupMemberPath="Date" KeyMemberPath="Currency" ValueMemberPath="Value" /> <TilesTest:KeyConverter x:Key="keyConverter"/> <DataTemplate x:Key="keyLegendItemTemplate"> <StackPanel Orientation="Horizontal" Margin="1" Visibility="{Binding Series.Visibility}"> <ContentPresenter Content="{Binding}" ContentTemplate="{Binding Series.LegendItemBadgeTemplate}" /> <ContentPresenter Content="{Binding Series.ValueMemberPath, Converter={StaticResource keyConverter}, ConverterParameter='_Value'}"/> </StackPanel> </DataTemplate> </Window.Resources> <Grid> <ig:XamDock x:Name="xmDockContainer" Margin="10" Grid.Row="1"> <Border CornerRadius="1" Margin="5" BorderThickness="1" Grid.Row="1"> <ig:XamDataChart x:Name="barChart" Legend="{Binding ElementName=xmLegend}" HorizontalZoomable="True" VerticalZoomable="True" > <ig:XamDataChart.Axes> <ig:CategoryXAxis x:Name="xmXAxis" Label="{}{Key}" ItemsSource="{StaticResource ResourceKey=grouped}"> <ig:CategoryXAxis.ToolTip> Cash Flow Dates </ig:CategoryXAxis.ToolTip> <ig:CategoryXAxis.LabelSettings > <ig:AxisLabelSettings Location="OutsideBottom" Extent="55" /> </ig:CategoryXAxis.LabelSettings> </ig:CategoryXAxis> <ig:NumericYAxis x:Name="xmYAxis" > <ig:NumericYAxis.LabelSettings > <ig:AxisLabelSettings Location="OutsideLeft" Extent="55"/> </ig:NumericYAxis.LabelSettings> </ig:NumericYAxis> </ig:XamDataChart.Axes> <ig:XamDataChart.Series >
<!--The AutoGenerateSeries Property should be set to True--> <ig:StackedColumnSeries x:Name="stack" SeriesCreated="stack_SeriesCreated" XAxis="{Binding ElementName=xmXAxis}" YAxis="{Binding ElementName=xmYAxis}" ItemsSource="{StaticResource ResourceKey=grouped}" AutoGenerateSeries="True" LegendItemTemplate ="{StaticResource ResourceKey=keyLegendItemTemplate}" > </ig:StackedColumnSeries> </ig:XamDataChart.Series> </ig:XamDataChart> </Border> <ig:Legend x:Name="xmLegend" Margin="5" ig:XamDock.Edge="OutsideRight"> </ig:Legend> </ig:XamDock> </Grid></Window>
2. MainWindow.xaml.cs
using System.Collections.ObjectModel;using System.Windows;using Infragistics.Controls.Charts;
namespace TilesTest{ /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow { public MainWindow() { InitializeComponent(); }
private void stack_SeriesCreated(object sender, Infragistics.Controls.Charts.StackedSeriesCreatedEventArgs e) { StackedFragmentSeries series = (StackedFragmentSeries)sender;
if (series != null) { series.Title = series.ValueMemberPath.Replace("_Value", string.Empty); }
} }
public class SeriesData { public ObservableCollection<DataPoint> DataPoints { get; set; }
public SeriesData() { DataPoints = new ObservableCollection<DataPoint>(); DataPoints.Add(new DataPoint { Currency = "GBP", Date = "May 2001", Value = 1500 });
DataPoints.Add(new DataPoint { Currency = "USD", Date = "May 2001", Value = 2500 });
DataPoints.Add(new DataPoint { Currency = "EUR", Date = "May 2001", Value = 8800 });
DataPoints.Add(new DataPoint { Currency = "GBPTest", Date = "May 2001", Value = 1500 });
DataPoints.Add(new DataPoint { Currency = "USDTest", Date = "May 2001", Value = 2500 });
DataPoints.Add(new DataPoint { Currency = "EURTest", Date = "May 2001", Value = 1800 });
DataPoints.Add(new DataPoint { Currency = "GBP", Date = "May 2002", Value = 1500 });
DataPoints.Add(new DataPoint { Currency = "USD", Date = "May 2002", Value = 0 });
DataPoints.Add(new DataPoint { Currency = "EUR", Date = "May 2002", Value = 0 });
DataPoints.Add(new DataPoint { Currency = "GBPTest", Date = "May 2002", Value = 1500 });
DataPoints.Add(new DataPoint { Currency = "USDTest", Date = "May 2002", Value = 2500 });
DataPoints.Add(new DataPoint { Currency = "EURTest", Date = "May 2002", Value = 1800 });
DataPoints.Add(new DataPoint { Currency = "GBPTest1", Date = "May 2001", Value = 1500 });
DataPoints.Add(new DataPoint { Currency = "USDTest1", Date = "May 2001", Value = 2500 });
DataPoints.Add(new DataPoint { Currency = "EURTest1", Date = "May 2001", Value = 1800 });
DataPoints.Add(new DataPoint { Currency = "GBPTest1", Date = "May 2002", Value = 1500 });
DataPoints.Add(new DataPoint { Currency = "USDTest1", Date = "May 2002", Value = 2500 });
DataPoints.Add(new DataPoint { Currency = "EURTest1", Date = "May 2002", Value = 1800 }); //DataPoints.Add(new DataPoint //{ // Currency = "GBP2", // Date = "May 2002", // Value = 1500 //});
//DataPoints.Add(new DataPoint //{ // Currency = "USD2", // Date = "May 2002", // Value = 200 //});
//DataPoints.Add(new DataPoint //{ // Currency = "EUR2", // Date = "May 2002", // Value = 200 //});
//DataPoints.Add(new DataPoint //{ // Currency = "GBP3", // Date = "May 2002", // Value = 150 //});
//DataPoints.Add(new DataPoint //{ // Currency = "USD3", // Date = "May 2002", // Value = 150 //});
//DataPoints.Add(new DataPoint //{ // Currency = "EUR3", // Date = "May 2002", // Value = 150 //});
public class DataPoint { public string Date { get; set; } public double Value { get; set; } public string Currency { get; set; } }
}
3. KeyConverter.cs
using
System;
System.Windows.Data;
namespace
TilesTest
{
public class KeyConverter
:
IValueConverter
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
if (value is string && parameter is string)
var key = (string)value;
var param = (string)parameter;
key = key.Replace(param,
"");
return key;
return "";
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
throw new NotImplementedException();
I have been looking into your reply and by default the color of the series is repeating itself after stacking 5 series. This is why you need to set the color brush of the XamDataChart manually as I have suggested you in my previous post.
If you have any other questions on this matter, feel free to aks.
yea, i figured it out. thanks!
Would u kindly modify my code to show how to set color brush when AutoGenerateSeries="True" for XamDataChart? Thanks!