<commit_before>/**
 * Created by bikramkawan on 21/01/2017.
 */

import {create as createMultiForm, addIconVisChooser} from 'phovea_core/src/multiform';
import App from './app';
import {MultiForm} from 'phovea_core/src/multiform';
import {createNode} from 'phovea_core/src/multiform/internal';
import {IMultiForm} from 'phovea_core/src/multiform';
import {choose} from 'phovea_ui/src/dialogs';
import Block from './Block';
import {makeSort} from './SortManager';
import FilterManager from './FilterManager';
import * as d3 from 'd3';

export default class VisManager {

  //private _visData;
  //private _visUID;
  private _parentDiv = App.visNode;
  private _filterManager;
  private blocks: Block[] = [];

  // private visUID = [];
  // private visData = [];
  // private blocks: MultiForm[] = [];
  // private blockDivs: HTMLDivElement[] = [];


  constructor() {
    //   this._visData = visData;
    //   this._visUID = visUID;
  }

  /*  get visData() {
   return this._visData;
   }

   set visData(value) {
   this._visData = value;
   }

   get visUID() {
   return this._visUID;
   }

   set visUID(value) {
   this._visUID = value;
   }*/

  get parentDiv() {
    return this._parentDiv;
  }

  set parentDiv(value) {
    this._parentDiv = value;
  }

  set filterManager(value) {
    this._filterManager = value;
  }

  createVis(visData, filteredVisData, visUID) {
    const parent = this._parentDiv
      .append('div')
      .attr('data-uid', visUID)
      // .call(drag)
      .html(`<header class="toolbar"></header><main class="vis"></main>`);
    const vis = createMultiForm(filteredVisData, <HTMLElement>parent.select('main').node());
    const block: Block = new Block(visData, filteredVisData, visUID, vis, parent);
    App.blockList.set(block.uid, block);
    this.addIconVisChooser(visUID, <HTMLElement>parent.select('header').node(), vis);


    /*  this.visData.push(visData);
     this.visUID.push(visUID);
     this.blocks.push(vis);
     this.blockDivs.push(parent);*/

  }


  private addIconVisChooser(visUID, toolbar: HTMLElement, ...forms: IMultiForm[]) {<commit_msg>Set default vis in multiform #22<commit_after>/**
 * Created by bikramkawan on 21/01/2017.
 */

import {create as createMultiForm, addIconVisChooser} from 'phovea_core/src/multiform';
import App from './app';
import {MultiForm} from 'phovea_core/src/multiform';
import {createNode} from 'phovea_core/src/multiform/internal';
import {IMultiForm} from 'phovea_core/src/multiform';
import {choose} from 'phovea_ui/src/dialogs';
import Block from './Block';
import {makeSort} from './SortManager';
import FilterManager from './FilterManager';
import * as d3 from 'd3';

export default class VisManager {

  //private _visData;
  //private _visUID;
  private _parentDiv = App.visNode;
  private _filterManager;
  private blocks: Block[] = [];

  // private visUID = [];
  // private visData = [];
  // private blocks: MultiForm[] = [];
  // private blockDivs: HTMLDivElement[] = [];


  constructor() {
    //   this._visData = visData;
    //   this._visUID = visUID;
  }

  /*  get visData() {
   return this._visData;
   }

   set visData(value) {
   this._visData = value;
   }

   get visUID() {
   return this._visUID;
   }

   set visUID(value) {
   this._visUID = value;
   }*/

  get parentDiv() {
    return this._parentDiv;
  }

  set parentDiv(value) {
    this._parentDiv = value;
  }

  set filterManager(value) {
    this._filterManager = value;
  }

  createVis(visData, filteredVisData, visUID) {
    const parent = this._parentDiv
      .append('div')
      .attr('data-uid', visUID)
      // .call(drag)
      .html(`<header class="toolbar"></header><main class="vis"></main>`);
    const vectorOrMatrix = (<any>filteredVisData.desc).type;
    let initialVis;
    if (vectorOrMatrix === 'vector') {
      const dataType = (<any>filteredVisData.desc).value.type;
      if (dataType === 'categorical' || dataType === 'int' || dataType === 'real') {
        initialVis = 'phovea-vis-heatmap1d';
      }

    } else if (vectorOrMatrix === 'matrix') {

      initialVis = 'phovea-vis-heatmap';
    }

    const vis = createMultiForm(filteredVisData, <HTMLElement>parent.select('main').node(), {'initialVis': initialVis});
    const block: Block = new Block(visData, filteredVisData, visUID, vis, parent);
    App.blockList.set(block.uid, block);
    this.addIconVisChooser(visUID, <HTMLElement>parent.select('header').node(), vis);


    /*  this.visData.push(visData);
     this.visUID.push(visUID);
     this.blocks.push(vis);
     this.blockDivs.push(parent);*/

  }


  private addIconVisChooser(visUID, toolbar: HTMLElement, ...forms: IMultiForm[]) {
{'fraction_non_alphanumeric': 0.15265866209262435, 'fraction_numerical': 0.00493138936535163, 'mean_word_length': 3.4301994301994303, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '761206', 'n_tokens_mistral': 1599, 'n_tokens_neox': 1536, 'n_words': 333}