Jump to content

3 series in 1 TChart

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1
tmatematikas

tmatematikas

    Newbie

  • Members
  • PipPip
  • 16 posts
Hello. I have a simple question about TChart.
The data are : x, y1, y2, y3, ...
The purpose is to draw a graph on them (y1(x), y2(x), ...). So I have written a code for this:

DeletePlot();

CreatePlot(x, y1, n, 1, clRed);

CreatePlot(x, y2, n, 2, clGreen);

CreatePlot(x, y3, n, 3, clBlue);

...

void TForm2::CreatePlot(double * x, double * y, int n, int series, TColor cl)

{

   if (x != NULL && y != NULL){

     for (int i = 0 ; i < n; i++){

       if (series == 1) Series1->AddXY(x[i], y[i], "", cl);

       if (series == 2) Series2->AddXY(x[i], y[i], "", cl);

       if (series == 3) Series3->AddXY(x[i], y[i], "", cl);

       // and so on ...

     }

   }

}


void TForm2::DeletePlot()

{

   Series1->Clear();

   Series2->Clear();

   Series3->Clear();

}

The problem is that the code above results in not desired graph. In the attached jpg' first graph is correct (I've done it with TImage) and the second is the result from code above. Do anybody happen to know why do these points mixe up?

Attached Files



#2
tmatematikas

tmatematikas

    Newbie

  • Members
  • PipPip
  • 16 posts
Oh, I found what was wrong:

CreatePlot(x, y1, n, 1, clRed);

CreatePlot(x, y2, n, 1, clGreen);

CreatePlot(x, y3, n, 1, clBlue);

The id of series was the same. Now everything works fine :thumbup1: