Problem with defining Itemssource in ViewModel

May 31, 2016 at 1:47 PM
Edited May 31, 2016 at 2:14 PM
Hi,

I want to define the Series ItemsSources in my Viewmodel.

To accomplish this, I have done the following:

XAML:
<GAGraph:GAMultipleTypeSeriesChart DataContext="{Binding ''}" ChartTitle="{Binding ChartTitle}" ChartSubTitle="{Binding ChartSubTitle}" Grid.Row="0" Width="Auto" 
                                                   Height="Auto" IsRowColumnSwitched="True" ChartLegendVisibility="Visible" Series="{Binding ChartDataList}">
and in VM:
GAColumnPiece testcolumn = new GAColumnPiece();
                GALinePiece testline = new GALinePiece();

                ChartSeries chartSerie = new ChartSeries();
                chartSerie.SeriesTitle = "Total";
                chartSerie.DisplayMember = "Date";
                chartSerie.ValueMember = "Count";
                chartSerie.DataPointType = testcolumn.GetType();

                ChartDataList.Add(chartSerie);                     
                chartSerie.ItemsSource = TotalCount;

                ChartSeries maximumLine = new ChartSeries();
                maximumLine.SeriesTitle = "Max";
                maximumLine.DisplayMember = "Date";
                maximumLine.ValueMember = "Count";
                maximumLine.DataPointType = testline.GetType();

                ChartDataList.Add(maximumLine);
                maximumLine.ItemsSource = MaxLine;
Both the TotalCount and MaxLine are Observable Collection that are filled with values (I checked this).
If I hover the mouse over the binding in the Xaml, I also can see that it is filled with values.
The problem is, it doesn't show anything. Can someone point out what I'm doing wrong?

The same code (minus the type definitions) works fine in the original Ui Charts from Torsten Mandelkow. It just can't display two different charts, so I want to use this enhancement.

Thanks in advance for every hint.

EDIT:
By the way, the chart does scale correctly. The y-axis scales to 12000 (highest value in TotalCount is 11 thousand and somewhat), but the x-axis doesn't show up.
Coordinator
May 31, 2016 at 7:07 PM
Hi,

The code to have multiple series on the same chart is very different to the original code. You must use the GAMultipleTypeSeriesChart.Series not the chart series. Have a look at the documentation under xaml markup and try to implement that in code. I have only done it via xaml, so there is no guarantees it will work. Here is a copy past from that page

<GAChart:GAMultipleTypeSeriesChart  Style="{StaticResource MinimalChartStyle}"
                        Width="400" Height="400"
                        DataContext="{Binding ''}"
                        ChartTitle="GA Multiple Series Type Chart" 
                        ChartSubTitle="Series overlap - column, scatter, line, custom"
                        SelectedItem="{Binding selectedItem, Mode=TwoWay}"
                                                       
                >

                        <GAChart:GAMultipleTypeSeriesChart.Series >
                            <GAChart:ChartSeries
                                SeriesTitle="Target Line"
                                DisplayMember="date"
                                ValueMember="amount"
                                ItemsSource="{Binding scatterData.Items}"
                                DataPointType="{x:Type GAChart:GAColumnPiece}"
                                
                        />
                            <GAChart:ChartSeries
                                SeriesTitle="{Binding scatterData1.seriesDisplayName}"
                                DisplayMember="date"
                                ValueMember="amount"
                                ItemsSource="{Binding scatterData.Items}"
                                DataPointType="{x:Type GAChart:GAScatterPiece}"
                                
                        />
                            <GAChart:ChartSeries
                                SeriesTitle="{Binding scatterData.seriesDisplayName}"
                                DisplayMember="date"
                                ValueMember="amount"
                                ItemsSource="{Binding scatterData.Items}"
                                DataPointType="{x:Type GAChart:GALinePiece}"
                                RelativeSeriesColour="Previous"
                                SeriesLegendVisibilty="Collapsed"
                                
                        />
                            <GAChart:ChartSeries
                                SeriesTitle="{Binding scatterData2.seriesDisplayName}"
                                DisplayMember="date"
                                ValueMember="amount"
                                ItemsSource="{Binding scatterData2.Items}"
                                
                                DataPointType="{x:Type GAChart:GAScatterPiece}"
                                 DataPointStyle="{StaticResource RectangleFilledStyle}"
                                DataPointSelectedStyle="{StaticResource NotFilledCircleStyle}"
                                
                        />
                            <GAChart:ChartSeries
                                SeriesTitle="{Binding scatterData3.seriesDisplayName}"
                                DisplayMember="date"
                                ValueMember="amount"
                                ItemsSource="{Binding scatterData3.Items}"
                                DataPointType="{x:Type GAChart:GALinePiece}"
                                
                        />
                        </GAChart:GAMultipleTypeSeriesChart.Series>
                    </GAChart:GAMultipleTypeSeriesChart>
Jun 8, 2016 at 9:34 AM
Edited Jun 8, 2016 at 9:34 AM
Hi, thanks for your answer.

I know that I have to use the MutlipleTypeSeriesChart, thats why I did it like this in the xaml:
<GAGraph:GAMultipleTypeSeriesChart DataContext="{Binding ''}" x:Name="DailyTotalTyres" ChartTitle="{Binding ChartTitle}" ChartSubTitle="{Binding ChartSubTitle}" Grid.Row="0" Width="Auto" 
                                                   Height="Auto" IsRowColumnSwitched="True" ChartLegendVisibility="Visible" Series="{Binding ChartDataList}" >
I bind the Series property to a List of ChartSeries. In your xaml you also use the ChartSeries, which are a child of MultipleTypeChartSeries, arent they?
Jun 8, 2016 at 12:14 PM
For a test, I tried the exact way that is shown in the documentation and I get the exact same result :(