Skip to content

Commit

Permalink
simple functional transform
Browse files Browse the repository at this point in the history
  • Loading branch information
max-mapper committed Jun 10, 2012
1 parent 2aca8da commit 2c75d6d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions attachments/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
16 changes: 16 additions & 0 deletions attachments/script/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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
})
})
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"underscore",
"flatdb"
],
"version": "0.0.1-64",
"version": "0.0.1-66",
"scripts": {
"start": "app.js"
},
Expand Down

0 comments on commit 2c75d6d

Please sign in to comment.