how to do chart like a gallery example

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
jaysmurch
Newbie
Newbie
Posts: 3
Joined: Thu Sep 09, 2004 4:00 am
Location: chicago, il

how to do chart like a gallery example

Post by jaysmurch » Tue Sep 14, 2004 5:09 pm

hello, browsing through your TeeChart Gallery.

The very first chart example, a gantt chart: How does one add that semi-transparent "overlay" effect, titled "holiday period." It's not another series, is it? How does one line it up with the correct dates? Can more than one overlay be added?

I guess a couple of lines of code as an example would be very helpful. (If the code for the gallery example is available somewhere, point me to it.)

Thanks and regards.

Marjan
Site Admin
Site Admin
Posts: 745
Joined: Fri Nov 07, 2003 5:00 am
Location: Slovenia
Contact:

Post by Marjan » Wed Sep 15, 2004 7:34 am

Hi.
It's not another series, is it?
Nope. It's a TColorBandTool tool, combined with annotation tool (for "Holiday period" caption). Alternatively, you could also manually drawn required text over the color band in the chart OnAfterDraw event. Something like this:

Code: Select all

var x,y,th: Integer;
begin
  x := Chart1.Axes.Bottom.CalcPosValue(ChartTool1.StartValue);
  With Chart1.Axes.Left do
    y := (IStartPos + IEndPos) div 2;
  With Chart1.Canvas, Chart1 do
  begin
    ClipRectangle(ChartRect);
    Font.Height := -13;
    Font.Color := clNavy;
    th := TextHeight('W');
    TextOut(x+20,y-(th div 2),'Holiday period');
    UnclipRectangle;
  end;
end;
How does one line it up with the correct dates?
By setting the colorband tool StartValue and EndValue. Here is an example where start and end value are set to specific datetime range:

Code: Select all

endDate := EncodeDate(2004,9,10);
Chart1.Axes.Bottom.SetMinMax(endDate-45,enddate);
colorBandTool1.Axis := Chart1.Axes.Bottom;
colorBandTool1.StartValue := EncodeDate(2004,8,6);
colorBandTool1.EndValue := EncodeDate(2004,8,21);
colorBandTool1.Transparency := 50;
Can more than one overlay be added?
Yes (add multiple instances at design or at runtime).
Marjan Slatinek,
http://www.steema.com

Post Reply