XD-DENG / ECharts2Shiny

To insert interactive charts from ECharts into R Shiny applications (在R Shiny app中插入ECharts可交互图形)
https://CRAN.R-project.org/package=ECharts2Shiny
GNU General Public License v2.0
130 stars 47 forks source link

New Feature: 矩形树图 #36

Closed XD-DENG closed 8 years ago

XD-DENG commented 8 years ago

NORMAL

    var option = {
        tooltip : {
            trigger: 'item',
            formatter: "{b}: {c}"
        },
        toolbox: {
            show : true,
            feature : {
                mark : {show: true},
                dataView : {show: true, readOnly: false},
                restore : {show: true},
                saveAsImage : {show: true}
            }
        },
        calculable : false,
        series : [
            {
                name:'Main Chart',
                type:'treemap',
                itemStyle: {
                    normal: {
                        label: {
                            show: true,
                            formatter: "{b}"
                        },
                        borderWidth: 1
                    },
                    emphasis: {
                        label: {
                            show: true
                        }
                    }
                },
                data:[
                    {
                        name: 'A',
                        value: 6,
                        children: [
                        {
                            name: 'A-1',
                            value: 6
                        },
                        {
                            name: 'A-2',
                            value: 3
                        },
                        {
                            name: 'A-3',
                            value: 3
                        }
                    ]
                    },
                    {
                        name: 'B',
                        value: 6,
                        children: [
                            {name : 'B-1',
                                value:10
                            },
                            {
                                name:"B-2",
                                value:2
                            }
                            ]
                    },
                    {
                        name: 'C',
                        value: 4
                    },
                    {
                        name: 'D',
                        value: 1
                    },
                    {
                        name: 'E',
                        value: 1
                    },
                    {
                        name: 'F',
                        value: 1
                    },
                    {
                        name: 'G',
                        value: 1
                    }
                ]
            }
        ]
    };
XD-DENG commented 8 years ago

Drill Down

The "drill down" feature is mainly handled by leafDepth argument.


    var option = {
        tooltip : {
            trigger: 'item',
            formatter: "{b}: {c}"
        },
        toolbox: {
            show : true,
            feature : {
                mark : {show: true},
                dataView : {show: true, readOnly: false},
                restore : {show: true},
                saveAsImage : {show: true}
            }
        },
        calculable : false,
        series : [
            {
                name:'Main Chart',
                type:'treemap',
                leafDepth: 2,
                itemStyle: {
                    normal: {
                        label: {
                            show: true,
                            formatter: "{b}"
                        },
                        borderWidth: 1
                    },
                    emphasis: {
                        label: {
                            show: true
                        }
                    }
                },
                data:[
                    {
                        name: 'A',
                        value: 6,
                        children: [
                        {
                            name: 'A-1',
                            value: 6,
                            children:[
                                {
                                    name: 'A-1-1',
                                    value: 6
                                },
                                {
                                    name: 'A-1-2',
                                    value: 2
                                }
                            ]
                        },
                        {
                            name: 'A-2',
                            value: 3
                        },
                        {
                            name: 'A-3',
                            value: 3
                        }
                    ]
                    },
                    {
                        name: 'B',
                        value: 6,
                        children: [
                            {name : 'B-1',
                                value:10
                            },
                            {
                                name:"B-2",
                                value:2
                            }
                            ]
                    },
                    {
                        name: 'C',
                        value: 4
                    },
                    {
                        name: 'D',
                        value: 1
                    },
                    {
                        name: 'E',
                        value: 1
                    },
                    {
                        name: 'F',
                        value: 1
                    },
                    {
                        name: 'G',
                        value: 1
                    }
                ]
            }
        ]
    };
XD-DENG commented 8 years ago

addressed with commit 73f41fb0a66236b235c7dd74f1dc92c3598233e4

XD-DENG commented 8 years ago

furtherly addressed with commit 77d90049b616a50ed5ee785ce11fcd8580edf6b0