Page 1 of 1

TChart : Axis Items overlaping

Posted: Mon Apr 30, 2012 7:58 am
by 16561334
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.

Re: TChart : Axis Items overlaping

Posted: Tue May 01, 2012 3:11 pm
by 16561334
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.

Re: TChart : Axis Items overlaping

Posted: Wed May 02, 2012 9:05 am
by yeray
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

Re: TChart : Axis Items overlaping

Posted: Wed May 02, 2012 9:47 am
by 16561334
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.

Re: TChart : Axis Items overlaping

Posted: Wed May 02, 2012 11:11 am
by yeray
Hi Nicolas,

Sorry, I forgot it.
Try with:

Code: Select all

Chart_VisuOperation.Series[0].Marks.Clip:=true;