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

pie chart labels #12174

Merged
merged 10 commits into from
Nov 17, 2017
Merged

pie chart labels #12174

merged 10 commits into from
Nov 17, 2017

Conversation

ppisljar
Copy link
Member

@ppisljar ppisljar commented Jun 5, 2017

Release Notes: Users can now add labels to pie charts.

image


Resolves #1702
partly addresses: #3686

summary: pie charts can now have labels on them to increase readability

@ppisljar ppisljar added Feature:Visualizations Generic visualization features (in case no more specific feature label is available) v6.0.0 v6.0.0-beta1 labels Jun 5, 2017
@ppisljar ppisljar requested a review from thomasneirynck June 5, 2017 16:50
@ppisljar ppisljar changed the title [WIP] pie chart labels pie chart labels Jun 6, 2017
@ppisljar ppisljar requested a review from marius-dr June 6, 2017 07:40
@ppisljar
Copy link
Member Author

ppisljar commented Jun 9, 2017

jenkins, test this

};

const conflicts = [];
let conflictIterations = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

this algo is a little dense for me. might help to go over with me in person.

Copy link
Contributor

@thomasneirynck thomasneirynck left a comment

Choose a reason for hiding this comment

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

Below some initial comments already:

this is genuinely a nice addition. It makes the pie charts a lot more usable.

I particularly like how readable it is, and I love the use of the "elbowed" connector lines. The left-right alignment makes the labels very readable. Pretty great approach IMO!

Most of the below is mainly minor comments. Biggest suggestion is to simplify the conflict detection. FWIW, I'd prefer fewer labels on screen with a more clean consistent layout of the connector-lines, than more labels but with a more complicated connector-lines. Perhaps others have different opinion.

  • positioning for a single label doesn't work right. It overlaps with the connector.

image

  • the double-rind pie chart is difficult visually to begin with. But for consitency, I would diplay labels on both sides, not just the right side.

image

  • can we make the labels and connecting lines the color of the pie-slice?

  • conflict detection:

    • the conflict detection discards entire swats of labels. e.g. notice how labels on the entire left side are dropped.
      image
    • Is it possible to have just a greedy algorithm that places each label in order. If there is room, it puts the label, if it does not, it does not place it. The current implementation seems to do more complex things.
    • Right now, by flipping the orientation the elbow of the connecting-lines, we get overlaps that hurt legibility. IMHO, this complexity isn't necessary. I think part of the cleanliness of the connectors is that because of the elbows, lines going out from all four quadrants never overlap. e.g.: overlapping connector-lines make it look more of a spaghetti
      image
  • the truncation parameter is a little bit voodoo. I think mainly because we are using pixels, which isn't all that intuitive.

    • can we use char-count iso pixels?
    • can we truncate the actual label, instead of replacing it with ... So e.g. foobar would become fo... and not ...
    • perhaps we should get rid of the truncation option anyway (?)

@ppisljar
Copy link
Member Author

thanks for looking into this @thomas ... answers to some of your comments

  • fixed the bug with single label

  • missing labels on the right side were not related to conflict resolution, but were simply pushed out too far to the left (and then hidden as they would go out of the vis bounds) ... i updated this to show labels closer to the pie itself, however you can still get into that scenario (on dashboard for example you should not make your container square .... but 'widescreen' so it can fit the labels as well.

  • colors of lines and texts: we loose legibility quite fast (think of light yellow slices)

  • truncation .... i would leave it as it is in this PR for consistency reasons (its like this everywhere else we have it). but i agree we should update this (everywhere).

@ppisljar
Copy link
Member Author

flipping of elbows: we don't flip them ... thats the thing ... elbow is always drawn thru 3 points:

  • centroid of the slice
  • middle point where x = centroid of outer arc and y = label y
  • label position

doesn't work well in all scenarios ... but not sure its worth complicating, it will mostly be used for simple charts probably.

@thomasneirynck
Copy link
Contributor

I didn't explain well enough about the "elbows". I mean, the elbow flips when you move labels that connect one quadrant of the pie to another quadrant. that's how you get that overlap.

e.g.: when there's a pie slice in the bottom-left quadrant, but position the label in the top-left quadrant, the "elbow" flips, and the connector-line crosses the chart.

agreed on preserving the black color, doing otherwise would make it worse

@ppisljar
Copy link
Member Author

@thomas i simplified conflict resolution a bit ... now elbows wont 'break' ... simply if label cant be positioned without conflict its skipped ....

this will render less labels, and won't prioritize labels with bigger slice size over the labels with smaller slices ... let me know what you think

@thomasneirynck thomasneirynck self-requested a review June 26, 2017 13:42
Copy link
Contributor

@thomasneirynck thomasneirynck left a comment

Choose a reason for hiding this comment

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

the below looks really really slick IMO

image

so lgtm from me, just on look&feel alone.

I would add a textual description of how the algorithm is supposed to work (and does work). That is probably one of the densest, low level pieces of code in Visualize, so it should be documented.

I am running into some issues where the algorithm can be slow and cause the visualization to "hang up" for a minute or so. Granted, these were for some more "academic" layouts (ie. 250 slices), that may not arise in practice.

I haven't tested this on Reporting yet.

@manninge
Copy link

So I see this has been solved, but I do not see the 'how to'. I am new to Kibana, so a little green. Picking up a project dumped by someone else and I need to add labels to the pie slices. Thanks.

@ppisljar ppisljar requested a review from timroes November 9, 2017 13:14
@thomasneirynck
Copy link
Contributor

Created #14926 to solve merge issues.

@timroes
Copy link
Contributor

timroes commented Nov 14, 2017

Close this in favor of #14926

@timroes timroes closed this Nov 14, 2017
@ppisljar
Copy link
Member Author

@timroes all your comments were addressed (from #14926)
@alexfrancoeur almoust all your comments were addressed ... for now i didn't add another checkbox to actually show the value in labels (instead of percentage) ... i guess we can do that as a follow up, when somebody opens an issue for it.

Copy link
Contributor

@timroes timroes left a comment

Choose a reason for hiding this comment

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

LGTM once the test passes

@ppisljar
Copy link
Member Author

CI failed on fail: "management import objects should allow for cancelling overrides" which i think is unrelated ... restarting

jenkins, test this

@ppisljar
Copy link
Member Author

CI failed on fail: "visualize app tile map visualize app tile map chart should save with zoom level and load, take screenshot" which is also unrelated ....

you just have to love our CI :)

jenkins, test this

@thomasneirynck
Copy link
Contributor

thomasneirynck commented Nov 17, 2017

when merging, could you also add a small summary paragraph to the description? it'll add it to the release-notes, thx!

@ppisljar ppisljar merged commit 5793410 into elastic:master Nov 17, 2017
ppisljar added a commit to ppisljar/kibana that referenced this pull request Nov 17, 2017
* pie labels

* add simple unit test

* fixing dashboard test

* fixing basedo on review

* simplifying conflict resolution

* removing unused code

* cleanup code

* minor changes based on review

* updating option templates to match new design

* updating truncate_labels to work with chars instead pixels
ppisljar added a commit that referenced this pull request Nov 17, 2017
* pie labels

* add simple unit test

* fixing dashboard test

* fixing basedo on review

* simplifying conflict resolution

* removing unused code

* cleanup code

* minor changes based on review

* updating option templates to match new design

* updating truncate_labels to work with chars instead pixels
@ppisljar
Copy link
Member Author

backport 6.x: 0b5052a

@alexfrancoeur
Copy link

yes @ppisljar!!! 🍻

@gui-f
Copy link

gui-f commented Jan 17, 2018

Great news!

However, I believed that on this version the # of counts of documents within legends of certain chart types (like bar and pie) would be available again.

image

Is there any way to include these informations on charts with terms aggregation?

@ppisljar
Copy link
Member Author

you are right, currently you can only show the percentage value, but not the actual document count.
could you open a separate issue for that ? thanks!

@cawoodm
Copy link

cawoodm commented May 29, 2020

I'm still seeing no values on my Pie chart if I disable Labels (which I don't want) but enable Values (which I do want):

image

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Visualizations Generic visualization features (in case no more specific feature label is available) release_note:enhancement v6.1.0 v7.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add labels to pie chart
7 participants