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

Message ListMessage List     Post MessagePost Message

  Marker on x-axis with date values
Posted by Alexandre on Oct-07-2011 21:53
Hello,

First, excuse my broken english : this is not my mother tongue.

I program in Java.
I can't place a marker on an x-axis of date.

/* ##### EXTRACT OF CODE ##### */
// method buildXTickValues(Date, Date) return a array of dates with [Start-date, ..., End-date], one day per cell, all days between the two specified dates
Date[] dates = buildXTickValues(new GregorianCalendar(2003,Calendar.JANUARY, 1).getTime(), new GregorianCalendar().getTime()) ;

// [...]

XYChart c = new XYChart(600, 400, Chart.Transparent, Chart.Transparent, 0);
c.setPlotArea(55, 40, 520, 195, Chart.Transparent, Chart.Transparent, Chart.Transparent, 0xcccccc, Chart.Transparent);

// [...]

// ### def of x-axis ###
c.xAxis().setLabelFormat("{value|mm/yyyy}") ;
c.xAxis().setLabelStyle("Arial", 7, Chart.TextColor, 45);
c.xAxis().setDateScale(new GregorianCalendar(2003,Calendar.JANUARY, 1).getTime(), dates[dates.length-1], 6*30*86400, 3*30*86400) ;

// ### Adding series ###
// first data series
AreaLayer layer0 = c.addAreaLayer(data0, 0xff5233, "Fonds");
layer0.setBorderColor(Chart.Transparent) ;
layer0.setXData(dates);
layer0.setLineWidth(1);

// second data series
LineLayer layer1 = c.addLineLayer2();
layer1.addDataSet(data1, 0xffd508, "SBF 120");
layer1.setXData2(new GregorianCalendar(2006,Calendar.JUNE,1).getTime(), new GregorianCalendar().getTime());
layer1.setLineWidth(2);
layer1.moveFront() ;

// third data series
LineLayer layer2 = c.addLineLayer2();
layer2.addDataSet(data2, 0x06f002, "SBF 120 div. r?invest.");
layer2.setXData2(dates[0], dates[dates.length-1]);
layer2.setLineWidth(2);
layer2.moveFront() ;

// ### markers ###
// first try : with a date : FAIL
c.xAxis().addMark(dates[dates.length/2].getTime(), 0xff00ff, "2004").setLineWidth(5) ;

// second try : i see on an another thread to use index of label : FAIL (twice try)
c.xAxis().addMark(5, 0x00ff00, "2004").setLineWidth(5) ;
c.xAxis().addMark(12, 0x00ff00, "2004").setLineWidth(5) ;

// third try : i try with the day index : FAIL
c.xAxis().addMark(364, 0xff0000, "2004").setLineWidth(5) ;
c.xAxis().addMark(365, 0x0000ff, "2004").setLineWidth(5) ;
c.xAxis().addMark(366, 0x00ff00, "2004").setLineWidth(5) ;


// work : it's just for verify
c.yAxis().addMark(100, 0xff00ff, "r?f").setLineWidth(2) ;

// [...]
/* ##### END OF EXTRACT OF CODE ##### */


Can anyone help and advise please ?
Thanks and regards,
Alexandre.

  Re: Marker on x-axis with date values
Posted by Peter Kwan on Oct-07-2011 23:31
Hi Alexandre,

You may try:

c.xAxis().addMark(Chart.CTime(dates[dates.length/2]), 0xff00ff, "2004").setLineWidth(5) ;

Hope this can help.

Regards
Peter Kwan

  Re: Marker on x-axis with date values
Posted by Alexandre on Oct-08-2011 00:01
Hi Peter,

Thanks for your answer. It works great.

Regards,
Alexandre