We are evaluating the surface controls and we found this issue.
Data
I have an xml which has cities sale data of different year. We have read the xml and created these classes: I have a class named “City” deriving from INotifyPropertyChanged and it has data like sales,year,name etc. I have one from class named “CustomDataModel” which has a property Locations and it is returing ObservableCollection<City> (a collection of city objects).
In XAML
I have created a control which has XamSurfaceChart on it solething like this:
<igSurface:XamSurfaceChart x:Name="xamSurfaceChart1" IsSurfaceManipulationEnabled="False" Margin="10,55,10,10">
<igSurface:XamSurfaceChart.Legend>
<igChart:Legend Foreground="White" UseDataTemplate="False"/>
</igSurface:XamSurfaceChart.Legend>
<igSurface:XamSurfaceChart.Axes>
<igChart:Axis Stroke="#00000000" AxisType="PrimaryX">
<igChart:Axis.Label>
<igChart:Label Foreground="White" Angle="-45" />
</igChart:Axis.Label>
<igChart:Axis.MajorGridline>
<igChart:Mark StrokeThickness="0" TickMarkSize="0"/>
</igChart:Axis.MajorGridline>
<igChart:Axis.MajorTickMark>
<igChart:Mark StrokeThickness="0"/>
</igChart:Axis.MajorTickMark>
</igChart:Axis>
<igChart:Axis AxisType="PrimaryY" >
<igChart:Label Foreground="White"/>
<igChart:Mark Stroke="#33FFFFFF"/>
<igChart:Axis.Stroke>
<SolidColorBrush/>
</igChart:Axis.Stroke>
</igSurface:XamSurfaceChart.Axes>
<igSurface:XamSurfaceChart.Series>
<igChart:Series ChartType="Column" UseDataTemplate="True">
<igChart:Series.Stroke>
</igChart:Series.Stroke>
<igChart:Series.ChartParameters>
<igChart:ChartParameter Type="RectangleRounding" Value="3"/>
</igChart:Series.ChartParameters>
</igChart:Series>
</igSurface:XamSurfaceChart.Series>
</igSurface:XamSurfaceChart>
In code behind:
I am setting the DataContxt on xamsurfaceControl to CustomDataModel like
xamsurfaceControl1.DataContext = customDataModel (an instance of CustomDataModel)
chartSeries = new Series();
chartSeries.ChartType = ChartType.Column;
chartSeries.ChartParameters.Add(ChartParameterType.RectangleRounding, 3);
chartSeries.Label = city.Year;
chartSeries.Fill = new SolidColorBrush(Colors.Red);
chartSeries.Stroke = new SolidColorBrush(Colors.Silver);
chartSeries.DataSource = dataModel.Locations;
chartSeries.DataMapping = "Value=" + city.Sales + ";Label=" + city.Name + ";ToolTip=" + city.Sales;
this.xamSurfaceChart1.Series.Add(chartSeries);
After doing all this, I am not able to see the datapoints plotted in the graph. x axis is showing numbers from 1-10 as I have 10 elements to show on x axis.
If i draw the datapoints explicitly then graph is coming.
I think the DataMapping is wrong. try changing
to
chartSeries.DataMapping = "Value=Sales;Label=Name;ToolTip=Sales";
I tried changing it to
chartSeries.DataMapping =
"Value=sales;Label=names";
I am reading sales etc from my custom class object "city"
Still it is not drawing the data points.
;
Could you show us what your City class looks like?
If you set your DataMapping to "Value = Sales, Label = Names" then make sure your City object has both those properties exactly, make sure your spelling and case is correct. And Sales should be type double (or something convertible to double), and Names should be type string.
-Graham