Package com.xeiam.xchart

Examples of com.xeiam.xchart.Chart


  @Override
  public Chart getChart() {

    // Create Chart
    Chart chart = new Chart(800, 600);

    // Customize Chart
    chart.setChartTitle(getClass().getSimpleName());
    chart.setXAxisTitle("Age");
    chart.setYAxisTitle("Amount");
    chart.getStyleManager().setLegendPosition(LegendPosition.InsideNW);
    chart.getStyleManager().setChartType(ChartType.Line);

    // @formatter:off
    double[] xAges = new double[]{
        60, 61, 62, 63, 64, 65, 66, 67, 68, 69,
        70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
        80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
        90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100};

    double[] yLiability = new double[]{
        672234,
        691729,
        711789,
        732431,
        753671,
        775528,
        798018,
        821160,
        844974,
        869478,
        907735,
        887139,
        865486,
        843023,
        819621,
        795398,
        770426,
        744749,
        719011,
        693176,
        667342,
        641609,
        616078,
        590846,
        565385,
        540002,
        514620,
        489380,
        465149,
        441817,
        419513,
        398465,
        377991,
        358784,
        340920,
        323724,
        308114,
        293097,
        279356,
        267008,
        254873
    };

    double[] yPercentile75th = new double[]{
        800000,
        878736,
        945583,
        1004209,
        1083964,
        1156332,
        1248041,
        1340801,
        1440138,
        1550005,
        1647728,
        1705046,
        1705032,
        1710672,
        1700847,
        1683418,
        1686522,
        1674901,
        1680456,
        1679164,
        1668514,
        1672860,
        1673988,
        1646597,
        1641842,
        1653758,
        1636317,
        1620725,
        1589985,
        1586451,
        1559507,
        1544234,
        1529700,
        1507496,
        1474907,
        1422169,
        1415079,
        1346929,
        1311689,
        1256114,
        1221034
    };

    double[] yPercentile50th = new double[]{
        800000,
        835286,
        873456,
        927048,
        969305,
        1030749,
        1101102,
        1171396,
        1246486,
        1329076,
        1424666,
        1424173,
        1421853,
        1397093,
        1381882,
        1364562,
        1360050,
        1336885,
        1340431,
        1312217,
        1288274,
        1271615,
        1262682,
        1237287,
        1211335,
        1191953,
        1159689,
        1117412,
        1078875,
        1021020,
        974933,
        910189,
        869154,
        798476,
        744934,
        674501,
        609237,
        524516,
        442234,
        343960,
        257025
    };

    double[] yPercentile25th = new double[]{
        800000,
        791439,
        809744,
        837020,
        871166,
        914836,
        958257,
        1002955,
        1054094,
        1118934,
        1194071,
        1185041,
        1175401,
        1156578,
        1132121,
        1094879,
        1066202,
        1054411,
        1028619,
        987730,
        944977,
        914929,
        880687,
        809330,
        783318,
        739751,
        696201,
        638242,
        565197,
        496959,
        421280,
        358113,
        276518,
        195571,
        109514,
        13876,
        29,
        0,
        0,
        0,
        0};
    // @formatter:on

    Series seriesLiability = chart.addSeries("Liability", xAges, yLiability);
    seriesLiability.setMarker(SeriesMarker.NONE);
    seriesLiability.setSeriesType(Series.SeriesType.Area);

    Series seriesPercentile75th = chart.addSeries("75th Percentile", xAges, yPercentile75th);
    seriesPercentile75th.setMarker(SeriesMarker.NONE);

    Series seriesPercentile50th = chart.addSeries("50th Percentile", xAges, yPercentile50th);
    seriesPercentile50th.setMarker(SeriesMarker.NONE);

    Series seriesPercentile25th = chart.addSeries("25th Percentile", xAges, yPercentile25th);
    seriesPercentile25th.setMarker(SeriesMarker.NONE);

    chart.getStyleManager().setYAxisLabelAlignment(StyleManager.TextAlignment.Right);
    chart.getStyleManager().setYAxisDecimalPattern("$ #,###.##");

    chart.getStyleManager().setPlotPadding(0);
    chart.getStyleManager().setAxisTickSpacePercentage(.95);
    // chart.getStyleManager().setYAxisMax(1620725 * 1.15); // We want to ensure there is a % of padding on the top of the chart
    return chart;
  }
View Full Code Here


public class DateChart05 implements ExampleChart {

  public static void main(String[] args) {

    ExampleChart exampleChart = new DateChart05();
    Chart chart = exampleChart.getChart();
    new SwingWrapper(chart).displayChart();
  }
View Full Code Here

  @Override
  public Chart getChart() {

    // Create Chart
    Chart chart = new ChartBuilder().width(800).height(600).title("Day Scale").build();
    chart.getStyleManager().setLegendVisible(false);

    // generate data
    List<Date> xData = new ArrayList<Date>();
    List<Double> yData = new ArrayList<Double>();

    Random random = new Random();

    DateFormat sdf = new SimpleDateFormat("MM-dd");
    Date date = null;
    for (int i = 1; i <= 14; i++) {
      try {
        date = sdf.parse("02-" + (6 * i + random.nextInt(2)));
      } catch (ParseException e) {
        e.printStackTrace();
      }
      xData.add(date);
      yData.add(Math.random() * i / -100000000);
    }

    chart.addSeries("blah", xData, yData);

    return chart;

  }
View Full Code Here

    double[] xData = new double[] { 0.0, 1.0, 2.0 };
    double[] yData = new double[] { 2.0, 1.0, 0.0 };

    // Create Chart
    Chart chart = QuickChart.getChart("Sample Chart", "X", "Y", "y(x)", xData, yData);

    // Show it
    new SwingWrapper(chart).displayChart();

  }
View Full Code Here

public class LineChart05 implements ExampleChart {

  public static void main(String[] args) {

    ExampleChart exampleChart = new LineChart05();
    Chart chart = exampleChart.getChart();
    new SwingWrapper(chart).displayChart();
  }
View Full Code Here

  @Override
  public Chart getChart() {

    // Create Chart
    Chart chart = new Chart(800, 600);

    // Customize Chart
    chart.setChartTitle("LineChart05");
    chart.setXAxisTitle("X");
    chart.setYAxisTitle("Y");
    chart.getStyleManager().setLegendPosition(LegendPosition.InsideSW);

    double[] xData = new double[] { 0.0, 1.0, 2.0, 3.0, 4.0, 5, 6 };
    double[] yData = new double[] { 106, 44, 26, 10, 7.5, 3.4, .88 };
    double[] yData2 = new double[] { 102, 49, 23.6, 11.3, 5.4, 2.6, 1.25 };

    Series series = chart.addSeries("A", xData, yData);
    series.setLineStyle(SeriesLineStyle.NONE);
    series.setMarker(SeriesMarker.DIAMOND);
    series.setMarkerColor(Color.BLACK);

    Series series2 = chart.addSeries("B", xData, yData2);
    series2.setMarker(SeriesMarker.NONE);
    series2.setLineStyle(SeriesLineStyle.DASH_DASH);
    series2.setLineColor(Color.BLACK);

    chart.getStyleManager().setYAxisLogarithmic(true);

    chart.getStyleManager().setYAxisMin(0.01);
    chart.getStyleManager().setYAxisMax(1000);

    chart.getStyleManager().setXAxisMin(2);
    chart.getStyleManager().setXAxisMax(7);

    return chart;
  }
View Full Code Here

public class BarChart03 implements ExampleChart {

  public static void main(String[] args) {

    ExampleChart exampleChart = new BarChart03();
    Chart chart = exampleChart.getChart();
    new SwingWrapper(chart).displayChart();
  }
View Full Code Here

  @Override
  public Chart getChart() {

    // Create Chart
    Chart chart = new ChartBuilder().chartType(ChartType.Bar).width(800).height(600).title("Score vs. Age").xAxisTitle("Age").yAxisTitle("Score").build();
    chart.addSeries("males", new double[] { 10, 20, 30, 40 }, new double[] { 40, -30, -20, -60 });

    return chart;
  }
View Full Code Here

public class DateChart02 implements ExampleChart {

  public static void main(String[] args) {

    ExampleChart exampleChart = new DateChart02();
    Chart chart = exampleChart.getChart();
    new SwingWrapper(chart).displayChart();
  }
View Full Code Here

  @Override
  public Chart getChart() {

    // Create Chart
    Chart chart = new ChartBuilder().width(800).height(600).title("Second Scale").build();
    chart.getStyleManager().setLegendVisible(false);

    // generate data
    List<Date> xData = new ArrayList<Date>();
    List<Double> yData = new ArrayList<Double>();

    Random random = new Random();

    DateFormat sdf = new SimpleDateFormat("HH:mm:ss.SSS");
    Date date = null;
    for (int i = 1; i <= 14; i++) {
      try {
        date = sdf.parse("23:45:" + (5 * i + random.nextInt(2)) + "." + random.nextInt(1000));
      } catch (ParseException e) {
        e.printStackTrace();
      }
      xData.add(date);
      yData.add(Math.random() * i);
    }

    chart.addSeries("blah", xData, yData);

    return chart;

  }
View Full Code Here

TOP

Related Classes of com.xeiam.xchart.Chart

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.