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

Cleanup redundant code in Sunburst chart #1660

Merged
merged 2 commits into from
Mar 5, 2020

Conversation

kum-deepak
Copy link
Collaborator

While working on some other refactors, I came across this.

Removing this code does not seem to have any impact. Test cases still pass, the charts work. In addition, reading the code makes the believe that the BaseMixin's implementation covers the needs of this chart.

@gordonwoodhull
Copy link
Contributor

It's apparently a performance improvement: 601e723

Probably to avoid the second case in the loop of the default filter handler:

dimension.filterFunction(d => {
for (let i = 0; i < filters.length; i++) {
const filter = filters[i];
if (filter.isFiltered && filter.isFiltered(d)) {
return true;
} else if (filter <= d && filter >= d) {
return true;
}
}
return false;
});

Correct fix for the workaround you propose removing would be

            if (filter.isFiltered) {
                if(filter.isFiltered(d)) {
                    return true;
                }
            } else if (filter <= d && filter >= d) {
                return true;
            }

I don't think we ever want a filter object which has .isFiltered and should be second-guessed if it returns false.

@kum-deepak
Copy link
Collaborator Author

Thanks! Makes sense.

@kum-deepak
Copy link
Collaborator Author

I am working on an experimental PR to refactor filters, dimensions, and groups. I will commit an initial version and future thoughts soon.

@gordonwoodhull
Copy link
Contributor

Cool, thanks @kum-deepak!

@kum-deepak kum-deepak deleted the cleanup branch March 19, 2020 06:46
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.

2 participants