enjalot / tributary

rapid prototyping with d3.js
http://tributary.io
Other
598 stars 70 forks source link

no refresh of magic tributary.$FILENAME after code changes #103

Closed froh closed 11 years ago

froh commented 11 years ago

Hi,

when the code using some magic TSV file happens to modify the magic file content, then after a reload of the code, the magic file content is not reset.

example. some_data.tsv (using spaces here for the lack of tabs):

Label X Y Z
a 1 2 3
b 3 2 4
c 1 3 1

inlet.js

magic_data = tributary.some_data

var colLabels = null,
     rowLabels = [],
     dataRowByRow = [];

magic_data.forEach(function (row) {
  var rowLabel = row.Label;
  rowLabels.push(rowLabel);
  delete row.Label; // This is the thing that strangely survives a refresh.

  if (!colLabels) {
    colLabels = d3.keys(row);
  }
  var rowData = [];
  // this guarantees identical column order for each row:
  colLabels.forEach(function (col) { rowData.push(row[col])});
  dataRowByRow.push(rowData);
})

var dataColumnByColumn = d3.transpose(dataRowByRow);

Now when I update the code in inlet.js, the magic_data is not reset, and there is no more row.Label to collect and the rowLabels will be all undefined.

I worked around this (by no more modifying the data but filtering out the Label column) but I think this is a bug anyhow.

enjalot commented 11 years ago

thanks for bringing this up, and sorry it was an inconvenience.

I think there is a way I can fix this issue so you don't need the work around, i'll try to get to it soon... it's a pretty bad undocumented behavior thats kind of hard to track down.

enjalot commented 11 years ago

i fixed this! turned out to be relatively simple. let me know if it works for you. simple test case: http://tributary.io/inlet/6418695

froh commented 11 years ago

thanks :)