echarts icon indicating copy to clipboard operation
echarts copied to clipboard

[Bug] do not combine dates on the chart line, when setting "stack" and type: 'time'

Open lexoring opened this issue 3 years ago • 9 comments

Version

5.3.1

Link to Minimal Reproduction

https://echarts.apache.org/examples/en/editor.html

Steps to Reproduce

option = {
  legend: {},
  xAxis: {
    type: 'time', min: '2018-08-09 10:00:00',
    name: 'Date',
  },
  yAxis: {
    type: 'category',
  },
  dataset: [
    {
      id: 'q1',
      source: [
        ['nm1', 'er1', 'er2'],
        ['bar', '2018-08-10 10:00:00', '2018-08-11 20:00:00'],
      ]
    }
  ],

  series: [
      { type: 'bar',  datasetId: 'q1', stack: 'bar1', name: 'start',
          encode: {
            x: 'er1',
            y: 'nm1'
          },
        itemStyle: {
          color: 'red'
        },
      },
      { type: 'bar', datasetId: 'q1',  stack: 'bar1', name: 'end',
          encode: {
            x: 'er2',
            y: 'nm1'
          },
        itemStyle: {
          color: 'blue'
        }
      }
  ]

};

Current Behavior

do not combine dates on the graph line when setting "stack".

If you specify the data as a date and combine it through a stack, then the graph is superimposed on each other. The stack does not work for type: 'time', but if you specify type: 'value ', then everything works.

Expected Behavior

So that the schedule does not overlap with each other

Environment

- OS:windows 10
- Browser: Chrome 98
- Framework: -

Any additional comments?

No response

lexoring avatar Mar 29 '22 13:03 lexoring

Hi, for now time and category type axis does not seem to support stack. Only value and log axis supports stack. @plainheart @pissang Should we add a notice about the scope of stack usage to documentation?

jiawulin001 avatar Mar 30 '22 01:03 jiawulin001

@lexoring If you want to show time period, you may refer to Gantt Chart.

jiawulin001 avatar Mar 30 '22 01:03 jiawulin001

I think we should. stack is meaningless on the time and category axis

pissang avatar Mar 30 '22 01:03 pissang

I am experiencing this same issue with x-axis being a category; however not sure if related, I am using multiple series on Y-axis, and if I disable certain one's, it will show the data of the one's hidden from stacking, and if all enabled, it will stack incorrectly, and not appear in the tooltip on hover. with all enabled: image vs if I disable the pink image

ozdv avatar Jun 20 '22 16:06 ozdv

@ozdv Would you like to show us the code you are using?

jiawulin001 avatar Jun 21 '22 01:06 jiawulin001

@jiawulin001 Here is the code showing the data:

                        .map((dataPoint) => ({
                            // eslint-disable-line prettier/prettier
                            ...dataPoint, // the format we use
                            // the format echarts axis uses
                            value:
                                layout === 'horizontal'
                                    ? [dataPoint[xDataKey], dataPoint[serum.name], dataPoint[zDataKey]]
                                    : [dataPoint[serum.name], dataPoint[yDataKey], dataPoint[zDataKey]],
                        }))
                        .filter((point) => point.value[0] !== undefined && point.value[1] !== undefined),

When console logging data, it shows that the 5th column has the values:

{
    "veqwGEb4DiZugpQJG9TiQ": 59.16498827262963,
    "UdEZvxRplMLIp2u0UDMCf": 18.090609023464722,
    "sqeJySXDsyyrErIfSv6Ld": null,
    "ik4ue89ET8QfseEE1HtGB": null,
    "aVMOxXnch1ftsMvwKR89q": 71.40060481507766,
    "j38A@F8N8mpreQmlRiKv8": "SHG"
}

and as seen in the first picture, it is only showing the 59.16 and 71.4 values. Then if you remove the 59.16 value in legend, it shows the 18.09 value.

Yet weirdly enough the last column shows the data appropriately:

{
    "veqwGEb4DiZugpQJG9TiQ": 119.79032873964,
    "UdEZvxRplMLIp2u0UDMCf": 70.82665533598106,
    "sqeJySXDsyyrErIfSv6Ld": null,
    "ik4ue89ET8QfseEE1HtGB": null,
    "aVMOxXnch1ftsMvwKR89q": 67.60575370017129,
    "j38A@F8N8mpreQmlRiKv8": "WLD"
}

Does this help illustrate it? Or is there other portions of the code that could help? Thank you!

ozdv avatar Jun 27 '22 19:06 ozdv

I think we should. stack is meaningless on the time and category axis

Hi, why is it meaningless? For such kind of graph (energy consumption by source), to allow to zoom into year/month/day/hour.

Griffe27 avatar Oct 24 '22 10:10 Griffe27

@jiawulin001 Here is a simple example that I believe shows the "gap" issue mentioned by @ozdv -- I believe the problem is something to do with what happens when some series do not have data for all x-axis values. In some cases, this also causes an overlap in the series bars. By changing the version of echarts used, you can see this was not a problem in 5.2.2, but is a problem in every version from 5.3.0 https://echarts.apache.org/examples/en/editor.html?c=bar-simple&code=PYBwLglsB2AEC8sDeAoWsAeBBDEDOAXMmurGAJ4gCmRA5JALZW0A0JAvm-uTvkaqTKUasWgDcAhgBsArsw5dYAEwlgJeKmCIBtEuiTKITaHigmdtCEtajgAIw0AnMVSUB9VTfHS5tALossHjAMo4AxiK6gvqwVnQAjDb2Ti7uqkTxgZKyIvGw7HqwfvmKMUpGVCZmhLDaltaBtMlUzq4eYF7ZvgFBIeGRhTFxogBMSQ4tqe1EI1k-IiP5hcUF6AEkThBUNVGkAtEU1HR2Eo6sg8qq6poAktBKVBhEAAylpMMARPEfb-h4amEANZED5gYBqKQ_C6VMLAB78C7oJ62CatNIdX6kch0LryaJLQScQr7QSHES0E5nTEqNQaMB3B7IzIXT4jKH4_4SIEgsEQ9nRGFwkQk6LIpqoqaeTHcHHzWgXVakIlrFDsADcQA&version=5.3.0

5.2.2

Screenshot 2024-04-30 at 1 03 36 PM

5.3.0

Screenshot 2024-04-30 at 1 04 00 PM

EmilyRagan avatar Apr 30 '24 19:04 EmilyRagan

@jiawulin001 The gap and overlap issue is even happening when using type: 'value' for the xAxis:

5.2.2

Screenshot 2024-04-30 at 3 30 49 PM

5.3.0

Screenshot 2024-04-30 at 3 15 48 PM

https://echarts.apache.org/examples/en/editor.html?code=PYBwLglsB2AEC8sDeAoWsAeBBDEDOAXMmurGAJ4gCmRA5AG4CGANgK5W0kC-ANCeTnxFUpMpRqwGLdp3S8SAE0ZhGeKmCIBtEuhGjYeYKwBOAYwnb9pJLGiMAthNoAhWj0wA1aRICM78l5sEgBMsPJWurYOTq7uGIHsRADM_gkhYXwRyFGOdLGe3kQArKmFsKFcOqQAupn6ChCO0HhQzVpVorR2jm4dpLQB3r1ZtPFDfdVV4dZ9hibm7Vk23U5YbgVBRH6wg5vlGX2RK3RrcWlEwaV7FXVWy9En62N7KTvn-9N3OatP7wAsV0SH1u-nuuUkpw2QJKbzKFQmIPQDSaLRghFglgiXWiwyxuxkiP6zxkEymJFqJDUxggVHRmN0fSo9hAAAtVEJiFkAGbAUysdG0Kk0vCyfSfUgQBR5XGiY6SWJ9JQqNRgACS0AUVAwRAADIS8CpTABrOgGxjGmWkCjUOgAI0Yxkt6Co0FMwE1wkOmDoxI4hPQ5Do-I4fXF6DdzGAxjoAGIuTqdQAOUVyEF6URM1ns9Hp_Q8vkCoW0lOkMOwSWPQly2inRXKVTqdWa7WwPyzQ0myRmi2E61Oe2Owkut0ezkRFujNJO0iByTBkupvoRqOxhNc5Nk9AU9BgYDAZiQECe0Ru6BciDQCRgYzsEF4FnAADuRGvt6qjFweAACsAL2AqNGY6iH2dDMBefp9MwjC2lQzDCJUogIQc6DMFQADmLpSmOABEaioaY_4KNhx6kNhzjEWQN5UCC2FYBRr5UNwKCVFwADcQA

EmilyRagan avatar Apr 30 '24 21:04 EmilyRagan