In this file,
I only modified
// package com.jrefinery.chart.demo.premium;
:
: // unchanged parts of the code
String url = "jdbc:mysql://localhost" + "/" + "test4";
Connection con;
try {
Class.forName("org.gjt.mm.mysql.Driver");
}
catch (ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
:
:
String sql = "SELECT mlc_date, x from try3;";
:
:
================================================
My database is
mysql> select * from try3;
+------------+------+
| mlc_date | x |
+------------+------+
| 2002-08-07 | 2 |
| 2002-08-06 | 2 |
+------------+------+
2 rows in set (0.00 sec)
mysql> describe try3;
+----------+---------+------+-----+------------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+---------+------+-----+------------+-------+
| mlc_date | date | | | 0000-00-00 | |
| x | int(11) | YES | | NULL | |
+----------+---------+------+-----+------------+-------+
2 rows in set (0.00 sec)
The code executed ok
BUT the graph is not displaying it right.
The x-axis shows time of a single day in the form of
00:00, 02:00 etc.
The y-aixs show correctly with value at 2.
Q1 - How do I display the graph correctly showing x-axis
of the different dates ?
Q2 - Does your Demo code dependent on the data type of the
mlc_date, ie the x-axis ? ie I cant use date or timestamp or other
date formats supported by MySQL ?
Please respond asap.
Thanks
Cant get JDBCXYChartDemo to work.
Re: Cant get JDBCXYChartDemo to work.
zw wrote:
> The code executed ok
> BUT the graph is not displaying it right.
> The x-axis shows time of a single day in the form of
> 00:00, 02:00 etc.
> The y-aixs show correctly with value at 2.
>
> Q1 - How do I display the graph correctly showing x-axis
> of the different dates ?
In JFreeChart, the date axis is a continuous time line. Tick marks are placed along the line at regular intervals (usually chosen in such a way that there are no labels overlapping). The tick marks are independent of your data observations, which may or may not occur at regular intervals.
> Q2 - Does your Demo code dependent on the data type of the
> mlc_date, ie the x-axis ? ie I cant use date or timestamp or
> other
> date formats supported by MySQL ?
Looking through the JdbcXYDataset class (I didn't write the code), it appears that it will read any of these types from the ResultSet as the x-values:
Types.DATE
Types.TIME
Types.TIMESTAMP
Types.NUMERIC:
Types.REAL:
Types.INTEGER:
Types.DOUBLE:
Types.FLOAT:
Types.BIGINT:
Regards,
Dave Gilbert
> The code executed ok
> BUT the graph is not displaying it right.
> The x-axis shows time of a single day in the form of
> 00:00, 02:00 etc.
> The y-aixs show correctly with value at 2.
>
> Q1 - How do I display the graph correctly showing x-axis
> of the different dates ?
In JFreeChart, the date axis is a continuous time line. Tick marks are placed along the line at regular intervals (usually chosen in such a way that there are no labels overlapping). The tick marks are independent of your data observations, which may or may not occur at regular intervals.
> Q2 - Does your Demo code dependent on the data type of the
> mlc_date, ie the x-axis ? ie I cant use date or timestamp or
> other
> date formats supported by MySQL ?
Looking through the JdbcXYDataset class (I didn't write the code), it appears that it will read any of these types from the ResultSet as the x-values:
Types.DATE
Types.TIME
Types.TIMESTAMP
Types.NUMERIC:
Types.REAL:
Types.INTEGER:
Types.DOUBLE:
Types.FLOAT:
Types.BIGINT:
Regards,
Dave Gilbert