Skip to content

[Bug] Bar positions on timeline #21269

@Lys-is

Description

@Lys-is

Version

5.5.1

Link to Minimal Reproduction

https://codesandbox.io/p/sandbox/apache-echarts-demo-forked-4vg9mg

Steps to Reproduce

just open https://codesandbox.io/p/sandbox/apache-echarts-demo-forked-4vg9mg

The bug is reproduced with the xAxis type = time and add any bars.

Current Behavior

Bars offset totally incorrect!

Image

Expected Behavior

The bars should be positioned exactly in their positions.

Environment

- OS: Ubuntu 20.04.6
- Browser: Chrome 139.0.7258.127
- Framework: Vue@2

Any additional comments?

src/layout/barGrid.ts

let offset = -widthSum / 2;
each(stacks, function (column, stackId) {
    result[coordSysName][stackId] = result[coordSysName][stackId] || {
        bandWidth: bandWidth,
        offset: offset,
        width: column.width
    } as BarWidthAndOffset[string][string];


    offset += column.width * (1 + barGapPercent);
});

if change it to

each(stacks, function (column, stackId) {
    result[coordSysName][stackId] = result[coordSysName][stackId] || {
        bandWidth: bandWidth,
        offset: -column.width / 2,
        width: column.width
    } as BarWidthAndOffset[string][string];
});

Everything is working as it should, but it seems that offset is needed for something :)). I have not found a single case where this would be necessary, everything seems to be working well.

If you tell me where this offset curve is needed, I will try to fix it and send you an pull request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugenThis issue is in EnglishpendingWe are not sure about whether this is a bug/new feature.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions