Hi,
I'm having an issue displaying series on a chart without having things hardcoded in the xaml( I can easily display a series with hardcoded things in the xaml and setting the charts datacontext to my ObservableCollection). But as soon as try to create my own series in the code behind, and try to throw it onto the chart, nothing gets displayed.
Here is my code for creating a series/putting it on the chart.
C#:
var listOfPoints1 = new ObservableCollection<DataPoint>()
{ new DataPoint() {Subject ="subject_1", X = 0, Y = 25.68}, new DataPoint() {Subject ="subject_1",X = 35, Y = 5.68}, new DataPoint() {Subject ="subject_1",X = 58, Y = 45.56}, new DataPoint() {Subject ="subject_1",X = 65, Y = 70.68}, new DataPoint() {Subject ="subject_1",X = 165, Y = 125.68}, new DataPoint() {Subject ="subject_1",X = 265, Y = 555.68}, new DataPoint() {Subject ="subject_1",X = 400, Y = 325.68}, }; NumericXAxis x = new NumericXAxis(); NumericYAxis y = new NumericYAxis();
ScatterSplineSeries series = new ScatterSplineSeries(); series.XAxis = x; series.YAxis = y; series.XMemberPath = "X"; series.YMemberPath = "Y"; series.ItemsSource = listOfPoints1; series.Title = "Subject 1"; series.Thickness = 3; series.MarkerType = MarkerType.None; xamChart1.Series.Add(series);
and my XAML looks like this:
<ig:XamDataChart Name="xamChart1" HorizontalZoomable="True" HorizontalZoombarVisibility="Collapsed" Padding="10" VerticalZoomable="True" VerticalZoombarVisibility="Collapsed" > <ig:XamDataChart.Axes> <ig:NumericXAxis x:Name="ScatterSplineXAxis" /> <ig:NumericYAxis x:Name="ScatterSplineYAxis" /> </ig:XamDataChart.Axes> <ig:XamDataChart.Series> </ig:XamDataChart.Series> </ig:XamDataChart>
Any help would be appreciated.
Thanks,
Nicolas
You also need to add your axes to the chart.
-Graham
There are axes to the chart, unless I'm completely missing something which I feel I've tried everything. I can show data on the graph if I bind something to the datasource of the actual chart and have a hardcoded series on the chart i.e:
<ig:ScatterSplineSeries ItemsSource="{Binding}" Thickness="3" XMemberPath="X" YMemberPath="Y" MarkerType="None" XAxis="{Binding ElementName=ScatterSplineXAxis}" YAxis="{Binding ElementName=ScatterSplineYAxis}" > </ig:ScatterSplineSeries>
But that's not what I'm looking for, I need to be able to dynamically add multiple series in the code behind and have them display on the chart.