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

Bar stacking doesn't work if the x-axis is value type instead of category type #15102

Closed
dirslashls opened this issue Jun 7, 2021 · 7 comments
Labels
bug en This issue is in English pending We are not sure about whether this is a bug/new feature. stale Inactive for a long time. Will be closed in 7 days. waiting-for: community

Comments

@dirslashls
Copy link

Version

5.1.1

Steps to reproduce

Use the following in the editor

option = {
    xAxis: {
        type: 'value',
        data: [1,2,3,4,5,6,7]
    },
    yAxis: {
        type: 'value'
    },
    "legend": {
        "show": true,
        "type": "scroll",
        "padding": 5,
        "selector": [
            "all",
            "inverse"
        ],
        "top": 5
    },
    series: [{
        name: "a",
        data: [120, 200, 150, 80, 70, 110, 130],
        type: 'bar',
        stack: 'one'
    }, {
        name: "b",
        data: [120, 200, 150, 80, 70, 110, 130],
        type: 'bar',
        stack: 'one'
    }]
};

What is expected?

I expected to see a stacked bar chart.

What is actually happening?

It shows only one of the two series.


Just change the type from 'value' to 'category' for xAxis and everything is good.

@echarts-bot
Copy link

echarts-bot bot commented Jun 7, 2021

Hi! We've received your issue and please be patient to get responded. 🎉
The average response time is expected to be within one day for weekdays.

In the meanwhile, please make sure that it contains a minimum reproducible demo and necessary images to illustrate. Otherwise, our committers will ask you to do so.

A minimum reproducible demo should contain as little data and components as possible but can still illustrate your problem. This is the best way for us to reproduce it and solve the problem faster.

You may also check out the API and chart option to get the answer.

If you don't get helped for a long time (over a week) or have an urgent question to ask, you may also send an email to dev@echarts.apache.org. Please attach the issue link if it's a technical question.

If you are interested in the project, you may also subscribe our mailing list.

Have a nice day! 🍵

@echarts-bot echarts-bot bot added bug en This issue is in English pending We are not sure about whether this is a bug/new feature. waiting-for: community labels Jun 7, 2021
@angrytongan
Copy link

This is very lightly mentioned in the series-bar documentation, but should definitely be more prominent.

@dirslashls
Copy link
Author

Some fields like grade of the student are numeric. What I see with bar charts is that they work great with category axis type and the data being string. If it is value type and/or numeric data then there are challenges. Any reason for limiting the full bar chart capabilities for value type and numeric data?

@hughess
Copy link

hughess commented Nov 2, 2021

+1 for needing stacking on a value axis.

Biggest problem for me with this is missing values - there may be parts of your x-axis where none of your series have any observations. It's a pain to have to iterate through the dataset and prepare it so that it shows missing data.

For example:

series1 = [
   [3, 10],
   [4, 13],
   [5, 16],
   [8, 21]
]

series2 = [
   [3, 15],
   [4, 17],
   [5, 21],
   [8, 23]
]

Using a category axis with this data won't show 6 or 7 on the axis. Using value would work if stacking was possible.

The current workaround for this would be to iterate through each of these series, see which x values are missing, and recreate the data so that 6 and 7 are included as rows in each dataset.

One approach that might work is to treat this situation in the same way as a histogram:

  • Assume a default interval based on the data provided to the chart (e.g., if it's years or integers, interval = 1. If it's a continuous variable, have some default logic to assume an interval)
  • Bin the data using the interval
  • Plot the data, effectively treating the x-axis as a category axis
  • You could probably even explicitly treat the axis as category - at least for me, I don't care if the axis is value or category. I would just prefer not to have to write the code to check/fill values for each chart I build

Copy link
Contributor

github-actions bot commented Nov 2, 2023

This issue has been automatically marked as stale because it did not have recent activity. It will be closed in 7 days if no further activity occurs. If you wish not to mark it as stale, please leave a comment in this issue.

@github-actions github-actions bot added the stale Inactive for a long time. Will be closed in 7 days. label Nov 2, 2023
Copy link
Contributor

This issue has been automatically closed because it did not have recent activity. If this remains to be a problem with the latest version of Apache ECharts, please open a new issue and link this to it. Thanks!

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 10, 2023
@mitar
Copy link

mitar commented Jan 10, 2024

This has been mentioned many time in other issues: #16765, #7937. Similar: #16744.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug en This issue is in English pending We are not sure about whether this is a bug/new feature. stale Inactive for a long time. Will be closed in 7 days. waiting-for: community
Projects
None yet
Development

No branches or pull requests

4 participants