Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
80
DataPoints are not getting rendered when the binding is done from code behind.
posted

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:Axis.Label>

                        <igChart:Label Foreground="White"/>

                    </igChart:Axis.Label>

                    <igChart:Axis.MajorGridline>

                        <igChart:Mark Stroke="#33FFFFFF"/>

                    </igChart:Axis.MajorGridline>

                    <igChart:Axis.MajorTickMark>

                        <igChart:Mark StrokeThickness="0"/>

                    </igChart:Axis.MajorTickMark>

                    <igChart:Axis.Stroke>

                        <SolidColorBrush/>

                    </igChart:Axis.Stroke>

                </igChart:Axis>

            </igSurface:XamSurfaceChart.Axes>

            <igSurface:XamSurfaceChart.Series>

                <igChart:Series ChartType="Column" UseDataTemplate="True">

                    <igChart:Series.Stroke>

                        <SolidColorBrush/>

                    </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.