How do I hide values in an Horizontal Bar chart?

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
bsonnino
Newbie
Newbie
Posts: 10
Joined: Tue Mar 23, 2004 5:00 am

How do I hide values in an Horizontal Bar chart?

Post by bsonnino » Fri Mar 31, 2006 6:44 pm

I'm trying to hide values in an horizontal bar chart. I tried to set the color to clNone or to use the SetNull function, both hide the bar but leave the label and the space in the bar. I'd like a way to completely hide the value from the chart and I don't want to delete it.

Bruno

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Mon Apr 03, 2006 8:38 am

Hi Bruno,

It works fine for me here using the code below. The bar space can not be hidden as it depends on each bar Y value but you can use each Y value for more than one bar. To have the label not being drawn set LabelStyle as here:

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
begin
  Series1.AddXY(3,1,'',clTeeColor);
  Series1.AddXY(5,2,'',clNone);
  Series1.AddXY(7,2,'',clTeeColor);
  Series1.AddXY(5,3,'',clNone);

  Chart1.Axes.Left.LabelStyle:=talMark;
end;
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

bsonnino
Newbie
Newbie
Posts: 10
Joined: Tue Mar 23, 2004 5:00 am

Post by bsonnino » Mon Apr 03, 2006 9:52 am

I tried it here, and it didn't work - maybe I'm missing something, I've got three horizontal bar spaces, and only two had bars?

This doesn't work if you try to hide the values after they are added. Try this, in the OnClickSeries event of the chart (add data with FillSampleValues):

Code: Select all

procedure TForm1.Chart1ClickSeries(Sender: TCustomChart; Series: TChartSeries;
  ValueIndex: Integer; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  Series1.SetNull(ValueIndex);
end;
This will hide the bar, but won't change the axis

Bruno

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Apr 05, 2006 10:17 am

Hi Bruno,

Then you may try to do something like in the All Features\Welcome!\Chart Styles\Financial\Candle (OHLC)\Axis Labels no Weekends example at TeeChart features demo. You'll find the demo at TeeChart's program group.
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

bsonnino
Newbie
Newbie
Posts: 10
Joined: Tue Mar 23, 2004 5:00 am

Post by bsonnino » Wed Apr 05, 2006 1:12 pm

This still doesn't work. It hides the label, but doesn't redraw the axis. What I want is to hide the value and also redraw the chart, so there is no blank space it it.
For example, I have 10 values in the horizontal bar chart. If I hide the 4th value, I don't want to have 3 bars, a space and another 6 bars. I want to have a new chart with 9 values, no spaces. I don't want to delete the value, as it can be shown again.

Bruno

Pep
Site Admin
Site Admin
Posts: 3299
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Wed Apr 05, 2006 2:21 pm

Hi Bruno,

there's not an automatic way to hide the Bar and remove the space.
The only way that I can think of is by deleting the datapoint or adding the points again to your Series, you could create a new Series, copy or add all the points except the ones you want to hide and then exchange the Series by the one which is displayed.

Post Reply