Page 1 of 1

CrossTableSource

Posted: Thu Feb 04, 2010 3:34 pm
by 9642394
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 ???

Re: CrossTableSource

Posted: Thu Feb 04, 2010 3:45 pm
by narcis
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.

Re: CrossTableSource

Posted: Thu Feb 04, 2010 5:56 pm
by 9642394
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();
        }


Re: CrossTableSource

Posted: Fri Feb 05, 2010 9:15 am
by 10050769
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,

Re: CrossTableSource

Posted: Fri Feb 05, 2010 12:12 pm
by 9642394
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".

Re: CrossTableSource

Posted: Mon Feb 08, 2010 9:11 am
by 10050769
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,

Re: CrossTableSource

Posted: Mon Feb 08, 2010 12:49 pm
by 9642394
Thanks.