473,322 Members | 1,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

How to set up TimeSeriesChart time format

(1)How to set up TimeSeriesChart time axis format similar to "yyyy-MM-dd HH:mm:ss", "HH:mm:ss", "HH:mm:ss", "yyyy-MM-dd HH:mm:ss" in a chart?
(2)If it is on the same day, only the first time format for the "yyyy-MM-dd HH:mm:ss", the other for "HH:mm:ss", until another day.
(3)For example, a time axis format for TimeSeriesChart is "2008-02-08 09:00:00", "10:00:00", "11:00:00", "2008-02-09 09:00:00".
(4)If someone have a piece of answer or code ?
Jul 1 '08 #1
12 5314
samido
52
as far as I am concerned this will do everything for you, it is up to you how you model your logic, the object is like:

SimpleDateFormat formatter = new SimpleDateFormat("E yyyy.MM.dd 'at' hh:mm:ss a zzz");

where: e.g.

Date and Time Pattern Results
"yyyy.MM.dd G 'at' HH:mm:ss z" 2001.07.04 AD at 12:08:56 PDT
"EEE, MMM d, ''yy" Wed, Jul 4, '01
"h:mm a" 12:08 PM
"hh 'o''clock' a, zzzz" 12 o'clock PM, Pacific Daylight Time
"K:mm a, z" 0:08 PM, PDT
"yyyyy.MMMMM.dd GGG hh:mm aaa" 02001.July.04 AD 12:08 PM
"EEE, d MMM yyyy HH:mm:ss Z" Wed, 4 Jul 2001 12:08:56 -0700
"yyMMddHHmmssZ" 010704120856-0700

kind regards: Sam Rabophala
Jul 1 '08 #2
Thank you for your reply..
But It is not my result..
I mean that a TimeSeriesChart on the two time format..
How to set up ?
Jul 1 '08 #3
samido
52
well, if TimeSeriesChart is a jfreechart and it doesn't have a setter method that suit your need, then you must implement your own TimeSeriesChart with method(s) that can set time as you want, all you need to do is to extend TimeSeriesChart and reuse all functionality without going extra miles.

hope this will helps you...

kind regards: Sam rabophala
Jul 1 '08 #4
Thanks..

Some examples?
Can you send me ?
I hope you can!!!!!
Jul 1 '08 #5
samido
52
this is how it looks like, you have to put your own methods to do what you want, my first example I gave to you will goes inside your method(s)

/*
2 * The contents of this file are subject to the terms
3 * of the Common Development and Distribution License
4 * (the License). You may not use this file except in
5 * compliance with the License.
6 *
7 * You can obtain a copy of the license at
8 * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9 * glassfish/bootstrap/legal/CDDLv1.0.txt.
10 * See the License for the specific language governing
11 * permissions and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL
14 * Header Notice in each file and include the License file
15 * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16 * If applicable, add the following below the CDDL Header,
17 * with the fields enclosed by brackets [] replaced by
18 * you own identifying information:
19 * "Portions Copyrighted [year] [name of copyright owner]"
20 *
21 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22 */
23
24 /*
25 * TimeSeriesChart.java
26 *
27 * Created on March 9, 2005, 11:10 PM
28 */
29 /* --------------------
30 * DynamicDataDemo.java
31 * --------------------
32 * (C) Copyright 2002-2004, by Object Refinery Limited.
33 *
34 */
35
36 package com.sun.enterprise.ee.tools.admingui.chart;
37
38 import java.awt.BorderLayout;
39 import java.awt.event.ActionEvent;
40 import java.awt.event.ActionListener;
41
42 import javax.swing.BorderFactory;
43 import javax.swing.JButton;
44 import javax.swing.JPanel;
45
46 import org.jfree.chart.ChartFactory;
47 import org.jfree.chart.ChartPanel;
48 import org.jfree.chart.JFreeChart;
49 import org.jfree.chart.axis.ValueAxis;
50 import org.jfree.chart.plot.XYPlot;
51 import org.jfree.data.time.Millisecond;
52 import org.jfree.data.time.TimeSeries;
53 import org.jfree.data.time.TimeSeriesCollection;
54 import org.jfree.data.xy.XYDataset;
55 import org.jfree.ui.ApplicationFrame;
56 import org.jfree.ui.RefineryUtilities;
57
58 /**
59 * A demonstration application showing a time series chart where you can dynamically add
60 * (random) data by clicking on a button.
61 */
62
63
64 public class TimeSeriesChart {
65
66 private JFreeChart chart;
67 private TimeSeries series;
68 /** The most recent value added. */
69 private double lastValue = 100.0;
70 private static double mm = 100.0;
71
72 public TimeSeriesChart() {
73 series = new TimeSeries("Random Data", Millisecond.class);
74 TimeSeriesCollection dataset = new TimeSeriesCollection(series);
75 chart = createChart(dataset);
76 }
77
78 /**
79 * Creates a sample chart.
80 *
81 * @param dataset the dataset.
82 *
83 * @return A sample chart.
84 */
85 private JFreeChart createChart(XYDataset dataset) {
86 JFreeChart result = ChartFactory.createTimeSeriesChart(
87 "Dynamic Data Demo",
88 "Time",
89 "Value",
90 dataset,
91 true,
92 true,
93 false
94 );
95 XYPlot plot = result.getXYPlot();
96 ValueAxis axis = plot.getDomainAxis();
97 axis.setAutoRange(true);
98 axis.setFixedAutoRange(60000.0); // 60 seconds
99 axis = plot.getRangeAxis();
100 axis.setRange(0.0, 200.00);
101 return result;
102 }
103
104 /**
105 * add a data point
106 */
107 public void addRandomData() {
108 double factor = 0.90 + 0.2 * Math.random();
109 this.lastValue = this.lastValue * factor;
110 //Millisecond now = new Millisecond();
111 //System.out.println("Now = " + now.toString());
112 this.series.add(new Millisecond(), this.lastValue);
113 }
114
115 public JFreeChart getChart()
116 {
117 return chart;
118 }
119
120 }

kind regards: Sam Rabophala
Jul 1 '08 #6
Good good very good!!
Thank you!
Jul 1 '08 #7
Hello Sam,

Now, I have to leave...

Tomorrow you are still here?
I would like to ask you some questions about jfreechart..
Jul 1 '08 #8
samido
52
Yup, always on line...
Jul 1 '08 #9
Hi, Sam......

I am on line , and you!?
Yesterday, I have tried a lot of ways, it is still not.
When I set format, all formats are being changed.
You have a better way?
Jul 2 '08 #10
when you want to set something like date or time .
in java "Date Format "class is there go through java docs & inthat look for
Date class it will help you better. im also having same problem while retrievving the date from oracle database
Jul 2 '08 #11

Jul 3 '08 #12
How to do that about this chart?
Img =

Jul 3 '08 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Gord | last post by:
Hello, VB6 accepts Date and Time values as 'Date'. I'm trying to verify entry into a database I'm creating by verifying that an appropriate Date or Time value has been entered. Using built-in...
8
by: Gerrit Holl | last post by:
Posted with permission from the author. I have some comments on this PEP, see the (coming) followup to this message. PEP: 321 Title: Date/Time Parsing and Formatting Version: $Revision: 1.3 $...
3
by: T-Narg | last post by:
I would like to produce the following output based on my XML file: My Album (2005) Elapsed Time (hh:mm:ss): 00:07:00 Song 1: title1 Length (hh:mm:ss): 00:02:30 Song 2: title2 Length...
6
by: Kenneth | last post by:
Hello, I'm having some serious problems debugging a script that I'm trying to make work. I'm working on a form where a user can type in a time (in the format of HH:MM), and another script...
6
by: Rene | last post by:
I am currently displaying the time of day value using the "h:mm:ss tt" format (hr=hours, mm=minutes, ss=seconds tt=AM/PM). I was looking under the "Regional and Language Options" and it looks...
7
by: Edward Mitchell | last post by:
I have a number of DateTimePicker controls, some set to dates, some set to a format of Time. The controls are all embedded in dialogs. I created the controls by dragging the DateTime picker from...
10
by: scorpion53061 | last post by:
What I thought would be pretty easy has turned out not to be. I have three variables. Actiontime is formatted as 08/11/2004 11:03PM Actiontime JobStreamStart (11:00:00PM) JobStreamEnd...
15
by: Khurram | last post by:
I have a problem while inserting time value in the datetime Field. I want to Insert only time value in this format (08:15:39) into the SQL Date time Field. I tried to many ways, I can extract...
18
by: Dirk Hagemann | last post by:
Hello, From a zone-file of a Microsoft Active Directory integrated DNS server I get the date/time of the dynamic update entries in a format, which is as far as I know the hours since january 1st...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.