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
THistogramSeries Hollow line: how ho hide vertical lines
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
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:
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,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
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:
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,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |