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

feat[pie/donut]: custom tooltips for aggregate #305

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

riccardogioratoatoms
Copy link

@riccardogioratoatoms riccardogioratoatoms commented Aug 28, 2020

Explanation About What Code Achieves:

This code fixes the issue I had with tooltips with pie charts and donuts charts, like I mentioned it here: #304

Considering the fact that these kind of graph have only 1 value I choose the naming of the function as tooltipOptions.formatTooltip without X or Y like it's possible to do with other kind of graphs.

Screenshots/GIFs:

image

TODOs:
  • maybe it would be nice to document this in the docs with a simple example too?
  • might be usefuel for the "progress" chart too to anyone?

Solves: #136

@scmmishra scmmishra self-assigned this Sep 1, 2020
@riccardogioratoatoms
Copy link
Author

Any news on this @scmmishra, would you like me to edit something?

@scmmishra
Copy link
Contributor

Hey @riccardogioratoatoms so sorry for the delay. I've been very busy lately with a few stuffs, I'll definitely review this tomorrow. On the surface it looks good to go, there won't be any changes required it seems.

I'll update the documentation for it as well.

Copy link
Contributor

@scmmishra scmmishra left a comment

Choose a reason for hiding this comment

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

We could extend the same to percentage chart as well

@@ -119,7 +122,11 @@ export default class PieChart extends AggregationChart {
let title = (this.formatted_labels && this.formatted_labels.length > 0
? this.formatted_labels[i] : this.state.labels[i]) + ': ';
let percent = (this.state.sliceTotals[i] * 100 / this.state.grandTotal).toFixed(1);
this.tip.setValues(x, y, {name: title, value: percent + "%"});
let valueTooltip = percent + "%";
if(this.config.formatTooltip){
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason to not reuse the formatTooltipX and formatTooltipY?

Choose a reason for hiding this comment

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

I didn't want to confuse this single type of values of aggregate charts with the charts legend X and Y cause in aggregate the concept of X and Y is not present.

Copy link
Contributor

Choose a reason for hiding this comment

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

formatTooltip itself is very generic, can we name it better? formatAggrTooltip is something that I can think of now, do you have any suggestions?

Copy link
Contributor

Choose a reason for hiding this comment

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

Beyond this, the feature works like a breeze, we're good to merge it.

Copy link
Contributor

@scmmishra scmmishra left a comment

Choose a reason for hiding this comment

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

I notice, this is not available for percentage chart, let's extend it to that too.

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