Page 1 of 1

How do I hide values in an Horizontal Bar chart?

Posted: Fri Mar 31, 2006 6:44 pm
by 9336586
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

Posted: Mon Apr 03, 2006 8:38 am
by narcis
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;

Posted: Mon Apr 03, 2006 9:52 am
by 9336586
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

Posted: Wed Apr 05, 2006 10:17 am
by narcis
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.

Posted: Wed Apr 05, 2006 1:12 pm
by 9336586
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

Posted: Wed Apr 05, 2006 2:21 pm
by Pep
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.