Skip to content

Fix issue where styles weren't reset when re-using SVGs in colorbar #5217

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

Merged
merged 3 commits into from
Oct 19, 2020

Conversation

anaplian
Copy link

@anaplian anaplian commented Oct 17, 2020

Fixes #5161

@archmoj
Copy link
Contributor

archmoj commented Oct 19, 2020

Good catch!
Before vs After.

@archmoj
Copy link
Contributor

archmoj commented Oct 19, 2020

@anaplian to lock this issue, would you please add a test possibly to the end of this block?

describe('drawing & editing', function() {

To run the colorbar test locally you could simply use

npm run test-jasmine -- colorbar

Thanks!

@anaplian
Copy link
Author

@archmoj Thanks! I have added a test. Let me know what you think 😄


var expectedAttrs = [];
var actualAttrs = [];

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test looks great.
Non-blocking, but maybe you could add a getter function to avoid duplication:
Something like:

function pushItemsTo(a) {
    var colorbars = d3.select(gd).selectAll('.colorbar');
    colorbars.selectAll('.cbfill').each(function() {
        var attrsForElem = {};
        for(var i = 0; i < this.attributes.length; i++) {
            var attr = this.attributes.item(i);
            attrsForElem[attr.name] = attr.value;
        }
        a.push(attrsForElem);
    });
}

Plotly.newPlot(gd, [{type: 'contour', z: z}])
.then(function() {
    pushItemsTo(expectedAttrs);

    return Plotly.newPlot(gd, [{type: 'heatmap', z: z}])
    .then(function() {
        return Plotly.react(gd, [{type: 'contour', z: z}]);
    });
})
.then(function() {
    pushItemsTo(actualAttrs);

    expect(actualAttrs).toEqual(expectedAttrs);
})

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 🙂

@archmoj
Copy link
Contributor

archmoj commented Oct 19, 2020

Nicely done!
Thanks very much @anaplian 🥇
💃

@archmoj archmoj merged commit 6eac0b3 into plotly:master Oct 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken community community contribution
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lowest colormap color is set to white when chart type is changed to contour
2 participants