Page 1 of 1
QRChart Axis Labels
Posted: Mon Jun 26, 2006 7:46 pm
by 9232023
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
Posted: Tue Jun 27, 2006 9:38 am
by narcis
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));
}
}
Posted: Tue Jun 27, 2006 12:35 pm
by 9232023
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
Posted: Tue Jun 27, 2006 12:44 pm
by narcis
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");
}
}