CrossTableSource

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
banzatto
Newbie
Newbie
Posts: 13
Joined: Mon Sep 04, 2006 12:00 am

CrossTableSource

Post by banzatto » Thu Feb 04, 2010 3:34 pm

I have a problem with crosstablesource and groupfield with only 1 type. Example:

in Table i have:

LabelField GroupField ValueField
Label1 Group1 10
Label2 Group1 20
Label3 Group1 30
Label4 Group1 40

The graphic dont show legend of the groupfield, but show legend of the labelfield. Now when i have a several groupfields, the graphic show correct. Why ???

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: CrossTableSource

Post by Narcís » Thu Feb 04, 2010 3:45 pm

Hi banzatto,

Can you please attach a simple example project we can run "as-is" to reproduce the problem here?

You could create a test data table at runtime as Christopher Ireland's example here.

Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

banzatto
Newbie
Newbie
Posts: 13
Joined: Mon Sep 04, 2006 12:00 am

Re: CrossTableSource

Post by banzatto » Thu Feb 04, 2010 5:56 pm

To show the problem change the gmax to 1

Code: Select all

        public Form1()
        {
          InitializeComponent();
          InitializeChart();
        }

        private Steema.TeeChart.Styles.Bar series;
        Steema.TeeChart.TChart tChart1;
        DataGrid grid;
        DataSet TeeDataSet = new DataSet();
        DataTable TeeDataTable = new DataTable();
        Steema.TeeChart.Data.CrossTabSource CrossTB = new Steema.TeeChart.Data.CrossTabSource();


        private void InitializeChart()
        {
          tChart1 = new Steema.TeeChart.TChart();
          grid = new DataGrid();
          grid.SetBounds(0, 0, 300, 100);
          grid.Dock = DockStyle.Left;

          this.Controls.Add(grid);
          this.Controls.Add(tChart1);
          tChart1.BringToFront();
          tChart1.Dock = DockStyle.Fill;
          
          FillData();
           
            

          series = new Bar(tChart1.Chart);

          series.DataSource = CrossTB;
          series.CheckDataSource();

          grid.DataBindings.Clear();

          grid.DataSource = TeeDataTable;
          



          tChart1.DoubleClick+=new EventHandler(tChart1_DoubleClick);

          grid.CurrentCellChanged += new EventHandler(grid_CurrentCellChanged);


        }

        void grid_CurrentCellChanged(object sender, EventArgs e)
        {
            series.CheckDataSource();
        }

        private void FillData()
        {
          DataRow newRow;

          DataColumn colLabField = new DataColumn("LabelField", typeof(String));
          DataColumn colGroupField = new DataColumn("GroupField", typeof(String));
          DataColumn colValueField = new DataColumn("ValueField", typeof(Double));


          TeeDataTable.Columns.Add(colLabField);
          TeeDataTable.Columns.Add(colGroupField);
          TeeDataTable.Columns.Add(colValueField);

          int lmax = 10;
          int gmax = 2; //to see problem change to 1



           Random r = new Random(); 

          for (int l = 0; l <= lmax; l++)
          {
              for (int g = 1; g <= gmax; g++)
              {
                  newRow = TeeDataTable.NewRow();
                  newRow[colLabField] = String.Format("{0} {1}", "Label", l);
                  newRow[colGroupField] = String.Format("{0} {1}", "Group", g);
                  newRow[colValueField] = r.NextDouble();
                  TeeDataTable.Rows.Add(newRow);
              }
          }

          TeeDataSet.Tables.Add(TeeDataTable);

            CrossTB.DataSource = TeeDataTable;
            CrossTB.Formula = Steema.TeeChart.Data.GroupFormula.Sum;
            CrossTB.GroupField = "GroupField";
            CrossTB.LabelField = "LabelField";
            CrossTB.ValueField = "ValueField";


        }

        void tChart1_DoubleClick(object sender, EventArgs e)
        {
          tChart1.ShowEditor();
        }


Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: CrossTableSource

Post by Sandra » Fri Feb 05, 2010 9:15 am

Hello banzatto,


I couldn't reproduce your problem here using last version of TeeChart.Net concretely version 4. Please, could you tell us what version you are using the TeeChart .Net?


Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

banzatto
Newbie
Newbie
Posts: 13
Joined: Mon Sep 04, 2006 12:00 am

Re: CrossTableSource

Post by banzatto » Fri Feb 05, 2010 12:12 pm

I used version 4. The problem is legend show LabelFields and not GroupFields when GroupFields has the same text.
The example show this it. Change gmax to 1 and legend show labels fields "label 1, label 2, label 3" and not "Group 1".

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: CrossTableSource

Post by Sandra » Mon Feb 08, 2010 9:11 am

Hello banzatto,

I found a solution for your problem. Please check adding next line of code your application works as you want.

Code: Select all

          tChart1.Legend.LegendStyle = Steema.TeeChart.LegendStyles.Series; 

I hope will helps.

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

banzatto
Newbie
Newbie
Posts: 13
Joined: Mon Sep 04, 2006 12:00 am

Re: CrossTableSource

Post by banzatto » Mon Feb 08, 2010 12:49 pm

Thanks.

Post Reply