LS,
I'm trying to create a StackingColumn chart with a DateTimeAxis as PrimaryAxis. I can't get it to work.
With a CategoryAxis (and ChartDataPoint(string, double)) it works partially. The value on the axis are all 0 iso the string value I put in the chartdatapoint, but it shows the StackingColumn. When I use the DateTimeAxis the values on the Axis are shown correctly but not stacked. The Xaml code I use looks like this:
<chart:SfChart.PrimaryAxis>
<chart:DateTimeAxis IntervalType="Minutes" ShowMajorGridLines="True">
<chart:DateTimeAxis.MajorGridLineStyle>
<chart:ChartLineStyle StrokeWidth="1" StrokeColor="#7EDBDBDB" />
</chart:DateTimeAxis.MajorGridLineStyle>
<chart:DateTimeAxis.Title>
<chart:ChartAxisTitle Text="Tijd" TextColor="{x:Static local:ColorResources.AccentColor}" />
</chart:DateTimeAxis.Title>
<chart:DateTimeAxis.LabelStyle>
<chart:ChartAxisLabelStyle LabelFormat="mm" TextColor="{x:Static local:ColorResources.AccentColor}" />
</chart:DateTimeAxis.LabelStyle>
</chart:DateTimeAxis>
<!---
<chart:CategoryAxis>
<chart:CategoryAxis.Title>
<chart:ChartAxisTitle Text="Tijd" TextColor="{x:Static local:ColorResources.AccentColor}" />
</chart:CategoryAxis.Title>
<chart:CategoryAxis.LabelStyle>
<chart:ChartAxisLabelStyle TextColor="{x:Static local:ColorResources.AccentColor}" />
</chart:CategoryAxis.LabelStyle>
</chart:CategoryAxis>
-->
</chart:SfChart.PrimaryAxis>
<chart:SfChart.SecondaryAxis>
<chart:NumericalAxis>
<chart:NumericalAxis.Title>
<chart:ChartAxisTitle Text="Aantal" TextColor="{x:Static local:ColorResources.AccentColor}" />
</chart:NumericalAxis.Title>
<chart:NumericalAxis.LabelStyle>
<chart:ChartAxisLabelStyle TextColor="{x:Static local:ColorResources.AccentColor}" />
</chart:NumericalAxis.LabelStyle>
</chart:NumericalAxis>
</chart:SfChart.SecondaryAxis>
<chart:SfChart.Series>
<chart:StackingColumnSeries Label = "Goed" ItemsSource = "{Binding AantalGoed}" Color = "Green" />
<chart:StackingColumnSeries Label="OK" ItemsSource="{Binding AantalOk}" Color="Yellow" />
<chart:StackingColumnSeries Label = "Fout" ItemsSource = "{Binding AantalFout}" Color = "Red" />
</chart:SfChart.Series>
The code in the view model is as follows:
if (App.CurrentData.Samples.Count > 0) {
DateTime dt = App.CurrentData.Samples [0].DatumTijd;
int count = 0;
foreach (var sample in App.CurrentData.Samples) {
count += 1;
if (count < 15) {
double dAantalGoed = 0;
double dAantalOk = 0;
double dAantalFout = 0;
foreach (var type in sample.Messages) {
dAantalGoed += type.AantalGoed;
dAantalOk += type.AantalOK;
dAantalFout += type.AantalFout;
};
_AantalGoed.Add (new ChartDataPoint (sample.DatumTijd, dAantalGoed));
_AantalOk.Add (new ChartDataPoint (sample.DatumTijd, dAantalOk));
_AantalFout.Add (new ChartDataPoint (sample.DatumTijd, dAantalFout));
}
if (dt.CompareTo (sample.DatumTijd) < 0)
dt = sample.DatumTijd;
}
LastSample = string.Format ("{0}:{1}", dt.ToString("HH"), dt.ToString("mm"));
}
Any help is appreciated.
Regards Joost platenburg