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

请问时间数据支持堆叠吗? #8955

Closed
maoyr opened this issue Aug 27, 2018 · 6 comments
Closed

请问时间数据支持堆叠吗? #8955

maoyr opened this issue Aug 27, 2018 · 6 comments
Labels

Comments

@maoyr
Copy link

maoyr commented Aug 27, 2018

One-line summary [问题简述]

在做甘特图,需要时间数据进行堆叠,但好像现在不支持时间数据的堆叠展示?

因为要用 dataZoom,如果把数据转换为数值的话,堆叠是正常的,但 dataZoom 就不能用了。

如果设置 barGap 为 '-100%',可以使柱子重叠,在此基础上,增加了一个坐标系为隐藏,但 barGap 对 series 中所有柱子生效,还是不能实现甘特图。barGap 能否设置为只针对某一坐标系下的 series 柱子重叠?

Version & Environment [版本及环境]

  • ECharts version [ECharts 版本]:
  • Browser version [浏览器类型和版本]:
  • OS Version [操作系统类型和版本]:

在官网运行下面的例子

Expected behaviour [期望结果]

希望时间数据可以堆叠,或者有什么方法将时间数据转换然后展示正常,并且 dataZoom 可用。

ECharts option [ECharts配置项]

function  FormatTime(oldTime){    
    let newTime = [];
    oldTime.forEach((time)=>{
        newTime.push( new Date(time) );
    })
    return newTime ;
}

option = {
    tooltip: {
        trigger: 'axis'
    },
    xAxis: [
        {
            type: 'time'
           
        }
    ],
    yAxis: [
        {
            type: 'category',
            data: ['task1','task2','task3','task4','task5' ]
        }
    ],
     dataZoom: [ {
        type: 'slider'
    }],
    series: [
        {
            name:'计划开始时间',
            type: 'bar',
            stack: '计划',
            itemStyle: {
                normal: {
                    borderColor: 'rgba(0,0,0,0)',
                    color: 'rgba(0,0,0,0)'
                },
                emphasis: {
                    borderColor: 'rgba(0,0,0,0)',
                    color: 'rgba(0,0,0,0)'
                }
            },
            data: FormatTime ([
                "2018/01/01", 
                "2018/02/01", 
                "2018/03/01", 
                "2018/04/01", 
                "2018/05/01"
            ])
        },
        {
            name:'计划结束时间',
            type: 'bar',
            stack: '计划',
            data: FormatTime ([
                "2018/02/01", 
                "2018/03/01", 
                "2018/04/01", 
                "2018/05/01", 
                "2018/06/01"
            ])
        },
        {
            name:'实际开始时间',
            type: 'bar',
            stack: '实际',
            itemStyle: {
                normal: {
                    borderColor: 'rgba(0,0,0,0)',
                    color: 'rgba(0,0,0,0)'
                },
                emphasis: {
                    borderColor: 'rgba(0,0,0,0)',
                    color: 'rgba(0,0,0,0)'
                }
            },
            data: FormatTime ([
                "2018/01/01", 
                "2018/03/01", 
                "2018/04/01", 
                "2018/05/01", 
                "2018/06/01"
            ])
        },
        {
            name:'实际结束时间',
            type: 'bar',
            stack: '实际',
            data: FormatTime ([
                "2018/03/01", 
                "2018/04/01", 
                "2018/05/01", 
                "2018/06/01", 
                "2018/07/01"
            ])
        }
        
    ]
};

Other comments [其他信息]

@Ovilia
Copy link
Contributor

Ovilia commented Aug 27, 2018

传入数据的时候还是传数字,而不是时间,因为理论上时间点和时间点的叠加是没有意义的,只有时长的叠加才是有意义的。

@Ovilia Ovilia added the support label Aug 27, 2018
@maoyr
Copy link
Author

maoyr commented Aug 27, 2018

如果传时长的话,是不是没法使用 dataZoom 了?

@Ovilia
Copy link
Contributor

Ovilia commented Aug 27, 2018

数据可以这样处理,new Date().getTime() 作为实际数据,再用 formatter 转为日期时间类型,不影响使用 dataZoom

@maoyr
Copy link
Author

maoyr commented Aug 28, 2018

目前静止状态展示正常,但区域缩放时,柱子会超出窗口范围,展示错乱。请问是哪里没设置好吗?
http://gallery.echartsjs.com/editor.html?c=xrkpPTDzD7&v=1

@Ovilia
Copy link
Contributor

Ovilia commented Aug 28, 2018

在是一个已知的 bug #8935 会尽快修复。别的没问题的话可以 close 这个 issue 了。

@maoyr
Copy link
Author

maoyr commented Aug 28, 2018

好的。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants