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

Incorrect border highlight in Pie Charts #2381

Closed
Tutuchan opened this issue Apr 26, 2016 · 8 comments · Fixed by #5841
Closed

Incorrect border highlight in Pie Charts #2381

Tutuchan opened this issue Apr 26, 2016 · 8 comments · Fixed by #5841

Comments

@Tutuchan
Copy link

Hello,

When creating a pie chart with a hoverBorderColor, not all wedges borders are higlighted on mouseover.

See here: https://output.jsbin.com/jezuce/1
Some borders are black when highlighted while others are not.

@etimberg etimberg added this to the Version 2.0.x milestone Apr 27, 2016
@etimberg
Copy link
Member

@Tutuchan thanks for the report. I think the issue is draw order. The arcs are drawn clockwise so the 2nd arc overlaps one of the edges of the first arc.

@Tutuchan
Copy link
Author

Tutuchan commented May 5, 2016

I tried to take a look at this problem but I'm not sure I'm in the right track as I'm not really proficient with JavaScript.

I modified the draw function in controller.dougnut.js to be able to take a lastIndex parameter in order to redraw one of the arcs after all the others:

draw: function(ease, lastIndex) {
    var easingDecimal = ease || 1;
    helpers.each(this.getMeta().data, function(arc, index) {
    arc.transition(easingDecimal).draw();
    });
    if (lastIndex) this.getMeta().data[lastIndex].draw()
}

Then, in core.controller.js, I added a call to the draw function when setting the hover styling:

// Built in hover styling
if (this.active.length && this.options.hover.mode) {
    switch (this.options.hover.mode) {
        case 'single':
            this.getDatasetMeta(this.active[0]._datasetIndex).controller.setHoverStyle(this.active[0]);
            this.getDatasetMeta(this.active[0]._datasetIndex).controller.draw(0, this.active[0]._index);
            break;
...

This seems to be more or less working but the hovered edges do not appear on first entering the wedge, only when moving the mouse around and even then not immediately.

I don't know how to create a jsbin with this modified version but I forked it there.

@etimberg
Copy link
Member

etimberg commented May 5, 2016

@Tutuchan i think the angles in the doughnut controller need to be updated for the size of the border.

arc._model.endAngle = arc._model.startAngle + arc._model.circumference;
The circumference is in radians, but somehow the border width should also be taken into account

@Tutuchan
Copy link
Author

Tutuchan commented Jun 6, 2016

@etimberg I had some time to take a look at this and I'm not sure about the angles approach. The overlap between two segments is different on the inner radius and on the outer radius so even if you make it so the borders do not overlap near the outer radius, they will overlap near the inner one.

See here for example:

image

@knstntn
Copy link

knstntn commented Jun 24, 2016

+1

@steve231293
Copy link

Hi everyone, seem this bug is not fixed yet, any help?

@development-s365
Copy link

+1

@GiorgioMartini
Copy link

+2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants