civic-data-design-lab / atlas-lighting

atlas-of-lighting-web-application
4 stars 6 forks source link

Brush update. #140

Closed egeozin closed 7 years ago

egeozin commented 7 years ago

@Kallirroi if you have time, an extra hand/mind would help me a lot. I have a question for you in the end.

So our probably last major challenge,

[1] When a brush is selected in any of the dc charts, [2] and a particular business type or instagram topic is repetitively selected and deselected a couple of times (try 4 or 5),

selecting and deselecting 3 times:

screen shot 2017-03-04 at 7 29 40 pm

selecting and deselecting 5 times:

screen shot 2017-03-04 at 7 31 05 pm

a. the dc charts y-axis scale changes b. the data within the brush range doesn't change but because the scale of the unbrushed bins change we only see the bins in the brushed range reduce in size to the point where they become barely visible.

[3] When the brush is released from that dc chart, the data looks skewed and the number of cells show mistakenly large number for example for SanJose, it shows 16 095 cells after selecting and deselecting a business type repetitively for 5 times.

[4] The data becomes normal when no brush is selected in any dc chart but a business type or an instagram topic is selected and deselected. Because what happens here is we bind the original data(the one that is not filtered with anything) to window.ndx.

Possible solutions:

  1. https://github.com/dc-js/dc.js/blob/master/web/examples/replacing-data.html

This records the previous filters on a dc chart and reapplies them after ndx.remove() but before ndx.add() . I've tried this but some cells were not able to be assigned to something so this " NaN" errors proliferated(around 36 errors,) but everything looks like how we wanted to be.

  1. Find a way to reapply the original data to dc chart after filterCells update (Any ideas on this @Kallirroi)

  2. Disabling selecting brushes before selecting a type or topic tag but enabling after selecting a type or topic tag . (Which is a little weird to ask from people)

egeozin commented 7 years ago

I've fixed this. Will push an update in the morning.

cosmicespresso commented 7 years ago

ah good bc I have been looking at it for the past half hour trying to understand the problem! 😌

egeozin commented 7 years ago

Discrepancy fixed in c75e9c4, but after deselecting the final tag in busTypes/instaTopics chart, brush is still there but without filtering the cells on the map.

You have to move the brush to start refiltering correctly.

@Kallirroi , do you know how to remove the brush at any time on dc charts. That might be useful in this context

cosmicespresso commented 7 years ago

maybe this can help? https://github.com/dc-js/dc.js/issues/151

egeozin commented 7 years ago

@Kallirroi , that didn't help, but if we can solve this the big problem will end.

cosmicespresso commented 7 years ago

I will work on implementing the Case Studies and will return to this and OBI later.

egeozin commented 7 years ago

To be more specific:

  1. I tried saving the pre-filterCells-function/tag-selection filters from each dc chart before starting updating the ndx with( ndx.remove()). Then re-uploading them to the dc charts that had filter before the filterCells just before ndx.add(newData) as suggested in here:

https://github.com/dc-js/dc.js/blob/master/web/examples/replacing-data.html

But, unfortunately, this produced some(mostly around 40) rect - NaN errors, although we were able to get the pre-filterCells-function/tag-selection filters on dc charts.

I would not recommend going this route, as a more trained eye will notice those errors on chrome inspector, and it will not look fun.

  1. [Recommended Route] When the selected last tag(whether in instaTopics or busTypes) is deselected, we have to get rid of all the filters out there(including the ones on dc charts). I know this is a little weird but this is what we can do with our current configuration of dc and d3 charts combination. This produces no errors, but we have to get rid of brushes on dc charts after deselecting the last tag in busTypes/instaTopics chart.
egeozin commented 7 years ago

One more idea on this (that is most likely to work):

Keep the old configuration, make brushes look weird when brushed and tag selected but find a way to bind originalData to charts dimension when deselecting all tags.

egeozin commented 7 years ago

Fixed in e55e0a5