镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

[Feature] Support for 100% stacked charts #17179

Closed

Description

@Shaq76

What problem does this feature solve?

I am trying to emulate the functionality provided by Excel and echarts has no native support for 100% stacked charts.
I have tried to work around this by calculating the percentages myself but then you lose the original value tooltip.

There is an existing issue about this here:
#8785

Apache superset has already implemented this feature, see here: (in the superset code it's called a 'contribution')
apache/superset#13580

What does the proposed API look like?

My suggestion is that you extend the 'stack' syntax to support something like this:
stack: { name: 'male', type: '100%' }

Activity

  1. added
    enThis issue is in English
    pendingWe are not sure about whether this is a bug/new feature.
    on Jun 7, 2022
  2. Ovilia commented on Jun 8, 2022

    @Ovilia
    Contributor

    The advised way to do so is to calculate percentage as you said. The tooltip can set formatter or valueFormatter to calculate the original value. If you or anyone from the Apache Superset community wish to implement this in Apache ECharts, we would appreciate it very much. Maybe an option like stackPercent: true should be added.

  3. added and removed
    pendingWe are not sure about whether this is a bug/new feature.
    on Jun 8, 2022
  4. Shaq76 commented on Jun 8, 2022

    @Shaq76
    Author

    Hi @Ovilia, I tried implementing the tooltip in valueFormatter but I'm not given the params object (which is available a few levels up the call stack) so the only information I know is the percentage value. If I use the tooltip formatter instead then I lose the nice default tooltip containing the series colour and other information. Thanks for your help :)

  5. Ovilia commented on Jun 8, 2022

    @Ovilia
    Contributor

    You should probably save the sum to a variable that can be accessed by valueFormatter.

  6. Shaq76 commented on Jun 21, 2022

    @Shaq76
    Author

    Just a note that this looks similar in implementation to the following PR:
    #17086

  7. Creatium commented on Nov 7, 2022

    @Creatium

    Hi. Any updates on this? I still see no way to make bar charts stack to 100% easily, without hacking with 0.X values.

  8. LeoDiep commented on Sep 8, 2023

    @LeoDiep

    Hi. is this still updated

  9. 108EAA0A commented on Feb 22, 2024

    @108EAA0A

    +1, Please implement this

  10. Shaq76 commented on Feb 26, 2024

    @Shaq76
    Author

    Hi, I have looked at the two examples and these do work around part of the problem, but not fully.
    By transforming the incoming data in to percentages we can no longer get access to the original values.
    The result is that the tooltip can only show the percentage value, see below.
    image
    So the problem remains: I want to plot 100% stacked while keeping the source data as the original value?

  11. sjcobb commented on Apr 10, 2025

    @sjcobb
    Contributor

    Hi, I have looked at the two examples and these do work around part of the problem, but not fully. By transforming the incoming data in to percentages we can no longer get access to the original values. The result is that the tooltip can only show the percentage value, see below. image So the problem remains: I want to plot 100% stacked while keeping the source data as the original value?

    I've opened a PR #20910 to address this by adding stackPercent: boolean, which will show the original value and normalized value (as a percent of the total stack) in the tooltip:

    Image

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions