/**
   * Series edition
   *
   * @param series Series to edit
   */
  void editSeries(final Series series) {
    String[] style = series.getStyle().split(";");
    String strColor = "black";
    final TextField editWidth = new TextField();

    String tempS = "null";
    for (String e : style) {
      if (e.contains("color: ")) {
        strColor = e.replace("color: ", "");
      } else if (e.contains("width: ")) {
        editWidth.setText(e.replace("width: ", ""));
      } else if (e.contains("shape: ")) {
        tempS = e.replace("shape: ", "");
      }
    }
    final String symbol = tempS;

    final List<SeriesShape> symbolList = new ArrayList<>();
    final ObservableList<SeriesShape> symbolListModel;
    final ListView<SeriesShape> comboSymbol = new ListView();
    symbolList.add(new SeriesShape("null", javafx.scene.paint.Color.web(strColor)));
    symbolList.add(new SeriesShape("rectangle", javafx.scene.paint.Color.web(strColor)));
    symbolList.add(new SeriesShape("circle", javafx.scene.paint.Color.web(strColor)));
    symbolList.add(new SeriesShape("triangle", javafx.scene.paint.Color.web(strColor)));
    symbolList.add(new SeriesShape("crux", javafx.scene.paint.Color.web(strColor)));
    symbolList.add(new SeriesShape("diamond", javafx.scene.paint.Color.web(strColor)));
    symbolList.add(new SeriesShape("empty rectangle", javafx.scene.paint.Color.web(strColor)));
    symbolList.add(new SeriesShape("empty circle", javafx.scene.paint.Color.web(strColor)));
    symbolList.add(new SeriesShape("empty triangle", javafx.scene.paint.Color.web(strColor)));
    symbolList.add(new SeriesShape("empty diamond", javafx.scene.paint.Color.web(strColor)));

    symbolListModel = FXCollections.observableList(symbolList);
    comboSymbol.setItems(symbolListModel);
    comboSymbol.setCellFactory(
        new Callback<ListView<SeriesShape>, ListCell<SeriesShape>>() {
          @Override
          public ListCell<SeriesShape> call(ListView<SeriesShape> p) {
            ListCell<SeriesShape> cell =
                new ListCell<SeriesShape>() {
                  @Override
                  protected void updateItem(SeriesShape t, boolean bln) {
                    super.updateItem(t, bln);
                    if (t != null) {
                      setText("");
                      setGraphic(t.getShapeGraphic());
                    }
                  }
                };

            return cell;
          }
        });
    for (SeriesShape smb : symbolListModel) {
      if (smb.getName().equals(symbol)) {
        comboSymbol.getSelectionModel().select(smb);
      }
    }

    final ColorPicker colorPicker = new ColorPicker(javafx.scene.paint.Color.web(strColor));

    colorPicker.setOnAction(
        (ActionEvent t) -> {
          String sc = colorPicker.getValue().toString();
          symbolListModel.clear();
          symbolListModel.add(new SeriesShape("null", javafx.scene.paint.Color.web(sc)));
          symbolListModel.add(new SeriesShape("rectangle", javafx.scene.paint.Color.web(sc)));
          symbolListModel.add(new SeriesShape("circle", javafx.scene.paint.Color.web(sc)));
          symbolListModel.add(new SeriesShape("triangle", javafx.scene.paint.Color.web(sc)));
          symbolListModel.add(new SeriesShape("crux", javafx.scene.paint.Color.web(sc)));
          symbolListModel.add(new SeriesShape("diamond", javafx.scene.paint.Color.web(sc)));
          symbolListModel.add(new SeriesShape("empty rectangle", javafx.scene.paint.Color.web(sc)));
          symbolListModel.add(new SeriesShape("empty circle", javafx.scene.paint.Color.web(sc)));
          symbolListModel.add(new SeriesShape("empty triangle", javafx.scene.paint.Color.web(sc)));
          symbolListModel.add(new SeriesShape("empty diamond", javafx.scene.paint.Color.web(sc)));

          comboSymbol.setItems(symbolListModel);
          for (SeriesShape smb : symbolListModel) {
            if (smb.getName().equals(symbol)) {
              comboSymbol.getSelectionModel().select(smb);
            }
          }
        });

    GridPane grid = new GridPane();

    grid.setHgap(10);
    grid.setVgap(10);
    grid.setPadding(new Insets(0, 10, 0, 10));

    grid.add(new Label("Series"), 0, 0);
    grid.add(new Label(series.getKey().toString()), 1, 0);
    grid.add(new Label("Color"), 0, 1);
    grid.add(colorPicker, 1, 1);
    grid.add(new Label("Width"), 0, 2);
    grid.add(editWidth, 1, 2);
    grid.add(new Label("Shape"), 0, 3);
    grid.add(comboSymbol, 1, 3);

    new PseudoModalDialog(skeleton, grid, true) {
      @Override
      public boolean validation() {
        String strColor = colorPicker.getValue().toString();
        String strWidth = editWidth.getText();
        double dWidth = Double.valueOf(strWidth);
        String strSimbolo = "null";
        SeriesShape simb =
            new SeriesShape(
                comboSymbol.getSelectionModel().getSelectedItem().toString(),
                javafx.scene.paint.Color.web(strColor));

        XYItemRenderer renderer = (XYItemRenderer) plot.getRenderer(series.getAxisIndex());

        renderer.setSeriesPaint(series.getSeriesIndex(), scene2awtColor(colorPicker.getValue()));

        try {
          if (Double.valueOf(strWidth) > 0) {
            ((XYLineAndShapeRenderer) renderer)
                .setSeriesLinesVisible(series.getSeriesIndex(), true);
            renderer.setSeriesStroke(
                series.getSeriesIndex(), new BasicStroke(Integer.valueOf(strWidth)));
          } else {
            ((XYLineAndShapeRenderer) renderer)
                .setSeriesLinesVisible(series.getSeriesIndex(), false);
          }
        } catch (NumberFormatException ex) {

        }

        if (simb.getName().contains("null")) {
          ((XYLineAndShapeRenderer) renderer)
              .setSeriesShapesVisible(series.getSeriesIndex(), false);
          renderer.setSeriesShape(series.getSeriesIndex(), null);
        } else {
          ((XYLineAndShapeRenderer) renderer).setSeriesShapesVisible(series.getSeriesIndex(), true);
          renderer.setSeriesShape(series.getSeriesIndex(), simb.getShapeAWT());
          if (simb.getName().contains("empty")) {
            ((XYLineAndShapeRenderer) renderer)
                .setSeriesShapesFilled(series.getSeriesIndex(), false);
          } else {
            ((XYLineAndShapeRenderer) renderer)
                .setSeriesShapesFilled(series.getSeriesIndex(), true);
          }
        }

        series.setStyle(
            "color: "
                + strColor
                + ";width: "
                + editWidth.getText()
                + ";shape: "
                + strSimbolo
                + ";");

        for (Node le : legendFrame.getChildren()) {
          if (le instanceof LegendAxis) {
            for (Node nn : ((LegendAxis) le).getChildren()) {
              if (nn instanceof Label) {
                if (((Label) nn).getText().equals(series.getKey().toString())) {
                  ((Label) nn).setGraphic(simb.getShapeGraphic());
                }
              }
            }
          }
        }
        return true;
      }
    }.show();
  }
  /**
   * @param axis Axis name to wich the new series belongs
   * @param cs Series Coinfiguration
   */
  @Override
  public final void addSeries(String axis, SimpleSeriesConfiguration cs) {
    for (int i = 0; i < axes.size(); i++) {
      if (axes.get(i).getName().equals(axis)) {
        String strColor;
        javafx.scene.paint.Color color;
        int indice = seriesList.size();
        if (cs.getColor() == null) {
          color = getColor(indice);
        } else {
          color = cs.getColor();
        }
        strColor = color.toString();

        XYSeriesCollection dataset = datasetList.get(i);
        Series series =
            new Series(
                cs.getName(),
                "color: "
                    + strColor
                    + ";width: "
                    + String.valueOf(cs.getLineWidth())
                    + ";shape: "
                    + cs.getShapeName()
                    + ";",
                i,
                dataset.getSeriesCount());
        dataset.addSeries(series);

        XYItemRenderer renderer = plot.getRenderer(i);
        renderer.setSeriesPaint(dataset.getSeriesCount() - 1, scene2awtColor(color));

        SeriesShape simb =
            new SeriesShape(
                cs.getShapeName(), javafx.scene.paint.Color.web(strColor.replace("#", "0x")));

        if (cs.getLineWidth() > 0) {
          ((XYLineAndShapeRenderer) renderer)
              .setSeriesLinesVisible(dataset.getSeriesCount() - 1, true);
          renderer.setSeriesStroke(
              dataset.getSeriesCount() - 1, new BasicStroke(cs.getLineWidth()));
        } else {
          ((XYLineAndShapeRenderer) renderer)
              .setSeriesLinesVisible(dataset.getSeriesCount() - 1, false);
        }

        if (cs.getShapeName().equals("null")) {
          renderer.setSeriesShape(dataset.getSeriesCount() - 1, null);
          ((XYLineAndShapeRenderer) renderer)
              .setSeriesShapesVisible(dataset.getSeriesCount() - 1, false);
        } else {
          renderer.setSeriesShape(dataset.getSeriesCount() - 1, simb.getShapeAWT());
          ((XYLineAndShapeRenderer) renderer)
              .setSeriesShapesVisible(dataset.getSeriesCount() - 1, true);
          if (cs.getShapeName().contains("empty")) {
            ((XYLineAndShapeRenderer) renderer)
                .setSeriesShapesFilled(dataset.getSeriesCount() - 1, false);
          } else {
            ((XYLineAndShapeRenderer) renderer)
                .setSeriesShapesFilled(dataset.getSeriesCount() - 1, true);
          }
        }

        if (i == 0) {
          plot.setRenderer(renderer);
        } else {
          plot.setRenderer(i, renderer);
        }

        seriesList.add(series);

        final LegendAxis le = getLegendAxis(axis);
        final Label label = new Label(cs.toString());
        Platform.runLater(
            () -> {
              label.setStyle(
                  "fondo: "
                      + strChartBackgroundColor
                      + ";-fx-background-color: fondo;-fx-text-fill: ladder(fondo, white 49%, black 50%);-fx-padding:5px;-fx-background-radius: 5;-fx-font-size: "
                      + String.valueOf(fontSize)
                      + "px");
            });

        label.setOnMouseClicked(
            (MouseEvent t) -> {
              if (t.getClickCount() == 2) {
                for (int i1 = 0; i1 < seriesList.size(); i1++) {
                  if (seriesList.get(i1).getKey().toString().equals(label.getText())) {
                    editSeries(seriesList.get(i1));
                    break;
                  }
                }
              }
            });
        label.setOnMouseExited(
            (MouseEvent t) -> {
              label.setStyle(
                  label
                      .getStyle()
                      .replace("-fx-background-color: blue", "-fx-background-color: fondo"));
            });
        label.setOnMouseEntered(
            (MouseEvent t) -> {
              label.setStyle(
                  label
                      .getStyle()
                      .replace("-fx-background-color: fondo", "-fx-background-color: blue"));
              for (Node le1 : legendFrame.getChildren()) {
                if (le1 instanceof LegendAxis) {
                  le1.setStyle("-fx-background-color:" + strBackgroundColor);
                  ((LegendAxis) le1).selected = false;
                }
              }
            });
        label.setStyle(
            "fondo: "
                + strChartBackgroundColor
                + ";-fx-text-fill: white;-fx-background-color: fondo;-fx-padding:5px;-fx-background-radius: 5;-fx-font-size: "
                + String.valueOf(fontSize)
                + "px");

        le.getChildren().add(label);
        label.setGraphic(simb.getShapeGraphic());

        break;
      }
    }
  }