constructor()

in code/decision-tree/js/EntropyTree.js [17:49]


  constructor(opts) {
    const that = this;
    // selections
    this.container = opts.chartContainer;
    this.data = opts.data;

    this.radius = etMobile ? 40 : 80;
    this.strokeWidth = etMobile ? 2 : 4;

    // set constant SVG parameters
    this.MARGIN = {
      TOP: etMobile ? this.radius * 3 : this.radius * 2,
      BOTTOM: etMobile ? this.radius * 1.5 : this.radius + 10,
      LEFT: etMobile ? 0 : this.radius + 40,
      RIGHT: etMobile ? 0 : this.radius + 60,
    };
    const containerSize = select(`#${this.container}`)
      .node()
      .getBoundingClientRect();
    this.WIDTH = etMobile ? containerSize.width : containerSize.width * 0.8;
    this.HEIGHT = containerSize.height * 0.99;

    this.classNames = ["apple", "cherry", "oak"];
    this.strokeColors = ["#74ADA9", "#7B3972", "#F9BC92"];
    this.levelHeight = this.HEIGHT / 4;
    // todo make radiys scale based on screen size

    // set up svg
    this.treeG = this.initChartSvg();

    // draw charts
    this.drawTree();
  }