//- 转换单位函数 const tradecount = function(val){ if(Number(val) >= 10000 && Number(val) < 100000000 ) { const count = String(Number(val) / 10000); const length = count.split('.'); return count.substring(0,length[0].length + 3) + '万'; }; if(Number(val) >= 100000000 ) { const count = String(Number(val) / 100000000); const length = count.split('.'); return count.substring(0,length[0].length + 3) + '亿'; }else{ const count = String(val); const length = count.split('.'); return count.substring(0,length[0].length + 3); } }; // 业绩图表函数 const performanceechart = function(element,data,date,Company){ const myChart = echarts.init(element); const option = { tooltip: { trigger: 'axis', axisPointer: { type: 'cross', crossStyle: { color: '#999' } } }, legend: { data: ['线形图(单位 '+Company+')','柱状图(单位 '+Company+')'], left: '0', itemWidth:6, itemHeight:6, align:'left', bottom:'0' }, grid:{ top:30, left:20, height:80, width:'90%' }, xAxis: [ { type: 'category', data: date, axisTick: { show: false, //是否显示网状线 默认为true }, axisLabel:{ textStyle:{ fontSize:'10', color:'#999' } } } ], yAxis: [ { type: 'value', show: false, }, ], series: [ { type: 'bar', color:'#fec1b4', name:'柱状图(单位 '+Company+')', data, barWidth : 25,//柱图宽度 }, { type: 'line', symbolSize:10, itemStyle : { normal: { label : { color:'#FF5A32', formatter: function(c){ return tradecount(c.value); }, show: true, fontSize:'10', }, lineStyle:{ width:3//设置线条粗细 } } }, color:'#FF5A32', name:'线形图(单位 '+Company+')', data, smooth: true } ] }; myChart.setOption(option); }; // 饼图函数 const pieechart = function(element,data){ // 基于准备好的dom,初始化echarts实例 const myChart = echarts.init(element); const option = { tooltip: { trigger: 'item', //- formatter: 'aa' }, legend: { orient: 'vertical', right: '5%', itemWidth:6, itemHeight:6, align:'left', top:"middle" }, series: [ { type: 'pie', radius: ['40%', '60%'], center : [ '40%', '50%' ], labelLine: { normal: { length: 15, length2: 5, lineStyle: { color: '#eee' } } }, itemStyle: { normal: { label: { show: true, position: "outside", // color: "#ddd", formatter:"{d}%" } } }, data } ] }; // 使用刚指定的配置项和数据显示图表。 myChart.setOption(option); } const barechart = function(element,date,data){ const myChart = echarts.init(element); const option = { tooltip: { trigger: 'axis', extraCssText:'width:38px;height:20px;text-align:center;', formatter:'
{c}
' }, grid: { left: '3%', right: '4%', bottom: '3%', top:'15%', containLabel: true }, xAxis: [ { type: 'category', data:date, axisTick: { alignWithLabel: true } } ], yAxis: [ { type: 'value' } ], series: [ { name: 'Direct', type: 'bar', barWidth: '30%', data, itemStyle: { normal: { color: '#FF5A32', barBorderRadius:[100, 100, 0, 0] } } }, ] }; myChart.setOption(option); }