Page 1 of 1

TColorBandTool set min pixels

Posted: Mon Oct 29, 2007 1:23 am
by 5887294
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.

Posted: Tue Oct 30, 2007 10:16 am
by narcis
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!

Posted: Wed Oct 31, 2007 7:02 am
by 5887294
That works great. Thanks. :)