1. 在chart1中实现坐标的显示
2. 如何用代码在DBCHART中增加一个Series[0]呢?
1. 在chart1中实现坐标的显示
//在chart1中实现坐标的显示 参考csdn中的 yf2100(劲舞飞猪)
void __fastcall TForm1::Chart1MouseMove(TObject *Sender, TShiftState Shift,
int X, int Y)
{
// double XPos,YPos;
// int index;
AnsiString strMouseInfoX,strMouseInfoY1;//,strMouseInfoY2;
// for(unsigned int i=0;i<2;i++)
// if(index=Chart1->Series[i]->GetCursorValueIndex())
// index=Chart1->Series[0]->GetCursorValueIndex();
// XPos=Chart1->BottomAxis->CalcPosPoint(X);
// if(index>-1)
// {
// strMouseInfoX="X坐标"+IntToStr(index);//+"] 时间:"+DateTimeToStr(XPos);
// strMouseInfoY1="Y1坐标"+FloatToStr(Chart1->Series[0]->YValue[index]);
// strMouseInfoY2="Y2坐标"+FloatToStr(Chart1->Series[1]->YValue[index]);
// }
// else
// {
strMouseInfoX="X坐标"+FormatFloat("#,##0.000",Chart1->BottomAxis->CalcPosPoint(X));
strMouseInfoY1="Y坐标"+FormatFloat("#,##0.000",Chart1->LeftAxis->CalcPosPoint(Y));
// }
Label1->Caption=strMouseInfoX;
Label2->Caption=strMouseInfoY1;//+":"+strMouseInfoY2;
}
2. 如何用代码在DBCHART中增加一个Series[0]呢?
TLineSeries *mLineSeries2;
mLineSeries2=new TLineSeries(Chart1);
Chart1->AddSeries(mLineSeries2);
mLineSeries2->AddXY(100,200,"w");
mLineSeries2->AddXY(120,250,"e");
mLineSeries2->AddXY(180,125,"fd");