All Downloads are FREE. Search and download functionalities are using the official Maven repository.

tech.tablesaw.plotly.components.change.Change Maven / Gradle / Ivy

The newest version!
package tech.tablesaw.plotly.components.change;

import java.util.HashMap;
import java.util.Map;
import tech.tablesaw.plotly.components.Component;

public abstract class Change extends Component {

  // private static final ChangeLine DEFAULT_CHANGE_LINE = new LineBuilder().build();

  private final ChangeLine changeLine;
  private final String fillColor;

  @Override
  public String asJavascript() {
    return asJSON();
  }

  Change(ChangeBuilder builder) {
    this.changeLine = builder.changeLine;
    this.fillColor = builder.fillColor;
  }

  @Override
  protected Map getJSONContext() {
    Map context = new HashMap<>();
    if (changeLine != null) context.put("line", changeLine.getJSONContext());
    if (fillColor != null) context.put("fillcolor", fillColor);
    return context;
  }

  @Override
  protected Map getContext() {
    return getJSONContext();
  }

  public static class ChangeBuilder {

    protected String fillColor;
    protected ChangeLine changeLine;

    public ChangeBuilder fillColor(String color) {
      this.fillColor = color;
      return this;
    }

    public ChangeBuilder changeLine(ChangeLine line) {
      this.changeLine = line;
      return this;
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy