facets
facets copied to clipboard
Accept JSON data on <facets-overview> component
Would there be a way to use the <facets-overview> component without creating a protobuf? I'd love if there could be some default inference, taking data= in the same way the <facets-dive> works.
Something similar is supported now but still needs documenting. The facets-overview element has a method getStatsProto that accepts an array of objects where each object is a dict of features to values (so it accepts json when it is an array of flat objects) which returns the calculated proto which can then be provided as the protoInput param on the element.
Does that work for your use case?
You can see it being used on the gh-pages branch which contains the demo site's code: https://github.com/PAIR-code/facets/blob/gh-pages/index.html#L237
Trying that out now, getting a long line of blue squares. 😉
In case you're curious, I was playing with this here: https://github.com/nteract/commuter/pull/211
Were you able to get overview working with the getStatsProto method to convert an array of data item dicts into the feature stats proto?
Nope.
Not sure what those crazy blue squares are (is the facets-overview element taking up a reasonable width and height?), but if the getStatsProto method is returning a valid proto object, then setting the protoInput property on the polymer element to that proto should be all it takes. At first glance, the code you linked to seems reasonable, although I'm not familiar with react.
Because facets-overview supports multiple sources of data, getStatsProto takes an array of data in a format of:
[ {data: [], name: 'test.csv'}, {data: [], name: 'test2.csv'} ]
where the array in data has the same json data format that is used for facets-dive.