TColorBandTool set min pixels

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Marcus
Newbie
Newbie
Posts: 6
Joined: Fri Nov 15, 2002 12:00 am

TColorBandTool set min pixels

Post by Marcus » Mon Oct 29, 2007 1:23 am

Is it possible to force the TColorBandTool to draw the band N pixels wide but centered on a particular axis value?

Background
---------------

Im using the TColorBandTool to display a shaded region on a chart (with a TLineSeries) where the values for that series are either NaNs or INFs. i.e the series may have valid numbers followed by one or more NaNs and then more valid numbers. Where NaNs exist in the series, i use the AddNullXY method to insert a break in the series and then shade this area using the TColorBandTool.

Setting the StartValue and EndValue properties of the TColorBandTool works fine if you have a large enough visible area (depending on the scaling/zoom of the chart, number of points in the series vs number of NaNs). But if i have a large series of say 10,000 points with only one NaN value and the whole series range is visible, the NaN region is too small to be usefully visible to the user. It's important that any NaN regions are immediately obvious to the user when they view the chart.

I would like to set the TColorBandTool to draw N pixels wide but centered on a particular axis value. It would also be useful to have a TColorBandTool determine which mode is appropriate depending on the chart scaling. i.e IF the StartValue EndValue display area (in pixels) is smaller than the N pixels wide, THEN display the N pixels wide ELSE display the StartValue EndValue region.

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 Oct 30, 2007 10:16 am

Hi Marcus,

In that case you can try doing something like this:

Code: Select all

procedure TForm1.Button1Click(Sender: TObject);
begin
  if ((Chart1.Axes.Bottom.Maximum - Chart1.Axes.Bottom.Minimum) < 5000) then
  begin
    ChartTool1.StartValue:=Series1.CalcXPos(3);
    ChartTool1.EndValue:=Series1.CalcXPos(6);
  end
  else
  begin
    ChartTool1.StartValue:=Chart1.Axes.bottom.CalcPosPoint(Series1.CalcXPos(5)-50);
    ChartTool1.EndValue:=Chart1.Axes.bottom.CalcPosPoint(Series1.CalcXPos(5)+50);
  end;
end;
Hope this helps!
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

Marcus
Newbie
Newbie
Posts: 6
Joined: Fri Nov 15, 2002 12:00 am

Post by Marcus » Wed Oct 31, 2007 7:02 am

That works great. Thanks. :)

Post Reply