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
45
Problem with piechart label
posted

im facing a small issue with xamchart control.

i have a datatable with two fields symbol and abs_value. i want to show the value of 'symbol' field as label on piechart but it displays the value of 'abs_value' field. im unable to find a property or method that cna help me do so.

the sample code is attached below :-

xaml

 <Window x:Class="InfraCharts.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525" xmlns:igCA="http://infragistics.com/Chart">
    <Grid ShowGridLines="True">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="auto">
            </ColumnDefinition>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="auto">
            </RowDefinition>
        </Grid.RowDefinitions>
        <igCA:XamChart HorizontalAlignment="Left" Margin="5,5,5,5"
                       Grid.Column="0" Grid.Row="0"
                       Name="xamChart1" VerticalAlignment="Top">
        </igCA:XamChart>
    </Grid>
</Window>

xaml.cs

 public partial class MainWindow : Window
    {
        public DataTable model;

        public MainWindow()
        {
            InitializeComponent();
            SetModel();
            Setchart();
        }

        private void Setchart()
        {
            Marker marker = new Marker() { Type = MarkerType.None };
            xamChart1.Series.Add(new Infragistics.Windows.Chart.Series()
            {
                ChartType = Infragistics.Windows.Chart.ChartType.Pie,
                DataSource = model,
                DataMapping = "Value=abs_value;Label=symbol;ToolTip=abs_value",
                DataPointColor = Infragistics.Windows.Chart.DataPointColor.Different,
                Marker = marker
            });
           
            xamChart1.Legend.Visible = false;
            xamChart1.Refresh();
        }

        private void SetModel()
        {
            model = new DataTable();
            model.Columns.Add(new DataColumn { ColumnName = "symbol", DataType = typeof(String) });
            model.Columns.Add(new DataColumn { ColumnName = "abs_value", DataType = typeof(double) });
            model.Columns.Add(new DataColumn { ColumnName = "sym", DataType = typeof(String) });

            DataRow dr = model.NewRow();
            dr.ItemArray = new object[] { "A", 10000000.0, "A1" };
            model.Rows.Add(dr);

            dr = model.NewRow();
            dr.ItemArray = new object[] { "B", 20000000.0, "B1" };
            model.Rows.Add(dr);

            dr = model.NewRow();
            dr.ItemArray = new object[] { "C", 30000000.0, "C1" };
            model.Rows.Add(dr);

            dr = model.NewRow();
            dr.ItemArray = new object[] { "D", 40000000.0, "D1" };
            model.Rows.Add(dr);

            dr = model.NewRow();
            dr.ItemArray = new object[] { "E", 50000000.0, "E1" };
            model.Rows.Add(dr);

            dr = model.NewRow();
            dr.ItemArray = new object[] { "F", 60000000.0, "F1" };
            model.Rows.Add(dr);

            dr = model.NewRow();
            dr.ItemArray = new object[] { "G", 70000000.0, "G1" };
            model.Rows.Add(dr);
        }
    }

any help to resolve it would be very useful. i think im making a small mistake but im unable to find good sample or documentation so i am posting this issue.

thanks in advance.

Parents
No Data
Reply Children
No Data