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

Add Boxplot #39

Closed XD-DENG closed 5 years ago

XD-DENG commented 8 years ago
var data = echarts.dataTool.prepareBoxplotData([
    [850, 740, 900, 1070, 930, 850, 950, 1000, 960, 960, 1500],
    [210,280,250],
    [100, 200, 110]

]);

option = {

    tooltip: {
        trigger: 'item',
        axisPointer: {
            type: 'shadow'
        }
    },

    grid: {
        left: '10%',
        right: '10%',
        bottom: '5%'
    },

    xAxis: {
        type: 'category',
        name:"X Axis name here",
        data: ['A', 'B', "C"],
        boundaryGap: true,
        nameGap: 3,
        axisLabel: {
            formatter: '{value}'
        }
    },

    yAxis: {
        type: 'value',
        name: 'Give Y axis name here'
    },

    series: [
        {
            name: 'boxplot',
            type: 'boxplot',
            data: data.boxData,
            tooltip: {
                formatter: function (param) {
                    return [
                        param.name + ': ',
                        'upper: ' + param.data[4],
                        'Q3: ' + param.data[3],
                        'median: ' + param.data[2],
                        'Q1: ' + param.data[1],
                        'lower: ' + param.data[0]
                    ].join('<br/>')
                }
            }
        },
        {
            name: 'outlier',
            type: 'scatter',
            data: data.outliers
        }
    ]
};