THistogramSeries Hollow line: how ho hide vertical lines

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Maz
Newbie
Newbie
Posts: 4
Joined: Mon Jun 25, 2007 12:00 am

THistogramSeries Hollow line: how ho hide vertical lines

Post by Maz » Thu Apr 16, 2009 9:59 am

Hello,
I am a Teechart 8 user on Delphi 7 / 2007 platform, and this is my situation:

- Normally I plot a simple vertical bar chart that represents some values during the days of a month.

- Sometimes I need to show an additional target line, this target line can vary from day to day.

- I found the Histogram "hollow" type the perfect fit to have the stairs exactly over the existing bars but it is not nice to see the first left vertical line and the last right vertical line of this serie.

- I tried other solutions like using the line series with stairs options but it starts in the middle of the values bar and I cannot find an offset for this.

- So, my question is if it is possible, programmatically, to hide the vertical lines of a THistogram (ot TBar) type bar (in my specific case I need to hide, or colour it like my background, the leftmost and rightmost vertical lines).

Thanks in Advance,
Massimo

Yeray
Site Admin
Site Admin
Posts: 9602
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Post by Yeray » Thu Apr 16, 2009 11:04 am

Hi Massimo,

Have you tried this?

Code: Select all

Series1.Pen.Color := Series1.Color;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Maz
Newbie
Newbie
Posts: 4
Joined: Mon Jun 25, 2007 12:00 am

Post by Maz » Thu Apr 16, 2009 11:36 am

9348257 wrote:Hi Massimo,

Have you tried this?

Code: Select all

Series1.Pen.Color := Series1.Color;
Hi Yeray,
I need to modify the color only for one side of the bar, for example something like this:

Series1.<bar left side>Pen.Color := clWhite;

Yeray
Site Admin
Site Admin
Posts: 9602
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Post by Yeray » Thu Apr 16, 2009 1:50 pm

Hi Massimo,

In that case I'm afraid that you only can draw the lines directly to the canvas by yourself. Here is a simple example:

Code: Select all

uses series, TeCanvas;

var series1: TBarSeries;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1.View3D := False;
  series1 := TBarSeries.Create(nil);
  Chart1.AddSeries(series1);
  series1.FillSampleValues(10);
  series1.BarWidthPercent := 100;
end;

procedure TForm1.Chart1AfterDraw(Sender: TObject);
var X, Y0, Y1: Integer;
begin
  with Chart1.Canvas do
  begin
    X := series1.CalcXPos(0);
    Y0 := Chart1.Axes.Left.CalcYPosValue(0);
    Y1 := series1.CalcYPos(0);

    Pen.Color := clRed;
    Line(X,Y0,X,Y1);

    X := series1.CalcXPos(series1.Count-1) + series1.BarWidth;
    Y0 := Chart1.Axes.Left.CalcYPosValue(0);
    Y1 := series1.CalcYPos(series1.Count-1);

    Pen.Color := clRed;
    Line(X,Y0,X,Y1);
  end;
end;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Maz
Newbie
Newbie
Posts: 4
Joined: Mon Jun 25, 2007 12:00 am

Post by Maz » Thu Apr 16, 2009 3:00 pm

9348257 wrote: series1 := TBarSeries.Create(nil);
...
X := series1.CalcXPos(series1.Count-1) + series1.BarWidth;
Thanks Alonso,
and how to identify X in case of THistogramSeries ?
I don't have the BarWidth property in THistogramSeries...

Massimo

Yeray
Site Admin
Site Admin
Posts: 9602
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Post by Yeray » Fri Apr 17, 2009 8:45 am

Hi Massimo,

Yes, with histograms you should calculate the bar width by yourself. Also note that Bar series, by default, sets left axis minimum to zero while Histogram series takes the series minimum.

So for histogram series here is the example:

Code: Select all

uses Series, TeCanvas;

var series1: THistogramSeries;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1.View3D := False;
  series1 := THistogramSeries.Create(nil);
  Chart1.AddSeries(series1);
  series1.FillSampleValues(10);
end;

procedure TForm1.Chart1AfterDraw(Sender: TObject);
var X, Y0, Y1, BarWidth: Integer;
begin
  BarWidth := series1.CalcXPos(1) - series1.CalcXPos(0);

  with Chart1.Canvas do
  begin
    X := series1.CalcXPos(0) - (BarWidth div 2);
    Y0 := Chart1.Axes.Left.CalcYPosValue(Chart1.Axes.Left.Minimum);
    Y1 := series1.CalcYPos(0);

    Pen.Color := clRed;
    Line(X,Y0,X,Y1);

    X := series1.CalcXPos(series1.Count-1) + (BarWidth div 2);
    Y0 := Chart1.Axes.Left.CalcYPosValue(Chart1.Axes.Left.Minimum);
    Y1 := series1.CalcYPos(series1.Count-1);

    Pen.Color := clRed;
    Line(X,Y0,X,Y1);
  end;
end;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Maz
Newbie
Newbie
Posts: 4
Joined: Mon Jun 25, 2007 12:00 am

Post by Maz » Fri Apr 17, 2009 10:09 am

Thanks Alonso,
it works perfectly as my needs !

Regards
Massimo

Post Reply