1

While using a C++ builder 6 XE4 for creating a finance charts, i was trying to create, draw line feature. The Series that i had created was candle Stick Series. I tried to move to the XY co-ordinate as pointed out by the mouse pointer but whenever the below piece of code was hit, it threw an exception.

Chart1->Canvas->MoveTo(10,20); --> have given some valid values.

Is it possible to draw a line or any figures on the Chart (not on the form)? If yes, could you please let me know, how should it be done.

Thanks.

4

1 に答える 1

0

はい。TeeChart Pro VCL/FMX には、その目的のために DrawLine ツール (TDrawLineTool) が含まれています。C++ Builder XE4 に同梱されている TeeChart バージョンでは、以下のコード例のように、チャート キャンバスに手動で線を引くことができます。

//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit2.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "VCLTee.CandleCh"
#pragma link "VCLTee.OHLChart"
#pragma resource "*.dfm"
TForm2 *Form2;
int X0,Y0;
int X1,Y1;
//---------------------------------------------------------------------------
__fastcall TForm2::TForm2(TComponent* Owner)
    : TForm(Owner)
{
    X0=-1;
    Y0=-1;
    X1=-1;
    Y1=-1;
}
//---------------------------------------------------------------------------
void __fastcall TForm2::Chart1MouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift,
          int X, int Y)
{
    if ((X0==-1) || (Y0==-1)) {
        X0=X;
        Y0=Y;
    }
    else {
        X1=X;
        Y1=Y;
        Chart1->Draw();
    }

}
//---------------------------------------------------------------------------
void __fastcall TForm2::Chart1AfterDraw(TObject *Sender)
{
    if ((X1!=-1) && (Y1!=-1)) {
        Chart1->Canvas->Line(X0,Y0,X1,Y1);
        X0=-1;
        Y0=-1;
        X1=-1;
        Y1=-1;
    }
}
//---------------------------------------------------------------------------
于 2013-11-14T13:06:38.853 に答える