Page 1 of 1

X-Axis and Vertical Zoom Problems

Posted: Mon Mar 03, 2014 5:27 am
by 16566546
X-Axis and Vertical Zoom Problems. I have created a stacked bar chart, setting self.owner.chart.BottomAxis.Automatic := True. I have the following problems:
1. The x-axis always displays the fourth rock type code, which I am unable to hide. Why is this and how do I hide this label? See attachment Label_On_XAxis.
2. The graph is always displayed in the centre of the x-axis. Is it possible to specify where the bar chart is located?
3. When I zoom, the chart always jumps to the left axis. Why is this and how do I prevent this? See attachments Zoom and After_Zoom.
4. Can I make the legend symbols higher without increasing the font. If I set self.Owner.Chart.Legend.Symbol.Continuous := True; the legend symbol height is increased for all but the first and last. Is it possible to increase the height for all symbols.

Note that the symbols at the left of the chart are drawn on a custom axis.
Label_On_XAxis.png
Label_On_XAxis.png (19.01 KiB) Viewed 8033 times
Zoom.png
Zoom.png (19.81 KiB) Viewed 8008 times
After_Zoom.png
After_Zoom.png (15.65 KiB) Viewed 8012 times

Re: X-Axis and Vertical Zoom Problems

Posted: Mon Mar 03, 2014 2:30 pm
by yeray
Hi Errol,

Your last reply seems to treat completely different issues to the discussed in the thread where you posted it. That's why I split it into a new thread.
Please, try to open a new thread for each different issue or problem to report. This makes things easier for us and for anyone with a similar problem looking for the solution suggested.
We'll reply the inquiries asap.

Re: X-Axis and Vertical Zoom Problems

Posted: Mon Mar 03, 2014 3:36 pm
by yeray
Hi Errol,
Errol wrote:1. The x-axis always displays the fourth rock type code, which I am unable to hide. Why is this and how do I hide this label? See attachment Label_On_XAxis.

Code: Select all

Doing the following, I get "label 0" in the bottom axis label.
uses Series;

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
  Chart1.View3D:=false;
  Chart1.Legend.Alignment:=laBottom;

  for i:=0 to 4 do
    with Chart1.AddSeries(TBarSeries) as TBarSeries do
    begin
      Add(50+random*25, 'label ' + IntToStr(i));
      MultiBar:=mbStacked;
      MarksOnBar:=true;
      MarksLocation:=mlCenter;
    end;
end;
If you are doing something similar to the above, and you want to show no text in the bottom axis, you can use the OnGetAxisLabel as follows:

Code: Select all

uses Series;

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
  Chart1.View3D:=false;
  Chart1.Legend.Alignment:=laBottom;

  for i:=0 to 4 do
    with Chart1.AddSeries(TBarSeries) as TBarSeries do
    begin
      Add(50+random*25, 'label ' + IntToStr(i));
      MultiBar:=mbStacked;
      MarksOnBar:=true;
      MarksLocation:=mlCenter;
    end;

  Chart1.OnGetAxisLabel:=GetAxisLabel;
end;

procedure TForm1.GetAxisLabel(Sender:TChartAxis; Series:TChartSeries; ValueIndex:Integer; var LabelText:String);
begin
  if Sender=Chart1.Axes.Bottom then
    LabelText:='';
end;
Errol wrote:2. The graph is always displayed in the centre of the x-axis. Is it possible to specify where the bar chart is located?
Yes, playing with the bottom axis minimum and maximum properties. In the example above, we've added the values with the Add() method, specifying no XValue. Doing it this way, the XValue is generated by TeeChart and it is 0. Then, if you want to move the bar to the left, you can set a bottom axis minimum -1 and a maximum 2. Ie:

Code: Select all

Chart1.Axes.Bottom.SetMinMax(-1, 2);
Errol wrote:3. When I zoom, the chart always jumps to the left axis. Why is this and how do I prevent this? See attachments Zoom and After_Zoom.
It won't happen any more if you implement the solution for the point above (2).
Errol wrote:4. Can I make the legend symbols higher without increasing the font. If I set self.Owner.Chart.Legend.Symbol.Continuous := True; the legend symbol height is increased for all but the first and last. Is it possible to increase the height for all symbols.
Not exactly for me here. The first symbol height increases in its bottom and the last symbol height increases in its top. This is because this property is thought for the Left/Right alignments, not for the Top/Bottom.
If you want to customize the symbols I'd suggest you to use the Legend.Symbol.OnDraw event as shown in the example at "All features\Welcome !\Miscellaneous\Legend\Symbol OnDraw" in the features demo program shipped with the installation.

Re: X-Axis and Vertical Zoom Problems

Posted: Tue Mar 04, 2014 1:38 am
by 16566546
Yeray wrote:Hi Errol,

Your last reply seems to treat completely different issues to the discussed in the thread where you posted it. That's why I split it into a new thread.
Please, try to open a new thread for each different issue or problem to report. This makes things easier for us and for anyone with a similar problem looking for the solution suggested.
We'll reply the inquiries asap.
I wasn't sure of your policy re new threads. I will follow your suggestion in future.

Re: X-Axis and Vertical Zoom Problems

Posted: Tue Mar 04, 2014 2:37 am
by 16566546
I have successfully removed the X-Axis labels and placed the bar chart where required, as your suggestion to use SetMinMax - thanks. I had previously tried using Chart1.BottomAxis.Minimum and Chart1.BottomAxis.Maximum to set the axis range. The chart still moves around a bit on Zoom, so I wrote an OnZoom event to reset the X-axis Min and Max values each time.

By the way, I realized that my bar chart was located at position 4 on the x-axis as I have 3 other series on the chart (namely the symbols on the left axis).

Thanks and regards

Errol

Re: X-Axis and Vertical Zoom Problems

Posted: Tue Mar 04, 2014 10:32 am
by yeray
Hi Errol,

Thanks for understanding and for the information. I'm glad to hear you achieved to make it work as you wish.