ecomfe / awesome-echarts

Awesome list of Apache ECharts

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Outliers in boxplot with multiple categories using dataset and transform

SergioEanX opened this issue · comments

I want to draw a multiple categories boxplot and show outliers for each category but I wasn't able, so far, to figure it out how, below my code:

var data0 = [[22.21, 20.37, 40.41, 29.59, 40.76, 37.76]]

var data1 = [[60.21, 58.37, 40.41, 39.59, 40.76, 47.76]]


option = {
    title: {
        text: 'Multiple Categories',
        left: 'center'
    },
    dataset: [{
        source: data0
    }, {
        source: data1
    },  {
        fromDatasetIndex: 0,
        transform: { type: 'boxplot' }
    }, {
        fromDatasetIndex: 1,
        transform: { type: 'boxplot' }
    }],
    legend: {
        top: '10%'
    },

   
    tooltip: {
                formatter: function(param) {
                    
                    return [
                         param.marker+ param.seriesName,
                        "Max: " + param.data[5],
                        "Q3: " + param.data[4],
                        "median: " + param.data[3],
                        "Q1: " + param.data[2],
                        "Min: " + param.data[1]
                    ].join("<br/>");
                }
            },
    grid: {
        left: '10%',
        top: '20%',
        right: '10%',
        bottom: '15%'
    },
    xAxis: {
        type: 'category',
         axisLabel: {
      show: false
    },

        boundaryGap: true,
        nameGap: 30,
        splitArea: {
            show: false
        },
        splitLine: {
            show: false
        }
    },
    yAxis: {
        type: 'value',
        name: 'Value',
        splitArea: {
            show: false
        }
    },
  
    series: [{
        name: 'PM1',
        type: 'boxplot',
        datasetIndex: 2
    }, {
        name: 'PM2.5',
        type: 'boxplot',
        datasetIndex: 3
    }]
};