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
QRChart Axis Labels
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Kev,
The code below only works when using custom labels. You can use custom labels doing something like this:
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 |
Instructions - How to post in this forum |
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
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
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Kev,
Then you can do something like this:
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 |
Instructions - How to post in this forum |