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

Message ListMessage List     Post MessagePost Message

  Date Scale on x-axis
Posted by Alden on Jun-06-2012 15:32
Hi Peter,

On a multiline chart, if I have three sets of data to plot each with different sets of date
points for their data(i.e. each data point has it's own date), how can I add a date range to
the x-axis and have the data point display at their relevant date point on the x-axis for all
three lines? Obviously I can't display three different sets of date labels on the x-axis.

If it helps, my data is passed into the charting class using a LinkedHashMap<String,
ArrayList<Object[]>>; where each Object[] in each arraylist has a date and a
double value. There can be multiple Arraylists in the hashmap.

Thanks,
Alden

  Re: Date Scale on x-axis
Posted by Peter Kwan on Jun-07-2012 01:03
Hi Alden,

There is a sample code "Uneven Data Points" included in ChartDirector, which should be close to your case.

In brief, the code is like:

//assuming the followings are your (x, y) data series
double[] yData0;
java.util.Date[] xDates0;

double[] yData1;
java.util.Date[] xDates1;

double[] yData2;
java.util.Date[] xDates2;


Layer layer0 = c.addLineLayer(yData0, .....);
layer0.setXData(xDates0);

Layer layer1 = c.addLineLayer(yData1, .....);
layer0.setXData(xDates1);

Layer layer2 = c.addLineLayer(yData2, .....);
layer0.setXData(xDates2);

//You can let ChartDirector auto-scale the x-axis, just like how it auto-scales the
//y-axis, or you may use Axis.setDateScale to set the x-axis scale.
c.xAxis().setDateScale(startDate, endDate, labelSpacingInSeconds);

//You can optionally use Axis.setLabelFormat to control the label format.
c.xAxis().setLabelFormat("{value|yyyy-mm-dd}");


Hope this can help.

Regards
Peter Kwan