timwis / vizwit

An interactive data visualization tool
http://vizwit.io
GNU General Public License v2.0
100 stars 35 forks source link

Table doesn't render point fields as text #104

Open timwis opened 9 years ago

timwis commented 9 years ago

Shows [object Object] instead

marks commented 8 years ago

@timwis there is probably a more elegant way to do this (or better place to stash this code) but I think that stringify'ing the JSON is a good start to solving this bug.

demo: https://marks.github.io/vizwit/?gist=cf635692f034e9a81c16

marks commented 8 years ago

Finally, a clean commit from me to fix this issue. Got confused with different ticket numbers. Will be an easy merge if you want to do handle it this way

timwis commented 8 years ago

Pardon my delay on this. Going back and forth about this one because it has to loop through every record and every field in each record and test its type, and I'm wondering whether that geojson string looks any less confusing than [Object object] :-/

I think I have an idea -- in socrata-fields.js it maps socrata field types to DataTables field types using a hash at the top (typeMap). What if there was another hash for custom renderers using DataTables render option? For instance:

renderMap: {
  point: function (data, type, row, meta) {
    return data.coordinates ? data.coordinates[1] + ', ' + data.coordinates[0] : ''
  }
}

The only downside here is that it's putting table/view logic inside the fields collection. But maybe we could do it in the table view..thoughts?

marks commented 8 years ago

All good points. Let me look into a way to implement this.