TColorLine problem

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Andrew
Newbie
Newbie
Posts: 11
Joined: Thu Feb 06, 2003 5:00 am

TColorLine problem

Post by Andrew » Tue Feb 20, 2007 5:58 am

Hi guys,

I have a small problem with the TColorLineTool. If I create a TColorLineTool and set the value to 20, but show a trend where the vertical range is between 11 and 19, the colorline appears outside of the chart area. Don't know if I'm explaining it very well - I've uploaded a screenshot using the upload file section.

Code (note I'm using a custom vertical axis):

TColorLineTool *line = new TColorLineTool(Chart);
Chart->Tools->Add(line);
line->AllowDrag = false;
line->NoLimitDrag = false;
line->Axis = axisVert;
line->Value = 20;

Any ideas or suggestions on how to stop this from happening?

Andrew

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Feb 20, 2007 9:28 am

Hi Andrew,

Sorry but I don't understand what are you exactly doing here. Could you please send us a simple example project we can run "as-is" to reproduce the problem here?

Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Andrew
Newbie
Newbie
Posts: 11
Joined: Thu Feb 06, 2003 5:00 am

Post by Andrew » Tue Feb 20, 2007 11:39 pm

The screenshot that I uploaded demonstrates the problem pretty clearly - if you set a TColorLineTool->Value property to a value that's outside of the vertical axis min/max, the ColorLine should not be visible...but it is. It appears in the whitespace above or below the chart grid area - this is what I want to stop from happening.

I'll see if I can come up with a small app that demonstrates the problem, but it could take some time.

Andrew
Newbie
Newbie
Posts: 11
Joined: Thu Feb 06, 2003 5:00 am

Post by Andrew » Wed Feb 21, 2007 1:36 am

Having trouble uploading files - here's the complete chunk of code that will demonstrate the problem. All that is required is a TChart object named TrendChart on a form, and put this in form's constructor:

//Definitions
double dblMin = 10;
double dblMax = 30;
double dblInterval = 1.0/24.0/20.0;

//Add horizontal axis
TChartAxis *axisHorz = new TChartAxis(TrendChart);

TDateTime tdt = TDateTime::CurrentDateTime();
axisHorz->Maximum = tdt;
axisHorz->Minimum = tdt - 1.0/24.0;
axisHorz->ExactDateTime = true;
axisHorz->DateTimeFormat = "dd/mm/yyyy hh:mm:ss";
axisHorz->Increment = DateTimeStep[dtOneSecond];
axisHorz->LabelsMultiLine = true;

axisHorz->Grid->Visible = true;
axisHorz->Automatic = false;
axisHorz->AutomaticMinimum = false;
axisHorz->AutomaticMaximum = false;
axisHorz->PositionPercent = 0;
axisHorz->Horizontal = true;
axisHorz->OtherSide = false;
axisHorz->Visible = true;
axisHorz->LabelsFont->Color = clRed;

//Add vertical axis
TChartAxis *axisVert = new TChartAxis(TrendChart);

axisVert->Maximum = dblMax + 1;
axisVert->Minimum = dblMin - 1;
axisVert->Grid->Visible = true;
axisVert->Automatic = false;
axisVert->AutomaticMinimum = false;
axisVert->AutomaticMaximum = false;
axisVert->PositionPercent = 0;
axisVert->Horizontal = false;
axisVert->OtherSide = false;
axisVert->Visible = true;
axisVert->LabelsFont->Color = clRed;

//Create a series to show some values
TChartSeries *series = new TLineSeries(TrendChart);
series->ParentChart = TrendChart;

TCustomSeries *cSeries = dynamic_cast<TCustomSeries *>(series);
cSeries->LinePen->Width = 2;
series->SeriesColor = clRed;
series->HorizAxis = aBottomAxis;
series->VertAxis = aLeftAxis;

series->CustomHorizAxis = axisHorz;
series->CustomVertAxis = axisVert;
series->XValues->DateTime = true;
series->ZOrder = 0;
series->Active = true;

TDateTime tdtTime = axisHorz->Minimum;

//Now add some random data
for (int i=0; i < 20; i++)
{
double dblValue = rand();
while ( (dblValue < dblMin) || (dblValue > (dblMax)) )
{
dblValue = rand();
}
series->AddXY(tdtTime, dblValue);
tdtTime += dblInterval;
}

//Now add colorlinetool outside the min/max range of the data
TColorLineTool *line = new TColorLineTool(TrendChart);
TrendChart->Tools->Add(line);
line->AllowDrag = false;
line->NoLimitDrag = false;
line->Axis = axisVert;
line->Pen->Color = clBlue;
line->Pen->Width = 2;
line->Value = 32;

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Feb 21, 2007 8:35 am

Hi Andrew,

Thanks for the information and code.

In case you were dragging the tool you have the NoLimitDrag property. However, in your case you can check if ColorLine's value is outside axis range and make it active accordingly:

Code: Select all

	if ((line->Value > line->Axis->Maximum) || (line->Value < line->Axis->Minimum))
	{
		line->Active = false;
	}
	else
	{
		line->Active = true;
	}
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply