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

Message ListMessage List     Post MessagePost Message

  Problem with aligning background color with major ticks
Posted by Eva on Mar-31-2016 04:17
Attachments:
Hello Peter,

I have a problem with the alternate background colors on the plot area when the chart doesn’t start at the beginning of a year.

I’m including the images of the chart with time labels. Notice, when the chart starts in the first day of the year (second image), the alternate background color and grids work. But when the chart starts within a year (example with Q4), the background doesn’t lineup with years (I created the major tick increment as one year). How I can fix that?

Here are the steps in Java:

1. I created a XYChart (Gantt Chart). I added “custom” time labels with a CDMLTable and positioned the table at exact location of the yAxis:
yAxisTable = chart.addTable(0, 0, Chart.TopLeft, nCol, nRows);

2. Fill in the yAxisTable, and adjust the cell widths based on ticks

3. Use setDateScale() to setup the chart dates as well as major and minor ticks increments.

int majorTickInc = 360 * 86400; //year
int minorTicksInc = 3 * 30 * 86400;//3 months

this.chart.yAxis().setRounding(true, true);
this.chart.yAxis().setDateScale(chartStartDate, chartEndDate, majorTickInc, minorTicksInc);
this.chart.yAxis().setColors(Chart.Transparent, Chart.Transparent);

//we don't want the ChartDirector to format the date/time axis labels
chart.yAxis().setLabelFormat(" ");

4. Format the PlotArea
chart.setPlotArea(x, y, plotWidth, plotHeigh, plotBackground, plotAltBackground,
      edgeColor, hGridColor, vGridColor).setGridWidth(1, 1, 1, 1);

this.chart.getPlotArea().setGridColor( , , , );

Thank you,
Eva
Charts.png

  Re: Problem with aligning background color with major ticks
Posted by Peter Kwan on Apr-01-2016 00:19
Hi Eva,

Assuming you are using ChartDirector 6.0, please change the line:

this.chart.yAxis().setRounding(true, true);

to:

this.chart.yAxis().setRounding(false, false);

(Note: The setRounding should be applied before setDateScale, which is the case in your code.)

Regards
Peter Kwan