<commit_before>package water.util;

import water.api.RequestBuilders;

public class D3Plot {
  private String link_title = "show plot";
  private String title = "Missing Title";
  private String xaxislabel = "x axis";
  private String yaxislabel = "y axis";
  private int width = 1200;
  private int height = 400;
  private int padding = 40;
  private int font_size = 11;
  private float[] x;
  private float[] y;

  private D3Plot() {
  }

  public D3Plot(float[] x, float[] y) {
    this.x = x;
    this.y = y;
  }

  public D3Plot(float[] x, float[] y, String link_title, String title, String xaxislabel, String yaxislabel, int font_size, int height, int width, int padding) {
    this.link_title = link_title;
    this.title = title;
    this.xaxislabel = xaxislabel;
    this.yaxislabel = yaxislabel;
    this.width = width;
    this.height = height;
    this.padding = padding;
    this.font_size = font_size;
    this.x = x;
    this.y = y;
  }

  public D3Plot(float[] x, float[] y, String xaxislabel, String yaxislabel, String title, String link_title) {
    this.yaxislabel = yaxislabel;
    this.xaxislabel = xaxislabel;
    this.title = title;
    this.link_title = link_title;
    this.x = x;
    this.y = y;
  }

  public D3Plot(float[] x, float[] y, String xaxislabel, String yaxislabel, String title) {
    this.yaxislabel = yaxislabel;
    this.xaxislabel = xaxislabel;
    this.title = title;
    this.x = x;
    this.y = y;
    this.link_title = "Toggle view of plot of " + title;
  }

  public void generate(StringBuilder sb) {
    final String plot = title.replaceAll(" ", "");
    assert(x.length == y.length);
    sb.append("<script type=\"text/javascript\" src='/h2o/js/d3.v3.min.js'></script>");
    sb.append("<span style='display: inline-block;'>");
    //sb.append("<div class=\"pull-left\">");
    sb.append("<a href=\"#\" onclick=\'$(\"#" + "plot" + plot
            + "\").toggleClass(\"hide\");\' class=\'btn btn-inverse btn-mini\'>" + link_title + "</a></div>");
    sb.append("<div class=\"hide\" id=\"" + "plot" + plot + "\">");
    sb.append("<style type=\"text/css\">");
    sb.append(".axis path," +<commit_msg>Cleanup of D3Plot code.  TODO: add log scale, etc.<commit_after>package water.util;

import water.api.RequestBuilders;

/**
 * Helper class to plot simple 2D scatter plots.
 * Input: x and y are two equal-sized float arrays with X and Y coordinates to be plotted.
 */
public class D3Plot {
  private float[] x;
  private float[] y;
  private String xaxislabel = "x axis";
  private String yaxislabel = "y axis";
  private String title = "Missing Title";

  // default values are usually fine - might want to add a formatting method later
  private String link = "Toggle view of plot";
  private int width = 1000;
  private int height = 400;
  private int padding = 40;
  private int font_size = 11;

  public D3Plot(float[] x, float[] y, String xaxislabel, String yaxislabel, String title) {
    this.yaxislabel = yaxislabel;
    this.xaxislabel = xaxislabel;
    this.title = title;
    this.x = x;
    this.y = y;
    this.link = "Toggle view of plot of " + title;
    assert(x.length == y.length);
  }

  // populate the StringBuilder object with the Javascript code to display a 2D plot in a HTML page
  public void generate(StringBuilder sb) {
    final String plot = title.replaceAll(" ", "");
    sb.append("<script type=\"text/javascript\" src='/h2o/js/d3.v3.min.js'></script>");
    sb.append("<span style='display: inline-block;'>");
    //sb.append("<div class=\"pull-left\">");
    sb.append("<a href=\"#\" onclick=\'$(\"#" + "plot" + plot
            + "\").toggleClass(\"hide\");\' class=\'btn btn-inverse btn-mini\'>" + link + "</a></div>");
    sb.append("<div class=\"hide\" id=\"" + "plot" + plot + "\">");
    sb.append("<style type=\"text/css\">");
    sb.append(".axis path," +
{'fraction_non_alphanumeric': 0.16194437223810762, 'fraction_numerical': 0.010137769690668054, 'mean_word_length': 3.1690140845070425, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '804943', 'n_tokens_mistral': 1304, 'n_tokens_neox': 1258, 'n_words': 372}