Home - oliverwatkins/Iceberg-Charts GitHub Wiki

Getting Started..

Here is a simple Iceberg Charts example.

  ArrayList<DataPoint> values = new ArrayList<DataPoint>();
  values.add(new DataPoint(5, 96));
  values.add(new DataPoint(58, 43));
  values.add(new DataPoint(101, 90));
  values.add(new DataPoint(135, 67));
  values.add(new DataPoint(150, 70));
  
  XYChart lineChart = new XYChart(values, "My Easy Example");
  
  JFrame frame = new JFrame();
  frame.add(lineChart);
  frame.setSize(700, 500);
  frame.setVisible(true);

The chart you will see will look like this :

Iceberg Charts automatically fits the data onto a chart with an x-axis and y-axis that have a scale which represents the data in a way which is easy on the eye.

#Many Series..

Let's have a look at more than one data series. Let's create a number data lists and use a different constructor.

  ArrayList<DataPoint> values = new ArrayList<DataPoint>();
  values.add(new DataPoint(5, 30));
  values.add(new DataPoint(10, 11));
  values.add(new DataPoint(15, 14));
  values.add(new DataPoint(20, 5));
  values.add(new DataPoint(25, 8));
  ArrayList<DataPoint> values2 = new ArrayList<DataPoint>();
  values2.add(new DataPoint(5, 2));
  values2.add(new DataPoint(10, 33));
  values2.add(new DataPoint(15, 6));
  values2.add(new DataPoint(20, 14));
  values2.add(new DataPoint(25, 17));
  ArrayList<DataPoint> values3 = new ArrayList<DataPoint>();
  values3.add(new DataPoint(5, 130));
  values3.add(new DataPoint(10, 74));
  values3.add(new DataPoint(15, 67));
  values3.add(new DataPoint(20, 22));
  values3.add(new DataPoint(25, 68));
  
  ArrayList<DataPoint> values4 = new ArrayList<DataPoint>();
  values4.add(new DataPoint(5, 90));
  values4.add(new DataPoint(10, 65));
  values4.add(new DataPoint(15, 80));
  values4.add(new DataPoint(20, 83));
  values4.add(new DataPoint(23, 90));
  XYDataSeries series = new XYDataSeries(values, "First");
  XYDataSeries series2 = new XYDataSeries(values2, "Second");
  XYDataSeries series3 = new XYDataSeries(values3, "Third");
  XYDataSeries series4 = new XYDataSeries(values4, "Fourth");
  XYChart lineChart = new XYChart("Many Series Example", "My X Axis", "My Y Axis", series, series2, series3, series4); 

If you run this code then you should see something like this :

In an XY Chart, data series differ from each other usually by color and/or line style. Iceberg Charts chooses a style for you. Of course everything in Iceberg charts is configurable, including the data series styles, but one of Iceberg Charts principles is 'ease of use' and a number of simple constructors are exposed where Iceberg Charts does most of the work for you.

Next..

⚠️ **GitHub.com Fallback** ⚠️