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

generateColor gets wrong color during select/unselect path #874

Closed
solgarius opened this issue Jan 9, 2015 · 4 comments
Closed

generateColor gets wrong color during select/unselect path #874

solgarius opened this issue Jan 9, 2015 · 4 comments
Labels
C-bug Category: This is a bug resolved maybe

Comments

@solgarius
Copy link

I have noticed when performing unselect on a path the 'd' node that is passed through to generate color is the object that contains a 'data' sub object with no id. This results in generateColor function not finding the color for the selected/unselected element and it will then just change the color of that path to the next unused color in the list of colors.

This is probably best seen in a pie chart. See: http://jsfiddle.net/lakerz/n8hqk3z1/
Steps to replicate:
1> select a pie segment
2> select a second pie segment
Note that the first segment is now red instead of its original color.

The fix for this should be pretty simple. It should be something along the lines of:

c3_chart_internal_fn.generateColor = function () {
        var $$ = this, config = $$.config, d3 = $$.d3,
            colors = config.data_colors,
            pattern = notEmpty(config.color_pattern) ? config.color_pattern : d3.scale.category10().range(),
            callback = config.data_color,
            ids = [];

        return function (d) {
            var color;
            var id = d.id || (d.data && d.data.id) || d;

            // if callback function is provided
            if (colors[id] instanceof Function) {
                color = colors[id](d);
            }
@aendra-rininsland
Copy link
Member

Ah. That indeed looks like a bug. Wanting to submit a pull request...? 😄

@aendra-rininsland aendra-rininsland added the C-bug Category: This is a bug label Jan 9, 2015
@masayuki0812
Copy link
Member

Thank you for reporting. I think this has been fixed by the commit above and I'll release as v0.4.9 shortly. Thanks.

@masayuki0812
Copy link
Member

v0.4.9 has been released, so please let me close.

@solgarius
Copy link
Author

Thanks @masayuki0812, works perfectly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug resolved maybe
Projects
None yet
Development

No branches or pull requests

3 participants