Difference between revisions of "Data Visualization with Java"

From Self-Organization Wiki
Jump to: navigation, search
(JChart2D Library)
(Code Examples)
Line 15: Line 15:
 
   import javax.swing.JFrame;
 
   import javax.swing.JFrame;
 
   public class MinimalStaticChart {
 
   public class MinimalStaticChart {
    private MinimalStaticChart() {
+
  private MinimalStaticChart() {
      super();
+
    super();
    }
+
  }
    public static void main(String[]args){
+
  public static void main(String[]args){
     Chart2D chart = new Chart2D();       // Create a chart:
+
    // Create a chart: 
     ITrace2D trace = new Trace2DSimple(); // Create an ITrace:  
+
     Chart2D chart = new Chart2D();
     chart.addTrace(trace);               // Add the trace to the chart:
+
    // Create an ITrace:  
 +
     ITrace2D trace = new Trace2DSimple();  
 +
    // Add the trace to the chart:  
 +
     chart.addTrace(trace);  
 
     // Create the Points and add them to the trace
 
     // Create the Points and add them to the trace
     for(int i=10000;i>=0;i--){
+
     for(double i=0;i<=10;i+=0.001){
       trace.addPoint(Math.cos(3*(double)i/1000.0),Math.sin(4*(double)i/1000.0));
+
       trace.addPoint(Math.cos(3*i),Math.sin(4*i));
     }  
+
     }
     // Show the chart on the screen
+
     // Create a frame.
 
     JFrame frame = new JFrame("MinimalStaticChart");
 
     JFrame frame = new JFrame("MinimalStaticChart");
 +
    // add the chart to the frame:
 
     frame.getContentPane().add(chart);
 
     frame.getContentPane().add(chart);
 +
    // make a few adjustments for the Frame
 
     frame.setSize(400,300);
 
     frame.setSize(400,300);
 
     frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 
     frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

Revision as of 09:07, 5 July 2010

JChart2D Library

  • License Model: open source (LGPL license)
  • Webpage and download: [1]

The library is very easy to use because you don't have to spend a lot of time on making adjustments. You can create for example static line charts and dynamic line charts but you cannot create Pie Charts or Bar Charts.

Code Examples

The follwing code snipped creates a static XY Diagramm

 import info.monitorenter.gui.chart.Chart2D;
 import info.monitorenter.gui.chart.ITrace2D;
 import info.monitorenter.gui.chart.traces.Trace2DSimple;
 import javax.swing.JFrame;
 public class MinimalStaticChart {
 private MinimalStaticChart() {
   super();
 }
 public static void main(String[]args){
   // Create a chart:  
   Chart2D chart = new Chart2D();
   // Create an ITrace: 
   ITrace2D trace = new Trace2DSimple(); 
   // Add the trace to the chart: 
   chart.addTrace(trace); 
   // Create the Points and add them to the trace
   for(double i=0;i<=10;i+=0.001){
     trace.addPoint(Math.cos(3*i),Math.sin(4*i));
   }  
   // Create a frame.
   JFrame frame = new JFrame("MinimalStaticChart");
   // add the chart to the frame: 
   frame.getContentPane().add(chart);
   // make a few adjustments for the Frame
   frame.setSize(400,300);
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.setVisible(true);
   }
 }

which looks like this:

Screenshot

ExampleChart Library

  • License Model: open source (LGPL license)
  • Webpage and download: [2]

The library bla bla bla .....

Code Examples

The follwing code snipped creates a pie chart together with a life update Venn Diagramm

code

code code
code code? // comment
code code code !!

which looks like this:

Screenshot

Other Libraries

The following Java libraries looked promising, but turned out to be not recommendable:

  • M$$-Chart commercial license (500 € per license)
  • Crash-Chart beta version, still needs a lot of development, crashes frequently
  • Bad-Chart bad performance, missing important chart types like xy-Diagrams