Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix label for missing values in CategoricalStackedDistributionlCellRenderer #118

Merged
merged 2 commits into from
Nov 30, 2018

Conversation

thinkh
Copy link
Member

@thinkh thinkh commented Nov 30, 2018

closes datavisyn/tdp_core#144

prerequisites:

  • branch is up-to-date with the branch to be merged with, i.e. develop
  • build is successful
  • code is cleaned up and formatted
  • tested with Firefox 52, Firefox 57+, Chrome 64+, MS Edge 16+

Summary

Debugging datavisyn/tdp_core#144 revealed that the missing value div is rendered two times:

image

The first one is added right after mapping the categories:

https://github.com/datavisyn/lineupjs/blob/c0a9ba907f6cb1cd64024958453331a206314c33/src/renderer/CategoricalStackedDistributionlCellRenderer.ts#L91

The other one is introduced in the renderer template.

The duplication leads to a problem, as the renderer iterates over the DOM collection and there are less categories available.

https://github.com/datavisyn/lineupjs/blob/c0a9ba907f6cb1cd64024958453331a206314c33/src/renderer/CategoricalStackedDistributionlCellRenderer.ts#L98-L103

I removed the last div from the renderer template and now the number of children is correct and the bug is fixed:

image

@sgratzl Please have a look, if my fix has some side effects. Because you know best, if the removed missing value div is used elsewhere.

@sgratzl
Copy link
Member

sgratzl commented Nov 30, 2018

The duplication leads to a problem, as the renderer iterates over the DOM collection and there are less categories available.

but it checks:

const y = i >= hist.length ? missing : hist[i].y; 

thus for the last one it takes the missing value

@thinkh
Copy link
Member Author

thinkh commented Nov 30, 2018

Correct. I get the documented error, since there are 44 DOM elements are available, but only 43 items are available in cat. So either the last DOM element for the missing values must be replaced or removed.

@sgratzl
Copy link
Member

sgratzl commented Nov 30, 2018

so you actually wanna have

const label = i >= cats.length ? 'Missing Values' : cats[i].label; 

@thinkh
Copy link
Member Author

thinkh commented Nov 30, 2018

Yes! That works, even though there are still more DOM elements than categories.

image

@thinkh thinkh changed the title Remove missing value div from CategoricalStackedDistributionlCellRenderer template Fix label for missing values in CategoricalStackedDistributionlCellRenderer Nov 30, 2018
@sgratzl
Copy link
Member

sgratzl commented Nov 30, 2018

on purpose. if you have a group with 50% missing values then stacked bar should also just go to 50% of the width.

@thinkh
Copy link
Member Author

thinkh commented Nov 30, 2018

I see. Thanks for the fix and the explanation. 👍

@thinkh
Copy link
Member Author

thinkh commented Nov 30, 2018

@sgratzl Should I merge the PR or will you do it?

@sgratzl sgratzl merged commit e93f82e into develop Nov 30, 2018
@sgratzl sgratzl deleted the thinkh/fix-cat-stack-dist-cell-renderer branch November 30, 2018 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants