I am having some trouble here configure the look of a chart.
I need to make this
but this is what I have
I've been reading over documentation, but I it is evading me on this configuration and I know it is just something simple I'm missing.
Here is one way how you would approach the top screenshot:The xaml:
<UserControl.Resources> <local:BaseData x:Key="base" /> <local:TwoXScenarioData x:Key="twoX" /> <local:BEScenarioData x:Key="be" /> </UserControl.Resources> <Grid x:Name="LayoutRoot" Background="White"> <Grid.ColumnDefinitions> <ColumnDefinition /> <ColumnDefinition Width="Auto" /> </Grid.ColumnDefinitions> <igChart:XamDataChart x:Name="theChart" Legend="{Binding ElementName=legend}"> <igChart:XamDataChart.Axes> <igChart:NumericYAxis x:Name="yAxis" /> <igChart:CategoryXAxis x:Name="xAxis" ItemsSource="{StaticResource base}" Label="{}{Label}"/> </igChart:XamDataChart.Axes> <igChart:XamDataChart.Series> <igChart:ColumnSeries x:Name="base" ItemsSource="{StaticResource base}" XAxis="{Binding ElementName=xAxis}" YAxis="{Binding ElementName=yAxis}" ValueMemberPath="Value" Title="Base"/> <igChart:ColumnSeries x:Name="twoX" ItemsSource="{StaticResource twoX}" XAxis="{Binding ElementName=xAxis}" YAxis="{Binding ElementName=yAxis}" ValueMemberPath="Value" Title="2x Scenario"/> <igChart:ColumnSeries x:Name="be" ItemsSource="{StaticResource be}" XAxis="{Binding ElementName=xAxis}" YAxis="{Binding ElementName=yAxis}" ValueMemberPath="Value" Title="B/E Scenario"/> </igChart:XamDataChart.Series> </igChart:XamDataChart> <igChart:Legend x:Name="legend" Grid.Column="1" VerticalAlignment="Top" /> </Grid>
And the code behind:
public partial class MainPage : UserControl { public MainPage() { InitializeComponent(); } } public class BaseData : ObservableCollection<DataItem> { public BaseData() { Add(new DataItem() { Label = "Volume", Value = 1.7 }); Add(new DataItem() { Label = "Sales", Value = 5 }); Add(new DataItem() { Label = "Profit", Value = .3 }); } } public class TwoXScenarioData : ObservableCollection<DataItem> { public TwoXScenarioData() { Add(new DataItem() { Label = "Volume", Value = 3 }); Add(new DataItem() { Label = "Sales", Value = 10 }); Add(new DataItem() { Label = "Profit", Value = 1.2 }); } } public class BEScenarioData : ObservableCollection<DataItem> { public BEScenarioData() { Add(new DataItem() { Label = "Volume", Value = 3.2 }); Add(new DataItem() { Label = "Sales", Value = 10.2 }); Add(new DataItem() { Label = "Profit", Value = 1.4 }); } } public class DataItem { public string Label { get; set; } public double Value { get; set; } }
Hope this helps!-Graham
This only changes the look and not the data, I'm needing, i'm needing the first 3 columns to be Volume and the second 3 to be Sales, then the third set of 3 to be Income. That the problem that I'm running into, cause if I make one Obser. collection pull all volume and another pull all Sales and then another pull all Income, how would I group them together in one chart.