echarts 相关label配置

2018-11-30  本文已影响0人  一个好昵称X

eacarts API  配置项:echart API

echart option配置项

let option = {

    title : {

        text: 'title',

        show: false,

    },

    tooltip : {

        trigger: 'axis'

    },

    grid: {

        left: '1%',

        right: '8%',

        bottom: '1%',

        containLabel: true

    },

    legend: {

        data: [value1, value2],

        textStyle: {

            fontSize: 14,

            color: '#000',

            fontWeight: 600,

            fontFamily: 'Microsoft YaHei',

        }

    },

    toolbox: {

        left: 'right',

        feature: {

            dataZoom: {

                yAxisIndex: 'none'

             },

            restore: {},

            saveAsImage: {}

        }

    },

    calculable : true,

    xAxis : [

        {

            name : 'xAxisName',

            type : 'category',

            data : xAxis1,

            // nameLocation: 'center',

            axisLabel: {

                textStyle: {

                fontSize: 14,

                    color: '#000',

                    fontWeight: 600,

                    fontFamily: 'Microsoft YaHei',

                }

            },

            nameTextStyle: {

                fontSize: 14,

                color: '#000',

                fontWeight: 600,

                fontFamily: 'Microsoft YaHei',

            },

        }

    ],

    yAxis : [

        {

            name : 'yAxisName',

            type : 'value',

            min: 0,

            max: 50,

            nameTextStyle: {

                fontSize: 14,

                color: '#000',

                fontWeight: 600,

                fontFamily: 'Microsoft YaHei',

            },

            axisLabel: {

                textStyle: {

                    fontSize: 14,

                    color: '#000',

                    fontWeight: 600,

                    fontFamily: 'Microsoft YaHei',

                }

            },

        }

],

    series : [

        {

            name: ' barName',

            type:'bar',

            label: {

                normal: {

                    show: true,

                    position: 'top',

                    formatter: '{c}%',

                    textStyle: {

                        fontSize: 14,

                        color: '#000',

                        fontWeight: 600,

                        fontFamily: 'Microsoft YaHei',

                    }

                }

            },

            data: []

        },

        {

            name: 'barName2',

            type:'bar',

            label: {

                normal: {

                    show: true,

                    position: 'top',

                    formatter: function (value: any) {

                        if(value.data > 0){

                            return value.data + '%';

                        }else {

                            return value.data;

                        }

                    },

                    textStyle: {

                        fontSize: 14,

                        color: '#000',

                        fontWeight: 600,

                        fontFamily: 'Microsoft YaHei',

                    }

                },

            },

            itemStyle: {

                normal:{

                    color: '#49A9EE'

                }

            },

            data: []

        }

]

}

上一篇 下一篇

猜你喜欢

热点阅读