Home >Database >Mysql Tutorial >How to Visualize Time Series Data with JDBCXYDataset and JFreeChart?
JDBCXYDataset Represents Time Series Data
This example demonstrates how to create a JDBCXYDataset representing time series data and visualize it using JFreeChart.
Database Setup
We create an in-memory database (using H2) with a table named inventory that has three columns: when (timestamp), n1 (integer), and n2 (integer).
Code Overview
createDataset():
display():
Time Series Representation
JDBCXYDataset recognizes time series data. When querying the dataset, the returned values are instances of Number or org.jfree.date.Date. The latter represents timestamps as java.util.Date objects. This allows JFreeChart to handle the display of time values correctly in time series charts.
Output
The chart will display a plot of the n1 and n2 values over time. The x-axis will show the date and time of each data point in hourly intervals.
Notes
The above is the detailed content of How to Visualize Time Series Data with JDBCXYDataset and JFreeChart?. For more information, please follow other related articles on the PHP Chinese website!