-
Notifications
You must be signed in to change notification settings - Fork 13.7k
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(echarts-pie): add string template support for labels #28774
feat(echarts-pie): add string template support for labels #28774
Conversation
/testenv up |
@rusackas Ephemeral environment spinning up at http://34.223.245.15:8080. Credentials are |
This is pretty cool!!! Think it's worth adding some tests to make sure things display as expected? We don't need to test that ECharts works as expected, but maybe just make sure the transformProps file works (and continues to work) as expected. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but leaving it open awaiting feedback about the testing comment.
Thanks @rusackas , I'll add some tests later |
I also think this is a great direction, and one we should consider for all charts. As this can be difficult to change after merging, I would almost doing a quick SIP round to make sure we have a solution that is generic enough to work for all charts. CC @michael-s-molina |
While working on SIP-50, I noticed many inconsistencies between ECharts plugins. They range from missing control types to control types that treat the same information differently. I believe the main cause for the problem is because we treat each plugin individually when adding new features. This leads to duplicated code and poor UX. My plan is to review all Explore controls after we complete the ECharts migrations and make sure they are consistent between plugins (same code, same behavior).
This would certainly help given that the control and code would be the same for all plugins. |
Another thing is that we would need a clear description of how the template works and which variables are available. Maybe in the form of a tooltip. |
There are already instructions on a tooltip in this PR... you can see it in the ephemeral env if you want to try it out :) |
@rusackas Thank you for the info.
That would be helpful indeed. |
|
Why yes, that does help! 😍 |
I'll drop a related thought I've been playing around with: In Tableau it's possible to add the equivalent of metrics as tooltip fields. This is really useful, as you may want to have the main metric in the chart, but then display other related metrics for the same series. Also we should expose all existing formatters etc to make it possible to customize the final format. I feel this templating feature should support this. So if we were to make it possible to add additional metrics that don't show up on the chart, but would then be able to reference those on the tooltip, I think we'd close a big gap to Tableau. The flow could be something like this:
The exact syntax and control solution for adding the extra metrics would need to be ironed out first, of course, and I propose doing this in a dedicated SIP for this. |
Ephemeral environment shutdown and build artifacts deleted. |
Ok, so this is cool, it's useful, and it seems portable. Worth merging in my book! I completely agree with the other points on the thread: |
SUMMARY
Currently, we support several static label types:
Providing a dynamic way for users to customize labels could be a great and innovative feature, making our pie charts more useful.
We have introduced a new label type called
template
to support this feature. Users can customize the label by writing a string template. The string template supports the following variables:{name}
the name of a data item{value}
the value of a data item, formatted with number format option{percent}
the percentage of a data item, formatted with number formatterAdditionally, for ECharts compatibility, the following variables are supported:
{a}
series name.{b}
the name of a data item, unformatted{c}
the value of a data item, unformatted{d}
percentage, unformatted\n
is supported to represent a new line.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Formatted variables:
ECharts compatible variables:
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION