JGuru
Wise Old Owl
Charting Guide using JFreeChart
JFreeChart (JFreeChart) is a free utility to draw various Charts like BarChart , PieChart, AreaCharts, Gantt Chart, Line Chart, Financial Charts, Statistical Charts,
Time Series Charts , etc.,
Here in this tutorial I'm going to show you how to write various Charts using JFreeChart.
Remember to run these demos you need to include jfreechart-1.0.15.jar & jcommon-1.0.18.jar in your CLASSPATH!!! Otherwise the program won't compile!!!
Here is how:
To Compile
Windows
javac -cp .;"path-to/jfreechart-1.0.15.jar;path-to/jcommon-1.0.18.jar" BarChartDemo1.java
Linux
javac -cp .;"path-to/jfreechart-1.0.15.jar
ath-to/jcommon-1.0.18.jar" BarChartDemo1.java
To Run
Windows
java -cp .;"path-to/jfreechart-1.0.15.jar;path-to/jcommon-1.0.18.jar" BarChartDemo1
Linux
java -cp .;"path-to/jfreechart-1.0.15.jar
ath-to/jcommon-1.0.18.jar" BarChartDemo1
Alternatively you can copy the JAR file jfreechart-1.0.15.jar & jcommon-1.0.18.jar to the extension folder.
Windows (32-bit & 64-bit JDK )
32-bit JDK in Windows 32-bit, or 64-bit JDK in Windows 64-bit
C:\Program Files\Java\jdk1.7.0_25\jre\lib\ext
32-bit JDK in Windows 64-bit
C:\Program Files (x86)\Java\jdk1.7.0_25\jre\lib\ext
There is also a JRE folder under the Java folder (C:\Program Files\Java\jre7) also copy the JAR files to the ext folder (C:\Program Files\Java\jre7\lib\ext)
For JDK 7 it's JRE7, for JDK 8 it's JRE8 and so on.
Linux
/usr/java/jdk1.7.0_25/jre/lib/ext
Some Linux distros like Debian, Ubuntu, Knoppix, Suse install Java JDK in some alternate location.
You need to search it & copy the JAR files to the appropriate directory.
Since You have copied the JAR file containing the packages needed for the demos to the ext folder.
You can compile & run the demos like a normal Java program!!!
When JVM loads it searches for the necessary class files (packages) in the "lib" & "ext" directories.If it finds the class files there, then the program
will compile & run without any problem!!
Alternatively those who use IDE like NetBeans , Eclipse, IDEA can create a library called 'JFreeChart'
& include the library to compile & run the project
Procedure: In NetBeans IDE from the menu Tools - > Libraries -> Click on button "New library..." on the left side, enter the library name as 'JFreeChart' & click on the
'Add JAR/Folder...' Create a 'lib' directory under the project folder & place the JAR files jfreechart-1.0.15.jar, jcommon-1.0.18.jar there.
Here is a demo that shows a BarChart!!
BarChartDemo1.java
*s21.postimg.org/d8rvugg7n/Bar_Chart_Demo1.jpg
Here is a Cylinder Chart demo
CylinderChartDemo2.java
*s28.postimg.org/wd3sx6vtl/Cylinder_Chart_Demo2.jpg
Here is a PieChart demo
PieChartDemo1.java
*s10.postimg.org/x55vkmgqd/Pie_Chart_Demo1.jpg
Here is another one!!
PieChart3DDemo1.java
*s18.postimg.org/52g76pn5h/Pie_Chart3_DDemo1.jpg
Here is a Price Volume chart
PriceVolumeDemo1.java
*s16.postimg.org/vbv2fuji9/Price_Volume_Demo1.jpg
Here is a Stacked BarChart
*s1.postimg.org/m2cffua6j/Stacked_Bar_Chart3_DDemo1.jpg
Here is a Ring Chart!!
RingChartDemo1.java
*s8.postimg.org/x0intxgj5/Ring_Chart_Demo1.jpg
Here is a Scatter plot demo!!
*s27.postimg.org/oqhltcklb/Scatter_Plot_Demo1.jpg
Here is a LineChart demo
LineChartDemo3.java
*s30.postimg.org/m5logn8x9/Line_Chart_Demo3.jpg
Here is a Mutiple axis demo!!
MultipleAxisDemo2.java
*s24.postimg.org/geyhl7vdd/Multiple_Axis_Demo2.jpg
Here is a Normal distribution demo!!
NormalDistributionDemo2.java
*s4.postimg.org/v385xapl5/Normal_Distribution_Demo2.jpg
Here is a Statistical bar chart!!
StatisticalBarChartDemo1 .java
*s1.postimg.org/ninxxzd3f/Statistical_Bar_Chart_Demo1.jpg
Here is a Time Series chart!!
TimeSeriesDemo7.java
*s30.postimg.org/rk2u75s6l/Time_Series_Demo7.jpg
Here is a Gantt chart demo!!
GanttDemo1.java
*s22.postimg.org/d0conl4p9/Gantt_Demo1.jpg
Here is a Layered bar chart demo!!
LayeredBarChartDemo2.java
*s29.postimg.org/3yzpc1v7n/Layered_Bar_Chart_Demo2.jpg
Here is a Bar chart using a Gradient!!
GradientPaintTransformerDemo1.java
*s21.postimg.org/jhd7o1dsj/Gradient_Paint_Transformer_Demo1.jpg
Here is a combined X Y plot demo!!
CombinedXYPlotDemo3.java
Here is a Polar chart demo!!
PolarChartDemo1.java
*s4.postimg.org/xzv6xkvex/Polar_Chart_Demo1.jpg
Here is a Y interval demo!!
YIntervalChartDemo1.java
*s30.postimg.org/ez6yhhgx9/YInterval_Chart_Demo1.jpg
This wraps up the Charting guide using JFreeChart!!
JFreeChart (JFreeChart) is a free utility to draw various Charts like BarChart , PieChart, AreaCharts, Gantt Chart, Line Chart, Financial Charts, Statistical Charts,
Time Series Charts , etc.,
Here in this tutorial I'm going to show you how to write various Charts using JFreeChart.
Remember to run these demos you need to include jfreechart-1.0.15.jar & jcommon-1.0.18.jar in your CLASSPATH!!! Otherwise the program won't compile!!!
Here is how:
To Compile
Windows
javac -cp .;"path-to/jfreechart-1.0.15.jar;path-to/jcommon-1.0.18.jar" BarChartDemo1.java
Linux
javac -cp .;"path-to/jfreechart-1.0.15.jar
To Run
Windows
java -cp .;"path-to/jfreechart-1.0.15.jar;path-to/jcommon-1.0.18.jar" BarChartDemo1
Linux
java -cp .;"path-to/jfreechart-1.0.15.jar
Alternatively you can copy the JAR file jfreechart-1.0.15.jar & jcommon-1.0.18.jar to the extension folder.
Windows (32-bit & 64-bit JDK )
32-bit JDK in Windows 32-bit, or 64-bit JDK in Windows 64-bit
C:\Program Files\Java\jdk1.7.0_25\jre\lib\ext
32-bit JDK in Windows 64-bit
C:\Program Files (x86)\Java\jdk1.7.0_25\jre\lib\ext
There is also a JRE folder under the Java folder (C:\Program Files\Java\jre7) also copy the JAR files to the ext folder (C:\Program Files\Java\jre7\lib\ext)
For JDK 7 it's JRE7, for JDK 8 it's JRE8 and so on.
Linux
/usr/java/jdk1.7.0_25/jre/lib/ext
Some Linux distros like Debian, Ubuntu, Knoppix, Suse install Java JDK in some alternate location.
You need to search it & copy the JAR files to the appropriate directory.
Since You have copied the JAR file containing the packages needed for the demos to the ext folder.
You can compile & run the demos like a normal Java program!!!
When JVM loads it searches for the necessary class files (packages) in the "lib" & "ext" directories.If it finds the class files there, then the program
will compile & run without any problem!!
Alternatively those who use IDE like NetBeans , Eclipse, IDEA can create a library called 'JFreeChart'
& include the library to compile & run the project
Procedure: In NetBeans IDE from the menu Tools - > Libraries -> Click on button "New library..." on the left side, enter the library name as 'JFreeChart' & click on the
'Add JAR/Folder...' Create a 'lib' directory under the project folder & place the JAR files jfreechart-1.0.15.jar, jcommon-1.0.18.jar there.
Here is a demo that shows a BarChart!!
BarChartDemo1.java
Code:
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GradientPaint;
import java.awt.Toolkit;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.StandardChartTheme;
import org.jfree.chart.axis.CategoryAxis;
import org.jfree.chart.axis.CategoryLabelPositions;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.renderer.category.BarRenderer;
import org.jfree.data.category.CategoryDataset;
import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;
/**
* A simple demonstration application showing how to create a bar chart.
*/
public class BarChartDemo1 extends ApplicationFrame {
private static final long serialVersionUID = 1L;
{
// set a theme using the new shadow generator feature available in
// 1.0.14 - for backwards compatibility it is not enabled by default
ChartFactory.setChartTheme(new StandardChartTheme("JFree/Shadow",
true));
}
/**
* Creates a new demo instance.
*
* [MENTION=9956]PARAM[/MENTION] title the frame title.
*/
public BarChartDemo1(String title) {
super(title);
CategoryDataset dataset = createDataset();
JFreeChart chart = createChart(dataset);
ChartPanel chartPanel = new ChartPanel(chart);
chartPanel.setFillZoomRectangle(true);
chartPanel.setMouseWheelEnabled(true);
Dimension scrDim = Toolkit.getDefaultToolkit().getScreenSize();
chartPanel.setPreferredSize(new Dimension(scrDim.width / 2, scrDim.height / 2));
setContentPane(chartPanel);
}
/**
* Returns a sample dataset.
*
* @return The dataset.
*/
private static CategoryDataset createDataset() {
// row keys...
String series1 = "First";
String series2 = "Second";
String series3 = "Third";
// column keys...
String category1 = "Category 1";
String category2 = "Category 2";
String category3 = "Category 3";
String category4 = "Category 4";
String category5 = "Category 5";
// create the dataset...
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
dataset.addValue(1.0, series1, category1);
dataset.addValue(4.0, series1, category2);
dataset.addValue(3.0, series1, category3);
dataset.addValue(5.0, series1, category4);
dataset.addValue(5.0, series1, category5);
dataset.addValue(5.0, series2, category1);
dataset.addValue(7.0, series2, category2);
dataset.addValue(6.0, series2, category3);
dataset.addValue(8.0, series2, category4);
dataset.addValue(4.0, series2, category5);
dataset.addValue(4.0, series3, category1);
dataset.addValue(3.0, series3, category2);
dataset.addValue(2.0, series3, category3);
dataset.addValue(3.0, series3, category4);
dataset.addValue(6.0, series3, category5);
return dataset;
}
/**
* Creates a sample chart.
*
* [MENTION=9956]PARAM[/MENTION] dataset the dataset.
*
* @return The chart.
*/
private static JFreeChart createChart(CategoryDataset dataset) {
// create the chart...
JFreeChart chart = ChartFactory.createBarChart(
"Bar Chart Demo 1", // chart title
"Category", // domain axis label
"Value", // range axis label
dataset, // data
PlotOrientation.VERTICAL, // orientation
true, // include legend
true, // tooltips?
false // URLs?
);
// NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
// set the background color for the chart...
chart.setBackgroundPaint(Color.white);
// get a reference to the plot for further customisation...
CategoryPlot plot = (CategoryPlot) chart.getPlot();
// set the range axis to display integers only...
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
// disable bar outlines...
BarRenderer renderer = (BarRenderer) plot.getRenderer();
renderer.setDrawBarOutline(false);
// set up gradient paints for series...
GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue,
0.0f, 0.0f, new Color(0, 0, 64));
GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green,
0.0f, 0.0f, new Color(0, 64, 0));
GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red,
0.0f, 0.0f, new Color(64, 0, 0));
renderer.setSeriesPaint(0, gp0);
renderer.setSeriesPaint(1, gp1);
renderer.setSeriesPaint(2, gp2);
CategoryAxis domainAxis = plot.getDomainAxis();
domainAxis.setCategoryLabelPositions(
CategoryLabelPositions.createUpRotationLabelPositions(
Math.PI / 6.0));
// OPTIONAL CUSTOMISATION COMPLETED.
return chart;
}
/**
* Starting point for the demonstration application.
*
* [MENTION=9956]PARAM[/MENTION] args ignored.
*/
public static void main(String[] args) {
BarChartDemo1 demo = new BarChartDemo1("BarChart Demo1");
demo.pack();
RefineryUtilities.centerFrameOnScreen(demo);
demo.setVisible(true);
}
}
*s21.postimg.org/d8rvugg7n/Bar_Chart_Demo1.jpg
Here is a Cylinder Chart demo
CylinderChartDemo2.java
Code:
import java.awt.*;
import javax.swing.JPanel;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.labels.StandardCategoryToolTipGenerator;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.category.CategoryDataset;
import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.GradientPaintTransformType;
import org.jfree.ui.RefineryUtilities;
import org.jfree.ui.StandardGradientPaintTransformer;
public class CylinderChartDemo2 extends ApplicationFrame {
public CylinderChartDemo2(String paramString) {
super(paramString);
ChartPanel localChartPanel = (ChartPanel) createDemoPanel();
Dimension scrDim = Toolkit.getDefaultToolkit().getScreenSize();
localChartPanel.setPreferredSize(new Dimension(scrDim.width / 2, scrDim.height / 2));
setContentPane(localChartPanel);
}
private static CategoryDataset createDataset() {
DefaultCategoryDataset localDefaultCategoryDataset = new DefaultCategoryDataset();
localDefaultCategoryDataset.addValue(4.0D, "S1", "Monday");
localDefaultCategoryDataset.addValue(5.0D, "S1", "Tuesday");
localDefaultCategoryDataset.addValue(-7.0D, "S1", "Wednesday");
localDefaultCategoryDataset.addValue(6.0D, "S1", "Thursday");
localDefaultCategoryDataset.addValue(4.0D, "S1", "Friday");
return localDefaultCategoryDataset;
}
private static JFreeChart createChart(CategoryDataset paramCategoryDataset) {
JFreeChart localJFreeChart = ChartFactory.createBarChart3D("Cylinder Chart Demo 2", "Category", "Value", paramCategoryDataset, PlotOrientation.HORIZONTAL, false, true, false);
CategoryPlot localCategoryPlot = (CategoryPlot) localJFreeChart.getPlot();
localCategoryPlot.setRangePannable(true);
Paint[] arrayOfPaint = createPaint();
CustomCylinderRenderer localCustomCylinderRenderer = new CustomCylinderRenderer(arrayOfPaint);
localCustomCylinderRenderer.setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_VERTICAL));
localCustomCylinderRenderer.setBaseOutlinePaint(Color.gray);
localCustomCylinderRenderer.setBaseOutlineStroke(new BasicStroke(0.3F));
localCustomCylinderRenderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
localCategoryPlot.setRenderer(localCustomCylinderRenderer);
ChartUtilities.applyCurrentTheme(localJFreeChart);
return localJFreeChart;
}
private static Paint[] createPaint() {
Paint[] arrayOfPaint = new Paint[5];
arrayOfPaint[0] = new GradientPaint(0.0F, 0.0F, Color.white, 0.0F, 0.0F, Color.red);
arrayOfPaint[1] = new GradientPaint(0.0F, 0.0F, Color.white, 0.0F, 0.0F, Color.green);
arrayOfPaint[2] = new GradientPaint(0.0F, 0.0F, Color.white, 0.0F, 0.0F, Color.blue);
arrayOfPaint[3] = new GradientPaint(0.0F, 0.0F, Color.white, 0.0F, 0.0F, Color.orange);
arrayOfPaint[4] = new GradientPaint(0.0F, 0.0F, Color.white, 0.0F, 0.0F, Color.magenta);
return arrayOfPaint;
}
public static JPanel createDemoPanel() {
JFreeChart localJFreeChart = createChart(createDataset());
ChartPanel localChartPanel = new ChartPanel(localJFreeChart);
localChartPanel.setMouseWheelEnabled(true);
return localChartPanel;
}
public static void main(String[] paramArrayOfString) {
CylinderChartDemo2 localCylinderChartDemo2 = new CylinderChartDemo2("CylinderChartDemo2.java");
localCylinderChartDemo2.pack();
RefineryUtilities.centerFrameOnScreen(localCylinderChartDemo2);
localCylinderChartDemo2.setVisible(true);
}
static class CustomCylinderRenderer extends CylinderRenderer {
private Paint[] colors;
public CustomCylinderRenderer(Paint[] paramArrayOfPaint) {
this.colors = paramArrayOfPaint;
}
public Paint getItemPaint(int paramInt1, int paramInt2) {
return this.colors[(paramInt2 % this.colors.length)];
}
}
}
*s28.postimg.org/wd3sx6vtl/Cylinder_Chart_Demo2.jpg
Here is a PieChart demo
PieChartDemo1.java
Code:
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Toolkit;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PiePlot;
import org.jfree.chart.title.TextTitle;
import org.jfree.data.general.DefaultPieDataset;
import org.jfree.data.general.PieDataset;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;
public class PieChartDemo1 extends ApplicationFrame {
public PieChartDemo1(String paramString) {
super(paramString);
JPanel localJPanel = createDemoPanel();
Dimension scrDim = Toolkit.getDefaultToolkit().getScreenSize();
localJPanel.setPreferredSize(new Dimension(scrDim.width / 2, scrDim.height / 2));
setContentPane(localJPanel);
}
private static PieDataset createDataset() {
DefaultPieDataset localDefaultPieDataset = new DefaultPieDataset();
localDefaultPieDataset.setValue("One", new Double(43.200000000000003D));
localDefaultPieDataset.setValue("Two", new Double(10.0D));
localDefaultPieDataset.setValue("Three", new Double(27.5D));
localDefaultPieDataset.setValue("Four", new Double(17.5D));
localDefaultPieDataset.setValue("Five", new Double(11.0D));
localDefaultPieDataset.setValue("Six", new Double(19.399999999999999D));
return localDefaultPieDataset;
}
private static JFreeChart createChart(PieDataset paramPieDataset) {
JFreeChart localJFreeChart = ChartFactory.createPieChart("Pie Chart Demo 1", paramPieDataset, true, true, false);
TextTitle localTextTitle = localJFreeChart.getTitle();
localTextTitle.setToolTipText("A title tooltip!");
PiePlot localPiePlot = (PiePlot) localJFreeChart.getPlot();
localPiePlot.setLabelFont(new Font("SansSerif", 0, 12));
localPiePlot.setNoDataMessage("No data available");
localPiePlot.setCircular(false);
localPiePlot.setLabelGap(0.02D);
return localJFreeChart;
}
public static JPanel createDemoPanel() {
JFreeChart localJFreeChart = createChart(createDataset());
ChartPanel localChartPanel = new ChartPanel(localJFreeChart);
localChartPanel.setMouseWheelEnabled(true);
return localChartPanel;
}
public static void main(String[] paramArrayOfString) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
PieChartDemo1 localPieChartDemo1 = new PieChartDemo1("PieChartDemo1");
localPieChartDemo1.pack();
RefineryUtilities.centerFrameOnScreen(localPieChartDemo1);
localPieChartDemo1.setVisible(true);
}
});
}
}
*s10.postimg.org/x55vkmgqd/Pie_Chart_Demo1.jpg
Here is another one!!
PieChart3DDemo1.java
Code:
import java.awt.Dimension;
import java.awt.Toolkit;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PiePlot3D;
import org.jfree.data.general.DefaultPieDataset;
import org.jfree.data.general.PieDataset;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;
import org.jfree.util.Rotation;
public class PieChart3DDemo1 extends ApplicationFrame
{
public PieChart3DDemo1(String paramString)
{
super(paramString);
ChartPanel localChartPanel = createDemoPanel();
Dimension scrDim = Toolkit.getDefaultToolkit().getScreenSize();
localChartPanel.setPreferredSize(new Dimension(scrDim.width/2, scrDim.height/2));
setContentPane(localChartPanel);
}
private static PieDataset createDataset()
{
DefaultPieDataset localDefaultPieDataset = new DefaultPieDataset();
localDefaultPieDataset.setValue("Java", new Double(43.200000000000003D));
localDefaultPieDataset.setValue("Visual Basic", new Double(10.0D));
localDefaultPieDataset.setValue("C/C++", new Double(17.5D));
localDefaultPieDataset.setValue("PHP", new Double(32.5D));
localDefaultPieDataset.setValue("Perl", null);
return localDefaultPieDataset;
}
private static JFreeChart createChart(PieDataset paramPieDataset)
{
JFreeChart localJFreeChart = ChartFactory.createPieChart3D("Pie Chart 3D Demo 1", paramPieDataset, true, true, false);
PiePlot3D localPiePlot3D = (PiePlot3D)localJFreeChart.getPlot();
localPiePlot3D.setDarkerSides(true);
localPiePlot3D.setStartAngle(290.0D);
localPiePlot3D.setDirection(Rotation.CLOCKWISE);
localPiePlot3D.setForegroundAlpha(0.5F);
localPiePlot3D.setNoDataMessage("No data to display");
return localJFreeChart;
}
public static ChartPanel createDemoPanel()
{
JFreeChart localJFreeChart = createChart(createDataset());
ChartPanel localChartPanel = new ChartPanel(localJFreeChart);
localChartPanel.setMouseWheelEnabled(true);
return localChartPanel;
}
public static void main(String[] paramArrayOfString)
{
PieChart3DDemo1 localPieChart3DDemo1 = new PieChart3DDemo1("PieChart3DDemo1.java");
localPieChart3DDemo1.pack();
RefineryUtilities.centerFrameOnScreen(localPieChart3DDemo1);
localPieChart3DDemo1.setVisible(true);
}
}
*s18.postimg.org/52g76pn5h/Pie_Chart3_DDemo1.jpg
Here is a Price Volume chart
PriceVolumeDemo1.java
Code:
import java.awt.Dimension;
import java.awt.Toolkit;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import javax.swing.JPanel;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.labels.StandardXYToolTipGenerator;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.xy.StandardXYBarPainter;
import org.jfree.chart.renderer.xy.XYBarRenderer;
import org.jfree.chart.renderer.xy.XYItemRenderer;
import org.jfree.data.time.Day;
import org.jfree.data.time.TimeSeries;
import org.jfree.data.time.TimeSeriesCollection;
import org.jfree.data.xy.IntervalXYDataset;
import org.jfree.data.xy.XYDataset;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;
public class PriceVolumeDemo1 extends ApplicationFrame {
public PriceVolumeDemo1(String paramString) {
super(paramString);
JFreeChart localJFreeChart = createChart();
ChartPanel localChartPanel = new ChartPanel(localJFreeChart, true, true, true, false, true);
Dimension scrDim = Toolkit.getDefaultToolkit().getScreenSize();
localChartPanel.setPreferredSize(new Dimension(scrDim.width/2, scrDim.height/2));
setContentPane(localChartPanel);
}
private static JFreeChart createChart() {
XYDataset localXYDataset = createPriceDataset();
String str = "Eurodollar Futures Contract (MAR03)";
JFreeChart localJFreeChart = ChartFactory.createTimeSeriesChart(str, "Date", "Price", localXYDataset, true, true, false);
XYPlot localXYPlot = (XYPlot) localJFreeChart.getPlot();
NumberAxis localNumberAxis1 = (NumberAxis) localXYPlot.getRangeAxis();
localNumberAxis1.setLowerMargin(0.4D);
DecimalFormat localDecimalFormat = new DecimalFormat("00.00");
localNumberAxis1.setNumberFormatOverride(localDecimalFormat);
XYItemRenderer localXYItemRenderer = localXYPlot.getRenderer();
localXYItemRenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator("{0}: ({1}, {2})", new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00")));
NumberAxis localNumberAxis2 = new NumberAxis("Volume");
localNumberAxis2.setUpperMargin(1.0D);
localXYPlot.setRangeAxis(1, localNumberAxis2);
localXYPlot.setDataset(1, createVolumeDataset());
localXYPlot.setRangeAxis(1, localNumberAxis2);
localXYPlot.mapDatasetToRangeAxis(1, 1);
XYBarRenderer localXYBarRenderer = new XYBarRenderer(0.2D);
localXYBarRenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator("{0}: ({1}, {2})", new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0,000.00")));
localXYPlot.setRenderer(1, localXYBarRenderer);
ChartUtilities.applyCurrentTheme(localJFreeChart);
localXYBarRenderer.setBarPainter(new StandardXYBarPainter());
localXYBarRenderer.setShadowVisible(false);
return localJFreeChart;
}
private static XYDataset createPriceDataset() {
TimeSeries localTimeSeries = new TimeSeries("Price");
localTimeSeries.add(new Day(2, 1, 2002), 95.564999999999998D);
localTimeSeries.add(new Day(3, 1, 2002), 95.640000000000001D);
localTimeSeries.add(new Day(4, 1, 2002), 95.709999999999994D);
localTimeSeries.add(new Day(7, 1, 2002), 95.930000000000007D);
localTimeSeries.add(new Day(8, 1, 2002), 95.930000000000007D);
localTimeSeries.add(new Day(9, 1, 2002), 95.959999999999994D);
localTimeSeries.add(new Day(10, 1, 2002), 96.055000000000007D);
localTimeSeries.add(new Day(11, 1, 2002), 96.334999999999994D);
localTimeSeries.add(new Day(14, 1, 2002), 96.290000000000006D);
localTimeSeries.add(new Day(15, 1, 2002), 96.275000000000006D);
localTimeSeries.add(new Day(16, 1, 2002), 96.239999999999995D);
localTimeSeries.add(new Day(17, 1, 2002), 96.079999999999998D);
localTimeSeries.add(new Day(18, 1, 2002), 96.144999999999996D);
localTimeSeries.add(new Day(22, 1, 2002), 96.120000000000005D);
localTimeSeries.add(new Day(23, 1, 2002), 96.015000000000001D);
localTimeSeries.add(new Day(24, 1, 2002), 95.890000000000001D);
localTimeSeries.add(new Day(25, 1, 2002), 95.864999999999995D);
localTimeSeries.add(new Day(28, 1, 2002), 95.879999999999995D);
localTimeSeries.add(new Day(29, 1, 2002), 96.049999999999997D);
localTimeSeries.add(new Day(30, 1, 2002), 96.064999999999998D);
localTimeSeries.add(new Day(31, 1, 2002), 95.909999999999997D);
localTimeSeries.add(new Day(1, 2, 2002), 96.015000000000001D);
localTimeSeries.add(new Day(4, 2, 2002), 96.140000000000001D);
localTimeSeries.add(new Day(5, 2, 2002), 96.194999999999993D);
localTimeSeries.add(new Day(6, 2, 2002), 96.245000000000005D);
localTimeSeries.add(new Day(7, 2, 2002), 96.219999999999999D);
localTimeSeries.add(new Day(8, 2, 2002), 96.280000000000001D);
localTimeSeries.add(new Day(11, 2, 2002), 96.265000000000001D);
localTimeSeries.add(new Day(12, 2, 2002), 96.159999999999997D);
localTimeSeries.add(new Day(13, 2, 2002), 96.120000000000005D);
localTimeSeries.add(new Day(14, 2, 2002), 96.125D);
localTimeSeries.add(new Day(15, 2, 2002), 96.265000000000001D);
localTimeSeries.add(new Day(19, 2, 2002), 96.290000000000006D);
localTimeSeries.add(new Day(20, 2, 2002), 96.275000000000006D);
localTimeSeries.add(new Day(21, 2, 2002), 96.280000000000001D);
localTimeSeries.add(new Day(22, 2, 2002), 96.305000000000007D);
localTimeSeries.add(new Day(25, 2, 2002), 96.265000000000001D);
localTimeSeries.add(new Day(26, 2, 2002), 96.185000000000002D);
localTimeSeries.add(new Day(27, 2, 2002), 96.305000000000007D);
localTimeSeries.add(new Day(28, 2, 2002), 96.215000000000003D);
localTimeSeries.add(new Day(1, 3, 2002), 96.015000000000001D);
localTimeSeries.add(new Day(4, 3, 2002), 95.969999999999999D);
localTimeSeries.add(new Day(5, 3, 2002), 95.935000000000002D);
localTimeSeries.add(new Day(6, 3, 2002), 95.935000000000002D);
localTimeSeries.add(new Day(7, 3, 2002), 95.704999999999998D);
localTimeSeries.add(new Day(8, 3, 2002), 95.484999999999999D);
localTimeSeries.add(new Day(11, 3, 2002), 95.504999999999995D);
localTimeSeries.add(new Day(12, 3, 2002), 95.540000000000006D);
localTimeSeries.add(new Day(13, 3, 2002), 95.674999999999997D);
localTimeSeries.add(new Day(14, 3, 2002), 95.510000000000005D);
localTimeSeries.add(new Day(15, 3, 2002), 95.5D);
localTimeSeries.add(new Day(18, 3, 2002), 95.5D);
localTimeSeries.add(new Day(19, 3, 2002), 95.534999999999997D);
localTimeSeries.add(new Day(20, 3, 2002), 95.420000000000002D);
localTimeSeries.add(new Day(21, 3, 2002), 95.400000000000006D);
localTimeSeries.add(new Day(22, 3, 2002), 95.375D);
localTimeSeries.add(new Day(25, 3, 2002), 95.349999999999994D);
localTimeSeries.add(new Day(26, 3, 2002), 95.504999999999995D);
localTimeSeries.add(new Day(27, 3, 2002), 95.549999999999997D);
localTimeSeries.add(new Day(28, 3, 2002), 95.484999999999999D);
localTimeSeries.add(new Day(1, 4, 2002), 95.484999999999999D);
localTimeSeries.add(new Day(2, 4, 2002), 95.629999999999995D);
localTimeSeries.add(new Day(3, 4, 2002), 95.734999999999999D);
localTimeSeries.add(new Day(4, 4, 2002), 95.694999999999993D);
localTimeSeries.add(new Day(5, 4, 2002), 95.810000000000002D);
localTimeSeries.add(new Day(8, 4, 2002), 95.810000000000002D);
localTimeSeries.add(new Day(9, 4, 2002), 95.864999999999995D);
localTimeSeries.add(new Day(10, 4, 2002), 95.885000000000005D);
localTimeSeries.add(new Day(11, 4, 2002), 95.900000000000006D);
localTimeSeries.add(new Day(12, 4, 2002), 95.980000000000004D);
localTimeSeries.add(new Day(15, 4, 2002), 96.034999999999997D);
localTimeSeries.add(new Day(16, 4, 2002), 96.0D);
localTimeSeries.add(new Day(17, 4, 2002), 96.034999999999997D);
localTimeSeries.add(new Day(18, 4, 2002), 96.084999999999994D);
localTimeSeries.add(new Day(19, 4, 2002), 96.075000000000003D);
localTimeSeries.add(new Day(22, 4, 2002), 96.105000000000004D);
localTimeSeries.add(new Day(23, 4, 2002), 96.075000000000003D);
localTimeSeries.add(new Day(24, 4, 2002), 96.209999999999994D);
localTimeSeries.add(new Day(25, 4, 2002), 96.254999999999995D);
localTimeSeries.add(new Day(26, 4, 2002), 96.310000000000002D);
localTimeSeries.add(new Day(29, 4, 2002), 96.310000000000002D);
localTimeSeries.add(new Day(30, 4, 2002), 96.325000000000003D);
localTimeSeries.add(new Day(1, 5, 2002), 96.344999999999999D);
localTimeSeries.add(new Day(2, 5, 2002), 96.284999999999997D);
localTimeSeries.add(new Day(3, 5, 2002), 96.385000000000005D);
localTimeSeries.add(new Day(6, 5, 2002), 96.379999999999995D);
localTimeSeries.add(new Day(7, 5, 2002), 96.484999999999999D);
localTimeSeries.add(new Day(8, 5, 2002), 96.230000000000004D);
localTimeSeries.add(new Day(9, 5, 2002), 96.310000000000002D);
localTimeSeries.add(new Day(10, 5, 2002), 96.444999999999993D);
localTimeSeries.add(new Day(13, 5, 2002), 96.355000000000004D);
localTimeSeries.add(new Day(14, 5, 2002), 96.180000000000007D);
localTimeSeries.add(new Day(15, 5, 2002), 96.239999999999995D);
localTimeSeries.add(new Day(16, 5, 2002), 96.325000000000003D);
localTimeSeries.add(new Day(17, 5, 2002), 96.200000000000003D);
localTimeSeries.add(new Day(20, 5, 2002), 96.305000000000007D);
localTimeSeries.add(new Day(21, 5, 2002), 96.385000000000005D);
localTimeSeries.add(new Day(22, 5, 2002), 96.444999999999993D);
localTimeSeries.add(new Day(23, 5, 2002), 96.385000000000005D);
localTimeSeries.add(new Day(24, 5, 2002), 96.390000000000001D);
localTimeSeries.add(new Day(28, 5, 2002), 96.390000000000001D);
localTimeSeries.add(new Day(29, 5, 2002), 96.474999999999994D);
localTimeSeries.add(new Day(30, 5, 2002), 96.555000000000007D);
localTimeSeries.add(new Day(31, 5, 2002), 96.5D);
localTimeSeries.add(new Day(3, 6, 2002), 96.540000000000006D);
localTimeSeries.add(new Day(4, 6, 2002), 96.605000000000004D);
localTimeSeries.add(new Day(5, 6, 2002), 96.579999999999998D);
localTimeSeries.add(new Day(6, 6, 2002), 96.609999999999999D);
localTimeSeries.add(new Day(7, 6, 2002), 96.599999999999994D);
localTimeSeries.add(new Day(10, 6, 2002), 96.614999999999995D);
localTimeSeries.add(new Day(11, 6, 2002), 96.704999999999998D);
localTimeSeries.add(new Day(12, 6, 2002), 96.75D);
localTimeSeries.add(new Day(13, 6, 2002), 96.829999999999998D);
localTimeSeries.add(new Day(14, 6, 2002), 96.965000000000003D);
localTimeSeries.add(new Day(17, 6, 2002), 96.944999999999993D);
localTimeSeries.add(new Day(18, 6, 2002), 96.989999999999995D);
localTimeSeries.add(new Day(19, 6, 2002), 97.165000000000006D);
localTimeSeries.add(new Day(20, 6, 2002), 97.030000000000001D);
localTimeSeries.add(new Day(21, 6, 2002), 97.144999999999996D);
localTimeSeries.add(new Day(24, 6, 2002), 97.120000000000005D);
localTimeSeries.add(new Day(25, 6, 2002), 97.174999999999997D);
localTimeSeries.add(new Day(26, 6, 2002), 97.364999999999995D);
localTimeSeries.add(new Day(27, 6, 2002), 97.245000000000005D);
localTimeSeries.add(new Day(28, 6, 2002), 97.245000000000005D);
localTimeSeries.add(new Day(1, 7, 2002), 97.290000000000006D);
localTimeSeries.add(new Day(2, 7, 2002), 97.379999999999995D);
localTimeSeries.add(new Day(3, 7, 2002), 97.379999999999995D);
localTimeSeries.add(new Day(5, 7, 2002), 97.219999999999999D);
localTimeSeries.add(new Day(8, 7, 2002), 97.325000000000003D);
localTimeSeries.add(new Day(9, 7, 2002), 97.454999999999998D);
localTimeSeries.add(new Day(10, 7, 2002), 97.579999999999998D);
localTimeSeries.add(new Day(11, 7, 2002), 97.605000000000004D);
localTimeSeries.add(new Day(12, 7, 2002), 97.689999999999998D);
localTimeSeries.add(new Day(15, 7, 2002), 97.730000000000004D);
localTimeSeries.add(new Day(16, 7, 2002), 97.579999999999998D);
localTimeSeries.add(new Day(17, 7, 2002), 97.640000000000001D);
localTimeSeries.add(new Day(18, 7, 2002), 97.680000000000007D);
localTimeSeries.add(new Day(19, 7, 2002), 97.715000000000003D);
localTimeSeries.add(new Day(22, 7, 2002), 97.814999999999998D);
localTimeSeries.add(new Day(23, 7, 2002), 97.875D);
localTimeSeries.add(new Day(24, 7, 2002), 97.834999999999994D);
localTimeSeries.add(new Day(25, 7, 2002), 97.924999999999997D);
localTimeSeries.add(new Day(26, 7, 2002), 97.959999999999994D);
localTimeSeries.add(new Day(29, 7, 2002), 97.745000000000005D);
localTimeSeries.add(new Day(30, 7, 2002), 97.709999999999994D);
localTimeSeries.add(new Day(31, 7, 2002), 97.930000000000007D);
localTimeSeries.add(new Day(1, 8, 2002), 98.0D);
localTimeSeries.add(new Day(2, 8, 2002), 98.170000000000002D);
localTimeSeries.add(new Day(5, 8, 2002), 98.224999999999994D);
localTimeSeries.add(new Day(6, 8, 2002), 98.114999999999995D);
localTimeSeries.add(new Day(7, 8, 2002), 98.265000000000001D);
localTimeSeries.add(new Day(8, 8, 2002), 98.180000000000007D);
localTimeSeries.add(new Day(9, 8, 2002), 98.185000000000002D);
localTimeSeries.add(new Day(12, 8, 2002), 98.150000000000006D);
localTimeSeries.add(new Day(13, 8, 2002), 98.290000000000006D);
localTimeSeries.add(new Day(14, 8, 2002), 98.155000000000001D);
localTimeSeries.add(new Day(15, 8, 2002), 98.075000000000003D);
localTimeSeries.add(new Day(16, 8, 2002), 98.0D);
localTimeSeries.add(new Day(19, 8, 2002), 98.040000000000006D);
localTimeSeries.add(new Day(20, 8, 2002), 98.135000000000005D);
localTimeSeries.add(new Day(21, 8, 2002), 98.109999999999999D);
localTimeSeries.add(new Day(22, 8, 2002), 98.004999999999995D);
localTimeSeries.add(new Day(23, 8, 2002), 98.055000000000007D);
localTimeSeries.add(new Day(26, 8, 2002), 98.064999999999998D);
localTimeSeries.add(new Day(27, 8, 2002), 97.980000000000004D);
localTimeSeries.add(new Day(28, 8, 2002), 98.034999999999997D);
localTimeSeries.add(new Day(29, 8, 2002), 98.094999999999999D);
localTimeSeries.add(new Day(30, 8, 2002), 98.060000000000002D);
localTimeSeries.add(new Day(3, 9, 2002), 98.25D);
localTimeSeries.add(new Day(4, 9, 2002), 98.245000000000005D);
localTimeSeries.add(new Day(5, 9, 2002), 98.314999999999998D);
localTimeSeries.add(new Day(6, 9, 2002), 98.170000000000002D);
localTimeSeries.add(new Day(9, 9, 2002), 98.079999999999998D);
localTimeSeries.add(new Day(10, 9, 2002), 98.090000000000003D);
localTimeSeries.add(new Day(11, 9, 2002), 98.030000000000001D);
localTimeSeries.add(new Day(12, 9, 2002), 98.105000000000004D);
localTimeSeries.add(new Day(13, 9, 2002), 98.135000000000005D);
localTimeSeries.add(new Day(16, 9, 2002), 98.114999999999995D);
localTimeSeries.add(new Day(17, 9, 2002), 98.125D);
localTimeSeries.add(new Day(18, 9, 2002), 98.129999999999995D);
localTimeSeries.add(new Day(19, 9, 2002), 98.254999999999995D);
localTimeSeries.add(new Day(20, 9, 2002), 98.254999999999995D);
localTimeSeries.add(new Day(23, 9, 2002), 98.280000000000001D);
localTimeSeries.add(new Day(24, 9, 2002), 98.310000000000002D);
localTimeSeries.add(new Day(25, 9, 2002), 98.25D);
localTimeSeries.add(new Day(26, 9, 2002), 98.299999999999997D);
localTimeSeries.add(new Day(27, 9, 2002), 98.409999999999997D);
localTimeSeries.add(new Day(30, 9, 2002), 98.495000000000005D);
localTimeSeries.add(new Day(1, 10, 2002), 98.439999999999998D);
localTimeSeries.add(new Day(2, 10, 2002), 98.439999999999998D);
localTimeSeries.add(new Day(3, 10, 2002), 98.439999999999998D);
localTimeSeries.add(new Day(4, 10, 2002), 98.379999999999995D);
localTimeSeries.add(new Day(7, 10, 2002), 98.385000000000005D);
localTimeSeries.add(new Day(8, 10, 2002), 98.340000000000003D);
localTimeSeries.add(new Day(9, 10, 2002), 98.420000000000002D);
localTimeSeries.add(new Day(10, 10, 2002), 98.375D);
localTimeSeries.add(new Day(11, 10, 2002), 98.275000000000006D);
localTimeSeries.add(new Day(14, 10, 2002), 98.275000000000006D);
localTimeSeries.add(new Day(15, 10, 2002), 98.135000000000005D);
localTimeSeries.add(new Day(16, 10, 2002), 98.165000000000006D);
localTimeSeries.add(new Day(17, 10, 2002), 98.170000000000002D);
localTimeSeries.add(new Day(18, 10, 2002), 98.165000000000006D);
localTimeSeries.add(new Day(21, 10, 2002), 98.105000000000004D);
localTimeSeries.add(new Day(22, 10, 2002), 98.125D);
localTimeSeries.add(new Day(23, 10, 2002), 98.185000000000002D);
localTimeSeries.add(new Day(24, 10, 2002), 98.245000000000005D);
localTimeSeries.add(new Day(25, 10, 2002), 98.319999999999993D);
localTimeSeries.add(new Day(28, 10, 2002), 98.420000000000002D);
localTimeSeries.add(new Day(29, 10, 2002), 98.540000000000006D);
localTimeSeries.add(new Day(30, 10, 2002), 98.545000000000002D);
localTimeSeries.add(new Day(31, 10, 2002), 98.560000000000002D);
return new TimeSeriesCollection(localTimeSeries);
}
private static IntervalXYDataset createVolumeDataset() {
TimeSeries localTimeSeries = new TimeSeries("Volume");
localTimeSeries.add(new Day(2, 1, 2002), 41020.0D);
localTimeSeries.add(new Day(3, 1, 2002), 45586.0D);
localTimeSeries.add(new Day(4, 1, 2002), 81672.0D);
localTimeSeries.add(new Day(7, 1, 2002), 81975.0D);
localTimeSeries.add(new Day(8, 1, 2002), 79692.0D);
localTimeSeries.add(new Day(9, 1, 2002), 53187.0D);
localTimeSeries.add(new Day(10, 1, 2002), 87929.0D);
localTimeSeries.add(new Day(11, 1, 2002), 107047.0D);
localTimeSeries.add(new Day(14, 1, 2002), 86276.0D);
localTimeSeries.add(new Day(15, 1, 2002), 79005.0D);
localTimeSeries.add(new Day(16, 1, 2002), 80632.0D);
localTimeSeries.add(new Day(17, 1, 2002), 88797.0D);
localTimeSeries.add(new Day(18, 1, 2002), 57179.0D);
localTimeSeries.add(new Day(22, 1, 2002), 36611.0D);
localTimeSeries.add(new Day(23, 1, 2002), 57063.0D);
localTimeSeries.add(new Day(24, 1, 2002), 101938.0D);
localTimeSeries.add(new Day(25, 1, 2002), 87177.0D);
localTimeSeries.add(new Day(28, 1, 2002), 39831.0D);
localTimeSeries.add(new Day(29, 1, 2002), 67654.0D);
localTimeSeries.add(new Day(30, 1, 2002), 81162.0D);
localTimeSeries.add(new Day(31, 1, 2002), 64923.0D);
localTimeSeries.add(new Day(1, 2, 2002), 73481.0D);
localTimeSeries.add(new Day(4, 2, 2002), 54723.0D);
localTimeSeries.add(new Day(5, 2, 2002), 76708.0D);
localTimeSeries.add(new Day(6, 2, 2002), 81281.0D);
localTimeSeries.add(new Day(7, 2, 2002), 66553.0D);
localTimeSeries.add(new Day(8, 2, 2002), 53592.0D);
localTimeSeries.add(new Day(11, 2, 2002), 29410.0D);
localTimeSeries.add(new Day(12, 2, 2002), 60345.0D);
localTimeSeries.add(new Day(13, 2, 2002), 67339.0D);
localTimeSeries.add(new Day(14, 2, 2002), 40057.0D);
localTimeSeries.add(new Day(15, 2, 2002), 67865.0D);
localTimeSeries.add(new Day(19, 2, 2002), 58628.0D);
localTimeSeries.add(new Day(20, 2, 2002), 52109.0D);
localTimeSeries.add(new Day(21, 2, 2002), 50195.0D);
localTimeSeries.add(new Day(22, 2, 2002), 47806.0D);
localTimeSeries.add(new Day(25, 2, 2002), 31711.0D);
localTimeSeries.add(new Day(26, 2, 2002), 88328.0D);
localTimeSeries.add(new Day(27, 2, 2002), 95805.0D);
localTimeSeries.add(new Day(28, 2, 2002), 84035.0D);
localTimeSeries.add(new Day(1, 3, 2002), 113584.0D);
localTimeSeries.add(new Day(4, 3, 2002), 71872.0D);
localTimeSeries.add(new Day(5, 3, 2002), 83016.0D);
localTimeSeries.add(new Day(6, 3, 2002), 62273.0D);
localTimeSeries.add(new Day(7, 3, 2002), 138508.0D);
localTimeSeries.add(new Day(8, 3, 2002), 139428.0D);
localTimeSeries.add(new Day(11, 3, 2002), 80232.0D);
localTimeSeries.add(new Day(12, 3, 2002), 75693.0D);
localTimeSeries.add(new Day(13, 3, 2002), 104068.0D);
localTimeSeries.add(new Day(14, 3, 2002), 72171.0D);
localTimeSeries.add(new Day(15, 3, 2002), 117262.0D);
localTimeSeries.add(new Day(18, 3, 2002), 66048.0D);
localTimeSeries.add(new Day(19, 3, 2002), 87079.0D);
localTimeSeries.add(new Day(20, 3, 2002), 116084.0D);
localTimeSeries.add(new Day(21, 3, 2002), 113206.0D);
localTimeSeries.add(new Day(22, 3, 2002), 68326.0D);
localTimeSeries.add(new Day(25, 3, 2002), 34340.0D);
localTimeSeries.add(new Day(26, 3, 2002), 104413.0D);
localTimeSeries.add(new Day(27, 3, 2002), 57277.0D);
localTimeSeries.add(new Day(28, 3, 2002), 69936.0D);
localTimeSeries.add(new Day(1, 4, 2002), 57282.0D);
localTimeSeries.add(new Day(2, 4, 2002), 74686.0D);
localTimeSeries.add(new Day(3, 4, 2002), 108601.0D);
localTimeSeries.add(new Day(4, 4, 2002), 123381.0D);
localTimeSeries.add(new Day(5, 4, 2002), 106691.0D);
localTimeSeries.add(new Day(8, 4, 2002), 118535.0D);
localTimeSeries.add(new Day(9, 4, 2002), 85577.0D);
localTimeSeries.add(new Day(10, 4, 2002), 75441.0D);
localTimeSeries.add(new Day(11, 4, 2002), 88845.0D);
localTimeSeries.add(new Day(12, 4, 2002), 137141.0D);
localTimeSeries.add(new Day(15, 4, 2002), 72518.0D);
localTimeSeries.add(new Day(16, 4, 2002), 122100.0D);
localTimeSeries.add(new Day(17, 4, 2002), 136419.0D);
localTimeSeries.add(new Day(18, 4, 2002), 141338.0D);
localTimeSeries.add(new Day(19, 4, 2002), 80274.0D);
localTimeSeries.add(new Day(22, 4, 2002), 40449.0D);
localTimeSeries.add(new Day(23, 4, 2002), 72292.0D);
localTimeSeries.add(new Day(24, 4, 2002), 110644.0D);
localTimeSeries.add(new Day(25, 4, 2002), 145142.0D);
localTimeSeries.add(new Day(26, 4, 2002), 139573.0D);
localTimeSeries.add(new Day(29, 4, 2002), 51509.0D);
localTimeSeries.add(new Day(30, 4, 2002), 105782.0D);
localTimeSeries.add(new Day(1, 5, 2002), 170680.0D);
localTimeSeries.add(new Day(2, 5, 2002), 140800.0D);
localTimeSeries.add(new Day(3, 5, 2002), 170411.0D);
localTimeSeries.add(new Day(6, 5, 2002), 46172.0D);
localTimeSeries.add(new Day(7, 5, 2002), 137251.0D);
localTimeSeries.add(new Day(8, 5, 2002), 220626.0D);
localTimeSeries.add(new Day(9, 5, 2002), 175902.0D);
localTimeSeries.add(new Day(10, 5, 2002), 128807.0D);
localTimeSeries.add(new Day(13, 5, 2002), 78208.0D);
localTimeSeries.add(new Day(14, 5, 2002), 212048.0D);
localTimeSeries.add(new Day(15, 5, 2002), 145643.0D);
localTimeSeries.add(new Day(16, 5, 2002), 121520.0D);
localTimeSeries.add(new Day(17, 5, 2002), 147820.0D);
localTimeSeries.add(new Day(20, 5, 2002), 75969.0D);
localTimeSeries.add(new Day(21, 5, 2002), 118970.0D);
localTimeSeries.add(new Day(22, 5, 2002), 131013.0D);
localTimeSeries.add(new Day(23, 5, 2002), 141100.0D);
localTimeSeries.add(new Day(24, 5, 2002), 63606.0D);
localTimeSeries.add(new Day(28, 5, 2002), 78687.0D);
localTimeSeries.add(new Day(29, 5, 2002), 86743.0D);
localTimeSeries.add(new Day(30, 5, 2002), 164376.0D);
localTimeSeries.add(new Day(31, 5, 2002), 150108.0D);
localTimeSeries.add(new Day(3, 6, 2002), 132363.0D);
localTimeSeries.add(new Day(4, 6, 2002), 144902.0D);
localTimeSeries.add(new Day(5, 6, 2002), 123834.0D);
localTimeSeries.add(new Day(6, 6, 2002), 125004.0D);
localTimeSeries.add(new Day(7, 6, 2002), 165049.0D);
localTimeSeries.add(new Day(10, 6, 2002), 88069.0D);
localTimeSeries.add(new Day(11, 6, 2002), 114146.0D);
localTimeSeries.add(new Day(12, 6, 2002), 149992.0D);
localTimeSeries.add(new Day(13, 6, 2002), 191261.0D);
localTimeSeries.add(new Day(14, 6, 2002), 207444.0D);
localTimeSeries.add(new Day(17, 6, 2002), 117081.0D);
localTimeSeries.add(new Day(18, 6, 2002), 135924.0D);
localTimeSeries.add(new Day(19, 6, 2002), 179654.0D);
localTimeSeries.add(new Day(20, 6, 2002), 260936.0D);
localTimeSeries.add(new Day(21, 6, 2002), 140283.0D);
localTimeSeries.add(new Day(24, 6, 2002), 199052.0D);
localTimeSeries.add(new Day(25, 6, 2002), 191804.0D);
localTimeSeries.add(new Day(26, 6, 2002), 384936.0D);
localTimeSeries.add(new Day(27, 6, 2002), 313065.0D);
localTimeSeries.add(new Day(28, 6, 2002), 169963.0D);
localTimeSeries.add(new Day(1, 7, 2002), 109906.0D);
localTimeSeries.add(new Day(2, 7, 2002), 140644.0D);
localTimeSeries.add(new Day(3, 7, 2002), 150898.0D);
localTimeSeries.add(new Day(5, 7, 2002), 181355.0D);
localTimeSeries.add(new Day(8, 7, 2002), 155042.0D);
localTimeSeries.add(new Day(9, 7, 2002), 204305.0D);
localTimeSeries.add(new Day(10, 7, 2002), 300113.0D);
localTimeSeries.add(new Day(11, 7, 2002), 338948.0D);
localTimeSeries.add(new Day(12, 7, 2002), 281325.0D);
localTimeSeries.add(new Day(15, 7, 2002), 256101.0D);
localTimeSeries.add(new Day(16, 7, 2002), 348164.0D);
localTimeSeries.add(new Day(17, 7, 2002), 242995.0D);
localTimeSeries.add(new Day(18, 7, 2002), 200744.0D);
localTimeSeries.add(new Day(19, 7, 2002), 181071.0D);
localTimeSeries.add(new Day(22, 7, 2002), 163266.0D);
localTimeSeries.add(new Day(23, 7, 2002), 188508.0D);
localTimeSeries.add(new Day(24, 7, 2002), 308070.0D);
localTimeSeries.add(new Day(25, 7, 2002), 230901.0D);
localTimeSeries.add(new Day(26, 7, 2002), 162577.0D);
localTimeSeries.add(new Day(29, 7, 2002), 216318.0D);
localTimeSeries.add(new Day(30, 7, 2002), 280677.0D);
localTimeSeries.add(new Day(31, 7, 2002), 260236.0D);
localTimeSeries.add(new Day(1, 8, 2002), 242803.0D);
localTimeSeries.add(new Day(2, 8, 2002), 298490.0D);
localTimeSeries.add(new Day(5, 8, 2002), 182890.0D);
localTimeSeries.add(new Day(6, 8, 2002), 232273.0D);
localTimeSeries.add(new Day(7, 8, 2002), 253552.0D);
localTimeSeries.add(new Day(8, 8, 2002), 165365.0D);
localTimeSeries.add(new Day(9, 8, 2002), 160382.0D);
localTimeSeries.add(new Day(12, 8, 2002), 118030.0D);
localTimeSeries.add(new Day(13, 8, 2002), 208807.0D);
localTimeSeries.add(new Day(14, 8, 2002), 231599.0D);
localTimeSeries.add(new Day(15, 8, 2002), 343482.0D);
localTimeSeries.add(new Day(16, 8, 2002), 186116.0D);
localTimeSeries.add(new Day(19, 8, 2002), 96437.0D);
localTimeSeries.add(new Day(20, 8, 2002), 151735.0D);
localTimeSeries.add(new Day(21, 8, 2002), 167390.0D);
localTimeSeries.add(new Day(22, 8, 2002), 127184.0D);
localTimeSeries.add(new Day(23, 8, 2002), 80205.0D);
localTimeSeries.add(new Day(26, 8, 2002), 79893.0D);
localTimeSeries.add(new Day(27, 8, 2002), 201723.0D);
localTimeSeries.add(new Day(28, 8, 2002), 114001.0D);
localTimeSeries.add(new Day(29, 8, 2002), 188389.0D);
localTimeSeries.add(new Day(30, 8, 2002), 162801.0D);
localTimeSeries.add(new Day(3, 9, 2002), 200951.0D);
localTimeSeries.add(new Day(4, 9, 2002), 129229.0D);
localTimeSeries.add(new Day(5, 9, 2002), 183348.0D);
localTimeSeries.add(new Day(6, 9, 2002), 216722.0D);
localTimeSeries.add(new Day(9, 9, 2002), 128575.0D);
localTimeSeries.add(new Day(10, 9, 2002), 224714.0D);
localTimeSeries.add(new Day(11, 9, 2002), 144224.0D);
localTimeSeries.add(new Day(12, 9, 2002), 195721.0D);
localTimeSeries.add(new Day(13, 9, 2002), 160724.0D);
localTimeSeries.add(new Day(16, 9, 2002), 65473.0D);
localTimeSeries.add(new Day(17, 9, 2002), 141274.0D);
localTimeSeries.add(new Day(18, 9, 2002), 115084.0D);
localTimeSeries.add(new Day(19, 9, 2002), 242106.0D);
localTimeSeries.add(new Day(20, 9, 2002), 130034.0D);
localTimeSeries.add(new Day(23, 9, 2002), 95215.0D);
localTimeSeries.add(new Day(24, 9, 2002), 229288.0D);
localTimeSeries.add(new Day(25, 9, 2002), 163672.0D);
localTimeSeries.add(new Day(26, 9, 2002), 193573.0D);
localTimeSeries.add(new Day(27, 9, 2002), 170741.0D);
localTimeSeries.add(new Day(30, 9, 2002), 199615.0D);
localTimeSeries.add(new Day(1, 10, 2002), 170771.0D);
localTimeSeries.add(new Day(2, 10, 2002), 138498.0D);
localTimeSeries.add(new Day(3, 10, 2002), 154774.0D);
localTimeSeries.add(new Day(4, 10, 2002), 287154.0D);
localTimeSeries.add(new Day(7, 10, 2002), 111762.0D);
localTimeSeries.add(new Day(8, 10, 2002), 172535.0D);
localTimeSeries.add(new Day(9, 10, 2002), 148339.0D);
localTimeSeries.add(new Day(10, 10, 2002), 178796.0D);
localTimeSeries.add(new Day(11, 10, 2002), 153499.0D);
localTimeSeries.add(new Day(14, 10, 2002), 4589.0D);
localTimeSeries.add(new Day(15, 10, 2002), 172088.0D);
localTimeSeries.add(new Day(16, 10, 2002), 151267.0D);
localTimeSeries.add(new Day(17, 10, 2002), 222680.0D);
localTimeSeries.add(new Day(18, 10, 2002), 127019.0D);
localTimeSeries.add(new Day(21, 10, 2002), 118226.0D);
localTimeSeries.add(new Day(22, 10, 2002), 183031.0D);
localTimeSeries.add(new Day(23, 10, 2002), 221005.0D);
localTimeSeries.add(new Day(24, 10, 2002), 121333.0D);
localTimeSeries.add(new Day(25, 10, 2002), 138179.0D);
localTimeSeries.add(new Day(28, 10, 2002), 162012.0D);
localTimeSeries.add(new Day(29, 10, 2002), 237355.0D);
localTimeSeries.add(new Day(30, 10, 2002), 161650.0D);
localTimeSeries.add(new Day(31, 10, 2002), 207569.0D);
return new TimeSeriesCollection(localTimeSeries);
}
public static JPanel createDemoPanel() {
JFreeChart localJFreeChart = createChart();
return new ChartPanel(localJFreeChart);
}
public static void main(String[] paramArrayOfString) {
PriceVolumeDemo1 localPriceVolumeDemo1 = new PriceVolumeDemo1("PriceVolumeChartDemo1.java");
localPriceVolumeDemo1.pack();
RefineryUtilities.centerFrameOnScreen(localPriceVolumeDemo1);
localPriceVolumeDemo1.setVisible(true);
}
}
*s16.postimg.org/vbv2fuji9/Price_Volume_Demo1.jpg
Here is a Stacked BarChart
Code:
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.JPanel;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.labels.ItemLabelAnchor;
import org.jfree.chart.labels.ItemLabelPosition;
import org.jfree.chart.labels.StandardCategoryItemLabelGenerator;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.IntervalMarker;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.renderer.category.BarRenderer;
import org.jfree.data.category.CategoryDataset;
import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;
import org.jfree.ui.TextAnchor;
public class StackedBarChart3DDemo1 extends ApplicationFrame {
private static final long serialVersionUID = 1L;
public StackedBarChart3DDemo1(String paramString) {
super(paramString);
JPanel localJPanel = createDemoPanel();
Dimension scrDim = Toolkit.getDefaultToolkit().getScreenSize();
localJPanel.setPreferredSize(new Dimension(scrDim.width / 2, scrDim.height / 2));
setContentPane(localJPanel);
}
public static CategoryDataset createDataset() {
DefaultCategoryDataset localDefaultCategoryDataset = new DefaultCategoryDataset();
localDefaultCategoryDataset.addValue(10.0D, "Series 1", "C1");
localDefaultCategoryDataset.addValue(5.0D, "Series 1", "C2");
localDefaultCategoryDataset.addValue(6.0D, "Series 1", "C3");
localDefaultCategoryDataset.addValue(7.0D, "Series 1", "C4");
localDefaultCategoryDataset.addValue(8.0D, "Series 1", "C5");
localDefaultCategoryDataset.addValue(9.0D, "Series 1", "C6");
localDefaultCategoryDataset.addValue(10.0D, "Series 1", "C7");
localDefaultCategoryDataset.addValue(11.0D, "Series 1", "C8");
localDefaultCategoryDataset.addValue(3.0D, "Series 1", "C9");
localDefaultCategoryDataset.addValue(4.0D, "Series 2", "C1");
localDefaultCategoryDataset.addValue(7.0D, "Series 2", "C2");
localDefaultCategoryDataset.addValue(17.0D, "Series 2", "C3");
localDefaultCategoryDataset.addValue(15.0D, "Series 2", "C4");
localDefaultCategoryDataset.addValue(6.0D, "Series 2", "C5");
localDefaultCategoryDataset.addValue(8.0D, "Series 2", "C6");
localDefaultCategoryDataset.addValue(9.0D, "Series 2", "C7");
localDefaultCategoryDataset.addValue(13.0D, "Series 2", "C8");
localDefaultCategoryDataset.addValue(7.0D, "Series 2", "C9");
localDefaultCategoryDataset.addValue(15.0D, "Series 3", "C1");
localDefaultCategoryDataset.addValue(14.0D, "Series 3", "C2");
localDefaultCategoryDataset.addValue(12.0D, "Series 3", "C3");
localDefaultCategoryDataset.addValue(11.0D, "Series 3", "C4");
localDefaultCategoryDataset.addValue(10.0D, "Series 3", "C5");
localDefaultCategoryDataset.addValue(0.0D, "Series 3", "C6");
localDefaultCategoryDataset.addValue(7.0D, "Series 3", "C7");
localDefaultCategoryDataset.addValue(9.0D, "Series 3", "C8");
localDefaultCategoryDataset.addValue(11.0D, "Series 3", "C9");
localDefaultCategoryDataset.addValue(14.0D, "Series 4", "C1");
localDefaultCategoryDataset.addValue(3.0D, "Series 4", "C2");
localDefaultCategoryDataset.addValue(7.0D, "Series 4", "C3");
localDefaultCategoryDataset.addValue(0.0D, "Series 4", "C4");
localDefaultCategoryDataset.addValue(9.0D, "Series 4", "C5");
localDefaultCategoryDataset.addValue(6.0D, "Series 4", "C6");
localDefaultCategoryDataset.addValue(7.0D, "Series 4", "C7");
localDefaultCategoryDataset.addValue(9.0D, "Series 4", "C8");
localDefaultCategoryDataset.addValue(10.0D, "Series 4", "C9");
return localDefaultCategoryDataset;
}
private static JFreeChart createChart(CategoryDataset paramCategoryDataset) {
JFreeChart localJFreeChart = ChartFactory.createStackedBarChart3D("Stacked Bar Chart 3D Demo 1", "Category", "Value", paramCategoryDataset, PlotOrientation.VERTICAL, true, true, false);
CategoryPlot localCategoryPlot = (CategoryPlot) localJFreeChart.getPlot();
IntervalMarker localIntervalMarker = new IntervalMarker(5.0D, 10.0D, Color.gray, new BasicStroke(0.5F), Color.blue, new BasicStroke(0.5F), 0.5F);
localCategoryPlot.addRangeMarker(localIntervalMarker);
BarRenderer localBarRenderer = (BarRenderer) localCategoryPlot.getRenderer();
localBarRenderer.setDrawBarOutline(false);
localBarRenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
localBarRenderer.setBaseItemLabelsVisible(true);
localBarRenderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER));
localBarRenderer.setBaseNegativeItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER));
return localJFreeChart;
}
public static JPanel createDemoPanel() {
JFreeChart localJFreeChart = createChart(createDataset());
return new ChartPanel(localJFreeChart);
}
public static void main(String[] paramArrayOfString) {
StackedBarChart3DDemo1 localStackedBarChart3DDemo1 = new StackedBarChart3DDemo1("Stacked Bar Chart 3D Demo 1");
localStackedBarChart3DDemo1.pack();
RefineryUtilities.centerFrameOnScreen(localStackedBarChart3DDemo1);
localStackedBarChart3DDemo1.setVisible(true);
}
}
*s1.postimg.org/m2cffua6j/Stacked_Bar_Chart3_DDemo1.jpg
Here is a Ring Chart!!
RingChartDemo1.java
Code:
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Toolkit;
import javax.swing.JPanel;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.RingPlot;
import org.jfree.data.general.DefaultPieDataset;
import org.jfree.data.general.PieDataset;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;
public class RingChartDemo1 extends ApplicationFrame {
public RingChartDemo1(String paramString) {
super(paramString);
JPanel localJPanel = createDemoPanel();
Dimension scrDim = Toolkit.getDefaultToolkit().getScreenSize();
localJPanel.setPreferredSize(new Dimension(scrDim.width / 2, scrDim.height / 2));
setContentPane(localJPanel);
}
private static PieDataset createDataset() {
DefaultPieDataset localDefaultPieDataset = new DefaultPieDataset();
localDefaultPieDataset.setValue("One", new Double(43.200000000000003D));
localDefaultPieDataset.setValue("Two", new Double(10.0D));
localDefaultPieDataset.setValue("Three", new Double(27.5D));
localDefaultPieDataset.setValue("Four", new Double(17.5D));
localDefaultPieDataset.setValue("Five", new Double(11.0D));
localDefaultPieDataset.setValue("Six", new Double(19.399999999999999D));
return localDefaultPieDataset;
}
private static JFreeChart createChart(PieDataset paramPieDataset) {
JFreeChart localJFreeChart = ChartFactory.createRingChart("Ring Chart Demo 1", paramPieDataset, false, true, false);
RingPlot localRingPlot = (RingPlot) localJFreeChart.getPlot();
localRingPlot.setLabelFont(new Font("SansSerif", 0, 12));
localRingPlot.setNoDataMessage("No data available");
localRingPlot.setSectionDepth(0.35D);
localRingPlot.setCircular(false);
localRingPlot.setLabelGap(0.02D);
return localJFreeChart;
}
public static JPanel createDemoPanel() {
JFreeChart localJFreeChart = createChart(createDataset());
ChartPanel localChartPanel = new ChartPanel(localJFreeChart);
localChartPanel.setMouseWheelEnabled(true);
return localChartPanel;
}
public static void main(String[] paramArrayOfString) {
RingChartDemo1 localRingChartDemo1 = new RingChartDemo1("RingChartDemo1");
localRingChartDemo1.pack();
RefineryUtilities.centerFrameOnScreen(localRingChartDemo1);
localRingChartDemo1.setVisible(true);
}
}
*s8.postimg.org/x0intxgj5/Ring_Chart_Demo1.jpg
Here is a Scatter plot demo!!
Code:
/**
*
* @author JGuru
*/
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.JPanel;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
import org.jfree.data.xy.XYDataset;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;
public class ScatterPlotDemo1 extends ApplicationFrame {
public ScatterPlotDemo1(String paramString) {
super(paramString);
JPanel localJPanel = createDemoPanel();
localJPanel.setPreferredSize(new Dimension(500, 270));
setContentPane(localJPanel);
}
private static JFreeChart createChart(XYDataset paramXYDataset) {
JFreeChart localJFreeChart = ChartFactory.createScatterPlot("Scatter Plot Demo 1", "X", "Y", paramXYDataset, PlotOrientation.VERTICAL, true, true, false);
XYPlot localXYPlot = (XYPlot) localJFreeChart.getPlot();
localXYPlot.setNoDataMessage("NO DATA");
localXYPlot.setDomainPannable(true);
localXYPlot.setRangePannable(true);
localXYPlot.setDomainZeroBaselineVisible(true);
localXYPlot.setRangeZeroBaselineVisible(true);
localXYPlot.setDomainGridlineStroke(new BasicStroke(0.0F));
localXYPlot.setDomainMinorGridlineStroke(new BasicStroke(0.0F));
localXYPlot.setDomainGridlinePaint(Color.blue);
localXYPlot.setRangeGridlineStroke(new BasicStroke(0.0F));
localXYPlot.setRangeMinorGridlineStroke(new BasicStroke(0.0F));
localXYPlot.setRangeGridlinePaint(Color.blue);
localXYPlot.setDomainMinorGridlinesVisible(true);
localXYPlot.setRangeMinorGridlinesVisible(true);
XYLineAndShapeRenderer localXYLineAndShapeRenderer = (XYLineAndShapeRenderer) localXYPlot.getRenderer();
localXYLineAndShapeRenderer.setSeriesOutlinePaint(0, Color.black);
localXYLineAndShapeRenderer.setUseOutlinePaint(true);
NumberAxis localNumberAxis1 = (NumberAxis) localXYPlot.getDomainAxis();
localNumberAxis1.setAutoRangeIncludesZero(false);
localNumberAxis1.setTickMarkInsideLength(2.0F);
localNumberAxis1.setTickMarkOutsideLength(2.0F);
localNumberAxis1.setMinorTickCount(2);
localNumberAxis1.setMinorTickMarksVisible(true);
NumberAxis localNumberAxis2 = (NumberAxis) localXYPlot.getRangeAxis();
localNumberAxis2.setTickMarkInsideLength(2.0F);
localNumberAxis2.setTickMarkOutsideLength(2.0F);
localNumberAxis2.setMinorTickCount(2);
localNumberAxis2.setMinorTickMarksVisible(true);
return localJFreeChart;
}
public static JPanel createDemoPanel() {
JFreeChart localJFreeChart = createChart(new SampleXYDataset2());
ChartPanel localChartPanel = new ChartPanel(localJFreeChart);
localChartPanel.setMouseWheelEnabled(true);
return localChartPanel;
}
public static void main(String[] paramArrayOfString) {
ScatterPlotDemo1 localScatterPlotDemo1 = new ScatterPlotDemo1("ScatterPlotDemo1");
Dimension scrDim = Toolkit.getDefaultToolkit().getScreenSize();
localScatterPlotDemo1.setPreferredSize(new Dimension(scrDim.width / 2, scrDim.height / 2));
localScatterPlotDemo1.pack();
RefineryUtilities.centerFrameOnScreen(localScatterPlotDemo1);
localScatterPlotDemo1.setVisible(true);
}
}
*s27.postimg.org/oqhltcklb/Scatter_Plot_Demo1.jpg
Here is a LineChart demo
LineChartDemo3.java
Code:
/**
*
* @author JGuru
*/
import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.JPanel;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
import org.jfree.data.xy.XYDataset;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;
public class LineChartDemo3 extends ApplicationFrame {
private static final long serialVersionUID = 1L;
public LineChartDemo3(String paramString) {
super(paramString);
JPanel localJPanel = createDemoPanel();
Dimension scrDim = Toolkit.getDefaultToolkit().getScreenSize();
localJPanel.setPreferredSize(new Dimension(scrDim.width / 2, scrDim.height / 2));
setContentPane(localJPanel);
}
public static JPanel createDemoPanel() {
JFreeChart localJFreeChart = createChart(createDataset());
ChartPanel localChartPanel = new ChartPanel(localJFreeChart);
localChartPanel.setMouseWheelEnabled(true);
return localChartPanel;
}
private static XYDataset createDataset() {
XYSeriesCollection localXYSeriesCollection = new XYSeriesCollection();
for (int i = 0; i < 10; i++) {
XYSeries localXYSeries = new XYSeries("S" + i);
for (int j = 0; j < 10; j++) {
localXYSeries.add(j, Math.random() * 100.0D);
}
localXYSeriesCollection.addSeries(localXYSeries);
}
return localXYSeriesCollection;
}
private static JFreeChart createChart(XYDataset paramXYDataset) {
JFreeChart localJFreeChart = ChartFactory.createXYLineChart("Line Chart Demo 3", "X", "Y", paramXYDataset, PlotOrientation.VERTICAL, true, true, false);
XYPlot localXYPlot = (XYPlot) localJFreeChart.getPlot();
localXYPlot.setDomainPannable(true);
localXYPlot.setRangePannable(true);
localXYPlot.setDomainZeroBaselineVisible(true);
localXYPlot.setRangeZeroBaselineVisible(true);
XYLineAndShapeRenderer localXYLineAndShapeRenderer = (XYLineAndShapeRenderer) localXYPlot.getRenderer();
localXYLineAndShapeRenderer.setBaseShapesVisible(true);
localXYLineAndShapeRenderer.setBaseShapesFilled(true);
localXYLineAndShapeRenderer.setDrawOutlines(true);
NumberAxis localNumberAxis = (NumberAxis) localXYPlot.getRangeAxis();
localNumberAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
return localJFreeChart;
}
public static void main(String[] paramArrayOfString) {
LineChartDemo3 localLineChartDemo3 = new LineChartDemo3("LineChartDemo3.java");
localLineChartDemo3.pack();
RefineryUtilities.centerFrameOnScreen(localLineChartDemo3);
localLineChartDemo3.setVisible(true);
}
}
*s30.postimg.org/m5logn8x9/Line_Chart_Demo3.jpg
Here is a Mutiple axis demo!!
MultipleAxisDemo2.java
Code:
/**
*
* @author JGuru
*/
import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.JPanel;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.AxisLocation;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
import org.jfree.data.time.Minute;
import org.jfree.data.time.RegularTimePeriod;
import org.jfree.data.time.TimeSeries;
import org.jfree.data.time.TimeSeriesCollection;
import org.jfree.data.xy.XYDataset;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;
public class MultipleAxisDemo2 extends ApplicationFrame
{
public MultipleAxisDemo2(String paramString)
{
super(paramString);
JPanel localJPanel = createDemoPanel();
Dimension scrDim = Toolkit.getDefaultToolkit().getScreenSize();
localJPanel.setPreferredSize(new Dimension(scrDim.width/2, scrDim.height/2));
setContentPane(localJPanel);
}
private static JFreeChart createChart()
{
XYDataset localXYDataset1 = createDataset("Series 1", 100.0D, new Minute(), 200);
JFreeChart localJFreeChart = ChartFactory.createTimeSeriesChart("Multiple Axis Demo 2", "Time of Day", "Primary Range Axis", localXYDataset1, true, true, false);
XYPlot localXYPlot = (XYPlot)localJFreeChart.getPlot();
localXYPlot.setDomainPannable(true);
localXYPlot.setOrientation(PlotOrientation.VERTICAL);
NumberAxis localNumberAxis1 = new NumberAxis("Domain Axis 2");
localNumberAxis1.setAutoRangeIncludesZero(false);
localXYPlot.setDomainAxis(1, localNumberAxis1);
NumberAxis localNumberAxis2 = new NumberAxis("Range Axis 2");
localXYPlot.setRangeAxis(1, localNumberAxis2);
localXYPlot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT);
XYDataset localXYDataset2 = createDataset("Series 2", 1000.0D, new Minute(), 170);
localXYPlot.setDataset(1, localXYDataset2);
localXYPlot.mapDatasetToDomainAxis(1, 1);
localXYPlot.mapDatasetToRangeAxis(1, 1);
localXYPlot.setRenderer(1, new XYLineAndShapeRenderer(true, false));
ChartUtilities.applyCurrentTheme(localJFreeChart);
return localJFreeChart;
}
private static XYDataset createDataset(String paramString, double paramDouble, RegularTimePeriod paramRegularTimePeriod, int paramInt)
{
TimeSeries localTimeSeries = new TimeSeries(paramString);
RegularTimePeriod localRegularTimePeriod = paramRegularTimePeriod;
double d = paramDouble;
for (int i = 0; i < paramInt; i++)
{
localTimeSeries.add(localRegularTimePeriod, d);
localRegularTimePeriod = localRegularTimePeriod.next();
d *= (1.0D + (Math.random() - 0.495D) / 10.0D);
}
TimeSeriesCollection localTimeSeriesCollection = new TimeSeriesCollection();
localTimeSeriesCollection.addSeries(localTimeSeries);
return localTimeSeriesCollection;
}
public static JPanel createDemoPanel()
{
JFreeChart localJFreeChart = createChart();
return new ChartPanel(localJFreeChart);
}
public static void main(String[] paramArrayOfString)
{
MultipleAxisDemo2 localMultipleAxisDemo2 = new MultipleAxisDemo2("MultipleAxisDemo2.java");
localMultipleAxisDemo2.pack();
RefineryUtilities.centerFrameOnScreen(localMultipleAxisDemo2);
localMultipleAxisDemo2.setVisible(true);
}
}
*s24.postimg.org/geyhl7vdd/Multiple_Axis_Demo2.jpg
Here is a Normal distribution demo!!
NormalDistributionDemo2.java
Code:
/**
*
* @author JGuru
*/
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.JPanel;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.annotations.XYPointerAnnotation;
import org.jfree.chart.axis.ValueAxis;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
import org.jfree.data.function.NormalDistributionFunction2D;
import org.jfree.data.general.DatasetUtilities;
import org.jfree.data.xy.XYDataset;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;
import org.jfree.ui.TextAnchor;
public class NormalDistributionDemo2 extends ApplicationFrame {
public NormalDistributionDemo2(String paramString) {
super(paramString);
JPanel localJPanel = createDemoPanel();
Dimension scrDim = Toolkit.getDefaultToolkit().getScreenSize();
localJPanel.setPreferredSize(new Dimension(scrDim.width / 2, scrDim.height / 2));
setContentPane(localJPanel);
}
public static JPanel createDemoPanel() {
JFreeChart localJFreeChart = createChart(createDataset());
ChartPanel localChartPanel = new ChartPanel(localJFreeChart);
localChartPanel.setMouseWheelEnabled(true);
return localChartPanel;
}
public static XYDataset createDataset() {
XYSeriesCollection localXYSeriesCollection = new XYSeriesCollection();
NormalDistributionFunction2D localNormalDistributionFunction2D1 = new NormalDistributionFunction2D(0.0D, 1.0D);
XYSeries localXYSeries1 = DatasetUtilities.sampleFunction2DToSeries(localNormalDistributionFunction2D1, -5.1D, 5.1D, 121, "N1");
localXYSeriesCollection.addSeries(localXYSeries1);
NormalDistributionFunction2D localNormalDistributionFunction2D2 = new NormalDistributionFunction2D(0.0D, Math.sqrt(0.2D));
XYSeries localXYSeries2 = DatasetUtilities.sampleFunction2DToSeries(localNormalDistributionFunction2D2, -5.1D, 5.1D, 121, "N2");
localXYSeriesCollection.addSeries(localXYSeries2);
NormalDistributionFunction2D localNormalDistributionFunction2D3 = new NormalDistributionFunction2D(0.0D, Math.sqrt(5.0D));
XYSeries localXYSeries3 = DatasetUtilities.sampleFunction2DToSeries(localNormalDistributionFunction2D3, -5.1D, 5.1D, 121, "N3");
localXYSeriesCollection.addSeries(localXYSeries3);
NormalDistributionFunction2D localNormalDistributionFunction2D4 = new NormalDistributionFunction2D(-2.0D, Math.sqrt(0.5D));
XYSeries localXYSeries4 = DatasetUtilities.sampleFunction2DToSeries(localNormalDistributionFunction2D4, -5.1D, 5.1D, 121, "N4");
localXYSeriesCollection.addSeries(localXYSeries4);
return localXYSeriesCollection;
}
public static JFreeChart createChart(XYDataset paramXYDataset) {
JFreeChart localJFreeChart = ChartFactory.createXYLineChart("Normal Distribution Demo 2", "X", "Y", paramXYDataset, PlotOrientation.VERTICAL, true, true, false);
XYPlot localXYPlot = (XYPlot) localJFreeChart.getPlot();
localXYPlot.setDomainZeroBaselineVisible(true);
localXYPlot.setRangeZeroBaselineVisible(true);
localXYPlot.setDomainPannable(true);
localXYPlot.setRangePannable(true);
ValueAxis localValueAxis = localXYPlot.getDomainAxis();
localValueAxis.setLowerMargin(0.0D);
localValueAxis.setUpperMargin(0.0D);
XYLineAndShapeRenderer localXYLineAndShapeRenderer = (XYLineAndShapeRenderer) localXYPlot.getRenderer();
localXYLineAndShapeRenderer.setDrawSeriesLineAsPath(true);
localXYLineAndShapeRenderer.setSeriesStroke(0, new BasicStroke(1.5F));
localXYLineAndShapeRenderer.setSeriesStroke(1, new BasicStroke(2.0F, 1, 1, 1.0F, new float[]{6.0F, 4.0F}, 0.0F));
localXYLineAndShapeRenderer.setSeriesStroke(2, new BasicStroke(2.0F, 1, 1, 1.0F, new float[]{6.0F, 4.0F, 3.0F, 3.0F}, 0.0F));
localXYLineAndShapeRenderer.setSeriesStroke(3, new BasicStroke(2.0F, 1, 1, 1.0F, new float[]{4.0F, 4.0F}, 0.0F));
XYPointerAnnotation localXYPointerAnnotation1 = new XYPointerAnnotation("? = -2.0, ?² = 0.5", -2.0D, 0.564D, 3.926990816987241D);
localXYPointerAnnotation1.setLabelOffset(4.0D);
localXYPointerAnnotation1.setTextAnchor(TextAnchor.BOTTOM_RIGHT);
localXYPointerAnnotation1.setBackgroundPaint(Color.yellow);
localXYPlot.addAnnotation(localXYPointerAnnotation1);
XYPointerAnnotation localXYPointerAnnotation2 = new XYPointerAnnotation("? = 0.0, ?² = 0.2", 0.225D, 0.8D, 0.0D);
localXYPointerAnnotation2.setLabelOffset(4.0D);
localXYPointerAnnotation2.setTextAnchor(TextAnchor.CENTER_LEFT);
localXYPointerAnnotation2.setBackgroundPaint(new Color(0, 0, 255, 63));
localXYPlot.addAnnotation(localXYPointerAnnotation2);
XYPointerAnnotation localXYPointerAnnotation3 = new XYPointerAnnotation("? = 0.0, ?² = 1.0", 0.75D, 0.3D, 5.497787143782138D);
localXYPointerAnnotation3.setLabelOffset(4.0D);
localXYPointerAnnotation3.setTextAnchor(TextAnchor.HALF_ASCENT_LEFT);
localXYPointerAnnotation3.setBackgroundPaint(new Color(255, 0, 0, 63));
localXYPlot.addAnnotation(localXYPointerAnnotation3);
XYPointerAnnotation localXYPointerAnnotation4 = new XYPointerAnnotation("? = 0.0, ?² = 5.0", 3.0D, 0.075D, 4.71238898038469D);
localXYPointerAnnotation4.setLabelOffset(4.0D);
localXYPointerAnnotation4.setTextAnchor(TextAnchor.BOTTOM_CENTER);
localXYPointerAnnotation4.setBackgroundPaint(new Color(0, 255, 0, 63));
localXYPlot.addAnnotation(localXYPointerAnnotation4);
return localJFreeChart;
}
public static void main(String[] paramArrayOfString) {
NormalDistributionDemo2 localNormalDistributionDemo2 = new NormalDistributionDemo2("NormalDistributionDemo2.java");
localNormalDistributionDemo2.pack();
RefineryUtilities.centerFrameOnScreen(localNormalDistributionDemo2);
localNormalDistributionDemo2.setVisible(true);
}
}
*s4.postimg.org/v385xapl5/Normal_Distribution_Demo2.jpg
Here is a Statistical bar chart!!
StatisticalBarChartDemo1 .java
Code:
/**
*
* @author JGuru
*/
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GradientPaint;
import java.awt.Toolkit;
import javax.swing.JPanel;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.labels.ItemLabelAnchor;
import org.jfree.chart.labels.ItemLabelPosition;
import org.jfree.chart.labels.StandardCategoryItemLabelGenerator;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.renderer.category.StatisticalBarRenderer;
import org.jfree.data.category.CategoryDataset;
import org.jfree.data.statistics.DefaultStatisticalCategoryDataset;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;
import org.jfree.ui.TextAnchor;
public class StatisticalBarChartDemo1 extends ApplicationFrame
{
private static final long serialVersionUID = 1L;
public StatisticalBarChartDemo1(String paramString)
{
super(paramString);
JPanel localJPanel = createDemoPanel();
Dimension scrDim = Toolkit.getDefaultToolkit().getScreenSize();
localJPanel.setPreferredSize(new Dimension(scrDim.width/2, scrDim.height/2));
setContentPane(localJPanel);
}
private static CategoryDataset createDataset()
{
DefaultStatisticalCategoryDataset localDefaultStatisticalCategoryDataset = new DefaultStatisticalCategoryDataset();
localDefaultStatisticalCategoryDataset.add(10.0D, 2.4D, "Row 1", "Column 1");
localDefaultStatisticalCategoryDataset.add(15.0D, 4.4D, "Row 1", "Column 2");
localDefaultStatisticalCategoryDataset.add(13.0D, 2.1D, "Row 1", "Column 3");
localDefaultStatisticalCategoryDataset.add(7.0D, 1.3D, "Row 1", "Column 4");
localDefaultStatisticalCategoryDataset.add(22.0D, 2.4D, "Row 2", "Column 1");
localDefaultStatisticalCategoryDataset.add(18.0D, 4.4D, "Row 2", "Column 2");
localDefaultStatisticalCategoryDataset.add(28.0D, 2.1D, "Row 2", "Column 3");
localDefaultStatisticalCategoryDataset.add(17.0D, 1.3D, "Row 2", "Column 4");
return localDefaultStatisticalCategoryDataset;
}
private static JFreeChart createChart(CategoryDataset paramCategoryDataset)
{
JFreeChart localJFreeChart = ChartFactory.createLineChart("Statistical Bar Chart Demo 1", "Type", "Value", paramCategoryDataset, PlotOrientation.VERTICAL, true, true, false);
CategoryPlot localCategoryPlot = (CategoryPlot)localJFreeChart.getPlot();
NumberAxis localNumberAxis = (NumberAxis)localCategoryPlot.getRangeAxis();
localNumberAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
localNumberAxis.setAutoRangeIncludesZero(false);
StatisticalBarRenderer localStatisticalBarRenderer = new StatisticalBarRenderer();
localStatisticalBarRenderer.setDrawBarOutline(false);
localStatisticalBarRenderer.setErrorIndicatorPaint(Color.black);
localStatisticalBarRenderer.setIncludeBaseInRange(false);
localCategoryPlot.setRenderer(localStatisticalBarRenderer);
ChartUtilities.applyCurrentTheme(localJFreeChart);
localStatisticalBarRenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
localStatisticalBarRenderer.setBaseItemLabelsVisible(true);
localStatisticalBarRenderer.setBaseItemLabelPaint(Color.yellow);
localStatisticalBarRenderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.INSIDE6, TextAnchor.BOTTOM_CENTER));
GradientPaint localGradientPaint1 = new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, new Color(0, 0, 64));
GradientPaint localGradientPaint2 = new GradientPaint(0.0F, 0.0F, Color.green, 0.0F, 0.0F, new Color(0, 64, 0));
localStatisticalBarRenderer.setSeriesPaint(0, localGradientPaint1);
localStatisticalBarRenderer.setSeriesPaint(1, localGradientPaint2);
return localJFreeChart;
}
public static JPanel createDemoPanel()
{
JFreeChart localJFreeChart = createChart(createDataset());
return new ChartPanel(localJFreeChart);
}
public static void main(String[] paramArrayOfString)
{
StatisticalBarChartDemo1 localStatisticalBarChartDemo1 = new StatisticalBarChartDemo1("StatisticalBarChartDemo1.java");
localStatisticalBarChartDemo1.pack();
RefineryUtilities.centerFrameOnScreen(localStatisticalBarChartDemo1);
localStatisticalBarChartDemo1.setVisible(true);
}
}
*s1.postimg.org/ninxxzd3f/Statistical_Bar_Chart_Demo1.jpg
Here is a Time Series chart!!
TimeSeriesDemo7.java
Code:
/**
*
* @author JGuru
*/
import java.awt.BasicStroke;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.geom.GeneralPath;
import java.util.Arrays;
import java.util.List;
import javax.swing.JPanel;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
import org.jfree.data.time.Day;
import org.jfree.data.time.TimeSeries;
import org.jfree.data.time.TimeSeriesCollection;
import org.jfree.data.xy.XYDataset;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;
public class TimeSeriesDemo7 extends ApplicationFrame {
public TimeSeriesDemo7(String paramString) {
super(paramString);
JPanel localJPanel = createDemoPanel();
Dimension scrDim = Toolkit.getDefaultToolkit().getScreenSize();
localJPanel.setPreferredSize(new Dimension(scrDim.width / 2, scrDim.height / 2));
setContentPane(localJPanel);
}
private static JFreeChart createChart(XYDataset paramXYDataset) {
JFreeChart localJFreeChart = ChartFactory.createTimeSeriesChart("Time Series Demo 7", "Date", "Value", paramXYDataset, true, true, false);
XYPlot localXYPlot = (XYPlot) localJFreeChart.getPlot();
NumberAxis localNumberAxis = new NumberAxis(null);
localNumberAxis.setAutoRangeIncludesZero(false);
localXYPlot.setRangeAxis(1, localNumberAxis);
List localList = Arrays.asList(new Integer[]{new Integer(0), new Integer(1)});
localXYPlot.mapDatasetToRangeAxes(0, localList);
XYLineAndShapeRenderer localXYLineAndShapeRenderer = (XYLineAndShapeRenderer) localXYPlot.getRenderer();
localXYLineAndShapeRenderer.setAutoPopulateSeriesStroke(false);
localXYLineAndShapeRenderer.setBaseStroke(new BasicStroke(1.5F, 1, 1));
localXYLineAndShapeRenderer.setDrawSeriesLineAsPath(true);
GeneralPath localGeneralPath = new GeneralPath();
localGeneralPath.moveTo(-6.0F, 0.0F);
localGeneralPath.lineTo(-3.0F, 6.0F);
localGeneralPath.lineTo(3.0F, -6.0F);
localGeneralPath.lineTo(6.0F, 0.0F);
localXYLineAndShapeRenderer.setLegendLine(localGeneralPath);
ChartUtilities.applyCurrentTheme(localJFreeChart);
return localJFreeChart;
}
private static XYDataset createDataset() {
TimeSeries localTimeSeries = new TimeSeries("EUR/GBP");
try {
localTimeSeries.add(new Day(2, 1, 2001), new Double(1.5788D));
localTimeSeries.add(new Day(3, 1, 2001), new Double(1.5913D));
localTimeSeries.add(new Day(4, 1, 2001), new Double(1.5807D));
localTimeSeries.add(new Day(5, 1, 2001), new Double(1.5711D));
localTimeSeries.add(new Day(8, 1, 2001), new Double(1.5778D));
localTimeSeries.add(new Day(9, 1, 2001), new Double(1.5851D));
localTimeSeries.add(new Day(10, 1, 2001), new Double(1.5846D));
localTimeSeries.add(new Day(11, 1, 2001), new Double(1.5727D));
localTimeSeries.add(new Day(12, 1, 2001), new Double(1.5585D));
localTimeSeries.add(new Day(15, 1, 2001), new Double(1.5694D));
localTimeSeries.add(new Day(16, 1, 2001), new Double(1.5629D));
localTimeSeries.add(new Day(17, 1, 2001), new Double(1.5831D));
localTimeSeries.add(new Day(18, 1, 2001), new Double(1.5624D));
localTimeSeries.add(new Day(19, 1, 2001), new Double(1.5694D));
localTimeSeries.add(new Day(22, 1, 2001), new Double(1.5615D));
localTimeSeries.add(new Day(23, 1, 2001), new Double(1.5656D));
localTimeSeries.add(new Day(24, 1, 2001), new Double(1.5795D));
localTimeSeries.add(new Day(25, 1, 2001), new Double(1.5852D));
localTimeSeries.add(new Day(26, 1, 2001), new Double(1.5797D));
localTimeSeries.add(new Day(29, 1, 2001), new Double(1.5862D));
localTimeSeries.add(new Day(30, 1, 2001), new Double(1.5803D));
localTimeSeries.add(new Day(31, 1, 2001), new Double(1.5714D));
localTimeSeries.add(new Day(1, 2, 2001), new Double(1.5717D));
localTimeSeries.add(new Day(2, 2, 2001), new Double(1.5735D));
localTimeSeries.add(new Day(5, 2, 2001), new Double(1.5691D));
localTimeSeries.add(new Day(6, 2, 2001), new Double(1.5676D));
localTimeSeries.add(new Day(7, 2, 2001), new Double(1.5677D));
localTimeSeries.add(new Day(8, 2, 2001), new Double(1.5737D));
localTimeSeries.add(new Day(9, 2, 2001), new Double(1.5654D));
localTimeSeries.add(new Day(12, 2, 2001), new Double(1.5621D));
localTimeSeries.add(new Day(13, 2, 2001), new Double(1.5761D));
localTimeSeries.add(new Day(14, 2, 2001), new Double(1.5898D));
localTimeSeries.add(new Day(15, 2, 2001), new Double(1.6045D));
localTimeSeries.add(new Day(16, 2, 2001), new Double(1.5852D));
localTimeSeries.add(new Day(19, 2, 2001), new Double(1.5704D));
localTimeSeries.add(new Day(20, 2, 2001), new Double(1.5892D));
localTimeSeries.add(new Day(21, 2, 2001), new Double(1.5844D));
localTimeSeries.add(new Day(22, 2, 2001), new Double(1.5934D));
localTimeSeries.add(new Day(23, 2, 2001), new Double(1.5951D));
localTimeSeries.add(new Day(26, 2, 2001), new Double(1.5848D));
localTimeSeries.add(new Day(27, 2, 2001), new Double(1.5706D));
localTimeSeries.add(new Day(28, 2, 2001), new Double(1.568D));
localTimeSeries.add(new Day(1, 3, 2001), new Double(1.5645D));
localTimeSeries.add(new Day(2, 3, 2001), new Double(1.5754D));
localTimeSeries.add(new Day(5, 3, 2001), new Double(1.5808D));
localTimeSeries.add(new Day(6, 3, 2001), new Double(1.5766D));
localTimeSeries.add(new Day(7, 3, 2001), new Double(1.5756D));
localTimeSeries.add(new Day(8, 3, 2001), new Double(1.576D));
localTimeSeries.add(new Day(9, 3, 2001), new Double(1.5748D));
localTimeSeries.add(new Day(12, 3, 2001), new Double(1.5779D));
localTimeSeries.add(new Day(13, 3, 2001), new Double(1.5837D));
localTimeSeries.add(new Day(14, 3, 2001), new Double(1.5886D));
localTimeSeries.add(new Day(15, 3, 2001), new Double(1.5931D));
localTimeSeries.add(new Day(16, 3, 2001), new Double(1.5945D));
localTimeSeries.add(new Day(19, 3, 2001), new Double(1.588D));
localTimeSeries.add(new Day(20, 3, 2001), new Double(1.5817D));
localTimeSeries.add(new Day(21, 3, 2001), new Double(1.5927D));
localTimeSeries.add(new Day(22, 3, 2001), new Double(1.6065D));
localTimeSeries.add(new Day(23, 3, 2001), new Double(1.6006D));
localTimeSeries.add(new Day(26, 3, 2001), new Double(1.6007D));
localTimeSeries.add(new Day(27, 3, 2001), new Double(1.5989D));
localTimeSeries.add(new Day(28, 3, 2001), new Double(1.6135D));
localTimeSeries.add(new Day(29, 3, 2001), new Double(1.6282D));
localTimeSeries.add(new Day(30, 3, 2001), new Double(1.609D));
localTimeSeries.add(new Day(2, 4, 2001), new Double(1.6107D));
localTimeSeries.add(new Day(3, 4, 2001), new Double(1.6093D));
localTimeSeries.add(new Day(4, 4, 2001), new Double(1.588D));
localTimeSeries.add(new Day(5, 4, 2001), new Double(1.5931D));
localTimeSeries.add(new Day(6, 4, 2001), new Double(1.5968D));
localTimeSeries.add(new Day(9, 4, 2001), new Double(1.6072D));
localTimeSeries.add(new Day(10, 4, 2001), new Double(1.6167D));
localTimeSeries.add(new Day(11, 4, 2001), new Double(1.6214D));
localTimeSeries.add(new Day(12, 4, 2001), new Double(1.612D));
localTimeSeries.add(new Day(17, 4, 2001), new Double(1.6229D));
localTimeSeries.add(new Day(18, 4, 2001), new Double(1.6298D));
localTimeSeries.add(new Day(19, 4, 2001), new Double(1.6159D));
localTimeSeries.add(new Day(20, 4, 2001), new Double(1.5996D));
localTimeSeries.add(new Day(23, 4, 2001), new Double(1.6042D));
localTimeSeries.add(new Day(24, 4, 2001), new Double(1.6061D));
localTimeSeries.add(new Day(25, 4, 2001), new Double(1.6045D));
localTimeSeries.add(new Day(26, 4, 2001), new Double(1.597D));
localTimeSeries.add(new Day(27, 4, 2001), new Double(1.6095D));
localTimeSeries.add(new Day(30, 4, 2001), new Double(1.6141D));
localTimeSeries.add(new Day(1, 5, 2001), new Double(1.6076D));
localTimeSeries.add(new Day(2, 5, 2001), new Double(1.6077D));
localTimeSeries.add(new Day(3, 5, 2001), new Double(1.6035D));
localTimeSeries.add(new Day(4, 5, 2001), new Double(1.606D));
localTimeSeries.add(new Day(8, 5, 2001), new Double(1.6178D));
localTimeSeries.add(new Day(9, 5, 2001), new Double(1.6083D));
localTimeSeries.add(new Day(10, 5, 2001), new Double(1.6107D));
localTimeSeries.add(new Day(11, 5, 2001), new Double(1.6209D));
localTimeSeries.add(new Day(14, 5, 2001), new Double(1.6228D));
localTimeSeries.add(new Day(15, 5, 2001), new Double(1.6184D));
localTimeSeries.add(new Day(16, 5, 2001), new Double(1.6167D));
localTimeSeries.add(new Day(17, 5, 2001), new Double(1.6223D));
localTimeSeries.add(new Day(18, 5, 2001), new Double(1.6305D));
localTimeSeries.add(new Day(21, 5, 2001), new Double(1.642D));
localTimeSeries.add(new Day(22, 5, 2001), new Double(1.6484D));
localTimeSeries.add(new Day(23, 5, 2001), new Double(1.6547D));
localTimeSeries.add(new Day(24, 5, 2001), new Double(1.6444D));
localTimeSeries.add(new Day(25, 5, 2001), new Double(1.6577D));
localTimeSeries.add(new Day(29, 5, 2001), new Double(1.6606D));
localTimeSeries.add(new Day(30, 5, 2001), new Double(1.6604D));
localTimeSeries.add(new Day(31, 5, 2001), new Double(1.6772D));
localTimeSeries.add(new Day(1, 6, 2001), new Double(1.6717D));
localTimeSeries.add(new Day(4, 6, 2001), new Double(1.6685D));
localTimeSeries.add(new Day(5, 6, 2001), new Double(1.6621D));
localTimeSeries.add(new Day(6, 6, 2001), new Double(1.646D));
localTimeSeries.add(new Day(7, 6, 2001), new Double(1.6333D));
localTimeSeries.add(new Day(8, 6, 2001), new Double(1.6265D));
localTimeSeries.add(new Day(11, 6, 2001), new Double(1.6311D));
localTimeSeries.add(new Day(12, 6, 2001), new Double(1.6238D));
localTimeSeries.add(new Day(13, 6, 2001), new Double(1.63D));
localTimeSeries.add(new Day(14, 6, 2001), new Double(1.6289D));
localTimeSeries.add(new Day(15, 6, 2001), new Double(1.6276D));
localTimeSeries.add(new Day(18, 6, 2001), new Double(1.6299D));
localTimeSeries.add(new Day(19, 6, 2001), new Double(1.6353D));
localTimeSeries.add(new Day(20, 6, 2001), new Double(1.6378D));
localTimeSeries.add(new Day(21, 6, 2001), new Double(1.6567D));
localTimeSeries.add(new Day(22, 6, 2001), new Double(1.6523D));
localTimeSeries.add(new Day(25, 6, 2001), new Double(1.6418D));
localTimeSeries.add(new Day(26, 6, 2001), new Double(1.6429D));
localTimeSeries.add(new Day(27, 6, 2001), new Double(1.6439D));
localTimeSeries.add(new Day(28, 6, 2001), new Double(1.6605D));
localTimeSeries.add(new Day(29, 6, 2001), new Double(1.6599D));
localTimeSeries.add(new Day(2, 7, 2001), new Double(1.6727D));
localTimeSeries.add(new Day(3, 7, 2001), new Double(1.662D));
localTimeSeries.add(new Day(4, 7, 2001), new Double(1.6628D));
localTimeSeries.add(new Day(5, 7, 2001), new Double(1.673D));
localTimeSeries.add(new Day(6, 7, 2001), new Double(1.6649D));
localTimeSeries.add(new Day(9, 7, 2001), new Double(1.6603D));
localTimeSeries.add(new Day(10, 7, 2001), new Double(1.6489D));
localTimeSeries.add(new Day(11, 7, 2001), new Double(1.6421D));
localTimeSeries.add(new Day(12, 7, 2001), new Double(1.6498D));
localTimeSeries.add(new Day(13, 7, 2001), new Double(1.6447D));
localTimeSeries.add(new Day(16, 7, 2001), new Double(1.6373D));
localTimeSeries.add(new Day(17, 7, 2001), new Double(1.6443D));
localTimeSeries.add(new Day(18, 7, 2001), new Double(1.6246D));
localTimeSeries.add(new Day(19, 7, 2001), new Double(1.6295D));
localTimeSeries.add(new Day(20, 7, 2001), new Double(1.6362D));
localTimeSeries.add(new Day(23, 7, 2001), new Double(1.6348D));
localTimeSeries.add(new Day(24, 7, 2001), new Double(1.6242D));
localTimeSeries.add(new Day(25, 7, 2001), new Double(1.6241D));
localTimeSeries.add(new Day(26, 7, 2001), new Double(1.6281D));
localTimeSeries.add(new Day(27, 7, 2001), new Double(1.6296D));
localTimeSeries.add(new Day(30, 7, 2001), new Double(1.6279D));
localTimeSeries.add(new Day(31, 7, 2001), new Double(1.63D));
localTimeSeries.add(new Day(1, 8, 2001), new Double(1.629D));
localTimeSeries.add(new Day(2, 8, 2001), new Double(1.6237D));
localTimeSeries.add(new Day(3, 8, 2001), new Double(1.6138D));
localTimeSeries.add(new Day(6, 8, 2001), new Double(1.6121D));
localTimeSeries.add(new Day(7, 8, 2001), new Double(1.617D));
localTimeSeries.add(new Day(8, 8, 2001), new Double(1.6135D));
localTimeSeries.add(new Day(9, 8, 2001), new Double(1.5996D));
localTimeSeries.add(new Day(10, 8, 2001), new Double(1.5931D));
localTimeSeries.add(new Day(13, 8, 2001), new Double(1.5828D));
localTimeSeries.add(new Day(14, 8, 2001), new Double(1.5824D));
localTimeSeries.add(new Day(15, 8, 2001), new Double(1.5783D));
localTimeSeries.add(new Day(16, 8, 2001), new Double(1.581D));
localTimeSeries.add(new Day(17, 8, 2001), new Double(1.5761D));
localTimeSeries.add(new Day(20, 8, 2001), new Double(1.5831D));
localTimeSeries.add(new Day(21, 8, 2001), new Double(1.587D));
localTimeSeries.add(new Day(22, 8, 2001), new Double(1.5808D));
localTimeSeries.add(new Day(23, 8, 2001), new Double(1.5845D));
localTimeSeries.add(new Day(24, 8, 2001), new Double(1.5844D));
localTimeSeries.add(new Day(28, 8, 2001), new Double(1.5924D));
localTimeSeries.add(new Day(29, 8, 2001), new Double(1.595D));
localTimeSeries.add(new Day(30, 8, 2001), new Double(1.5941D));
localTimeSeries.add(new Day(31, 8, 2001), new Double(1.5968D));
localTimeSeries.add(new Day(3, 9, 2001), new Double(1.602D));
localTimeSeries.add(new Day(4, 9, 2001), new Double(1.6236D));
localTimeSeries.add(new Day(5, 9, 2001), new Double(1.6352D));
localTimeSeries.add(new Day(6, 9, 2001), new Double(1.6302D));
localTimeSeries.add(new Day(7, 9, 2001), new Double(1.618D));
localTimeSeries.add(new Day(10, 9, 2001), new Double(1.6218D));
localTimeSeries.add(new Day(11, 9, 2001), new Double(1.6182D));
localTimeSeries.add(new Day(12, 9, 2001), new Double(1.6157D));
localTimeSeries.add(new Day(13, 9, 2001), new Double(1.6171D));
localTimeSeries.add(new Day(14, 9, 2001), new Double(1.596D));
localTimeSeries.add(new Day(17, 9, 2001), new Double(1.5952D));
localTimeSeries.add(new Day(18, 9, 2001), new Double(1.5863D));
localTimeSeries.add(new Day(19, 9, 2001), new Double(1.579D));
localTimeSeries.add(new Day(20, 9, 2001), new Double(1.5811D));
localTimeSeries.add(new Day(21, 9, 2001), new Double(1.5917D));
localTimeSeries.add(new Day(24, 9, 2001), new Double(1.6005D));
localTimeSeries.add(new Day(25, 9, 2001), new Double(1.5915D));
localTimeSeries.add(new Day(26, 9, 2001), new Double(1.6012D));
localTimeSeries.add(new Day(27, 9, 2001), new Double(1.6032D));
localTimeSeries.add(new Day(28, 9, 2001), new Double(1.6133D));
localTimeSeries.add(new Day(1, 10, 2001), new Double(1.6147D));
localTimeSeries.add(new Day(2, 10, 2001), new Double(1.6002D));
localTimeSeries.add(new Day(3, 10, 2001), new Double(1.6041D));
localTimeSeries.add(new Day(4, 10, 2001), new Double(1.6172D));
localTimeSeries.add(new Day(5, 10, 2001), new Double(1.6121D));
localTimeSeries.add(new Day(8, 10, 2001), new Double(1.6044D));
localTimeSeries.add(new Day(9, 10, 2001), new Double(1.5974D));
localTimeSeries.add(new Day(10, 10, 2001), new Double(1.5915D));
localTimeSeries.add(new Day(11, 10, 2001), new Double(1.6022D));
localTimeSeries.add(new Day(12, 10, 2001), new Double(1.6014D));
localTimeSeries.add(new Day(15, 10, 2001), new Double(1.5942D));
localTimeSeries.add(new Day(16, 10, 2001), new Double(1.5925D));
localTimeSeries.add(new Day(17, 10, 2001), new Double(1.6007D));
localTimeSeries.add(new Day(18, 10, 2001), new Double(1.6D));
localTimeSeries.add(new Day(19, 10, 2001), new Double(1.603D));
localTimeSeries.add(new Day(22, 10, 2001), new Double(1.6014D));
localTimeSeries.add(new Day(23, 10, 2001), new Double(1.5995D));
localTimeSeries.add(new Day(24, 10, 2001), new Double(1.5951D));
localTimeSeries.add(new Day(25, 10, 2001), new Double(1.5953D));
localTimeSeries.add(new Day(26, 10, 2001), new Double(1.6057D));
localTimeSeries.add(new Day(29, 10, 2001), new Double(1.6051D));
localTimeSeries.add(new Day(30, 10, 2001), new Double(1.6027D));
localTimeSeries.add(new Day(31, 10, 2001), new Double(1.6144D));
localTimeSeries.add(new Day(1, 11, 2001), new Double(1.6139D));
localTimeSeries.add(new Day(2, 11, 2001), new Double(1.6189D));
localTimeSeries.add(new Day(5, 11, 2001), new Double(1.6248D));
localTimeSeries.add(new Day(6, 11, 2001), new Double(1.6267D));
localTimeSeries.add(new Day(7, 11, 2001), new Double(1.6281D));
localTimeSeries.add(new Day(8, 11, 2001), new Double(1.631D));
localTimeSeries.add(new Day(9, 11, 2001), new Double(1.6313D));
localTimeSeries.add(new Day(12, 11, 2001), new Double(1.6272D));
localTimeSeries.add(new Day(13, 11, 2001), new Double(1.6361D));
localTimeSeries.add(new Day(14, 11, 2001), new Double(1.6323D));
localTimeSeries.add(new Day(15, 11, 2001), new Double(1.6252D));
localTimeSeries.add(new Day(16, 11, 2001), new Double(1.6141D));
localTimeSeries.add(new Day(19, 11, 2001), new Double(1.6086D));
localTimeSeries.add(new Day(20, 11, 2001), new Double(1.6055D));
localTimeSeries.add(new Day(21, 11, 2001), new Double(1.6132D));
localTimeSeries.add(new Day(22, 11, 2001), new Double(1.6074D));
localTimeSeries.add(new Day(23, 11, 2001), new Double(1.6065D));
localTimeSeries.add(new Day(26, 11, 2001), new Double(1.6061D));
localTimeSeries.add(new Day(27, 11, 2001), new Double(1.6039D));
localTimeSeries.add(new Day(28, 11, 2001), new Double(1.6069D));
localTimeSeries.add(new Day(29, 11, 2001), new Double(1.6044D));
localTimeSeries.add(new Day(30, 11, 2001), new Double(1.5928D));
} catch (Exception localException) {
System.err.println(localException.getMessage());
}
return new TimeSeriesCollection(localTimeSeries);
}
public static JPanel createDemoPanel() {
JFreeChart localJFreeChart = createChart(createDataset());
return new ChartPanel(localJFreeChart);
}
public static void main(String[] paramArrayOfString) {
TimeSeriesDemo7 localTimeSeriesDemo7 = new TimeSeriesDemo7("Time Series Demo 7");
localTimeSeriesDemo7.pack();
RefineryUtilities.centerFrameOnScreen(localTimeSeriesDemo7);
localTimeSeriesDemo7.setVisible(true);
}
}
*s30.postimg.org/rk2u75s6l/Time_Series_Demo7.jpg
Here is a Gantt chart demo!!
GanttDemo1.java
Code:
/**
*
* @author JGuru
*/
import java.awt.Dimension;
import java.awt.Toolkit;
import java.util.Calendar;
import java.util.Date;
import javax.swing.JPanel;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.renderer.category.GanttRenderer;
import org.jfree.data.category.IntervalCategoryDataset;
import org.jfree.data.gantt.Task;
import org.jfree.data.gantt.TaskSeries;
import org.jfree.data.gantt.TaskSeriesCollection;
import org.jfree.data.time.SimpleTimePeriod;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;
public class GanttDemo1 extends ApplicationFrame
{
public GanttDemo1(String paramString)
{
super(paramString);
JPanel localJPanel = createDemoPanel();
Dimension scrDim = Toolkit.getDefaultToolkit().getScreenSize();
localJPanel.setPreferredSize(new Dimension(scrDim.width/2, scrDim.height/2));
setContentPane(localJPanel);
}
public static IntervalCategoryDataset createDataset()
{
TaskSeries localTaskSeries1 = new TaskSeries("Scheduled");
localTaskSeries1.add(new Task("Write Proposal", new SimpleTimePeriod(date(1, 3, 2001), date(5, 3, 2001))));
localTaskSeries1.add(new Task("Obtain Approval", new SimpleTimePeriod(date(9, 3, 2001), date(9, 3, 2001))));
localTaskSeries1.add(new Task("Requirements Analysis", new SimpleTimePeriod(date(10, 3, 2001), date(5, 4, 2001))));
localTaskSeries1.add(new Task("Design Phase", new SimpleTimePeriod(date(6, 4, 2001), date(30, 4, 2001))));
localTaskSeries1.add(new Task("Design Signoff", new SimpleTimePeriod(date(2, 5, 2001), date(2, 5, 2001))));
localTaskSeries1.add(new Task("Alpha Implementation", new SimpleTimePeriod(date(3, 5, 2001), date(31, 6, 2001))));
localTaskSeries1.add(new Task("Design Review", new SimpleTimePeriod(date(1, 7, 2001), date(8, 7, 2001))));
localTaskSeries1.add(new Task("Revised Design Signoff", new SimpleTimePeriod(date(10, 7, 2001), date(10, 7, 2001))));
localTaskSeries1.add(new Task("Beta Implementation", new SimpleTimePeriod(date(12, 7, 2001), date(12, 8, 2001))));
localTaskSeries1.add(new Task("Testing", new SimpleTimePeriod(date(13, 8, 2001), date(31, 9, 2001))));
localTaskSeries1.add(new Task("Final Implementation", new SimpleTimePeriod(date(1, 10, 2001), date(15, 10, 2001))));
localTaskSeries1.add(new Task("Signoff", new SimpleTimePeriod(date(28, 10, 2001), date(30, 10, 2001))));
TaskSeries localTaskSeries2 = new TaskSeries("Actual");
localTaskSeries2.add(new Task("Write Proposal", new SimpleTimePeriod(date(1, 3, 2001), date(5, 3, 2001))));
localTaskSeries2.add(new Task("Obtain Approval", new SimpleTimePeriod(date(9, 3, 2001), date(9, 3, 2001))));
localTaskSeries2.add(new Task("Requirements Analysis", new SimpleTimePeriod(date(10, 3, 2001), date(15, 4, 2001))));
localTaskSeries2.add(new Task("Design Phase", new SimpleTimePeriod(date(15, 4, 2001), date(17, 5, 2001))));
localTaskSeries2.add(new Task("Design Signoff", new SimpleTimePeriod(date(30, 5, 2001), date(30, 5, 2001))));
localTaskSeries2.add(new Task("Alpha Implementation", new SimpleTimePeriod(date(1, 6, 2001), date(12, 8, 2001))));
localTaskSeries2.add(new Task("Design Review", new SimpleTimePeriod(date(12, 8, 2001), date(22, 8, 2001))));
localTaskSeries2.add(new Task("Revised Design Signoff", new SimpleTimePeriod(date(25, 8, 2001), date(27, 8, 2001))));
localTaskSeries2.add(new Task("Beta Implementation", new SimpleTimePeriod(date(27, 8, 2001), date(30, 9, 2001))));
localTaskSeries2.add(new Task("Testing", new SimpleTimePeriod(date(31, 9, 2001), date(17, 10, 2001))));
localTaskSeries2.add(new Task("Final Implementation", new SimpleTimePeriod(date(18, 10, 2001), date(5, 11, 2001))));
localTaskSeries2.add(new Task("Signoff", new SimpleTimePeriod(date(10, 11, 2001), date(11, 11, 2001))));
TaskSeriesCollection localTaskSeriesCollection = new TaskSeriesCollection();
localTaskSeriesCollection.add(localTaskSeries1);
localTaskSeriesCollection.add(localTaskSeries2);
return localTaskSeriesCollection;
}
private static Date date(int paramInt1, int paramInt2, int paramInt3)
{
Calendar localCalendar = Calendar.getInstance();
localCalendar.set(paramInt3, paramInt2, paramInt1);
Date localDate = localCalendar.getTime();
return localDate;
}
private static JFreeChart createChart(IntervalCategoryDataset paramIntervalCategoryDataset)
{
JFreeChart localJFreeChart = ChartFactory.createGanttChart("Gantt Chart Demo", "Task", "Date", paramIntervalCategoryDataset, true, true, false);
CategoryPlot localCategoryPlot = (CategoryPlot)localJFreeChart.getPlot();
localCategoryPlot.setRangePannable(true);
localCategoryPlot.getDomainAxis().setMaximumCategoryLabelWidthRatio(10.0F);
localCategoryPlot.setRangeCrosshairVisible(true);
GanttRenderer localGanttRenderer = (GanttRenderer)localCategoryPlot.getRenderer();
localGanttRenderer.setDrawBarOutline(false);
return localJFreeChart;
}
public static JPanel createDemoPanel()
{
JFreeChart localJFreeChart = createChart(createDataset());
ChartPanel localChartPanel = new ChartPanel(localJFreeChart);
localChartPanel.setMouseWheelEnabled(true);
return localChartPanel;
}
public static void main(String[] paramArrayOfString)
{
GanttDemo1 localGanttDemo1 = new GanttDemo1("GanttDemo1");
localGanttDemo1.pack();
RefineryUtilities.centerFrameOnScreen(localGanttDemo1);
localGanttDemo1.setVisible(true);
}
}
*s22.postimg.org/d0conl4p9/Gantt_Demo1.jpg
Here is a Layered bar chart demo!!
LayeredBarChartDemo2.java
Code:
/**
*
* @author Jguru
*/
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GradientPaint;
import java.awt.Toolkit;
import javax.swing.JPanel;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.renderer.category.LayeredBarRenderer;
import org.jfree.data.category.CategoryDataset;
import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;
import org.jfree.util.SortOrder;
public class LayeredBarChartDemo2 extends ApplicationFrame {
public LayeredBarChartDemo2(String paramString) {
super(paramString);
JPanel localJPanel = createDemoPanel();
Dimension scrDim = Toolkit.getDefaultToolkit().getScreenSize();
localJPanel.setPreferredSize(new Dimension(scrDim.width / 2, scrDim.height / 2));
setContentPane(localJPanel);
}
private static CategoryDataset createDataset() {
String str1 = "First";
String str2 = "Second";
String str3 = "Third";
String str4 = "Category 1";
String str5 = "Category 2";
String str6 = "Category 3";
String str7 = "Category 4";
String str8 = "Category 5";
DefaultCategoryDataset localDefaultCategoryDataset = new DefaultCategoryDataset();
localDefaultCategoryDataset.addValue(1.0D, str1, str4);
localDefaultCategoryDataset.addValue(4.0D, str1, str5);
localDefaultCategoryDataset.addValue(3.0D, str1, str6);
localDefaultCategoryDataset.addValue(5.0D, str1, str7);
localDefaultCategoryDataset.addValue(5.0D, str1, str8);
localDefaultCategoryDataset.addValue(5.0D, str2, str4);
localDefaultCategoryDataset.addValue(7.0D, str2, str5);
localDefaultCategoryDataset.addValue(6.0D, str2, str6);
localDefaultCategoryDataset.addValue(8.0D, str2, str7);
localDefaultCategoryDataset.addValue(4.0D, str2, str8);
localDefaultCategoryDataset.addValue(4.0D, str3, str4);
localDefaultCategoryDataset.addValue(3.0D, str3, str5);
localDefaultCategoryDataset.addValue(2.0D, str3, str6);
localDefaultCategoryDataset.addValue(3.0D, str3, str7);
localDefaultCategoryDataset.addValue(6.0D, str3, str8);
return localDefaultCategoryDataset;
}
private static JFreeChart createChart(CategoryDataset paramCategoryDataset) {
JFreeChart localJFreeChart = ChartFactory.createBarChart("Layered Bar Chart Demo 2", "Category", "Value", paramCategoryDataset, PlotOrientation.HORIZONTAL, true, true, false);
CategoryPlot localCategoryPlot = (CategoryPlot) localJFreeChart.getPlot();
localCategoryPlot.setDomainGridlinesVisible(true);
localCategoryPlot.setRangePannable(true);
localCategoryPlot.setRangeZeroBaselineVisible(true);
NumberAxis localNumberAxis = (NumberAxis) localCategoryPlot.getRangeAxis();
localNumberAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
LayeredBarRenderer localLayeredBarRenderer = new LayeredBarRenderer();
localLayeredBarRenderer.setDrawBarOutline(false);
localCategoryPlot.setRenderer(localLayeredBarRenderer);
localCategoryPlot.setRowRenderingOrder(SortOrder.DESCENDING);
GradientPaint localGradientPaint1 = new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, new Color(0, 0, 64));
GradientPaint localGradientPaint2 = new GradientPaint(0.0F, 0.0F, Color.green, 0.0F, 0.0F, new Color(0, 64, 0));
GradientPaint localGradientPaint3 = new GradientPaint(0.0F, 0.0F, Color.red, 0.0F, 0.0F, new Color(64, 0, 0));
localLayeredBarRenderer.setSeriesPaint(0, localGradientPaint1);
localLayeredBarRenderer.setSeriesPaint(1, localGradientPaint2);
localLayeredBarRenderer.setSeriesPaint(2, localGradientPaint3);
return localJFreeChart;
}
public static JPanel createDemoPanel() {
JFreeChart localJFreeChart = createChart(createDataset());
ChartPanel localChartPanel = new ChartPanel(localJFreeChart);
localChartPanel.setMouseWheelEnabled(true);
return localChartPanel;
}
public static void main(String[] paramArrayOfString) {
LayeredBarChartDemo2 localLayeredBarChartDemo2 = new LayeredBarChartDemo2("LayeredBarChartDemo2");
localLayeredBarChartDemo2.pack();
RefineryUtilities.centerFrameOnScreen(localLayeredBarChartDemo2);
localLayeredBarChartDemo2.setVisible(true);
}
}
*s29.postimg.org/3yzpc1v7n/Layered_Bar_Chart_Demo2.jpg
Here is a Bar chart using a Gradient!!
GradientPaintTransformerDemo1.java
Code:
/**
*
* @author JGuru
*/
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GradientPaint;
import java.awt.GridLayout;
import javax.swing.JPanel;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.renderer.category.BarRenderer;
import org.jfree.chart.renderer.category.StandardBarPainter;
import org.jfree.data.category.CategoryDataset;
import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.GradientPaintTransformType;
import org.jfree.ui.RefineryUtilities;
import org.jfree.ui.StandardGradientPaintTransformer;
public class GradientPaintTransformerDemo1 extends ApplicationFrame {
public GradientPaintTransformerDemo1(String paramString) {
super(paramString);
setContentPane(createDemoPanel());
}
private static JFreeChart createChart(String paramString, CategoryDataset paramCategoryDataset) {
JFreeChart localJFreeChart = ChartFactory.createBarChart(paramString, null, "Value", paramCategoryDataset, PlotOrientation.VERTICAL, true, true, false);
CategoryPlot localCategoryPlot = (CategoryPlot) localJFreeChart.getPlot();
BarRenderer localBarRenderer = (BarRenderer) localCategoryPlot.getRenderer();
localBarRenderer.setItemMargin(0.02D);
return localJFreeChart;
}
private static CategoryDataset createDataset() {
DefaultCategoryDataset localDefaultCategoryDataset = new DefaultCategoryDataset();
localDefaultCategoryDataset.addValue(7.0D, "Series 1", "Category 1");
localDefaultCategoryDataset.addValue(5.0D, "Series 2", "Category 1");
return localDefaultCategoryDataset;
}
public static JPanel createDemoPanel() {
DemoPanel localDemoPanel = new DemoPanel(new GridLayout(2, 2));
localDemoPanel.setPreferredSize(new Dimension(800, 600));
CategoryDataset localCategoryDataset = createDataset();
JFreeChart localJFreeChart1 = createChart("Type: VERTICAL", localCategoryDataset);
CategoryPlot localCategoryPlot1 = (CategoryPlot) localJFreeChart1.getPlot();
BarRenderer localBarRenderer1 = (BarRenderer) localCategoryPlot1.getRenderer();
localBarRenderer1.setBarPainter(new StandardBarPainter());
localBarRenderer1.setDrawBarOutline(false);
localBarRenderer1.setSeriesPaint(0, new GradientPaint(0.0F, 0.0F, Color.red, 0.0F, 0.0F, Color.yellow));
localBarRenderer1.setSeriesPaint(1, new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, Color.green));
localBarRenderer1.setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.VERTICAL));
ChartPanel localChartPanel1 = new ChartPanel(localJFreeChart1);
localDemoPanel.add(localChartPanel1);
JFreeChart localJFreeChart2 = createChart("Type: HORIZONTAL", localCategoryDataset);
CategoryPlot localCategoryPlot2 = (CategoryPlot) localJFreeChart2.getPlot();
BarRenderer localBarRenderer2 = (BarRenderer) localCategoryPlot2.getRenderer();
localBarRenderer2.setBarPainter(new StandardBarPainter());
localBarRenderer2.setDrawBarOutline(false);
localBarRenderer2.setSeriesPaint(0, new GradientPaint(0.0F, 0.0F, Color.red, 0.0F, 0.0F, Color.yellow));
localBarRenderer2.setSeriesPaint(1, new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, Color.green));
localBarRenderer2.setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.HORIZONTAL));
ChartPanel localChartPanel2 = new ChartPanel(localJFreeChart2);
localDemoPanel.add(localChartPanel2);
JFreeChart localJFreeChart3 = createChart("Type: CENTER_VERTICAL", localCategoryDataset);
CategoryPlot localCategoryPlot3 = (CategoryPlot) localJFreeChart3.getPlot();
BarRenderer localBarRenderer3 = (BarRenderer) localCategoryPlot3.getRenderer();
localBarRenderer3.setBarPainter(new StandardBarPainter());
localBarRenderer3.setDrawBarOutline(false);
localBarRenderer3.setSeriesPaint(0, new GradientPaint(0.0F, 0.0F, Color.red, 0.0F, 0.0F, Color.yellow));
localBarRenderer3.setSeriesPaint(1, new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, Color.green));
localBarRenderer3.setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_VERTICAL));
ChartPanel localChartPanel3 = new ChartPanel(localJFreeChart3);
localDemoPanel.add(localChartPanel3);
JFreeChart localJFreeChart4 = createChart("Type: CENTER_HORIZONTAL", localCategoryDataset);
CategoryPlot localCategoryPlot4 = (CategoryPlot) localJFreeChart4.getPlot();
BarRenderer localBarRenderer4 = (BarRenderer) localCategoryPlot4.getRenderer();
localBarRenderer4.setBarPainter(new StandardBarPainter());
localBarRenderer4.setDrawBarOutline(false);
localBarRenderer4.setSeriesPaint(0, new GradientPaint(0.0F, 0.0F, Color.red, 0.0F, 0.0F, Color.yellow));
localBarRenderer4.setSeriesPaint(1, new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, Color.green));
localBarRenderer4.setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_HORIZONTAL));
ChartPanel localChartPanel4 = new ChartPanel(localJFreeChart4);
localDemoPanel.add(localChartPanel4);
localDemoPanel.addChart(localJFreeChart1);
localDemoPanel.addChart(localJFreeChart2);
localDemoPanel.addChart(localJFreeChart3);
localDemoPanel.addChart(localJFreeChart4);
return localDemoPanel;
}
public static void main(String[] paramArrayOfString) {
GradientPaintTransformerDemo1 localGradientPaintTransformerDemo1 = new GradientPaintTransformerDemo1("GradientPaintTransformerDemo1");
localGradientPaintTransformerDemo1.pack();
RefineryUtilities.centerFrameOnScreen(localGradientPaintTransformerDemo1);
localGradientPaintTransformerDemo1.setVisible(true);
}
}
*s21.postimg.org/jhd7o1dsj/Gradient_Paint_Transformer_Demo1.jpg
Here is a combined X Y plot demo!!
CombinedXYPlotDemo3.java
Code:
/**
*
* @author JGuru
*/
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GradientPaint;
import java.awt.Toolkit;
import javax.swing.JPanel;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.DateAxis;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.CombinedRangeXYPlot;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.xy.StandardXYItemRenderer;
import org.jfree.chart.renderer.xy.XYBarRenderer;
import org.jfree.chart.title.TextTitle;
import org.jfree.data.time.Day;
import org.jfree.data.time.MovingAverage;
import org.jfree.data.time.TimeSeries;
import org.jfree.data.time.TimeSeriesCollection;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;
public class CombinedXYPlotDemo3 extends ApplicationFrame {
private static final long serialVersionUID = 1L;
public CombinedXYPlotDemo3(String paramString) {
super(paramString);
JFreeChart localJFreeChart = createCombinedChart();
ChartPanel localChartPanel = new ChartPanel(localJFreeChart, true, true, true, false, true);
localChartPanel.setPreferredSize(new Dimension(500, 270));
setContentPane(localChartPanel);
}
private static JFreeChart createCombinedChart() {
TimeSeriesCollection localTimeSeriesCollection1 = new TimeSeriesCollection();
TimeSeries localTimeSeries1 = createEURTimeSeries();
localTimeSeriesCollection1.addSeries(localTimeSeries1);
TimeSeriesCollection localTimeSeriesCollection2 = new TimeSeriesCollection();
TimeSeries localTimeSeries2 = MovingAverage.createMovingAverage(localTimeSeries1, "EUR/GBP (30 Day MA)", 30, 30);
localTimeSeriesCollection2.addSeries(localTimeSeries1);
localTimeSeriesCollection2.addSeries(localTimeSeries2);
TimeSeriesCollection localTimeSeriesCollection3 = new TimeSeriesCollection();
localTimeSeriesCollection3.addSeries(localTimeSeries1);
JFreeChart localJFreeChart = null;
NumberAxis localNumberAxis = new NumberAxis("Value");
localNumberAxis.setAutoRangeIncludesZero(false);
CombinedRangeXYPlot localCombinedRangeXYPlot = new CombinedRangeXYPlot(localNumberAxis);
XYPlot localXYPlot1 = new XYPlot(localTimeSeriesCollection1, new DateAxis("Date 1"), null, new StandardXYItemRenderer());
localCombinedRangeXYPlot.add(localXYPlot1, 1);
XYPlot localXYPlot2 = new XYPlot(localTimeSeriesCollection2, new DateAxis("Date 2"), null, new StandardXYItemRenderer());
localCombinedRangeXYPlot.add(localXYPlot2, 1);
XYPlot localXYPlot3 = new XYPlot(localTimeSeriesCollection3, new DateAxis("Date 3"), null, new XYBarRenderer(0.2D));
localCombinedRangeXYPlot.add(localXYPlot3, 1);
localJFreeChart = new JFreeChart("Demo Chart", JFreeChart.DEFAULT_TITLE_FONT, localCombinedRangeXYPlot, true);
TextTitle localTextTitle = new TextTitle("This is a subtitle", new Font("SansSerif", 1, 12));
localJFreeChart.addSubtitle(localTextTitle);
localJFreeChart.setBackgroundPaint(new GradientPaint(0.0F, 0.0F, Color.white, 0.0F, 1000.0F, Color.blue));
ChartUtilities.applyCurrentTheme(localJFreeChart);
return localJFreeChart;
}
public static TimeSeries createEURTimeSeries() {
TimeSeries localTimeSeries = new TimeSeries("EUR/GBP");
try {
localTimeSeries.add(new Day(2, 1, 2001), new Double(1.5788D));
localTimeSeries.add(new Day(3, 1, 2001), new Double(1.5913D));
localTimeSeries.add(new Day(4, 1, 2001), new Double(1.5807D));
localTimeSeries.add(new Day(5, 1, 2001), new Double(1.5711D));
localTimeSeries.add(new Day(8, 1, 2001), new Double(1.5778D));
localTimeSeries.add(new Day(9, 1, 2001), new Double(1.5851D));
localTimeSeries.add(new Day(10, 1, 2001), new Double(1.5846D));
localTimeSeries.add(new Day(11, 1, 2001), new Double(1.5727D));
localTimeSeries.add(new Day(12, 1, 2001), new Double(1.5585D));
localTimeSeries.add(new Day(15, 1, 2001), new Double(1.5694D));
localTimeSeries.add(new Day(16, 1, 2001), new Double(1.5629D));
localTimeSeries.add(new Day(17, 1, 2001), new Double(1.5831D));
localTimeSeries.add(new Day(18, 1, 2001), new Double(1.5624D));
localTimeSeries.add(new Day(19, 1, 2001), new Double(1.5694D));
localTimeSeries.add(new Day(22, 1, 2001), new Double(1.5615D));
localTimeSeries.add(new Day(23, 1, 2001), new Double(1.5656D));
localTimeSeries.add(new Day(24, 1, 2001), new Double(1.5795D));
localTimeSeries.add(new Day(25, 1, 2001), new Double(1.5852D));
localTimeSeries.add(new Day(26, 1, 2001), new Double(1.5797D));
localTimeSeries.add(new Day(29, 1, 2001), new Double(1.5862D));
localTimeSeries.add(new Day(30, 1, 2001), new Double(1.5803D));
localTimeSeries.add(new Day(31, 1, 2001), new Double(1.5714D));
localTimeSeries.add(new Day(1, 2, 2001), new Double(1.5717D));
localTimeSeries.add(new Day(2, 2, 2001), new Double(1.5735D));
localTimeSeries.add(new Day(5, 2, 2001), new Double(1.5691D));
localTimeSeries.add(new Day(6, 2, 2001), new Double(1.5676D));
localTimeSeries.add(new Day(7, 2, 2001), new Double(1.5677D));
localTimeSeries.add(new Day(8, 2, 2001), new Double(1.5737D));
localTimeSeries.add(new Day(9, 2, 2001), new Double(1.5654D));
localTimeSeries.add(new Day(12, 2, 2001), new Double(1.5621D));
localTimeSeries.add(new Day(13, 2, 2001), new Double(1.5761D));
localTimeSeries.add(new Day(14, 2, 2001), new Double(1.5898D));
localTimeSeries.add(new Day(15, 2, 2001), new Double(1.6045D));
localTimeSeries.add(new Day(16, 2, 2001), new Double(1.5852D));
localTimeSeries.add(new Day(19, 2, 2001), new Double(1.5704D));
localTimeSeries.add(new Day(20, 2, 2001), new Double(1.5892D));
localTimeSeries.add(new Day(21, 2, 2001), new Double(1.5844D));
localTimeSeries.add(new Day(22, 2, 2001), new Double(1.5934D));
localTimeSeries.add(new Day(23, 2, 2001), new Double(1.5951D));
localTimeSeries.add(new Day(26, 2, 2001), new Double(1.5848D));
localTimeSeries.add(new Day(27, 2, 2001), new Double(1.5706D));
localTimeSeries.add(new Day(28, 2, 2001), new Double(1.568D));
localTimeSeries.add(new Day(1, 3, 2001), new Double(1.5645D));
localTimeSeries.add(new Day(2, 3, 2001), new Double(1.5754D));
localTimeSeries.add(new Day(5, 3, 2001), new Double(1.5808D));
localTimeSeries.add(new Day(6, 3, 2001), new Double(1.5766D));
localTimeSeries.add(new Day(7, 3, 2001), new Double(1.5756D));
localTimeSeries.add(new Day(8, 3, 2001), new Double(1.576D));
localTimeSeries.add(new Day(9, 3, 2001), new Double(1.5748D));
localTimeSeries.add(new Day(12, 3, 2001), new Double(1.5779D));
localTimeSeries.add(new Day(13, 3, 2001), new Double(1.5837D));
localTimeSeries.add(new Day(14, 3, 2001), new Double(1.5886D));
localTimeSeries.add(new Day(15, 3, 2001), new Double(1.5931D));
localTimeSeries.add(new Day(16, 3, 2001), new Double(1.5945D));
localTimeSeries.add(new Day(19, 3, 2001), new Double(1.588D));
localTimeSeries.add(new Day(20, 3, 2001), new Double(1.5817D));
localTimeSeries.add(new Day(21, 3, 2001), new Double(1.5927D));
localTimeSeries.add(new Day(22, 3, 2001), new Double(1.6065D));
localTimeSeries.add(new Day(23, 3, 2001), new Double(1.6006D));
localTimeSeries.add(new Day(26, 3, 2001), new Double(1.6007D));
localTimeSeries.add(new Day(27, 3, 2001), new Double(1.5989D));
localTimeSeries.add(new Day(28, 3, 2001), new Double(1.6135D));
localTimeSeries.add(new Day(29, 3, 2001), new Double(1.6282D));
localTimeSeries.add(new Day(30, 3, 2001), new Double(1.609D));
localTimeSeries.add(new Day(2, 4, 2001), new Double(1.6107D));
localTimeSeries.add(new Day(3, 4, 2001), new Double(1.6093D));
localTimeSeries.add(new Day(4, 4, 2001), new Double(1.588D));
localTimeSeries.add(new Day(5, 4, 2001), new Double(1.5931D));
localTimeSeries.add(new Day(6, 4, 2001), new Double(1.5968D));
localTimeSeries.add(new Day(9, 4, 2001), new Double(1.6072D));
localTimeSeries.add(new Day(10, 4, 2001), new Double(1.6167D));
localTimeSeries.add(new Day(11, 4, 2001), new Double(1.6214D));
localTimeSeries.add(new Day(12, 4, 2001), new Double(1.612D));
localTimeSeries.add(new Day(17, 4, 2001), new Double(1.6229D));
localTimeSeries.add(new Day(18, 4, 2001), new Double(1.6298D));
localTimeSeries.add(new Day(19, 4, 2001), new Double(1.6159D));
localTimeSeries.add(new Day(20, 4, 2001), new Double(1.5996D));
localTimeSeries.add(new Day(23, 4, 2001), new Double(1.6042D));
localTimeSeries.add(new Day(24, 4, 2001), new Double(1.6061D));
localTimeSeries.add(new Day(25, 4, 2001), new Double(1.6045D));
localTimeSeries.add(new Day(26, 4, 2001), new Double(1.597D));
localTimeSeries.add(new Day(27, 4, 2001), new Double(1.6095D));
localTimeSeries.add(new Day(30, 4, 2001), new Double(1.6141D));
localTimeSeries.add(new Day(1, 5, 2001), new Double(1.6076D));
localTimeSeries.add(new Day(2, 5, 2001), new Double(1.6077D));
localTimeSeries.add(new Day(3, 5, 2001), new Double(1.6035D));
localTimeSeries.add(new Day(4, 5, 2001), new Double(1.606D));
localTimeSeries.add(new Day(8, 5, 2001), new Double(1.6178D));
localTimeSeries.add(new Day(9, 5, 2001), new Double(1.6083D));
localTimeSeries.add(new Day(10, 5, 2001), new Double(1.6107D));
localTimeSeries.add(new Day(11, 5, 2001), new Double(1.6209D));
localTimeSeries.add(new Day(14, 5, 2001), new Double(1.6228D));
localTimeSeries.add(new Day(15, 5, 2001), new Double(1.6184D));
localTimeSeries.add(new Day(16, 5, 2001), new Double(1.6167D));
localTimeSeries.add(new Day(17, 5, 2001), new Double(1.6223D));
localTimeSeries.add(new Day(18, 5, 2001), new Double(1.6305D));
localTimeSeries.add(new Day(21, 5, 2001), new Double(1.642D));
localTimeSeries.add(new Day(22, 5, 2001), new Double(1.6484D));
localTimeSeries.add(new Day(23, 5, 2001), new Double(1.6547D));
localTimeSeries.add(new Day(24, 5, 2001), new Double(1.6444D));
localTimeSeries.add(new Day(25, 5, 2001), new Double(1.6577D));
localTimeSeries.add(new Day(29, 5, 2001), new Double(1.6606D));
localTimeSeries.add(new Day(30, 5, 2001), new Double(1.6604D));
localTimeSeries.add(new Day(31, 5, 2001), new Double(1.6772D));
localTimeSeries.add(new Day(1, 6, 2001), new Double(1.6717D));
localTimeSeries.add(new Day(4, 6, 2001), new Double(1.6685D));
localTimeSeries.add(new Day(5, 6, 2001), new Double(1.6621D));
localTimeSeries.add(new Day(6, 6, 2001), new Double(1.646D));
localTimeSeries.add(new Day(7, 6, 2001), new Double(1.6333D));
localTimeSeries.add(new Day(8, 6, 2001), new Double(1.6265D));
localTimeSeries.add(new Day(11, 6, 2001), new Double(1.6311D));
localTimeSeries.add(new Day(12, 6, 2001), new Double(1.6238D));
localTimeSeries.add(new Day(13, 6, 2001), new Double(1.63D));
localTimeSeries.add(new Day(14, 6, 2001), new Double(1.6289D));
localTimeSeries.add(new Day(15, 6, 2001), new Double(1.6276D));
localTimeSeries.add(new Day(18, 6, 2001), new Double(1.6299D));
localTimeSeries.add(new Day(19, 6, 2001), new Double(1.6353D));
localTimeSeries.add(new Day(20, 6, 2001), new Double(1.6378D));
localTimeSeries.add(new Day(21, 6, 2001), new Double(1.6567D));
localTimeSeries.add(new Day(22, 6, 2001), new Double(1.6523D));
localTimeSeries.add(new Day(25, 6, 2001), new Double(1.6418D));
localTimeSeries.add(new Day(26, 6, 2001), new Double(1.6429D));
localTimeSeries.add(new Day(27, 6, 2001), new Double(1.6439D));
localTimeSeries.add(new Day(28, 6, 2001), new Double(1.6605D));
localTimeSeries.add(new Day(29, 6, 2001), new Double(1.6599D));
localTimeSeries.add(new Day(2, 7, 2001), new Double(1.6727D));
localTimeSeries.add(new Day(3, 7, 2001), new Double(1.662D));
localTimeSeries.add(new Day(4, 7, 2001), new Double(1.6628D));
localTimeSeries.add(new Day(5, 7, 2001), new Double(1.673D));
localTimeSeries.add(new Day(6, 7, 2001), new Double(1.6649D));
localTimeSeries.add(new Day(9, 7, 2001), new Double(1.6603D));
localTimeSeries.add(new Day(10, 7, 2001), new Double(1.6489D));
localTimeSeries.add(new Day(11, 7, 2001), new Double(1.6421D));
localTimeSeries.add(new Day(12, 7, 2001), new Double(1.6498D));
localTimeSeries.add(new Day(13, 7, 2001), new Double(1.6447D));
localTimeSeries.add(new Day(16, 7, 2001), new Double(1.6373D));
localTimeSeries.add(new Day(17, 7, 2001), new Double(1.6443D));
localTimeSeries.add(new Day(18, 7, 2001), new Double(1.6246D));
localTimeSeries.add(new Day(19, 7, 2001), new Double(1.6295D));
localTimeSeries.add(new Day(20, 7, 2001), new Double(1.6362D));
localTimeSeries.add(new Day(23, 7, 2001), new Double(1.6348D));
localTimeSeries.add(new Day(24, 7, 2001), new Double(1.6242D));
localTimeSeries.add(new Day(25, 7, 2001), new Double(1.6241D));
localTimeSeries.add(new Day(26, 7, 2001), new Double(1.6281D));
localTimeSeries.add(new Day(27, 7, 2001), new Double(1.6296D));
localTimeSeries.add(new Day(30, 7, 2001), new Double(1.6279D));
localTimeSeries.add(new Day(31, 7, 2001), new Double(1.63D));
localTimeSeries.add(new Day(1, 8, 2001), new Double(1.629D));
localTimeSeries.add(new Day(2, 8, 2001), new Double(1.6237D));
localTimeSeries.add(new Day(3, 8, 2001), new Double(1.6138D));
localTimeSeries.add(new Day(6, 8, 2001), new Double(1.6121D));
localTimeSeries.add(new Day(7, 8, 2001), new Double(1.617D));
localTimeSeries.add(new Day(8, 8, 2001), new Double(1.6135D));
localTimeSeries.add(new Day(9, 8, 2001), new Double(1.5996D));
localTimeSeries.add(new Day(10, 8, 2001), new Double(1.5931D));
localTimeSeries.add(new Day(13, 8, 2001), new Double(1.5828D));
localTimeSeries.add(new Day(14, 8, 2001), new Double(1.5824D));
localTimeSeries.add(new Day(15, 8, 2001), new Double(1.5783D));
localTimeSeries.add(new Day(16, 8, 2001), new Double(1.581D));
localTimeSeries.add(new Day(17, 8, 2001), new Double(1.5761D));
localTimeSeries.add(new Day(20, 8, 2001), new Double(1.5831D));
localTimeSeries.add(new Day(21, 8, 2001), new Double(1.587D));
localTimeSeries.add(new Day(22, 8, 2001), new Double(1.5808D));
localTimeSeries.add(new Day(23, 8, 2001), new Double(1.5845D));
localTimeSeries.add(new Day(24, 8, 2001), new Double(1.5844D));
localTimeSeries.add(new Day(28, 8, 2001), new Double(1.5924D));
localTimeSeries.add(new Day(29, 8, 2001), new Double(1.595D));
localTimeSeries.add(new Day(30, 8, 2001), new Double(1.5941D));
localTimeSeries.add(new Day(31, 8, 2001), new Double(1.5968D));
localTimeSeries.add(new Day(3, 9, 2001), new Double(1.602D));
localTimeSeries.add(new Day(4, 9, 2001), new Double(1.6236D));
localTimeSeries.add(new Day(5, 9, 2001), new Double(1.6352D));
localTimeSeries.add(new Day(6, 9, 2001), new Double(1.6302D));
localTimeSeries.add(new Day(7, 9, 2001), new Double(1.618D));
localTimeSeries.add(new Day(10, 9, 2001), new Double(1.6218D));
localTimeSeries.add(new Day(11, 9, 2001), new Double(1.6182D));
localTimeSeries.add(new Day(12, 9, 2001), new Double(1.6157D));
localTimeSeries.add(new Day(13, 9, 2001), new Double(1.6171D));
localTimeSeries.add(new Day(14, 9, 2001), new Double(1.596D));
localTimeSeries.add(new Day(17, 9, 2001), new Double(1.5952D));
localTimeSeries.add(new Day(18, 9, 2001), new Double(1.5863D));
localTimeSeries.add(new Day(19, 9, 2001), new Double(1.579D));
localTimeSeries.add(new Day(20, 9, 2001), new Double(1.5811D));
localTimeSeries.add(new Day(21, 9, 2001), new Double(1.5917D));
localTimeSeries.add(new Day(24, 9, 2001), new Double(1.6005D));
localTimeSeries.add(new Day(25, 9, 2001), new Double(1.5915D));
localTimeSeries.add(new Day(26, 9, 2001), new Double(1.6012D));
localTimeSeries.add(new Day(27, 9, 2001), new Double(1.6032D));
localTimeSeries.add(new Day(28, 9, 2001), new Double(1.6133D));
localTimeSeries.add(new Day(1, 10, 2001), new Double(1.6147D));
localTimeSeries.add(new Day(2, 10, 2001), new Double(1.6002D));
localTimeSeries.add(new Day(3, 10, 2001), new Double(1.6041D));
localTimeSeries.add(new Day(4, 10, 2001), new Double(1.6172D));
localTimeSeries.add(new Day(5, 10, 2001), new Double(1.6121D));
localTimeSeries.add(new Day(8, 10, 2001), new Double(1.6044D));
localTimeSeries.add(new Day(9, 10, 2001), new Double(1.5974D));
localTimeSeries.add(new Day(10, 10, 2001), new Double(1.5915D));
localTimeSeries.add(new Day(11, 10, 2001), new Double(1.6022D));
localTimeSeries.add(new Day(12, 10, 2001), new Double(1.6014D));
localTimeSeries.add(new Day(15, 10, 2001), new Double(1.5942D));
localTimeSeries.add(new Day(16, 10, 2001), new Double(1.5925D));
localTimeSeries.add(new Day(17, 10, 2001), new Double(1.6007D));
localTimeSeries.add(new Day(18, 10, 2001), new Double(1.6D));
localTimeSeries.add(new Day(19, 10, 2001), new Double(1.603D));
localTimeSeries.add(new Day(22, 10, 2001), new Double(1.6014D));
localTimeSeries.add(new Day(23, 10, 2001), new Double(1.5995D));
localTimeSeries.add(new Day(24, 10, 2001), new Double(1.5951D));
localTimeSeries.add(new Day(25, 10, 2001), new Double(1.5953D));
localTimeSeries.add(new Day(26, 10, 2001), new Double(1.6057D));
localTimeSeries.add(new Day(29, 10, 2001), new Double(1.6051D));
localTimeSeries.add(new Day(30, 10, 2001), new Double(1.6027D));
localTimeSeries.add(new Day(31, 10, 2001), new Double(1.6144D));
localTimeSeries.add(new Day(1, 11, 2001), new Double(1.6139D));
localTimeSeries.add(new Day(2, 11, 2001), new Double(1.6189D));
localTimeSeries.add(new Day(5, 11, 2001), new Double(1.6248D));
localTimeSeries.add(new Day(6, 11, 2001), new Double(1.6267D));
localTimeSeries.add(new Day(7, 11, 2001), new Double(1.6281D));
localTimeSeries.add(new Day(8, 11, 2001), new Double(1.631D));
localTimeSeries.add(new Day(9, 11, 2001), new Double(1.6313D));
localTimeSeries.add(new Day(12, 11, 2001), new Double(1.6272D));
localTimeSeries.add(new Day(13, 11, 2001), new Double(1.6361D));
localTimeSeries.add(new Day(14, 11, 2001), new Double(1.6323D));
localTimeSeries.add(new Day(15, 11, 2001), new Double(1.6252D));
localTimeSeries.add(new Day(16, 11, 2001), new Double(1.6141D));
localTimeSeries.add(new Day(19, 11, 2001), new Double(1.6086D));
localTimeSeries.add(new Day(20, 11, 2001), new Double(1.6055D));
localTimeSeries.add(new Day(21, 11, 2001), new Double(1.6132D));
localTimeSeries.add(new Day(22, 11, 2001), new Double(1.6074D));
localTimeSeries.add(new Day(23, 11, 2001), new Double(1.6065D));
localTimeSeries.add(new Day(26, 11, 2001), new Double(1.6061D));
localTimeSeries.add(new Day(27, 11, 2001), new Double(1.6039D));
localTimeSeries.add(new Day(28, 11, 2001), new Double(1.6069D));
localTimeSeries.add(new Day(29, 11, 2001), new Double(1.6044D));
localTimeSeries.add(new Day(30, 11, 2001), new Double(1.5928D));
} catch (Exception localException) {
System.err.println(localException.getMessage());
}
return localTimeSeries;
}
public static JPanel createDemoPanel() {
JFreeChart localJFreeChart = createCombinedChart();
return new ChartPanel(localJFreeChart);
}
public static void main(String[] paramArrayOfString) {
CombinedXYPlotDemo3 localCombinedXYPlotDemo3 = new CombinedXYPlotDemo3("CombinedXYPlotDemo3.java");
Dimension scrDim = Toolkit.getDefaultToolkit().getScreenSize();
localCombinedXYPlotDemo3.setPreferredSize(new Dimension(scrDim.width / 2, scrDim.height / 2));
localCombinedXYPlotDemo3.pack();
RefineryUtilities.centerFrameOnScreen(localCombinedXYPlotDemo3);
localCombinedXYPlotDemo3.setVisible(true);
}
}
Here is a Polar chart demo!!
PolarChartDemo1.java
Code:
/**
*
* @author JGuru
*/
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.JPanel;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.PolarPlot;
import org.jfree.data.xy.XYDataset;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;
public class PolarChartDemo1 extends ApplicationFrame {
public PolarChartDemo1(String paramString) {
super(paramString);
JPanel localJPanel = createDemoPanel();
Dimension scrDim = Toolkit.getDefaultToolkit().getScreenSize();
localJPanel.setPreferredSize(new Dimension(scrDim.width / 2, scrDim.height / 2));
setContentPane(localJPanel);
}
private static XYDataset createDataset() {
XYSeriesCollection localXYSeriesCollection = new XYSeriesCollection();
XYSeries localXYSeries1 = new XYSeries("Series 1");
localXYSeries1.add(0.0D, 2.0D);
localXYSeries1.add(90.0D, 13.0D);
localXYSeries1.add(180.0D, 9.0D);
localXYSeries1.add(270.0D, 8.0D);
localXYSeriesCollection.addSeries(localXYSeries1);
XYSeries localXYSeries2 = new XYSeries("Series 2");
localXYSeries2.add(90.0D, -11.199999999999999D);
localXYSeries2.add(180.0D, 21.399999999999999D);
localXYSeries2.add(250.0D, 17.300000000000001D);
localXYSeries2.add(355.0D, 10.9D);
localXYSeriesCollection.addSeries(localXYSeries2);
return localXYSeriesCollection;
}
private static JFreeChart createChart(XYDataset paramXYDataset) {
JFreeChart localJFreeChart = ChartFactory.createPolarChart("Polar Chart Demo 1", paramXYDataset, true, false, false);
PolarPlot localPolarPlot = (PolarPlot) localJFreeChart.getPlot();
localPolarPlot.addCornerTextItem("Corner Item 1");
localPolarPlot.addCornerTextItem("Corner Item 2");
localPolarPlot.setAngleGridlinePaint(Color.white);
localPolarPlot.setRadiusGridlinePaint(Color.white);
NumberAxis localNumberAxis = (NumberAxis) localPolarPlot.getAxis();
localNumberAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
ChartUtilities.applyCurrentTheme(localJFreeChart);
return localJFreeChart;
}
public static JPanel createDemoPanel() {
JFreeChart localJFreeChart = createChart(createDataset());
ChartPanel localChartPanel = new ChartPanel(localJFreeChart);
localChartPanel.setMouseZoomable(false);
return localChartPanel;
}
public static void main(String[] paramArrayOfString) {
PolarChartDemo1 localPolarChartDemo1 = new PolarChartDemo1("PolarChartDemo1.java");
localPolarChartDemo1.pack();
RefineryUtilities.centerFrameOnScreen(localPolarChartDemo1);
localPolarChartDemo1.setVisible(true);
}
}
*s4.postimg.org/xzv6xkvex/Polar_Chart_Demo1.jpg
Here is a Y interval demo!!
YIntervalChartDemo1.java
Code:
/**
*
* @author JGuru
*/
import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.JPanel;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.xy.YIntervalRenderer;
import org.jfree.data.xy.IntervalXYDataset;
import org.jfree.data.xy.YIntervalSeries;
import org.jfree.data.xy.YIntervalSeriesCollection;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;
public class YIntervalChartDemo1 extends ApplicationFrame
{
public YIntervalChartDemo1(String paramString)
{
super(paramString);
JPanel localJPanel = createDemoPanel();
Dimension scrDim = Toolkit.getDefaultToolkit().getScreenSize();
localJPanel.setPreferredSize(new Dimension(scrDim.width/2, scrDim.height/2));
setContentPane(localJPanel);
}
private static JFreeChart createChart(IntervalXYDataset paramIntervalXYDataset)
{
JFreeChart localJFreeChart = ChartFactory.createScatterPlot("Y Interval Chart Demo 1", "X", "Y", paramIntervalXYDataset, PlotOrientation.VERTICAL, true, true, false);
XYPlot localXYPlot = (XYPlot)localJFreeChart.getPlot();
localXYPlot.setDomainPannable(true);
localXYPlot.setRenderer(new YIntervalRenderer());
return localJFreeChart;
}
private static IntervalXYDataset createDataset()
{
double d = 100.0D;
YIntervalSeries localYIntervalSeries = new YIntervalSeries("Series 1");
for (int i = 0; i < 100; i++)
{
d += Math.random() - 0.49D;
localYIntervalSeries.add(i, d, d - 3.0D, d + 3.0D);
}
YIntervalSeriesCollection localYIntervalSeriesCollection = new YIntervalSeriesCollection();
localYIntervalSeriesCollection.addSeries(localYIntervalSeries);
return localYIntervalSeriesCollection;
}
public static JPanel createDemoPanel()
{
JFreeChart localJFreeChart = createChart(createDataset());
ChartPanel localChartPanel = new ChartPanel(localJFreeChart);
localChartPanel.setMouseWheelEnabled(true);
return localChartPanel;
}
public static void main(String[] paramArrayOfString)
{
YIntervalChartDemo1 localYIntervalChartDemo1 = new YIntervalChartDemo1("YIntervalChartDemo1.java");
localYIntervalChartDemo1.pack();
RefineryUtilities.centerFrameOnScreen(localYIntervalChartDemo1);
localYIntervalChartDemo1.setVisible(true);
}
}
*s30.postimg.org/ez6yhhgx9/YInterval_Chart_Demo1.jpg
This wraps up the Charting guide using JFreeChart!!