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
615
How to display multiple line series in chart from simple data collection in code behind?
posted

I'm working with the Xam Data chart and styling the  line series. I'm using sample data from code behind. The question is, how can I add more series (lines) to the chart using ObservableCollection fro the SimpleDataCollection?

{    public class SimpleDataCollection : ObservableCollection<SimpleDataPoint>
    {
        public SimpleDataCollection()
        {
            this.Add(new SimpleDataPoint() { Label = "1", Value = 4.0 });
            this.Add(new SimpleDataPoint() { Label = "2", Value = 3.0 });
            this.Add(new SimpleDataPoint() { Label = "3", Value = 2.0 });
            this.Add(new SimpleDataPoint() { Label = "4", Value = 7.0 });
            this.Add(new SimpleDataPoint() { Label = "5", Value = 4.0 });
            this.Add(new SimpleDataPoint() { Label = "6", Value = 9.0 });
           
        }
    }
    /// <summary>
    /// Simple storage class for pair of string and double value
    /// </summary>
    public class SimpleDataPoint
    {
        public double Value { get; set; }
        public string Label { get; set; }

       
    }

 

The Xaml code for the chart is this:

                <ig:XamDataChart x:Name="Test_Trend_Chart" HorizontalZoomable="True" HorizontalZoombarVisibility="Visible" VerticalZoombarVisibility="Visible" VerticalZoomable="True" WindowRect="0,0,1,100" Margin="0" Style="{DynamicResource XamDataChartStyleTester}" Height="284.4">
               
                    <ig:XamDataChart.DataContext>
                        <local:SimpleDataCollection/>
                    </ig:XamDataChart.DataContext>
                    <ig:XamDataChart.Axes>
                        <ig:CategoryXAxis x:Name="xmXAxis" ItemsSource="{Binding}" Label="{}{Label}" MajorStroke="#7F000000" MajorStrokeDashArray="1 2" >
                            <ig:CategoryXAxis.LabelSettings >
                                <ig:AxisLabelSettings Location="OutsideBottom" Extent="30" Foreground="Black" FontSize="12" />
                            </ig:CategoryXAxis.LabelSettings>
                        </ig:CategoryXAxis>
                        <ig:NumericYAxis x:Name="xmYAxis" FontFamily="Tahoma" MinorStrokeThickness="0.7" MajorStrokeDashArray="1 2" Stroke="#FFF11B1B" StrokeThickness="0" StrokeDashArray="1 2" >
                            <ig:NumericYAxis.ActualTickmarkValues>
                                <ig:LinearTickmarkValues/>
                            </ig:NumericYAxis.ActualTickmarkValues>
                            <ig:NumericYAxis.LabelSettings >
                                <ig:AxisLabelSettings Location="OutsideLeft" Extent="25" FontSize="12" TextAlignment="Right" />
                            </ig:NumericYAxis.LabelSettings>
                        </ig:NumericYAxis>
                    </ig:XamDataChart.Axes>
                    <ig:XamDataChart.Series>
                        <ig:LineSeries ValueMemberPath="Value" Thickness="3" MarkerType="None"
                            ItemsSource="{Binding}"
                            XAxis="{Binding ElementName=xmXAxis}"
                            YAxis="{Binding ElementName=xmYAxis}" />

                    </ig:XamDataChart.Series>
                </ig:XamDataChart>

Parents
No Data
Reply
  • 27093
    posted

    Hello,    

    I am just checking the progress of this issue and was wondering if you managed to achieve your goal or if you need any further assistance on the matter.

    If the above suggestion helped you solve your issue please verify the thread as answered so other users may take better advantage of it.

Children
No Data