apache / echarts

Apache ECharts is a powerful, interactive charting and data visualization library for browser
https://echarts.apache.org
Apache License 2.0
60.7k stars 19.62k forks source link

[Bug] Can't reuse dimension in "encode" #20330

Open andrus opened 2 months ago

andrus commented 2 months ago

Version

5.5.1

Link to Minimal Reproduction

https://codesandbox.io/p/sandbox/loving-franklin-nscx3x?workspaceId=82a1e239-6a5d-480b-ae78-4592614b9767

Steps to Reproduce

Once the sample loads, you should see X and Y axis, but no line series

Current Behavior

The following option works fine and renders a straight line:

{
    dataset: {
        source: [
            ['s1',3,11,14],
            ['s1',3,11,14]
        ]
    },
    xAxis: [
    {
        type: 'value'
    },
    ],
    yAxis: [
    {
        type: 'value'
    },
    ],
    series: [
        {
            name: 's1',
            encode: {
                x: 0,
                y: 1,
            },
            seriesLayoutBy: 'row',
            type: 'line'
        },
    ]
}

But since both rows in the dataset are exactly the same, I tried to simplify it to the following code, which results in the empty grid and no line displayed:

 {
    dataset: {
        source: [
            ['s1',3,11,14]
        ]
    },
    xAxis: [
    {
        type: 'value'
    },
    ],
    yAxis: [
    {
        type: 'value'
    },
    ],
    series: [
        {
            name: 's1',
            encode: {
                x: 0,
                y: 0,
            },
            seriesLayoutBy: 'row',
            type: 'line'
        },
    ]
};

Expected Behavior

I should be able to specify the same dimension for both X and Y in "encode" like this: encode: {x: 0, y: 0}

Environment

- OS: MacOS 14.6.1
- Browser: Chrome 128.0.6613.120, FireFox 130.0
- Framework: DFLib - https://github.com/dflib/dflib . DFLib is a Java framework that can generate ECharts JS code. I am working on a new DFLib version that tries to reuse repeating data in the dataset.

Any additional comments?

No response

helgasoft commented 2 months ago

if X and Y have the same values, the chart will be a straight 45-degree line. How is this meaningful ?

andrus commented 2 months ago

Of course, but that's still valid, so why prohibit that?

yuicer commented 1 month ago

same question here, users should have right to arrange dataset. it's useful when using scatter to see density