Permalink
Browse files

simple functional transform

  • Loading branch information...
1 parent 2aca8da commit 2c75d6d305e916bff1d1bdeb8dd7b4cf52cd9330 @maxogden committed Jun 10, 2012
Showing with 18 additions and 1 deletion.
  1. +1 −0 attachments/index.html
  2. +16 −0 attachments/script/application.js
  3. +1 −1 package.json
@@ -32,6 +32,7 @@
<p>DataCouch is currently being rewritten. <a href="http://github.com/maxogden/datacouch">Stay tuned</a></p>
<div id="wrapper"></div>
+ <textarea></textarea><input class="transformButton" type="button" value="dooooo it"></input>
<div id="dataviz">
<div id="chart"></div>
</div>
@@ -115,6 +115,7 @@ function createDimensions(key) {
return sorter.getBucket(+d[key])
})
var group = buckets.group()
+ buckets.filterRange([0,999999])
app.dimensions[key] = {
asc: asc,
desc: desc,
@@ -193,6 +194,12 @@ function parseCSV(fileStream) {
})
}
+function updateDocs(func) {
+ app.rows = _.map(app.rows, func)
+ renderDataTable(app.rows.slice(0, 9))
+ app.crossfilter = crossfilter(app.rows)
+}
+
$(function() {
app.on('csv', function(rows) {
app.rows = rows
@@ -206,4 +213,13 @@ $(function() {
render('uploadForm', '#wrapper')
$('#upload').click(handleCSVUpload)
})
+
+ $('textarea').val("function(doc) {\n \n return doc;\n}");
+
+ $('.transformButton').click(function(e) {
+ e.preventDefault()
+ eval("var func = " + $('textarea').val())
+ updateDocs(func)
+ return false
+ })
})
View
@@ -15,7 +15,7 @@
"underscore",
"flatdb"
],
- "version": "0.0.1-64",
+ "version": "0.0.1-66",
"scripts": {
"start": "app.js"
},

0 comments on commit 2c75d6d

Please sign in to comment.