echarts icon indicating copy to clipboard operation
echarts copied to clipboard

在对图进行平移并缩放窗口后无法重新将图居中

Open whxru opened this issue 8 years ago • 3 comments

One-line summary [问题简述]

  • 代码逻辑: option如后所示,series中roam属性为true,left属性为center,top属性为middle。在窗口大小改变时调用resize()函数,并重新设置option。
  • 操作:在窗口较大的情况下将图向左上方平移,随后缩小窗口。
  • 结果:图在极左上方。

Version & Environment [版本及环境]

  • Electron version [Electron 版本]: 1.7.9
  • Node version [Node 版本]: 7.9.0
  • ECharts version [ECharts 版本]: 4.0.2
  • Browser version [浏览器类型和版本]: 58.0.3029.110
  • OS Version [操作系统类型和版本]: Windows 10

Expected behaviour [期望结果]

在窗口缩放后图能够居中。 或者能够为echartsInstance提供类似名为setPosition()的方法。

ECharts option [ECharts配置项]

option = {
        animationDuration: 1500,
        animationEasingUpdate: 'quinticInOut',
        tooltip: {
            show: true,
            triggerOn: 'mousemove|click',
            enterable: true
        },
        toolbox:{
            feature:{
                saveAsImage: {
                    show: true,
                    title:'Image'
                }
            },
            iconStyle: {
                borderWidth: 2
            },
            bottom: 20,
            right: 20
        },
        series: [
            {
                name: 'NoteMap',
                type: 'graph',
                layout: 'circular',
                left: 'center',
                top: 'middle',
                roam: true,
                focusNodeAdjacency: true,
                label: {
                    show: true
                },
                nodes: [
                    {
                        name: 'NODE1',
                    },
                    {
                        name: 'NODE2',
                    },
                    {
                        name: 'NODE3'
                    }
                ],
                edges: [
                    {
                        source: 'NODE1',
                        target: 'NODE2'
                    },
                    {
                        source: 'NODE2',
                        target: 'NODE3'
                    }
                ]
            }
        ]
};

Other comments [其他信息]

完整的项目位于:https://github.com/whxru/NoteMap. 运行方法:

$ git clone https://github.com/whxru/NoteMap
$ cd NoteMap
$ npm install
$ git checkout dev

在根目录下配置config.json.TEMPLATE文件,填入申请好的evernote的developerToken。

$ npm start

whxru avatar Feb 12 '18 04:02 whxru

resize 方法不能重新使图像居中。 通过 API 使图像居中的方法,参见:http://echarts.baidu.com/examples/editor.html?c=map-locate

100pah avatar Feb 19 '18 11:02 100pah

@100pah 在'type'为'graph'的配置项里没有找到类似于'center'的属性,还望不吝赐教。

whxru avatar Mar 11 '18 12:03 whxru

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Apr 01 '20 22:04 stale[bot]