Page 1 of 1

TLineSeries Stairs type - Mark Point control

Posted: Thu Aug 28, 2008 9:53 am
by 10547875
Hi!

I am using TChart Pro 8.02 and in the current product TLineseries, Stairs type...

The Mark Text seems to be always placed at the end of the line drawn, pretty much where the x/y coordinates are for the point.

Is there a way to tell TChart that you want the marks to identify the beginning of the line and point to the initial point drawn?

Thanks,
Tim

Posted: Thu Aug 28, 2008 10:10 am
by narcis
Hi Tim,
I am using TChart Pro 8.02 and in the current product TLineseries, Stairs type...

The Mark Text seems to be always placed at the end of the line drawn, pretty much where the x/y coordinates are for the point.
Yes, that's right.
Is there a way to tell TChart that you want the marks to identify the beginning of the line and point to the initial point drawn?


Sorry but I don't understand what do you exactly mean here. Would you be so kind to give us some more details of what you are trying to achieve? An image would be helpful.

You may post your files at news://www.steema.net/stema.public.attachments newsgroup or at our upload page.

Thanks in advance.

Posted: Thu Aug 28, 2008 10:36 am
by 10547875
Yes, I can. e.g. If I have a time line (X) and a temperature (Y) and lets say the first step in some array of stpes says that something should run for e.g. 5 minutes, currently the Mark text is marked at e.g. 70C and 05:00...

Instead of marking 00:00 as the 1st Step... meaning it is pointing to the end of the line...

Is this better?

/Tim

Posted: Thu Aug 28, 2008 11:03 am
by narcis
Hi Tim,

Thanks for the info.

I'm using this code:

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
begin
  Series1.Clear;
  Series1.Stairs:=true;
  Series1.Marks.Visible:=true;

  Series1.AddXY(0,5);
  Series1.AddXY(1,7);
  Series1.AddXY(2,6);
  Series1.AddXY(10,8);
  Series1.AddXY(11,4);
end;
With v8.03 I get this chart:

Image

So, if I understood correctly, instead of getting the "6" mark at X=2 you get it at X=10?

Thanks in advance.

Posted: Thu Aug 28, 2008 1:05 pm
by 10547875
Hi,

try using time... as the x axis... and using minute + second display only...

e.g.

Chart1->Series[0]->AddXY(tAxisTime1.Val,70.7,sStep,clRed)

/Tim

Posted: Thu Aug 28, 2008 1:55 pm
by narcis
Hi Tim,

Sorry but I'm still unable to reproduce the issue here. Could you please send us a simple example project we can run "as-is" to reproduce the problem here?

Thanks in advance.

Posted: Thu Aug 28, 2008 2:07 pm
by 10547875
Will do. I'll mail it to you next week.

THANKS for your help.

There is always the possibility that I am doing something wrong!

/Tim

Posted: Thu Aug 28, 2008 2:27 pm
by narcis
Hi Tim,

Thanks. I'd prefer if you posted the files at the upload area I pointed you earlier in the thread. That way my colleagues can make their contributions to the discussion.

Thanks in advance!

Posted: Thu Aug 28, 2008 2:35 pm
by 10547875
OK!

Posted: Mon Sep 01, 2008 7:48 am
by 10547875
Hi!

The sample project TimGraph is now at your upload site...

You will see that Step 0 draws at 05:00 minutes... what we need is that the Mark/Draw shows that the Step starts at 00:00 and last 05:00 minutes...

Meaning it should show the start of the items, then the line showing duration, then a new step...

Tim

Posted: Mon Sep 01, 2008 9:17 am
by narcis
Hi Tim,

Thanks for the example project.

In that case you should add a value at 00:00, for example, modifying this part of your code:

Code: Select all

		 if(i==0)
		 {
			Chart1->Series[0]->AddXY(tAxisTime1.Val,60.7,"",clRed);
		   tAxisTime1 = tAxisTime+EncodeTime(0,5,0,0);
		 }
		 else
		 {
		   tAxisTime1 = tAxisTime1+EncodeTime(iHour,iMin,iSec+45,0);
		 }
and adding OnGetMarkText event like this:

Code: Select all

void __fastcall TForm1::Series1GetMarkText(TChartSeries *Sender, int ValueIndex,
	  AnsiString &MarkText)
{
	if (ValueIndex == 0) {
		MarkText="";
	}
}

Posted: Mon Sep 01, 2008 12:29 pm
by 10547875
Hi!

Adding a step to point to 00:00 and hiding the mark solves the starting time.

But that still leaves me with the problem that the Step Marks always point to the end of the step...not at the beginning of the step line.

If I have a task with a duration of 5 minutes than it should point to 00:00->05:00... or a task from 05:00->10:00... should point at start not end... Would I need to add invisible points to all stairs, if yes, than it might be either to make a line chart and connect the points and control the marks that way... meaning each line would have 2 points marking start and end... and only start showing the mark...

Do you have some better solution?

Thanks,
Tim

Posted: Mon Sep 01, 2008 1:34 pm
by narcis
Hi Tim,

In that case you can change your code like this:

Code: Select all

void __fastcall TForm1::DrawProtoGraph(void)
{
	int iHour=0;
	int iMin=0;
	int iSec=0;
	AnsiString sStep;

	TDateTime tAxisTime = Now();
	ReplaceTime(tAxisTime,EncodeTime(0,0,0,0)); //we want time to start at 00:00
	TDateTime tAxisTime1 = tAxisTime;

	Chart1->MaxPointsPerPage = 5;
	ChartTool2->Active = true;

	for(int i=0;i<10;i++)
	{
		sStep="Step "+IntToStr(i+1);

		if(i==0)
		{
			sStep = "Step "+IntToStr(i);
			Chart1->Series[0]->AddXY(tAxisTime1.Val,60.7,sStep,clRed);
			tAxisTime1 = tAxisTime+EncodeTime(0,5,0,0);
		}
		else
		{
			tAxisTime1 = tAxisTime1+EncodeTime(iHour,iMin,iSec+45,0);
		}

		if(i==3)
		{
			sStep = "Step "+IntToStr(i);
			Chart1->Series[0]->AddXY(tAxisTime1.Val,25.7,sStep,clRed);
		}
		else
		if(i==4)
		{
			sStep = sStep+" Loop";
			tAxisTime1 = tAxisTime1+EncodeTime(iHour,iMin+5,iSec,0);//just an offset to show step
			Chart1->Series[0]->AddXY(tAxisTime1.Val,70.0,sStep,clGreen);
		}
		else
		{
			if (i!=0)
			{
				sStep = "Step "+IntToStr(i);
				Chart1->Series[0]->AddXY(tAxisTime1.Val,60.7,sStep,clRed);
			}
		}
	}
}

Posted: Mon Sep 01, 2008 3:57 pm
by 10547875
thanks. I'll check this tomorrow.

Br, Tim