Page 1 of 1

cannt change the color of marks

Posted: Thu May 22, 2014 4:34 am
by 16566869
The color cannt be changed by the following code.
BTW, I am using the newest Teechart(2014) for C++Builder XE4 Firemonkey HD APP.

Code: Select all

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

#include <fmx.h>
#pragma hdrstop
#include <iostream>
#include <string>

#include "Unit12.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)

#pragma resource "*.fmx"
TForm12 *Form12;


__fastcall TForm12::TForm12(TComponent* Owner)
	: TForm(Owner)
{

	seriesSeries1->Marks->Visible = true;
	seriesSeries1->AddXY(10,10, "aa", claRed);
	seriesSeries1->AddXY(20,10, "bb", claBlue);

}

Re: cannt change the color of marks

Posted: Thu May 22, 2014 4:34 am
by 16566869
changcolor.jpg
changcolor.jpg (37.18 KiB) Viewed 15182 times

Re: cannt change the color of marks

Posted: Thu May 22, 2014 11:33 am
by yeray
Hello,

Is this a TLineSeries? I can't reproduce this with a TLineSeries.
If it's a TFastLineSeries, note this.

Reading the thread title again it mentions the marks. So I'm not sure if the intention of the code you posted was to set red and blue colors to the marks or to the line pen. If you want to change the marks colors, you have to use the corresponding Marks Items array after populating the series:

Code: Select all

   Chart1->View3D = false;

   TFastLineSeries *seriesSeries1 = new TFastLineSeries(this);
   Chart1->AddSeries(seriesSeries1);

   seriesSeries1->Marks->Visible = true;
   seriesSeries1->AddXY(10,10, "aa", claRed);
   seriesSeries1->AddXY(20,10, "bb", claBlue);

   seriesSeries1->Marks->Item[0]->Color = claRed;
   seriesSeries1->Marks->Item[1]->Color = claBlue;

Re: cannt change the color of marks

Posted: Thu May 22, 2014 1:02 pm
by 16566869
Thank you.
I meant the label..and I used the TFastLineSeries...
SO I will change to TLineSeries and try again.

Re: cannt change the color of marks

Posted: Thu May 22, 2014 1:10 pm
by 16566869
But I am confused about the result of the following code.

Code: Select all

    TFastLineSeries* line = new TFastLineSeries(Chart1);
    line->ParentChart = Chart1;
    line->Marks->Visible = true;

    line->FillSampleValues(10);

    // the count fo marks is  ZERO!!!   Even all the marks are showed just like in the attachment.
    ShowMessage(line->Marks->Items->Count);

Re: cannt change the color of marks

Posted: Fri May 23, 2014 10:03 am
by yeray
Hello,

The problem here is that the Marks->Items array is being populated as you access it; if you access the Marks->Item[index], the array is populated from the item 0 to the item being accessed, and Marks->Items->Count always indicates how many items are populated in the array.
Ie, if you access to the Item[0], then the Count will give you 1:

Code: Select all

	line->Marks->Item[0];
	ShowMessage(line->Marks->Items->Count);
Or, if you access the item[3], then the Count will give you 4:

Code: Select all

	line->Marks->Item[3];
	ShowMessage(line->Marks->Items->Count);
Then, if you want to get the complete Count, you have to access the last item. Ie:

Code: Select all

	line->Marks->Item[line->Count()-1];
	ShowMessage(line->Marks->Items->Count);

Re: cannt change the color of marks

Posted: Sat May 24, 2014 5:50 am
by 16566869
Thank you !