Page 1 of 2

Failed to add Marks manually

Posted: Mon Dec 23, 2013 7:40 am
by 16566869
I want to add Marks at some index of series, but failed..
please help me!

Find the attachment for the example project!
Add mark.png
Add mark.png (58.97 KiB) Viewed 24399 times

Re: Failed to add Marks manually

Posted: Mon Dec 23, 2013 11:19 am
by yeray
Hello,

Looking at your project, you have two series, named SeriesMark and SeriesData. Only SeriesData has points:

Code: Select all

__fastcall TForm2::TForm2(TComponent* Owner)
	: TForm(Owner)
{
	// Data series
	SeriesData->FillSampleValues(10);

}
Then, the button does this:

Code: Select all

void __fastcall TForm2::Button1Click(TObject *Sender)
{
	double max = Chart1->LeftAxis->Maximum;

	// Mark sereis which is used to show some mark.
	SeriesMark->Marks->Visible = true;
	SeriesMark->Marks->Transparent = true;

	// Tried to add a mark at index of 3 .
	SeriesMark->AddXY(3, max);
	SeriesMark->Marks->Item[3]->Text->Text = "N";
}
So you are adding a single point to the SeriesMark series, and then accessing to the point with index=3 to set its label.
Note that, if you are going to add the point and set the label at the same time, you can just pass the label in the same AddXY call:

Code: Select all

void __fastcall TForm2::Button1Click(TObject *Sender)
{
	double max = Chart1->LeftAxis->Maximum;

	// Mark sereis which is used to show some mark.
	SeriesMark->Marks->Visible = true;
	SeriesMark->Marks->Transparent = true;

	// Tried to add a mark at index of 3 .
	SeriesMark->AddXY(3, max, "N");
	//SeriesMark->Marks->Item[3]->Text->Text = "N";
}
If you need to set the label in a separate instruction, you can use "Labels->Labels[0]" (0 for the first point in the series).

Code: Select all

void __fastcall TForm2::Button1Click(TObject *Sender)
{
	double max = Chart1->LeftAxis->Maximum;

	// Mark sereis which is used to show some mark.
	SeriesMark->Marks->Visible = true;
	SeriesMark->Marks->Transparent = true;

	// Tried to add a mark at index of 3 .
	SeriesMark->AddXY(3, max);
	SeriesMark->Labels->Labels[0]="N";
}

Re: Failed to add Marks manually

Posted: Wed Dec 25, 2013 2:28 am
by 16566869
Thanks for your reply.

I know that the mark could be added directly by the code below,
but the grid also disapeared...

Code: Select all

SeriesMark->AddXY(3, max, "N");
Before.png
Before.png (74.93 KiB) Viewed 24331 times
After.png
After.png (51.36 KiB) Viewed 24333 times
So I have tried to use the following code to modify mark manually.

Code: Select all

SeriesMark->Marks->Item[3]->Text->Text = "N";
But it didn't work well...

Re: Failed to add Marks manually

Posted: Fri Dec 27, 2013 11:14 am
by Pep
Hello,
I know that the mark could be added directly by the code below,
but the grid also disapeared...
In the case you want to continue displaying all the axis grid lines and bottom axis labels you have to set the bottom axis style to Value :

Code: Select all

  Chart1.Axes.Bottom.LabelStyle := talValue;
elmec wrote:So I have tried to use the following code to modify mark manually.

Code: Select all

SeriesMark->Marks->Item[3]->Text->Text = "N";
But it didn't work well...
Here you're correct, this is a bug, you should be able to set a specific mark text but using the code above, I testing it here the mark appear without text on it.
Could you please add it to bugzilla ? Doing so you'll be identified as the creator of the issue and therefore notified about its evolution.

Thanks in advance.

Re: Failed to add Marks manually

Posted: Mon Dec 30, 2013 4:14 am
by 16566869
So is there any way to fix the problem...
We are going to release our software...

Re: Failed to add Marks manually

Posted: Mon Dec 30, 2013 10:06 am
by Pep
Hello,

yes, a workaround would be to set the axis label style to "talValue", like :

Code: Select all

procedure TForm1.BitBtn1Click(Sender: TObject);
var max : double;
begin
   max := Chart1.LeftAxis.Maximum;
   // Tried to add a mark at index of 3 .
   Series1.AddXY(3, max);
   Series1.Labels.Labels[0]:='N';
   Chart1.Axes.Bottom.LabelStyle := talValue;
end;

Re: Failed to add Marks manually

Posted: Sat Jan 18, 2014 9:58 am
by 16566869
Hello,

Thanks for your advice.

But would you please tell us how to fix the Marks problem.
We cannt wait for the next release.
Pep wrote:
elmec wrote:So I have tried to use the following code to modify mark manually.

Code: Select all

SeriesMark->Marks->Item[3]->Text->Text = "N";
But it didn't work well...
Here you're correct, this is a bug, you should be able to set a specific mark text but using the code above, I testing it here the mark appear without text on it.
Could you please add it to bugzilla ? Doing so you'll be identified as the creator of the issue and therefore notified about its evolution.

Thanks in advance.

Re: Failed to add Marks manually

Posted: Tue Jan 21, 2014 8:28 am
by yeray
Hello,
elmec wrote:But would you please tell us how to fix the Marks problem.
Isn't the workaround Pep suggested valid for you? Why?

Re: Failed to add Marks manually

Posted: Tue Jan 21, 2014 9:10 am
by Pep
Hello elmec,

as you can see at the bug resolution, it was my mistake when I say you were correct about the issue. It's not a bug. As you only have added one point to the Series, to be able to set a specific mark text for that point you have to use the 0 index for the item, like :

Code: Select all

	// Tried to add a mark at index of 3 .
	SeriesMark->AddXY(3, max);
	SeriesMark->Marks->Item[0]->Text->Text = "N";
        SeriesMark->Marks->Item[0]->Font->Size=18;

Re: Failed to add Marks manually

Posted: Wed Jan 22, 2014 9:04 am
by 16566869
OK , I'd like to repeat the problem again.
---------Code-----------

Code: Select all

	Series1->Marks->Visible = true;

	// Add 5 points to Series
	int xpoints[5] = {10, 20, 30, 40, 50};
	int y = 100;

	for (int i = 0; i < 5; i++)
	{
		Series1->AddXY(xpoints[i], y, IntToStr(i + 1));
	}


	Series1->Marks->Item[0]->Text->Text = "test";
---------Code-----------

But the result is as the attachment! There is no text on mark!

Re: Failed to add Marks manually

Posted: Wed Jan 22, 2014 12:04 pm
by Pep
Hello elmec,

It's strange, it's working fine here with the latest TeeChart Pro v2013.09.131217 version usign the code you posted.
Could you please check which TeeChart version appears into your About box ?

Re: Failed to add Marks manually

Posted: Thu Jan 23, 2014 12:33 am
by 16566869
Hello Pep,

Find the attachment for the Teechart version and example project.

Re: Failed to add Marks manually

Posted: Thu Jan 23, 2014 12:35 am
by 16566869
Hello Pep,

Find the attachment for the Teechart version and example project.
teechart version.png
teechart version.png (115.41 KiB) Viewed 24156 times

Re: Failed to add Marks manually

Posted: Fri Jan 24, 2014 12:44 pm
by yeray
Hello,

Since you are a source code customer, I'll send you a link to private beta version just built to the mail account you have registered in this forum.

Re: Failed to add Marks manually

Posted: Mon Feb 10, 2014 12:27 pm
by 16566869
Thanks,
I'll try it and tell you the result.