QRChart Axis Labels

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
kev
Newbie
Newbie
Posts: 42
Joined: Tue Apr 06, 2004 4:00 am
Location: Texas

QRChart Axis Labels

Post by kev » Mon Jun 26, 2006 7:46 pm

I am trying to set custom Labels for a TQRChart in the same way I have done for a standard TChart. For the TCHart I used a "OnGetAxisLabel" event which worked perfectly fine. For a QRChart however, I cannot find any such event. I tried to iterate through the labels and set them that way in the QReport "BeforePrint" event, but I can't seem to get to the actual Label count or the label strings themselves. I thought something like this would work:

for(int i=0;i<QRChart->Chart->LeftAxis->Items->Count;i++){
AnsiString LabelText;
LabelText = QRMapChart->Chart->LeftAxis->Items->Item->Text;

if(LabelText == "90")
LabelText == "3:00";

etc...

}

but Count is zero so the code never executes. I guess the chart doesn't know anything about the labels at this point????

Where am I going wrong?

thanks,
Kev

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

Post by Narcís » Tue Jun 27, 2006 9:38 am

Hi Kev,

The code below only works when using custom labels. You can use custom labels doing something like this:

Code: Select all

void __fastcall TForm1::FormCreate(TObject *Sender)
{
        Series1->FillSampleValues();

        Chart1->Axes->Bottom->Items->Clear();
        Chart1->Axes->Bottom->LabelsAngle=90;

        for(int i=0; i<Series1->Count(); i++)
        {
                Chart1->Axes->Bottom->Items->Add(i,"MyLabel "+IntToStr(i));
        }
}
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

kev
Newbie
Newbie
Posts: 42
Joined: Tue Apr 06, 2004 4:00 am
Location: Texas

Post by kev » Tue Jun 27, 2006 12:35 pm

I want to change the Left Axis labels for a chart that has already been populated. See the code below for what I did for a standard TChart.

void __fastcall TRGP_ChartForm::MapChartGetAxisLabel(TChartAxis *Sender,
TChartSeries *Series, int ValueIndex, AnsiString &LabelText)
{
if(Options.bUseDegrees == false){
if(Sender == MapChart->LeftAxis){
if(LabelText == "0")
LabelText = "12:00";
else if(LabelText == "90")
LabelText = " 3:00";
else if(LabelText == "180")
LabelText = " 6:00";
else if(LabelText == "270")
LabelText = "9:00";
}
}
}

This allows the user to select "Degrees" or "Clock" for the left axis labels. The values are already populated using degrees. Those values will not change, only the labels. I don't see how to implement this using your example which depends on Series->Count

thanks,
kev

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

Post by Narcís » Tue Jun 27, 2006 12:44 pm

Hi Kev,

Then you can do something like this:

Code: Select all

void __fastcall TForm1::FormCreate(TObject *Sender) 
{ 
        Series1->FillSampleValues(); 

        Chart1->Axes->Bottom->Items->Clear(); 
        Chart1->Axes->Bottom->LabelsAngle=90; 

	if(Options.bUseDegrees == false){ 

		Chart1->Axes->Left->Items->Add(0,"12:00"); 
		Chart1->Axes->Left->Items->Add(90,"3:00");
		Chart1->Axes->Left->Items->Add(180,"6:00");
		Chart1->Axes->Left->Items->Add(270,"9:00");
	}
}
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

Post Reply