Example #1
0
 /**
  * Retrieves the {@link Series} object with the given wickedChartsId from the given {@link
  * Options} object. Returns null if a Series with the given ID does not exist.
  */
 public static Series<?> getSeriesWithWickedChartsId(
     final Options options, final int wickedChartsId) {
   for (Series<?> series : options.getSeries()) {
     if (series.getWickedChartsId() == wickedChartsId) {
       return series;
     }
   }
   return null;
 }
Example #2
0
 /**
  * Returns the (0-based) index of the series with the given wickedChartsId or null.
  *
  * @param options the options in which to search
  * @param wickedChartsId the wickedChartsId of the series
  * @return the index of the series with the given id. Returns 0 if no series was found.
  */
 public static int getSeriesIndex(final Options options, final int wickedChartsId) {
   int index = 0;
   if (options.getSeries() == null) {
     throw new IllegalStateException("The given Options object does not contain any series!");
   }
   for (Series<?> series : options.getSeries()) {
     if (series.getWickedChartsId() == wickedChartsId) {
       return index;
     }
     index++;
   }
   return 0;
 }
Example #3
0
 private static boolean hasChartTypeNeedingMoreJs(final Options options) {
   if (options.getChartOptions() != null
       && options.getChartOptions().getType() != null
       && options.getChartOptions().getType().getChartType() == ChartType.ADVANCED) {
     return true;
   }
   if (options.getSeries() != null) {
     for (Series<?> series : options.getSeries()) {
       if (series.getType() != null && series.getType().getChartType() == ChartType.ADVANCED) {
         return true;
       }
     }
   }
   return false;
 }
Example #4
0
 /**
  * Retrieves the {@link Point} object with the given wickedChartsId from the given {@link Options}
  * object. Returns null if a Point with the given ID does not exist.
  */
 public static Point getPointWithWickedChartsId(final Options options, final int wickedChartsId) {
   for (Series<?> series : options.getSeries()) {
     for (Object object : series.getData()) {
       if (!(object instanceof Point)) {
         break;
       } else {
         Point point = (Point) object;
         if (point.getWickedChartsId() == wickedChartsId) {
           return point;
         }
       }
     }
   }
   return null;
 }
    public OpcionesDeGradienteDeGraficoSituacionNetbook(
        Map<SituacionDeNetbook, AtomicInteger> byCategory) {

      setChartOptions(
          new ChartOptions()
              .setPlotBackgroundColor(new NullColor())
              .setPlotBorderWidth(null)
              .setPlotShadow(Boolean.FALSE));

      setTitle(new Title("Estadistica de Situacion De Netbooks."));

      PercentageFormatter formatter = new PercentageFormatter();
      setTooltip(new Tooltip().setFormatter(formatter).setPercentageDecimals(1));

      setPlotOptions(
          new PlotOptionsChoice()
              .setPie(
                  new PlotOptions()
                      .setAllowPointSelect(Boolean.TRUE)
                      .setCursor(Cursor.POINTER)
                      .setDataLabels(
                          new DataLabels()
                              .setEnabled(Boolean.TRUE)
                              .setColor(new HexColor("#000000"))
                              .setConnectorColor(new HexColor("#000000"))
                              .setFormatter(formatter))));

      Series<Point> series = new PointSeries().setType(SeriesType.PIE);
      int i = 0;
      for (Map.Entry<SituacionDeNetbook, AtomicInteger> entry : byCategory.entrySet()) {
        series.addPoint(
            new Point(entry.getKey().name(), entry.getValue().get())
                .setColor(
                    new RadialGradient()
                        .setCx(0.5)
                        .setCy(0.3)
                        .setR(0.7)
                        .addStop(0, new HighchartsColor(i))
                        .addStop(1, new HighchartsColor(i).brighten(-0.3f))));
        i++;
      }
      addSeries(series);
    }
  public ComboOptions() {
    ChartOptions chartOptions = new ChartOptions();
    this.setChartOptions(chartOptions);
    this.setTitle(new Title("Combination chart"));

    Axis xAxis = new Axis();
    xAxis.setCategories(
        Arrays.asList(new String[] {"Apples", "Oranges", "Pears", "Bananas", "Plums"}));
    this.setxAxis(xAxis);

    this.setTooltip(new Tooltip());

    this.setLabels(new Labels().setStyle(new CssStyle()));

    Series<Number> series1 = new SimpleSeries();
    series1.setType(SeriesType.COLUMN);
    series1.setName("Jane");
    series1.setData(Arrays.asList(new Number[] {3, 2, 1, 3, 4}));
    this.addSeries(series1);

    Series<Number> series2 = new SimpleSeries();
    series2.setType(SeriesType.COLUMN);
    series2.setName("John");
    series2.setData(Arrays.asList(new Number[] {2, 3, 5, 7, 6}));
    this.addSeries(series2);

    Series<Number> series3 = new SimpleSeries();
    series3.setType(SeriesType.COLUMN);
    series3.setName("Joe");
    series3.setData(Arrays.asList(new Number[] {4, 3, 3, 9, 0}));
    this.addSeries(series3);

    Marker series4Marker = new Marker();
    series4Marker.setLineWidth(2);
    series4Marker.setLineColor(new HexColor("#990000"));
    series4Marker.setFillColor(new HexColor("#ffffff"));

    Series<Number> series4 = new SimpleSeries();
    series4.setType(SeriesType.SPLINE);
    series4.setName("Average");
    series4.setData(Arrays.asList(new Number[] {3, 2.67, 3, 6.33, 3.33}));
    series4.setMarker(series4Marker);
    this.addSeries(series4);

    PointSeries series5 = new PointSeries();
    series5.setType(SeriesType.PIE);
    series5.setName("Total consumption");
    series5.addPoint(new Point("Jane", 13, new HexColor("#4572A7")));
    series5.addPoint(new Point("John", 23, new HexColor("#AA4643")));
    series5.addPoint(new Point("Joe", 19, new HexColor("#89A54E")));
    series5.setCenter(new Center(100, 80, Center.Unit.PIXELS));
    series5.setSize(new PixelOrPercent(100, PixelOrPercent.Unit.PIXELS));
    series5.setShowInLegend(Boolean.FALSE);
    series5.setDataLabels(new DataLabels(Boolean.TRUE));
    this.addSeries(series5);
  }