Ejemplo n.º 1
0
  @Override
  public Chart getChart() {

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

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

    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().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().setNormalDecimalPattern("#0.000");
    chart.getStyleManager().setLocale(Locale.GERMAN);

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

    return chart;
  }
Ejemplo n.º 2
0
  @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;
  }