<commit_before>/**
 * Created by rind on 5/30/17.
 */

import * as events from 'phovea_core/src/event';
import * as d3 from 'd3';
import * as localforage from 'localforage';
import {MAppViews} from './app';

class SparklineBarChart implements MAppViews {

  private $node;
  private promiseData;

 constructor(parent: Element, private options: any) {
    this.$node = d3.select(parent)
      .append('div')
      .classed('barchart', true);
  }

  /**
   * Initialize the view and return a promise
   * that is resolved as soon the view is completely initialized.
   * @returns {Promise<ValidHeader>}
   */
  init() {
    this.build();
    this.attachListener();

    //Return the promise directly as long there is no dynamical data to update
    return Promise.resolve(this);
  }


  /**
   * Build the basic DOM elements
   */
  private build() {
        console.log("Hello Alex im barchart");
    this.$node.html(`
    <p>Hello World</p>
       `);

            //This is how we retrieve the data. As it's loaded async it is only available as promise.
        //We can save the promise thoug in a global variable and get the data later if we need
        this.promiseData = localforage.getItem('data').then((value) => {
          return value;<commit_msg>more expressive debug text<commit_after>/**
 * Created by rind on 5/30/17.
 */

import * as events from 'phovea_core/src/event';
import * as d3 from 'd3';
import * as localforage from 'localforage';
import {MAppViews} from './app';

class SparklineBarChart implements MAppViews {

  private $node;
  private promiseData;

 constructor(parent: Element, private options: any) {
    this.$node = d3.select(parent)
      .append('div')
      .classed('barchart', true);
  }

  /**
   * Initialize the view and return a promise
   * that is resolved as soon the view is completely initialized.
   * @returns {Promise<ValidHeader>}
   */
  init() {
    this.build();
    this.attachListener();

    //Return the promise directly as long there is no dynamical data to update
    return Promise.resolve(this);
  }


  /**
   * Build the basic DOM elements
   */
  private build() {
        console.log("Now executing SparklineBarChart :-)");
    this.$node.html(`
    <p>This will turn into a sparkline barchart</p>
       `);

            //This is how we retrieve the data. As it's loaded async it is only available as promise.
        //We can save the promise thoug in a global variable and get the data later if we need
        this.promiseData = localforage.getItem('data').then((value) => {
          return value;
{'fraction_non_alphanumeric': 0.11318553092182031, 'fraction_numerical': 0.006223259432127577, 'mean_word_length': 2.8273809523809526, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, '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': '2610409', 'n_tokens_mistral': 771, 'n_tokens_neox': 741, 'n_words': 272}