Page 1 of 1

TColorLine problem

Posted: Tue Feb 20, 2007 5:58 am
by 8575642
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

Posted: Tue Feb 20, 2007 9:28 am
by narcis
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.

Posted: Tue Feb 20, 2007 11:39 pm
by 8575642
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.

Posted: Wed Feb 21, 2007 1:36 am
by 8575642
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;

Posted: Wed Feb 21, 2007 8:35 am
by narcis
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;
	}