Package com.xeiam.xchart

Examples of com.xeiam.xchart.Chart


public class LineChart03 implements ExampleChart {

  public static void main(String[] args) {

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


  @Override
  public Chart getChart() {

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

    // generates linear data
    Collection<Date> xData = new ArrayList<Date>();
    Collection<Double> yData = new ArrayList<Double>();

    DateFormat sdf = new SimpleDateFormat("dd.MM.yyyy");
    Date date = null;
    for (int i = 1; i <= 10; i++) {

      try {
        date = sdf.parse(i + ".10.2008");
      } catch (ParseException e) {
        e.printStackTrace();
      }
      xData.add(date);
      yData.add(Math.random() * i);
    }

    // Customize Chart
    chart.setChartTitle("LineChart03");
    chart.setXAxisTitle("X");
    chart.setYAxisTitle("Y");
    chart.getStyleManager().setPlotBackgroundColor(ChartColor.getAWTColor(ChartColor.GREY));
    chart.getStyleManager().setPlotGridLinesColor(new Color(255, 255, 255));
    chart.getStyleManager().setChartBackgroundColor(Color.WHITE);
    chart.getStyleManager().setLegendBackgroundColor(Color.PINK);
    chart.getStyleManager().setChartFontColor(Color.MAGENTA);
    chart.getStyleManager().setChartTitleBoxBackgroundColor(new Color(0, 222, 0));
    chart.getStyleManager().setChartTitleBoxVisible(true);
    chart.getStyleManager().setChartTitleBoxBorderColor(Color.BLACK);
    chart.getStyleManager().setPlotGridLinesVisible(false);

    chart.getStyleManager().setAxisTickPadding(20);

    chart.getStyleManager().setAxisTickMarkLength(15);

    chart.getStyleManager().setPlotPadding(20);

    chart.getStyleManager().setChartTitleFont(new Font(Font.MONOSPACED, Font.BOLD, 24));
    chart.getStyleManager().setLegendFont(new Font(Font.SERIF, Font.PLAIN, 18));
    chart.getStyleManager().setLegendPosition(LegendPosition.InsideSE);
    chart.getStyleManager().setLegendSeriesLineLength(12);
    chart.getStyleManager().setAxisTitleFont(new Font(Font.SANS_SERIF, Font.ITALIC, 18));
    chart.getStyleManager().setAxisTickLabelsFont(new Font(Font.SERIF, Font.PLAIN, 11));
    chart.getStyleManager().setDatePattern("dd-MMM");
    chart.getStyleManager().setDecimalPattern("#0.000");
    chart.getStyleManager().setLocale(Locale.GERMAN);

    Series series = chart.addSeries("Fake Data", xData, yData);
    series.setLineColor(SeriesColor.BLUE);
    series.setMarkerColor(Color.ORANGE);
    series.setMarker(SeriesMarker.CIRCLE);
    series.setLineStyle(SeriesLineStyle.SOLID);

View Full Code Here

public class DateChart04 implements ExampleChart {

  public static void main(String[] args) {

    ExampleChart exampleChart = new DateChart04();
    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("Hour 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("dd-HH");
    Date date = null;
    for (int i = 1; i <= 14; i++) {
      try {
        date = sdf.parse("25-" + (2 * i + random.nextInt(2)));
      } catch (ParseException e) {
        e.printStackTrace();
      }
      xData.add(date);
      yData.add(Math.random() * i / 10000000000.0);
    }

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

    return chart;

  }
View Full Code Here

public class BarChart01 implements ExampleChart {

  public static void main(String[] args) {

    ExampleChart exampleChart = new BarChart01();
    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 Histogram").xAxisTitle("Score").yAxisTitle("Number").build();
    chart.addSeries("test 1", new double[] { 0, 1, 2, 3, 4 }, new double[] { 4, 5, 9, 6, 5 });

    // Customize Chart
    chart.getStyleManager().setLegendPosition(LegendPosition.InsideNW);

    return chart;
  }
View Full Code Here

public class DateChart03 implements ExampleChart {

  public static void main(String[] args) {

    ExampleChart exampleChart = new DateChart03();
    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("Minute 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("yyyy-MM-dd-HH:mm:ss.SSS");
    Date date = null;
    for (int i = 1; i <= 14; i++) {
      try {
        date = sdf.parse("2013-07-22-08:" + (5 * i + random.nextInt(2)) + ":" + (random.nextInt(2)) + "." + random.nextInt(1000));
      } catch (ParseException e) {
        e.printStackTrace();
      }
      // System.out.println(date.getTime());
      // System.out.println(date.toString());
      xData.add(date);
      yData.add(Math.random() * i * 1000000000);
    }

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

    return chart;

  }
View Full Code Here

public class BarChart06 implements ExampleChart {

  public static void main(String[] args) {

    ExampleChart exampleChart = new BarChart06();
    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 Histogram").xAxisTitle("Mean").yAxisTitle("Count").build();

    Histogram histogram1 = new Histogram(getGaussianData(10000), 30, -30, 30);
    Histogram histogram2 = new Histogram(getGaussianData(5000), 30, -30, 30);
    chart.addSeries("histogram 1", histogram1.getxAxisData(), histogram1.getyAxisData());
    chart.addSeries("histogram 2", histogram2.getxAxisData(), histogram2.getyAxisData());

    // Customize Chart
    chart.getStyleManager().setLegendPosition(LegendPosition.InsideNW);
    chart.getStyleManager().setBarWidthPercentage(.96);
    chart.getStyleManager().setBarsOverlapped(true);

    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.