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
440
2D Bar Graph
posted

Does anyone have an example of codebehind data binding for the 2D bar chart.

I am trying to figure out what the datamapping statement should look like.

 

 

Parents
No Data
Reply
  • 17605
    posted

    One simple approach can be:

    <igCA:XamChart x:Name="xamChart" Loaded="xamChart_Loaded">

                <igCA:XamChart.Series>

                    <igCA:Series x:Name="BarSeries" ChartType="Bar" DataMapping="Label=Label;Value=Value;ToolTip=Value">                   

                    </igCA:Series>

                </igCA:XamChart.Series>

            </igCA:XamChart>

     

    ...

        public partial class Window1 : Window

        {

            public Window1()

            {

                InitializeComponent();

            }

     

            private void xamChart_Loaded(object sender, RoutedEventArgs e)

            {

                ObservableCollection<Data> collection = new ObservableCollection<Data>();

                collection.Add(new Data("a", 5));

                collection.Add(new Data("b", 15));

                collection.Add(new Data("c", 10));

                collection.Add(new Data("d", 20));

     

                this.BarSeries.DataSource = collection;

            }

     

            public class Data

            {

                public Data(string label, double value)

                {

                    this.Label = label;

                    this.Value = value;

                }

     

                public string Label { get; set; }

                public double Value { get; set; }

            }

        }

     

Children
No Data