apache / echarts

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

如何自己实现多图布局 #6875

Closed FFHHVV closed 2 years ago

FFHHVV commented 7 years ago

One-line summary [问题简述]

官网上创建的例子支持多图布局,自己创建的例子怎么才能支持多图布局? 布局需要自己处理吗,还是有现成可用的API?没有发现API中有相关的方法 myChart.setOption( )方法,并不支持传入options=[ ]数组, myChart.setOption(options),这样传入会报“对象不支持split属性或方法”的错误 myChart.setOption(options[0]),这样传入没有问题 ![Uploading TIM截图20171021105126.png…]()

Version & Environment [版本及环境]

Expected behaviour [期望结果]

传入options = [ ]配置项数组,实现多图布局

ECharts option [ECharts配置项]

options = [{
    title: {
        text: ''
    },
    angleAxis: {
        type: 'category',
        data: ['N', 'NNE', 'NE', 'ENE', 'E', 'ESE', 'SE', 'SSE', 'S', 'SSW', 'SW', 'WSW', 'W', 'WNW', 'NW', 'NNW'],
        z: 0,
        boundaryGap: false,
        splitLine: {
            show: true,
            lineStyle: {
                color: '#ddd',
                type: 'solid'
            }
        },
        axisLine: {
            show: false
        }
    },
    radiusAxis: {},
    polar: {},
    series: [{
        type: 'bar',
        data: [3, 10, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 2],
        coordinateSystem: 'polar',
        name: '',
        stack: 'a',
        itemStyle: {
            normal: {
                color: '#00539F'
            }
        }
    }, {
        type: 'bar',
        data: [4, 6, 3, 0, 0, 0, 0, 1, 5, 2, 0, 0, 2, 0, 0, 0],
        coordinateSystem: 'polar',
        name: '',
        stack: 'a',
        itemStyle: {
            normal: {
                color: '#2694BD'
            }
        }
    }, {
        type: 'bar',
        data: [0, 7, 9, 2, 0, 0, 1, 3, 5, 1, 5, 1, 2, 3, 1, 1],
        coordinateSystem: 'polar',
        name: '',
        stack: 'a',
        itemStyle: {
            normal: {
                color: '#66BC29'
            }
        }
    }, {
        type: 'bar',
        data: [1, 8, 5, 4, 1, 1, 0, 3, 9, 3, 2, 0, 1, 2, 0, 1],
        coordinateSystem: 'polar',
        name: '',
        stack: 'a',
        itemStyle: {
            normal: {
                color: '#EAC911'
            }
        }
    }, {
        type: 'bar',
        data: [0, 2, 2, 2, 4, 0, 0, 2, 3, 3, 0, 0, 0, 2, 2, 0],
        coordinateSystem: 'polar',
        name: '',
        stack: 'a',
        itemStyle: {
            normal: {
                color: '#ED6E00'
            }
        }
    }, {
        type: 'bar',
        data: [0, 0, 0, 0, 0, 5, 2, 2, 8, 1, 0, 0, 0, 1, 0, 0],
        coordinateSystem: 'polar',
        name: '',
        stack: 'a',
        itemStyle: {
            normal: {
                color: '#BB3012'
            }
        }
    }]
}, {
    title: {
        text: ''
    },
    polar: {},
    angleAxis: {
        type: 'value'
    },
    radiusAxis: {
        axisAngle: 0
    },
    series: [{
        coordinateSystem: 'polar',
        angleAxisIndex: 0,
        radiusAxisIndex: 0,
        name: 'scatter',
        type: 'scatter',
        symbolSize: 5,
        data: [{
            value: [0.8792, 176.2322],
            itemStyle: {
                normal: {
                    color: '#66BC29'
                }
            }
        }, {
            value: [0.3551, 138.9667],
            itemStyle: {
                normal: {
                    color: '#66BC29'
                }
            }
        }, {
            value: [0.2297, 186.4351],
            itemStyle: {
                normal: {
                    color: '#66BC29'
                }
            }
        }, {
            value: [0.0062, 168.8333],
            itemStyle: {
                normal: {
                    color: '#66BC29'
                }
            }
        }, {
            value: [0.041, 168],
            itemStyle: {
                normal: {
                    color: '#BB3012'
                }
            }
        }, {
            value: [0, 168],
            itemStyle: {
                normal: {
                    color: '#ED6E00'
                }
            }
        }, {
            value: [0, 168],
            itemStyle: {
                normal: {
                    color: '#EAC911'
                }
            }
        }]
    }]
}];

Other comments [其他信息]

tim 20171021105126

zhouxin860114 commented 5 years ago

我也想用多图布局,用预览模式看了gallery的多图布局,发现其实还是多个div,每个options[i]与相应的div绑定的。 default

所以……自己写个排版+自动绑定(echarts.init)的函数就好了

Cp0204 commented 4 years ago

我觉得官方表达有问题,不是整个options = [],而是在各对象中[],如options.title=[] 见 https://gallery.echartsjs.com/editor.html?c=scatter-anscombe-quartet

github-actions[bot] commented 2 years ago

This issue has been automatically marked as stale because it did not have recent activity. It will be closed in 7 days if no further activity occurs. If you wish not to mark it as stale, please leave a comment in this issue.

github-actions[bot] commented 2 years ago

This issue has been automatically closed because it did not have recent activity. If this remains to be a problem with the latest version of Apache ECharts, please open a new issue and link this to it. Thanks!