Help...

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
conasdem
Posts: 9
Joined: Thu Jul 27, 2006 6:22 pm
Location: portugal

Help...

Post by conasdem » Thu Jul 27, 2006 6:41 pm

I'm trying to make a chart with “time spent on phone by month”. I’m doing some work with voip phones, and I wanted a chart were the administration could see how much time a user spend on the phone on a period of a couple of month’s.

The time data is in seconds and I would like to be on the chart in the format “HH:MM:SS”, this would be the left axis. The bottom axis is easy and it’s done, a DateAxis in the MMM-YY format. I would like it to be a line chart.

The left axis its harder… and I’m really don’t know how to do it. What DataSet to use? What left axis to use?

Could you please help me?

cenicienta
Posts: 15
Joined: Mon Jun 26, 2006 8:31 pm
Location: Paris

Post by cenicienta » Thu Jul 27, 2006 9:07 pm

If you use a TimeSeriesChart with TimeSeriesCollection and if values of TimeSeries are in seconds, you can use a DateAxis for range axis :

Code: Select all

        DateAxis dateAxisRange = new DateAxis("Time");
        dateAxisRange.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss")) ;
        xyplot.setRangeAxis(dateAxisRange );

conasdem
Posts: 9
Joined: Thu Jul 27, 2006 6:22 pm
Location: portugal

Post by conasdem » Fri Jul 28, 2006 3:56 pm

cenicienta wrote:If you use a TimeSeriesChart with TimeSeriesCollection and if values of TimeSeries are in seconds, you can use a DateAxis for range axis :

Code: Select all

        DateAxis dateAxisRange = new DateAxis("Time");
        dateAxisRange.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss")) ;
        xyplot.setRangeAxis(dateAxisRange );
Thanks for your solution.

There is just something I don’t understand, in the dataSet I have to put the values in milliseconds, but when they are converted to Date it ads one hour. For example:

Code: Select all

 
TimeSeries s2 = new TimeSeries("total call time", Month.class);
s2.add(new Month(7, 2006), 1000);
TimeSeriesCollection dataset = new TimeSeriesCollection();
dataset.addSeries(s2);
This dataSet should be displayed like 00:00:01 with the format “HH:mm:ss”, but its displayed 01:00:01. I don’t know why…. If I subtract a hour (-3600*1000) it is displayed correctly.


Another problem is the autoRange. I would like it to rescale the axis to ensure that all data is visible, but I wanted 00:00:00 to appear in the axis also. I Tried to use setRange but I have to define the lower and the upper bound. I just want to define the lower bound and “autoRange” the upper bound.

Could anyone help me.

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

Post by skunk » Fri Jul 28, 2006 4:45 pm

This dataSet should be displayed like 00:00:01 with the format “HH:mm:ss”, but its displayed 01:00:01. I don’t know why…. If I subtract a hour (-3600*1000) it is displayed correctly.
It sounds like there is an adjustment for daylight savings time taking place. You could test whether the timezone of the axis is currently observing daylight savings time to determine if you need to adjust the value.

conasdem
Posts: 9
Joined: Thu Jul 27, 2006 6:22 pm
Location: portugal

anwser

Post by conasdem » Fri Jul 28, 2006 11:08 pm

Yes that's it... have to find out how to get that information.


Still having toruble with the autoRange that I explained in my last post, please HELP :oops:

cenicienta
Posts: 15
Joined: Mon Jun 26, 2006 8:31 pm
Location: Paris

Post by cenicienta » Sun Jul 30, 2006 3:41 pm

What happens if you do that :

Code: Select all

        DateAxis dateAxis = new DateAxis() ;
        SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm:ss");
        timeFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
        dateAxis.setDateFormatOverride(timeFormat) ;
        xyplot.setRangeAxis(dateAxis);

conasdem
Posts: 9
Joined: Thu Jul 27, 2006 6:22 pm
Location: portugal

tks

Post by conasdem » Mon Jul 31, 2006 9:43 am

Tks, that works, for the time problem.


Another problem is the autoRange. I would like it to rescale the axis to ensure that all data is visible, but I wanted 00:00:00 to appear in the axis also. I Tried to use setRange but I have to define the lower and the upper bound. I just want to define the lower bound and “autoRange” the upper bound.

If anyone can help, tks...

conasdem
Posts: 9
Joined: Thu Jul 27, 2006 6:22 pm
Location: portugal

sorry

Post by conasdem » Wed Aug 02, 2006 11:01 am

Attention this is closed all my questions are anwsered

Thank you for all

Locked