TChart : Axis Items overlaping

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Nicolas Pierre
Newbie
Newbie
Posts: 3
Joined: Fri Jan 20, 2012 12:00 am

TChart : Axis Items overlaping

Post by Nicolas Pierre » Mon Apr 30, 2012 7:58 am

I have a TChart on which I build several TGanttSeries and one TLineSeries at run time.

Each TGanttSerie represent a step in a production process, each "line" represent one process. So each bars use its step number as a mark and I use LeftAxis.Items to display the correct labels.

Code: Select all

For <Each Item on the lowest series> do
begin
          Chart_VisuOperation.LeftAxis.Items.Add(groupIndex, groupName);
          Chart_VisuOperation.LeftAxis.Items.Automatic := False;
end;
Also, I have inverted my left axis as I need the line to be displayed in chronological creation order.

As we can have a lot of those lines I want to limit the simultaneous displayed results to 30. Also, as the data can span quite a long period, I limit the bottom axis to up to 60 days.
If there is less than 30 lines or 60 days, I don't put a limit on the axis.
I use two TChartScrollBar to manage the scrolling.

On to the problems :
1) When the marks are out of the main drawing zone but still in the component drawing space, the marks are displayed through the axis labels (this one is annoying but not a major problem)
2) When I scroll the lines vertically, the labels tends to stick on screen and overlap each other. This one is quite problematic as it's quickly impossible to read anything.

Bath are displayed in red box on the attached picture.

So
- Is there a way to mask out-of-the drawing zone labels and marks I tried to do something like

Code: Select all

procedure TForm_Planification.ChartLeftAxisDrawLabel(Sender:TChartAxis;
  var aX,aY,aZ:Integer; var aText:String; var aDrawLabel:Boolean);
Var Ymin, Ymax : Integer;
begin
  Ymax := Chart_VisuOperation.Series[0].CalcYPos(Ceil(Sender.Minimum));
  Ymin := Chart_VisuOperation.Series[0].CalcYPos(Floor(Sender.Maximum));
  if ((aY < Ymin) or (aY > Ymax)) Then
    aDrawLabel := False;
end;
But I didn't manage to get the right coordinates.

- Should I use something else than Gantt series ?

Amazing components, apart from that.
Nicolas.
Attachments
apperçu planif.gif
Screenshot of the problems
apperçu planif.gif (61.64 KiB) Viewed 4743 times

Nicolas Pierre
Newbie
Newbie
Posts: 3
Joined: Fri Jan 20, 2012 12:00 am

Re: TChart : Axis Items overlaping

Post by Nicolas Pierre » Tue May 01, 2012 3:11 pm

Sorry to insist. I'd need to know if something can be done.
Having the solution is important but knowing if I have to find another system to manage my charts is even more important, as I'll have to start soon.

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: TChart : Axis Items overlaping

Post by Yeray » Wed May 02, 2012 9:05 am

Hi Nicolas,

It sounds similar to this.
Here you have the same workaround the customer proposed, translated to delphi:

Code: Select all

procedure TForm1.CalcLabels;
var LabelIndex: Integer;
begin
  with Chart1.Axes.Left do
  for LabelIndex:=0 to Items.Count-1 do
  begin
    if (Items.Item[LabelIndex].Value > Maximum) or (Items.Item[LabelIndex].Value < Minimum) then
      Items.Item[LabelIndex].LabelPos:=-10;
  end;
end;
You could call this CalcLabels method at the scroll/zoom/unzoom events
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Nicolas Pierre
Newbie
Newbie
Posts: 3
Joined: Fri Jan 20, 2012 12:00 am

Re: TChart : Axis Items overlaping

Post by Nicolas Pierre » Wed May 02, 2012 9:47 am

Thanks a lot it works quite well when put in the "OnBeforeDrawAxes" event, even if it slow a bit then movement of the chart.

Well, now if you could help me with the marks, I would be completely happy.

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: TChart : Axis Items overlaping

Post by Yeray » Wed May 02, 2012 11:11 am

Hi Nicolas,

Sorry, I forgot it.
Try with:

Code: Select all

Chart_VisuOperation.Series[0].Marks.Clip:=true;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply