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

Message ListMessage List     Post MessagePost Message

  Aligning date labels with start of day on XYChart
Posted by Mark Chidwick on Mar-05-2017 05:55
Attachments:
Chart Director Support

I am using ChartDirector (latest version) in Java.

I have a simple XYChart to which I am adding a LineLayer.  The Xaxis is a DateScale.  I set the format for the labels as follows:

XYChart c = new XYChart(xs, ys, Chart.brushedSilverColor(), 0x888888);

c.xAxis().setDateScale(xminDate, xmaxDate, xMajorLabel, xMinorLabel);
// where xminDate is a Date
// where xmaxDate is a Date
// where xMajorLabel is 3600 * 24
// where xMinorLabel is 3600 * 24

c.xAxis().setMultiFormat(Chart.StartOfDayFilter(),
    "<*font=Arial*>{value|mmm d}", Chart.StartOfDayFilter(), "-{value|mmm d}");

layer = c.addLineLayer2();
layer.setXData(xdata);  // xdata is an array of Date[]

PROBLEM:
I have the chart in a scrollPane so that I can set a new start date, reload the chart with new data, then have it re-drawn.  So the date/time of the first sample provided to the chart may not be the start of a day.

I would like the chart to display those points on the X axis that are exactly the start of the day rather than the first sample and every 3600*24 samples after that.

I have attached the complete file that draws a chart for my application.

Can you suggest how I might achieve this.

Many thanks

Mark
DateLineChartPanel.java
DateLineChartPanel.java

9.92 Kb

  Re: Aligning date labels with start of day on XYChart
Posted by Peter Kwan on Mar-05-2017 14:46
Hi Mark,

For your case, before the line:

c.xAxis().setDateScale(xminDate, xmaxDate, xMajorLabel, xMinorLabel);

please insert:

c.xAxis().setRounding(false, false);

Hope this can help.

Regards
Peter Kwan