Ejemplo n.º 1
0
  /**
   * Creates a Chart with multiple Series for the same X-Axis data with default style
   *
   * @param chartTitle the Chart title
   * @param xTitle The X-Axis title
   * @param yTitle The Y-Axis title
   * @param seriesNames An array of the name of the multiple series
   * @param xData An array containing the X-Axis data
   * @param yData An array of double arrays containing multiple Y-Axis data
   * @return a Chart Object
   */
  public static Chart getChart(
      String chartTitle,
      String xTitle,
      String yTitle,
      String[] seriesNames,
      double[] xData,
      double[][] yData) {

    // Create Chart
    Chart chart = new Chart(WIDTH, HEIGHT);

    // Customize Chart
    chart.setChartTitle(chartTitle);
    chart.setXAxisTitle(xTitle);
    chart.setYAxisTitle(yTitle);

    // Series
    for (int i = 0; i < yData.length; i++) {
      Series series;
      if (seriesNames != null) {
        series = chart.addSeries(seriesNames[i], xData, yData[i]);
      } else {
        chart.getStyleManager().setLegendVisible(false);
        series = chart.addSeries(" " + i, xData, yData[i]);
      }
      series.setMarker(SeriesMarker.NONE);
    }

    return chart;
  }
Ejemplo n.º 2
0
  /**
   * Creates a Chart with default style
   *
   * @param chartTitle the Chart title
   * @param xTitle The X-Axis title
   * @param yTitle The Y-Axis title
   * @param seriesNames The name of the series
   * @param xData A Collection containing the X-Axis data
   * @param yData A Collection containing Y-Axis data
   * @return a Chart Object
   */
  public static Chart getChart(
      String chartTitle,
      String xTitle,
      String yTitle,
      String seriesName,
      List<Number> xData,
      List<Number> yData) {

    // Create Chart
    Chart chart = new Chart(WIDTH, HEIGHT);

    // Customize Chart
    chart.setChartTitle(chartTitle);
    chart.setXAxisTitle(xTitle);
    chart.setYAxisTitle(yTitle);

    Series series = chart.addSeries(seriesName, xData, yData);
    series.setMarker(SeriesMarker.NONE);

    return chart;
  }