var posList = [ 'left', 'right', 'top', 'bottom', 'inside', 'insideTop', 'insideLeft', 'insideRight', 'insideBottom', 'insideTopLeft', 'insideTopRight', 'insideBottomLeft', 'insideBottomRight' ]; var app = {} app.configParameters = { rotate: { min: -90, max: 90 }, align: { options: { left: 'left', center: 'center', right: 'right' } }, verticalAlign: { options: { top: 'top', middle: 'middle', bottom: 'bottom' } }, position: { options: echarts.util.reduce(posList, function (map, pos) { map[pos] = pos; return map; }, {}) }, distance: { min: 0, max: 100 } }; app.config = { rotate: 90, align: 'left', verticalAlign: 'middle', position: 'insideBottom', distance: 15, onChange: function () { var labelOption = { normal: { rotate: app.config.rotate, align: app.config.align, verticalAlign: app.config.verticalAlign, position: app.config.position, distance: app.config.distance } }; myChart.setOption({ series: [{ label: labelOption }, { label: labelOption }, { label: labelOption }, { label: labelOption }] }); } }; var labelOption = { normal: { show: true, position: app.config.position, distance: app.config.distance, align: app.config.align, verticalAlign: app.config.verticalAlign, rotate: app.config.rotate, formatter: '{c} {name|{a}}', fontSize: 16, rich: { name: { textBorderColor: '#fff' } } } }; var option = { color: ['#006699', '#e5323e', '#006699', '#e5323e'], tooltip: { trigger: 'axis', axisPointer: { type: 'shadow' } }, legend: { data: ['传统 首次加载', 'PWA 首次加载', '传统 刷新加载', 'PWA 刷新加载'] }, toolbox: { show: true, orient: 'vertical', left: 'right', top: 'center', feature: { mark: {show: true}, dataView: {show: true, readOnly: false}, magicType: {show: true, type: ['line', 'bar', 'stack', 'tiled']}, restore: {show: true}, saveAsImage: {show: true} } }, calculable: true, xAxis: [ { type: 'category', axisTick: {show: false}, data: ['HTML 加载时间', 'JS 脚本加载', '列表接口加载时间', '用户接口加载时间', '白屏时间', '数据渲染完成时间'] } ], yAxis: [ { type: 'value' } ], series: [ { name: '传统 首次加载', type: 'bar', barGap: 0, label: labelOption, data: [16, 237, 48, 33, 536, 587] }, { name: 'PWA 首次加载', type: 'bar', label: labelOption, data: [12, 277, 51, 29, 578, 604] }, { name: '传统 刷新加载', type: 'bar', label: labelOption, data: [13, 142, 100, 98, 474, 585] }, { name: 'PWA 刷新加载', type: 'bar', label: labelOption, data: [11, 263, 67, 27, 585, 663] } ] }; var myChart = echarts.init(document.getElementById('chart'), 'dark'); myChart.setOption(option)