echarts Time line chart stack issue

qoefvg9y  于 2022-11-05  发布在  Echarts
关注(0)|答案(5)|浏览(173)

Version

5.0.2

Steps to reproduce

option = {
    tooltip: {
        trigger: 'axis'
    },
	legend: {top:30},
    xAxis: {
        type: 'time'
    },
    yAxis: {
        type: 'value'
    },
    stack:true,
    series: [
        {
            name: 'Remaining',
            data: [
                ["2021-03-01 00:00:00",100],
                ["2021-03-02 00:00:00",90],
                ["2021-03-10 00:00:00",70],
                ["2021-03-11 00:00:00",60]
            ],
            type: 'line',
            step: 'end',
            //stack: 'IN'
        },
        {
            name: 'Deposited',
            data: [
                ["2021-03-03 00:00:00",20],
                ["2021-03-07 00:00:00",50],
                ["2021-03-08 00:00:00",65],
                ["2021-03-12 00:00:00",70]
            ],
            type: 'line',
            step: 'end',
            //stack: 'IN'
        }
    ]
};

What is expected?

The first 'Deposited' value is not 110.

What is actually happening?

Stack over time

mum43rcc

mum43rcc1#

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 thatyou have posted enough image to demo your request. 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! 🍵

kyvafyod

kyvafyod2#

Time axis doesn't support stacking yet.

hrysbysz

hrysbysz3#

@pissang Looks like stacking is only supported for category type axes. Is there a simple workaround to make it possible for value type axes?

oaxa6hgo

oaxa6hgo4#

Link: https://echarts.apache.org/examples/en/editor.html?c=line-stack

Go to the above link, and put the following code. You'll see the weird result.

option = {
  title: {
    text: 'Stacked Line'
  },
  grid: {
    left: '3%',
    right: '4%',
    bottom: '3%',
    containLabel: true
  },
  xAxis: {
    type: 'value',
    data: [0, 1, 2, 3, 4, 5, 6, 7, 8]
  },
  yAxis: {
    type: 'value'
  },
  series: [
    {
      name: 'Email',
      type: 'line',
      stack: 'Total',
      data: [[0, 120], [1, 132], [2, 101], [3, 134], [4, 90], [5, 230], [6, 210]]
    },
    {
      name: 'Union Ads',
      type: 'line',
      stack: 'Total',
      data: [[0, 120], [1, 132], [2, 101], [3, 134], [4, 90], [5, 230], [6, 210]]
    },
  ]
};

dpiehjr4

dpiehjr45#

@pissang@Ovilia
If I flip x, y axis, it seems to be working.

Link: https://echarts.apache.org/examples/en/editor.html?c=line-stack

Go to the above link, and put the following code.

const data = [[0, 120], [1, 132], [2, 101], [3, 134], [4, 90], [5, 230], [6, 210]];

const newData = data.map(item => [item[1], item[0]]);

option = {
  title: {
    text: 'Stacked Line'
  },
  grid: {
    left: '3%',
    right: '4%',
    bottom: '3%',
    containLabel: true
  },
  yAxis: {
    inverse: true,
    type: 'value',
    data: [0, 1, 2, 3, 4, 5, 6, 7, 8]
  },
  xAxis: {
    type: 'value',
  },
  series: [
    {
      name: 'Email',
      type: 'line',
      stack: 'Total',
      data: newData,
    },
    {
      name: 'Union Ads',
      type: 'line',
      stack: 'Total',
      data: newData,
    },
  ]
};

相关问题