Show/Hide individual Axis Custom Labels
Posted: Wed Oct 12, 2011 11:39 am
Hello, I'm having this type of problem with axis custom labels:
I have a TChart in which I dynamically create a set of TBarSeries, each one having a single bar value. I want to display in the bottom axis a string of text under each bar. I do this by adding custom labels to the chart BottomAxis:
This works. But then, I want to show/hide the above custom labels depending on which series are made visible by the user. I try do it in this way:
but this doesn't work, because all custom labels previously defined are always displayed, independently if the corresponding Series is active or not.
I think there should be some other BottomAxis property to be set to get the desired result, but I cannot find which one niether from help nor from examples.
Thank you very much for your help.
Piero
I have a TChart in which I dynamically create a set of TBarSeries, each one having a single bar value. I want to display in the bottom axis a string of text under each bar. I do this by adding custom labels to the chart BottomAxis:
Code: Select all
for i:=0 to NSeries-1 do
begin
Series:=TBarSeries.Create(Chart);
Series.AddXY(i,Values[i,0]);
Chart.BottomAxis.Items.Add(i,SeriesTitles[i]);
Series.ParentChart:=Chart;
end;
Code: Select all
with Chart do
for i:=0 to SeriesCount-1 do
if (Pos('1',Series[i].Title) <> 0) then // criteria that I'm using to decide wheter a series should be shown or not
begin
Series[i].Active:=true;
BottomAxis.Items[i].Format.Visible:=true;
end
else
begin
Series[i].Active:=false;
BottomAxis.Items[i].Format.Visible:=false;
end;
Chart.Refresh;
I think there should be some other BottomAxis property to be set to get the desired result, but I cannot find which one niether from help nor from examples.
Thank you very much for your help.
Piero