In [5]:
import json

import numpy as np
import pandas as pd

In [2]:
from jupyter_scisheets_widget import scisheets_widget

In [3]:
tbl = scisheets_widget.SciSheetTable()

In [7]:
json.dumps(data)


Out[7]:
'[{"name": "Lisp", "value": 1}, {"name": "Scala", "value": 2}, {"name": "Perl", "value": 4}, {"name": "Java", "value": 5}, {"name": "C++", "value": 8}, {"name": "Python", "value": 10}]'

In [6]:
data = [{"name": "Lisp", "value": 1}, {"name": "Scala", "value": 2}, {"name": "Perl", "value": 4}, {"name": "Java", "value": 5}, {"name": "C++", "value": 8}, {"name": "Python", "value": 10}]

tbl.set_data(data)

In [8]:
tbl



In [15]:
tbl._model_data


Out[15]:
u'[{"name": "Lisp", "value": 1}, {"name": "Scala", "value": 2}, {"name": "Perl", "value": 4}, {"name": "Java", "value": 5}, {"name": "C++", "value": 8}, {"name": "Python", "value": 10}]'

In [9]:
data = np.random.randint(size=(3, 5), low=100, high=900)
df = pd.DataFrame(data)
df


Out[9]:
0 1 2 3 4
0 307 649 548 264 466
1 118 262 314 452 806
2 219 468 526 247 752

In [10]:
df_test = scisheets_widget.SciSheetTable()

In [11]:
df_test.set_data(df)

In [12]:
type(df)


Out[12]:
pandas.core.frame.DataFrame

In [13]:
df_test


Test to make sure widgets work in notebook


In [ ]:
widgets.IntSlider()

In [ ]:


In [ ]:
%%javascript
var output_area = this;
// find my cell element
var cell_element = output_area.element.parents('.cell');
// which cell is it?
var cell_idx = Jupyter.notebook.get_cell_elements().index(cell_element);
// get the cell object
var cell = Jupyter.notebook.get_cell(cell_idx);

In [ ]:
%%javascript

var div = document.createElement('div');

div.innerHTML = '<span class="msg">Hello world.</span>';

In [ ]:
%%javascript

var table_id = 0;

this.$table = $('<div />')
                .attr('id', 'table_' + (table_id++))
                .appendTo(element);

this.$table.handsontable({data:data1});

// this.element.handsontable({data:data1});
// console.log('how?')

In [ ]:
%%javascript
element.text('Hi')
console.log('There')

In [5]:
data1 = df.to_json(orient='records')

In [7]:
%%javascript

$element.handsontable({data:data1});



In [ ]:


In [ ]:
df = pd.DataFrame({'a':[1,3,5,7,4,5,6,4,7,8,9],
                   'b':[3,5,6,2,4,6,7,8,7,8,9]})

In [ ]:
data = np.random.randint(size=(3, 5), low=100, high=900)
df = pd.DataFrame(data)

In [ ]:


In [ ]:
display(hdf)

In [ ]:
hdf = scisheets_widget.HandsonDataFrame(df)
hdf.show()

In [ ]:
display(hdf._widget)

In [ ]:
%%javascript

require(['handsontable'], function (handsontable){
    console.log("in require->handsontable");
    
  var data = [
    ["", "Maserati", "Mazda", "Mercedes", "Mini", "Mitsubishi"],
    ["2009", 0, 2941, 4303, 354, 5814],
    ["2010", 5, 2905, 2867, 412, 5284],
    ["2011", 4, 2517, 4822, 552, 6127],
    ["2012", 2, 2422, 5399, 776, 4151]
  ];
  
  $('#hs_example').handsontable({
    data: data,
    minSpareRows: 1,
    colHeaders: true,
    contextMenu: true
  });
  
  
  function bindDumpButton() {
      $('body').on('click', 'button[name=dump]', function () {
        var dump = $(this).data('dump');
        var $container = $(dump);
        console.log('data of ' + dump, $container.handsontable('getData'));
      });
    }
  bindDumpButton();    
    
});