|
No grids in the first column |
Posted by Eva on May-19-2016 04:33 |
|
Hi Peter,
I would like to get rid of minor grid lines in the first column of a Gantt Chart. The time labels are created using a CDMLTable. I set the date scale as follows:
chart.yAxis().setDateScale(chartStartDate, chartEndDate, majorTickInc, minorTicksInc);
I’m including an image of a desired output.
Do I need to set two date scales for different ranges? Is it possible?
(I use Java)
Thanks!
Eva
|
Re: No grids in the first column |
Posted by Peter Kwan on May-24-2016 16:18 |
|
Hi Eva,
Sorry for the late reply.
For your case, you may try to use an extra axis just for the labels. It is like:
// This is the main axis with but with no labels at all
c.yAxis().setDateScale(new GregorianCalendar(2014, 0, 1).getTime(), new GregorianCalendar(2017, 11, 21).getTime(), Chart.NoValue);
// Add another axis at the top
Axis labelAxis = c.addAxis(Chart.Top, 0);
// Set the first layer of labels. The "-" means the label is associated with a minor
// grid, while "~" means no grid
labelAxis.setLabels(new String[] { "~Q1", "~Q2", "~Q3", "Q4", "-Q1", "-Q2", "-Q3", "Q4", "-Q1", "-Q2", "-Q3", "Q4", "-Q1", "-Q2", "-Q3", "Q4" });
// Use this axis to draw the grid lines
c.getPlotArea().setGridAxis(c.xAxis(), labelAxis);
// Change the labels into a table so we can add a second layer of labels
CDMLTable labelTable = labelAxis.makeLabelTable();
labelTable.insertRow(0);
for (int i = 1; i < 4; ++i)
labelTable.setCell(i * 4, 0, 4, 1, "FY" + (2014 + i));
// Finally, merge the cells in the first 4 columns into a large "Prior" cell.
labelTable.setCell(0, 0, 4, 2, "Prior");
Hope this can help.
Regards
Peter Kwan
|
Re: No grids in the first column |
Posted by Eva on Jun-09-2016 01:27 |
|
Thank you Peter! I was able to create the axis labels as you showed me.
One issue came up:
Since we set NoValue for the majorTickInc, how do I achieve alternate shading as shown in my previous image?
Thanks,
Eva |
Re: No grids in the first column |
Posted by Peter Kwan on Jun-09-2016 16:24 |
|
Hi Eva,
Since ChartDirector is always using the primary y-axis to determine the alternative coloring, I think we still need to create major ticks in the primary y-axis:
Instead of using:
c.yAxis().setDateScale(new GregorianCalendar(2014, 0, 1).getTime(), new GregorianCalendar(2017, 11, 21).getTime(), Chart.NoValue);
please change the above to:
// A major tick every year for alternative coloring
c.yAxis().setDateScale(new GregorianCalendar(2014, 0, 1).getTime(), new GregorianCalendar(2017, 11, 31, 23, 59, 59).getTime(), 360 * 86400);
// No visible label
c.yAxis().setLabelFormat(" ");
Hope this can help.
Regards
Peter Kwan |
|