Example #1
0
  public void displayLocation() {
    pokupiPodatke();
    dateModel = new LineChartModel();

    dateModel.setExtender("chartExtender");
    dateModel.setZoom(true);
    dateModel.getAxis(AxisType.Y).setLabel("Values");

    for (ProgramMjerenja pm : selektiraniPodaci.keySet()) {
      List<Podatak> podaci = selektiraniPodaci.get(pm);

      LineChartSeries series1 = new LineChartSeries();
      series1.setLabel(pm.getKomponentaId().getNaziv());
      for (Podatak p : podaci) {
        if (p.getObuhvat() > 74) {
          series1.set(sdf.format(p.getVrijeme()), p.getVrijednost());
        }
      }
      //            series1.setMarkerStyle("circle");
      dateModel.addSeries(series1);
    }
    DateAxis axis = new DateAxis("Dates");
    axis.setTickAngle(-50);
    axis.setMin(sdf.format(d1));
    axis.setMax(sdf.format(d2));
    axis.setTickFormat("%m. %d. %H:%M");
    dateModel.getAxes().put(AxisType.X, axis);
    dateModel.setLegendPosition("ne");
  }
  private void createDateModel() {
    System.out.println("INICIA HISTORIAL");
    dateModel = new LineChartModel();
    LineChartSeries series1 = new LineChartSeries();
    series1.setLabel("Historial");

    for (int i = 0; i < histrorial.size(); i++) {
      String fecha =
          String.valueOf(histrorial.get(i).getFechaMedicion().getYear() + 1900)
              + "-"
              + String.valueOf(histrorial.get(i).getFechaMedicion().getMonth() + 1)
              + "-"
              + String.valueOf(histrorial.get(i).getFechaMedicion().getDate());
      series1.set(fecha, histrorial.get(i).getValor());
    }

    dateModel.addSeries(series1);

    dateModel.setTitle("HISTORIAL");
    dateModel.setZoom(true);
    dateModel.getAxis(AxisType.Y).setLabel("VALOR");
    DateAxis axis = new DateAxis("FECHA");
    axis.setTickAngle(-50);
    String fecha =
        String.valueOf(new Date().getYear() + 1900)
            + "-"
            + String.valueOf(new Date().getMonth() + 1)
            + "-"
            + String.valueOf(new Date().getDate());
    System.out.println("FECHA LIMITE " + fecha);
    axis.setMax(fecha);
    axis.setTickFormat("%#d %b, %y");

    dateModel.getAxes().put(AxisType.X, axis);
  }