123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- //- 转换单位函数
- 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:'<div style="color:#333;font-size:10px">{c}</div>'
- },
- 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);
- }
|