General questions on JFreeCharts

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
luis_esru
Posts: 42
Joined: Tue Jan 20, 2004 6:40 pm
Location: Glasgow
Contact:

General questions on JFreeCharts

Post by luis_esru » Tue Feb 17, 2004 12:47 pm

David

I've been using JFreeCharts for my project and it has been very useful. I've to say that they are the most powerful charts around, that said, I have a few questions individual charts that I'm using in my work:

1. StackedBar Chart
- Why isn't the zoom working properly with?
chartPanel.setMouseZoomable(true, false);

- When the log scale is applied, there is a lot of wasted space on top (e.g. the max value is 140 and the max number on the scale is 1000). Try data below:
double[] data1 = {1.878,0.000,10.113,4.555,0.000,120.413,1.147};
double[] data2 = {0.003,0.000,0.034,0.555,0.000,0.405,0.002};
double[] data3 = {0.002,0.000,0.125,0.255,0.000,1.489,0.001};

2. Bar Chart
- Why isn't the zoom working properly with?
chartPanel.setMouseZoomable(true, false);

- The bars can have a gray outline but the legend can’t! Is there a way of doing it? The reason for that is because I use white color for one of the series and it looks weird on the legend.

- For one series I use gradient paint with the following code, but in the legend the color is not gradient paint, is pink! Is there a way of implementing gradient paint in the legend?
GradientPaint gp = new GradientPaint(
0.0f, 0.0f, Color.pink,
0.0f, 0.0f, Color.gray
);

- Labels on top of each bar (but not with the value itself), I tried doing what you suggested by creating my own CategoryItemLabelGenerator(), but was not successful! Is it possible to send a sample code with it?

- Information in tooltips, you mentioned that the tooltips information could be customized, by creating my own tooltips generator, but again I tried and was not successful! Is it possible to send a sample code with it?

- When I use the following code (chart.addSubtitle(new TextTitle(info));) and if the information string is too long and the chart small, half of the subtitle disappears! Is there a way around the problem? For example, (setLineWrap(true); or setWrapStyleWord(true);)

3. Stacked Area Chart:
- You mentioned to me that you will include the negative functionality (like stacked bar). When would this be available?

- Why can't I include the 1st value for time as 00:30:00 (see error message)? I have to include 24:30:00 at the end instead!

org.jfree.data.SeriesException: XYSeries.add(...): x-value already exists.

at org.jfree.data.XYSeries.add(Unknown Source)

at org.jfree.data.XYSeries.add(Unknown Source)

at org.jfree.data.XYSeries.add(Unknown Source)

at TimeSeriesDemo8.createDataset(TimeSeriesDemo8.java:207)

at TimeSeriesDemo8.<init>(TimeSeriesDemo8.java:143)

at PerformanceViews.Line(PerformanceViews.java:429)

at PerformanceViews.<init>(PerformanceViews.java:256)

at ContentDefinition$20.actionPerformed(ContentDefinition.java:889)

at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1767)

at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1820)

at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:419)

at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:257)

at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:258)

at java.awt.Component.processMouseEvent(Component.java:5021)

at java.awt.Component.processEvent(Component.java:4818)

at java.awt.Container.processEvent(Container.java:1525)

at java.awt.Component.dispatchEventImpl(Component.java:3526)

at java.awt.Container.dispatchEventImpl(Container.java:1582)

at java.awt.Component.dispatchEvent(Component.java:3367)

at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3359)

at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3074)

at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3004)

at java.awt.Container.dispatchEventImpl(Container.java:1568)

at java.awt.Window.dispatchEventImpl(Window.java:1581)

at java.awt.Component.dispatchEvent(Component.java:3367)

at java.awt.EventQueue.dispatchEvent(EventQueue.java:445)

at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:191)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:144)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:130)

at java.awt.EventDispatchThread.run(EventDispatchThread.java:98)


4. Contour Chart:
- Is there a method (e.g. setEnable(false);) for an individual item in the pop-up menu.

- I tried what you mentioned to change the color scale (shades of gray) but was not successful! Could you send a sample code with that?

- I’m trying to implement a dynamic functionality where few data sets are loaded using a Timer! Are you planning to implement that in the future? Did anyone develop something similar in the past?

- How to control the tooltips information? Because it always gives x,y and z! Could you send a sample code for that?

5. XXX
What is your advise to display the following statistical data:

*report,13,stats,X,zones
*title,Relative humidity,%
*format,table,1,7
*fields,maximum,minimum,average,diversified_max,distributed_max,diversified_min,distributed_min
*data,85.317,26.145,54.856,85.317,85.317,0.000,26.145
*end_report

I thought about the stock chart but it’s not suitable because I have 3 maximums, 3 minimums and 1 average.


---

I’m asking a lot of questions that are related to very small details, but my project is about communicating building simulation outputs to users, where the HCI and cognition science are heavily involved.

Many thanks for your help it is most appreciated
Luis
University of Strathclyde in Glasgow
ESRU
luis@esru.strath.ac.uk

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

Re: General questions on JFreeCharts

Post by david.gilbert » Tue Feb 17, 2004 5:18 pm

You have a lot of questions, so I'll look at them one at a time - apologies in advance if I run out of time to get through them all.
luis_esru wrote:1. StackedBar Chart
- Why isn't the zoom working properly with?
chartPanel.setMouseZoomable(true, false);

- When the log scale is applied, there is a lot of wasted space on top (e.g. the max value is 140 and the max number on the scale is 1000). Try data below:
double[] data1 = {1.878,0.000,10.113,4.555,0.000,120.413,1.147};
double[] data2 = {0.003,0.000,0.034,0.555,0.000,0.405,0.002};
double[] data3 = {0.002,0.000,0.125,0.255,0.000,1.489,0.001};
With the CategoryPlot class, only the range axis can be zoomed. The domain axis (a CategoryAxis) doesn't have any concept of scale and can't be zoomed (I'm sure it would be technically possible to create a form of zooming, but I don't see the purpose of it). So the ChartPanel just allows vertical zooming

The logarithmic axis appears to force the upper and lower bounds to fall on a power of ten. I don't know why this is - the code was contributed by someone else. Each time I've attempted to "clean up" the logarithmic axis code, I've stalled. Numerous people have told me they think it needs fixing for this reason and that reason, so I know I will have to go back to it sometime, but there always seems to be something else to do first.
David Gilbert
JFreeChart Project Leader

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

luis_esru
Posts: 42
Joined: Tue Jan 20, 2004 6:40 pm
Location: Glasgow
Contact:

Post by luis_esru » Tue Feb 17, 2004 5:33 pm

David

Thanks in advanced for the help and sorry for asking so many questions. Reply when possible!

Zoom: Yes, I agree that only the range axis should be zoomed. But this does not work properly! It might zoom once, after 10 attempts. I'm talking about the mouse zoom, not the pop-up menu zoom (works fine).

Log scale: - I understand and will be waiting for some improvements!

Rgds
Luis
University of Strathclyde in Glasgow
ESRU
luis@esru.strath.ac.uk

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

Re: General questions on JFreeCharts

Post by david.gilbert » Tue Feb 17, 2004 5:59 pm

luis_esru wrote:2. Bar Chart
- Why isn't the zoom working properly with?
chartPanel.setMouseZoomable(true, false);

- The bars can have a gray outline but the legend can’t! Is there a way of doing it? The reason for that is because I use white color for one of the series and it looks weird on the legend.

- For one series I use gradient paint with the following code, but in the legend the color is not gradient paint, is pink! Is there a way of implementing gradient paint in the legend?
GradientPaint gp = new GradientPaint(
0.0f, 0.0f, Color.pink,
0.0f, 0.0f, Color.gray
);

- Labels on top of each bar (but not with the value itself), I tried doing what you suggested by creating my own CategoryItemLabelGenerator(), but was not successful! Is it possible to send a sample code with it?

- Information in tooltips, you mentioned that the tooltips information could be customized, by creating my own tooltips generator, but again I tried and was not successful! Is it possible to send a sample code with it?

- When I use the following code (chart.addSubtitle(new TextTitle(info));) and if the information string is too long and the chart small, half of the subtitle disappears! Is there a way around the problem? For example, (setLineWrap(true); or setWrapStyleWord(true);)
(a) The zooming is the same as the previous item.

(b) Outlines for the legend items can't be done, I've added an RFE for it:

https://sourceforge.net/tracker/index.p ... tid=365494

(c) The bar renderer supports GradientPaint, but the legend items don't yet. I've added an item in the bug database, as this needs fixing:

https://sourceforge.net/tracker/index.p ... tid=115494

(d) Labels on the bar, see this demo that I've added for 0.9.17 (hopefully it compiles with 0.9.16):

http://cvs.sourceforge.net/viewcvs.py/* ... in&rev=1.2

(e) Tooltips can be modified in the same way as (d), just override the generateToolTip() method in the item label generator.

(f) When you run AreaChartDemo.java, does the subtitle wrap? That was added in 0.9.16, so it should be working although there has been a bug fix recently in the CVS code.
David Gilbert
JFreeChart Project Leader

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

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 » Tue Feb 17, 2004 6:02 pm

luis_esru wrote:Zoom: Yes, I agree that only the range axis should be zoomed. But this does not work properly! It might zoom once, after 10 attempts. I'm talking about the mouse zoom, not the pop-up menu zoom (works fine).
What is your environment? It's working for me, so I'll need some more info to track this down.
David Gilbert
JFreeChart Project Leader

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

luis_esru
Posts: 42
Joined: Tue Jan 20, 2004 6:40 pm
Location: Glasgow
Contact:

Post by luis_esru » Wed Feb 18, 2004 6:16 pm

David

I’ve been working with version 15. But today I downloaded version 16 and for my surprise the problems increased.

1. chart.addSubtitle(new TextTitle(info)); is not supported in any chart:
java.lang.NoSuchMethodError: org.jfree.chart.JFreeChart.addSubtitle(Lorg/jfree/chart/title/Title;)V
at BarChartDemo.createChart(BarChartDemo.java:315)
at BarChartDemo.<init>(BarChartDemo.java:204)
at PerformanceViews.Bar(PerformanceViews.java:410)
at PerformanceViews.<init>(PerformanceViews.java:248)
at ContentDefinition$20.actionPerformed(ContentDefinition.java:889)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1767)
at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1820)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:419)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:257)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:258)
at java.awt.Component.processMouseEvent(Component.java:5021)
at java.awt.Component.processEvent(Component.java:4818)
at java.awt.Container.processEvent(Container.java:1525)
at java.awt.Component.dispatchEventImpl(Component.java:3526)
at java.awt.Container.dispatchEventImpl(Container.java:1582)
at java.awt.Component.dispatchEvent(Component.java:3367)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3359)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3074)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3004)
at java.awt.Container.dispatchEventImpl(Container.java:1568)
at java.awt.Window.dispatchEventImpl(Window.java:1581)
at java.awt.Component.dispatchEvent(Component.java:3367)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:445)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:191)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:144)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:130)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:98)

2. Mouse zoom functionality for the range axis does not work properly still (environment: Windows2000 and j2sdk1.4.0_01).

3. BarChartDemo7.java does not compile.
java.lang.NoSuchMethodError: org.jfree.chart.axis.CategoryAxis.setCategoryLabelPositions(Lorg/jfree/chart/axis/CategoryLabelPositions;)V
at BarChartDemo7.createChart(BarChartDemo7.java:222)
at BarChartDemo7.<init>(BarChartDemo7.java:100)
at PerformanceViews$3.actionPerformed(PerformanceViews.java:205)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1767)
at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1820)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:419)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:257)
at javax.swing.AbstractButton.doClick(AbstractButton.java:289)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1092)
at javax.swing.plaf.basic.BasicMenuItemUI$MouseInputHandler.mouseReleased(BasicMenuItemUI.java:932)
at java.awt.Component.processMouseEvent(Component.java:5021)
at java.awt.Component.processEvent(Component.java:4818)
at java.awt.Container.processEvent(Container.java:1525)
at java.awt.Component.dispatchEventImpl(Component.java:3526)
at java.awt.Container.dispatchEventImpl(Container.java:1582)
at java.awt.Component.dispatchEvent(Component.java:3367)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3359)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3074)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3004)
at java.awt.Container.dispatchEventImpl(Container.java:1568)
at java.awt.Window.dispatchEventImpl(Window.java:1581)
at java.awt.Component.dispatchEvent(Component.java:3367)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:445)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:191)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:144)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:130)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:98)

4. AreaChartDemo.java does not compile.
java.lang.NoSuchMethodError: org.jfree.chart.event.TitleChangeEvent.<init>(Lorg/jfree/chart/title/Title;)V
at org.jfree.chart.title.TextTitle.setFont(Unknown Source)
at AreaChartDemo.createChart(AreaChartDemo.java:145)
at AreaChartDemo.<init>(AreaChartDemo.java:96)
at PerformanceViews$3.actionPerformed(PerformanceViews.java:205)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1767)
at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1820)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:419)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:257)
at javax.swing.AbstractButton.doClick(AbstractButton.java:289)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1092)
at javax.swing.plaf.basic.BasicMenuItemUI$MouseInputHandler.mouseReleased(BasicMenuItemUI.java:932)
at java.awt.Component.processMouseEvent(Component.java:5021)
at java.awt.Component.processEvent(Component.java:4818)
at java.awt.Container.processEvent(Container.java:1525)
at java.awt.Component.dispatchEventImpl(Component.java:3526)
at java.awt.Container.dispatchEventImpl(Container.java:1582)
at java.awt.Component.dispatchEvent(Component.java:3367)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3359)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3074)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3004)
at java.awt.Container.dispatchEventImpl(Container.java:1568)
at java.awt.Window.dispatchEventImpl(Window.java:1581)
at java.awt.Component.dispatchEvent(Component.java:3367)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:445)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:191)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:144)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:130)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:98)

Many thanks
Luis
University of Strathclyde in Glasgow
ESRU
luis@esru.strath.ac.uk

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 » Wed Feb 18, 2004 10:16 pm

My first guess is that you still have the older jfreechart-0.9.15.jar file on your classpath.
David Gilbert
JFreeChart Project Leader

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

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

Re: General questions on JFreeCharts

Post by david.gilbert » Wed Feb 18, 2004 10:20 pm

luis_esru wrote:3. Stacked Area Chart:
- You mentioned to me that you will include the negative functionality (like stacked bar). When would this be available?

- Why can't I include the 1st value for time as 00:30:00 (see error message)? I have to include 24:30:00 at the end instead!

org.jfree.data.SeriesException: XYSeries.add(...): x-value already exists.

at org.jfree.data.XYSeries.add(Unknown Source)

at java.awt.EventDispatchThread.run(EventDispatchThread.java:98)
(1) I'm not sure when I'll get a chance to add support for negative values, there are just so many things to do.

(2) The error message is saying that you have already added an item for the specified x-value, so double check the code you are using to populate the XYSeries.
David Gilbert
JFreeChart Project Leader

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

luis_esru
Posts: 42
Joined: Tue Jan 20, 2004 6:40 pm
Location: Glasgow
Contact:

Post by luis_esru » Thu Feb 19, 2004 7:01 pm

David

1. You were right, I was using the version 15 in my class path still. So, the method to add subtitles works fine. Also, the wrapping mechanism works ok, except for long x-axis category labels because it overlaps them if the chart is too small – is there a way of stopping wrapping it?

2. For the Stacked Area Chart, you said: “The error message is saying that you have already added an item for the specified x-value, so double check the code you are using to populate the XYSeries.”

Check sample below:
/* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2004, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* --------------------
* TimeSeriesDemo8.java
* --------------------
* (C) Copyright 2003, 2004, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* $Id: TimeSeriesDemo8.java,v 1.8 2004/01/03 05:11:00 mungady Exp $
*
* Changes
* -------
* 05-Feb-2003 : Version 1 (DG);
*
*/
package org.jfree.chart.demo;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.labels.TimeSeriesToolTipGenerator;
import org.jfree.chart.Marker;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.StandardXYItemRenderer;
import org.jfree.chart.renderer.XYItemRenderer;
import org.jfree.data.XYDataset;
import org.jfree.chart.title.TextTitle;
import java.text.SimpleDateFormat;
import org.jfree.data.DefaultTableXYDataset;
import org.jfree.data.XYSeries;
import java.util.Locale;
import java.text.ParseException;

import java.awt.*;
import javax.swing.*;

/**
* A time series chart.
*
* @author David Gilbert
*/
public class TimeSeriesDemo8 extends JInternalFrame {


String what = "Resultant Temperature";
String when = "day 1";
String where = "group of zones 1";
String[] units = {"Time","degC"};
int[] catSerNbs = {24,4};
String[] series = {"reception","office","X1","X2"};
//must find out from jon, max. nb of zones a group can hold?

String[] time = {"01-Jul-1999 00:30:00",
"01-Jul-1999 01:30:00","01-Jul-1999 02:30:00","01-Jul-1999 03:30:00","01-Jul-1999 04:30:00",
"01-Jul-1999 05:30:00","01-Jul-1999 06:30:00","01-Jul-1999 07:30:00","01-Jul-1999 08:30:00","01-Jul-1999 09:30:00",
"01-Jul-1999 10:30:00","01-Jul-1999 11:30:00","01-Jul-1999 12:30:00","01-Jul-1999 13:30:00","01-Jul-1999 14:30:00",
"01-Jul-1999 15:30:00","01-Jul-1999 16:30:00","01-Jul-1999 17:30:00","01-Jul-1999 18:30:00","01-Jul-1999 19:30:00",
"01-Jul-1999 20:30:00","01-Jul-1999 21:30:00","01-Jul-1999 22:30:00","01-Jul-1999 23:30:00"/*,"01-Jul-1999 24:30:00"*/};

String[] time1 = {
"01-Jun-1999 01:30:00","01-Jun-1999 02:30:00","01-Jun-1999 03:30:00","01-Jun-1999 04:30:00",
"01-Jun-1999 05:30:00","01-Jun-1999 06:30:00","01-Jun-1999 07:30:00","01-Jun-1999 08:30:00","01-Jun-1999 09:30:00",
"01-Jun-1999 10:30:00","01-Jun-1999 11:30:00","01-Jun-1999 12:30:00","01-Jun-1999 13:30:00","01-Jun-1999 14:30:00",
"01-Jun-1999 15:30:00","01-Jun-1999 16:30:00","01-Jun-1999 17:30:00","01-Jun-1999 18:30:00","01-Jun-1999 19:30:00",
"01-Jun-1999 20:30:00","01-Jun-1999 21:30:00","01-Jun-1999 22:30:00","01-Jun-1999 23:30:00","01-Jun-1999 24:30:00"};

double[] data1 = {16.61,16.54,16.43,16.33,16.22,16.13,16.04,16.65,17.76,
18.40,18.99,19.48,19.74,20.01,20.24,20.37,20.33,19.67,18.65,18.13,17.63,17.15,16.95,16.69};
double[] data2 = {12.33,12.22,12.06,11.91,11.78,11.65,11.53,13.64,16.22,16.80,17.10,17.28,
17.39,17.48,17.57,17.62,17.65,17.64,16.83,14.64,13.58,13.32,12.79,12.59};
double[] data3 = {23.61,22.54,23.43,24.33,25.22,27.13,24.04,23.65,22.76,
21.40,22.99,23.48,24.74,23.01,22.24,22.37,22.33,23.67,23.65,24.13,25.63,26.15,27.95,28.69};
double[] data4 = {17.33,17.22,18.06,19.91,19.78,19.65,18.53,17.64,16.22,15.80,14.10,14.28,
14.39,14.48,15.57,16.62,17.65,18.64,19.83,19.64,19.58,18.32,17.79,16.59};

double criticalValue = 27;

/**
* A demonstration application showing how to create a simple time series chart.
*
* @param title the frame title.
*/
public TimeSeriesDemo8(String title, int locationFrame) {

super(title, true, true, true, true);

if (locationFrame==0 || locationFrame==12 || locationFrame==24) {setLocation(0,0); setSize(250,200);}
if (locationFrame==1 || locationFrame==13 || locationFrame==25) {setLocation(250,0); setSize(250,200);}
if (locationFrame==2 || locationFrame==14 || locationFrame==26) {setLocation(500,0); setSize(250,200);}
if (locationFrame==3 || locationFrame==15 || locationFrame==27) {setLocation(750,0); setSize(250,200);}
if (locationFrame==4 || locationFrame==16 || locationFrame==28) {setLocation(0,200); setSize(250,200);}
if (locationFrame==5 || locationFrame==17 || locationFrame==29) {setLocation(250,200); setSize(250,200);}
if (locationFrame==6 || locationFrame==18 || locationFrame==30) {setLocation(500,200); setSize(250,200);}
if (locationFrame==7 || locationFrame==19 || locationFrame==31) {setLocation(750,200); setSize(250,200);}
if (locationFrame==8 || locationFrame==20 || locationFrame==32) {setLocation(0,400); setSize(250,200);}
if (locationFrame==9 || locationFrame==21 || locationFrame==33) {setLocation(250,400); setSize(250,200);}
if (locationFrame==10 || locationFrame==22 || locationFrame==34) {setLocation(500,400); setSize(250,200);}
if (locationFrame==11 || locationFrame==23 || locationFrame==35) {setLocation(750,400); setSize(250,200);}


XYDataset dataset = createDataset();
JFreeChart chart = createChart(dataset);
ChartPanel chartPanel = new ChartPanel(chart);
chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
chartPanel.setMouseZoomable(true, false);
setContentPane(chartPanel);

}


private JFreeChart createChart(XYDataset dataset) {


JFreeChart chart = ChartFactory.createTimeSeriesChart(
what,
units[0],
units[1],
dataset,
true,
true,
false
);
chart.setBackgroundPaint(Color.white);

chart.addSubtitle(new TextTitle(when));


XYPlot plot = chart.getXYPlot();
plot.setInsets(new Insets(0, 0, 0, 20));
plot.addRangeMarker(new Marker(criticalValue, Color.BLACK,
new BasicStroke(1.0f), Color.BLACK, 0.8f));

XYItemRenderer renderer = plot.getRenderer();
if (renderer instanceof StandardXYItemRenderer) {
StandardXYItemRenderer r = (StandardXYItemRenderer) renderer;
r.setPlotShapes(true);
r.setShapesFilled(true);
TimeSeriesToolTipGenerator g = new TimeSeriesToolTipGenerator("dd-MMM-yyyy HH:mm:ss", "0.00");
r.setToolTipGenerator(g);
}


//this colors must be decided!!!
Paint[] paint = {Color.green,Color.cyan,Color.orange,Color.pink};

for (int i=0; i<catSerNbs[1]; i++){
renderer.setSeriesPaint(i, paint);
}

return chart;
}


public XYDataset createDataset() {
//good practice is <=4 series!!!
//must find a way of warning the user about it!
SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy hh:mm:ss", Locale.UK);
XYSeries series1 = new XYSeries(series[0], false);
XYSeries series2 = new XYSeries(series[1], false);
XYSeries series3 = new XYSeries(series[2], false);
XYSeries series4 = new XYSeries(series[3], false);

try {
for (int i=0; i<catSerNbs[0]; i++){
series1.add(sdf.parse(time).getTime(),data1);
series2.add(sdf.parse(time).getTime(),data2);
series3.add(sdf.parse(time1).getTime(),data3);
series4.add(sdf.parse(time1).getTime(),data4);
}
}
catch (ParseException e) {
// Not likely, given that the dates are hard-coded
e.printStackTrace();
}
DefaultTableXYDataset dataset = new DefaultTableXYDataset(series1);
dataset.addSeries(series2);
dataset.addSeries(series3);
dataset.addSeries(series4);

return dataset;
}

// ****************************************************************************
// * JFREECHART DEVELOPER GUIDE *
// * The JFreeChart Developer Guide, written by David Gilbert, is available *
// * to purchase from Object Refinery Limited: *
// * *
// * http://www.object-refinery.com/jfreechart/guide.html *
// * *
// * Sales are used to provide funding for the JFreeChart project - please *
// * support us so that we can continue developing free software. * *
// ****************************************************************************

/**
* Starting point for the demonstration application.
*
* @param args ignored.
*/
public static void main(String[] args) {

TimeSeriesDemo8 demo = new TimeSeriesDemo8("Time Series Demo 8");
demo.pack();
RefineryUtilities.centerFrameOnScreen(demo);
demo.setVisible(true);

}

}


Many thanks
Luis
University of Strathclyde in Glasgow
ESRU
luis@esru.strath.ac.uk

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

Re: General questions on JFreeCharts

Post by david.gilbert » Fri Feb 20, 2004 1:50 pm

luis_esru wrote:5. XXX
What is your advise to display the following statistical data:

*report,13,stats,X,zones
*title,Relative humidity,%
*format,table,1,7
*fields,maximum,minimum,average,diversified_max,distributed_max,diversified_min,distributed_min
*data,85.317,26.145,54.856,85.317,85.317,0.000,26.145
*end_report

I thought about the stock chart but it’s not suitable because I have 3 maximums, 3 minimums and 1 average.
Is there just a single instance of the data record, or multiple instances? I'd say choose how you want the output to appear then create an extended dataset type and corresponding renderer to get the result you want.
David Gilbert
JFreeChart Project Leader

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

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 » Fri Feb 20, 2004 1:52 pm

luis_esru wrote:2. For the Stacked Area Chart, you said: “The error message is saying that you have already added an item for the specified x-value, so double check the code you are using to populate the XYSeries.”

Check sample below:
The problem in your sample code is just the SimpleDateFormat you are using to parse the date strings. Change the 'hh' to 'HH'.
David Gilbert
JFreeChart Project Leader

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

luis_esru
Posts: 42
Joined: Tue Jan 20, 2004 6:40 pm
Location: Glasgow
Contact:

Post by luis_esru » Fri Feb 20, 2004 7:24 pm

David

1. The change of 'hh' to 'HH' works!

2. Chart advice to display the following data:

maximum=85.317
diversified_max=85.317
distributed_max=85.317

average=54.856

diversified_min=0.000
distributed_min=26.145
minimum=26.145

Note: Single instance to be displayed.

I would like to know if any of the charts (or other similar):
XYBoxAndWhiskerDemo.java
HighLowChartDemo.java
…can support what I require (ie 3 max, 3 min and 1 ave) to avoid displaying it on a bar chart.

Many thanks
Luis
University of Strathclyde in Glasgow
ESRU
luis@esru.strath.ac.uk

luis_esru
Posts: 42
Joined: Tue Jan 20, 2004 6:40 pm
Location: Glasgow
Contact:

Post by luis_esru » Thu Mar 04, 2004 3:20 pm

David

Any advice on point 2?

Regards
Luis
University of Strathclyde in Glasgow
ESRU
luis@esru.strath.ac.uk

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 » Fri Mar 05, 2004 4:29 pm

I would create a custom dataset and renderer to handle it.
David Gilbert
JFreeChart Project Leader

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

luis_esru
Posts: 42
Joined: Tue Jan 20, 2004 6:40 pm
Location: Glasgow
Contact:

Post by luis_esru » Fri Mar 05, 2004 4:43 pm

david

but do the charts (XYBoxAndWhiskerDemo or HighLowChartDemo) handle it (ie have 3 highs, 1 average and 3 lows) for each category?

rgds
luis
University of Strathclyde in Glasgow
ESRU
luis@esru.strath.ac.uk

Locked