how to add Domain Markers on X-axis (Day axis)?

Discussion about JFreeChart related to stockmarket charts.
Locked
ahlvarun
Posts: 1
Joined: Mon Jul 03, 2006 4:52 pm

how to add Domain Markers on X-axis (Day axis)?

Post by ahlvarun » Mon Jul 03, 2006 5:00 pm

hi
i am trying to add marker on domain axis i.e. x-axis , which is of type day in my case.

-- my snippet of code in chart processor--

XYPlot plot = (XYPlot) jfc.getPlot();
Day day = new Day(11,02,2006);
Marker m3 = new ValueMarker(day.getSerialIndex());
plot.addDomainMarker(m3);

But this does not give any marker on my chart.
Is there any marker where i can give day as input rather than a double??
Any clue??

Varun Ahluwalia.

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Mon Jul 03, 2006 5:35 pm

The getSerialIndex() method in the Day class returns an integer that is almost the same as the value used to represent dates in spreadsheets like Excel and Lotus 1-2-3.

The ValueMarker constructor expects a value which, for a DateAxis, should be specified in milliseconds since 1-Jan-1970 (like java.util.Date).

So that is the problem...you are not creating your ValueMarker with the correct value.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

skunk
Posts: 1087
Joined: Thu Jun 02, 2005 10:14 pm
Location: Brisbane, Australia

Post by skunk » Fri Jul 07, 2006 10:19 pm

Have you tried this?

Code: Select all

(double)DateUtilities.createDate(2006, 2, 11).getTime();

Locked