ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  How to make lines appear behind the bars in a chart?
Posted by Eva on Oct-13-2011 00:06
Attachments:
Hi Peter,

I created a Gantt Chart with dependency lines between bars.  Here is my code flow (Java):
...code to create Gantt chart?
...code to create and add my layers to the chart (bars , symbols and dates)?

chart.setPlotArea(...);

?code to generate my custom labels for the x and y-axis
(I use here chart.layoutAxes() to configure the distance for the time labels on the y-axis)?

? code to draw the dependency lines as follows:
1. chart.layout();
2. ...calculate coordinates?
3. series of lines created with the repeating two-line of code:
             newLine = chart.addLine(fromX, fromY, toX, toY, color, lineWidth);
             newLine.setZOrder(Chart.GridLinesZ);

4. create the arrow symbol:
DrawArea d = chart.makeChart3();
d.polygon(x, y, color, color);

I would expect the lines to be behind the bars and labels with the method
setZOrder(Chart.GridLinesZ).

I also tried at some point to call moveFront() for the layers, but without a success.
I'm including part of my chart image. I would like the date labels to be more visible - in front of the line, and the bars on top of the lines as well.

Thank you,
Eva
Bars and lines.png

  Re: How to make lines appear behind the bars in a chart?
Posted by Peter Kwan on Oct-14-2011 01:10
Hi Eva,

I have just tried similar code using the "Simple Gantt Chart" sample code, and the line does stay behind the bars and labels. The test code I am using is by inserting the following code near the end of the "Simple Gantt Chart" sample code to emulate the sequence of your code:

c.layoutAxes();
c.layout();

Line newLine = c.addLine(250, 0, 250, 400, 0xff0000, 3);
newLine.setZOrder(Chart.GridLinesZ);

c.makeChart3();

For your case, would you mind to verify if all the lines are really added before call makeChart3?

For example, the following code will cause the lines to stay in front of the labels:

for (int i = 0; i < n; ++i)
{
     newLine = chart.addLine(fromX, fromY, toX, toY, color, lineWidth);
     newLine.setZOrder(Chart.GridLinesZ);

     DrawArea d = chart.makeChart3();
     d.polygon(x, y, color, color);
}

In the above, with the exception of the first line (the one with i = 0), for all the other lines, the lines are created after calling makeChart3.

On the other hand, the code below should work:

for (int i = 0; i < n; ++i)
{
     newLine = chart.addLine(fromX, fromY, toX, toY, color, lineWidth);
     newLine.setZOrder(Chart.GridLinesZ);
}

//makeChart3 is called only after all the lines are created
for (int i = 0; i < n; ++i)
{
     DrawArea d = chart.makeChart3();
     d.polygon(x, y, color, color);
}

If the above still does not solve the problem, is it possible to modify the "Simple Gantt Chart" sample code to produce the same problem (that the line is in front of the bar)? This can help me to reproduce and diagnose the problem.

Regards
Peter Kwan