pie one record labels

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
bsoft
Newbie
Newbie
Posts: 4
Joined: Mon Mar 03, 2008 12:00 am

pie one record labels

Post by bsoft » Fri May 21, 2010 9:39 am

I have a single record pie bound to a datasource and I can't find how to define the labels. Whatever I try it keeps show the name of the columns.

Could someone help please?

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: pie one record labels

Post by Yeray » Fri May 21, 2010 4:12 pm

Hi bsoft,

Here it is the example from the Tutorial 8 - ADO Database access adapted to a Pies series:

Code: Select all

private void InitializeChart()
        {        
            string sQuery = "select * from Employee";

            string myConnString = "Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\\Program Files\\Steema Software\\TeeChart for .NET v3\\Sample data\\TeeChart.mdb;Uid=Admin;Pwd=;";
            System.Data.Odbc.OdbcConnection myConnection = new System.Data.Odbc.OdbcConnection(myConnString);
            System.Data.Odbc.OdbcCommand myCommand = new System.Data.Odbc.OdbcCommand(sQuery, myConnection);
            myConnection.Open();

            System.Data.Odbc.OdbcDataReader myReader = myCommand.ExecuteReader();
            int ValueColumn = myReader.GetOrdinal("SALARY");
            int LabelColumn = myReader.GetOrdinal("LASTNAME");

            Steema.TeeChart.Styles.Pie pie1 = new Steema.TeeChart.Styles.Pie(tChart1.Chart);

            while (myReader.Read())
            {
                pie1.Add(Convert.ToDouble(myReader[ValueColumn]), Convert.ToString(myReader[LabelColumn]));
            }

            myReader.Close();
            myConnection.Close();
        }
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

bsoft
Newbie
Newbie
Posts: 4
Joined: Mon Mar 03, 2008 12:00 am

Re: pie one record labels

Post by bsoft » Tue May 25, 2010 8:49 am

Hi Yeray,

Thanks a lot for your answer but could you expain to me something. The only way to do that is to use an TChart insteed of a TDBChart?
I don't know if i was clear enough to my previous post so I will try to explain to you tha whole thing once again.

I use a TDBChart. I create a Pie Series. In the Datasource tab I select "Single record" on the top of the form and then I select my TDatasource and the columns I want to display.
My TADODataset returns only one record and I have also set the displaylabel of the fields to what I want to be shown in the chart.

But, when i run the program it keeps show the name of the columns eg. column name = COL1 and displayLabel = '2010'.

I hope i was clear enough this time. It's difficult to me to believe that for something so simple there is no simple way to achieve this.

Thanks again and I'm waiting for your answer...

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: pie one record labels

Post by Yeray » Tue May 25, 2010 1:49 pm

Hi bsoft,

The difference between TChart and TDBChart is that with TDBChart the connections to databases are available at design time and at runtime, while with TChart only at runtime.
For "Singe Record" usage, please, take a look at the demo at All features/Welcome !/Database Charts/Single Record.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply