import { Injectable } from '@angular/core'; //模板option通用 let fff7 = '#fff'; //字體統一顏色rgba(255,255,255,0.7) let fs = 14; //圖表統一字體大小 let COLOR = ['#FBA3BC', '#0C8AEB', '#2EEA07', '#D74D0A', '#BE8EDE', '#66cccc', '#ff6666', '#cc3399', '#499FD9']; //主體顏色 //let COLOR = ['#8cc546', '#b3d3f0', '#f39e7a', '#f34d2f', '#42a3f5']; let toolboxColor = ['#fff', '#fff', '#fff']; //設置工具欄的每一個圖標和文字的顏色,設置的顏色會循環設置 let titlestyle = { fontSize: 14, fontWeight:400, color: fff7 }; //標題樣式 let AxisColor = '#0F495C'; //#204f81 軸的統一顏色值 let axisTick = { // 座標軸小標記 show: true, // 屬性show控制顯示與否,默認不顯示 interval: 'auto', inside: false, // 控制小標記是否在grid裏 length: 6, // 屬性length控制線長 lineStyle: { // 屬性lineStyle控制線條樣式 color: AxisColor, width: 2 } }; let dataViewIshow = true; //是否顯示數據視圖 let ItemStyle = { normal: { label: { show: true, position: 'top' ////insideTop(柱狀內部靠頂部),insideBottom(柱狀內部靠下方),insideRight(柱狀內部靠右邊),insideLeft(柱狀內部靠左邊) inside(自適應,柱狀內部中央),top(柱狀外的正上方),bottom(柱狀外的正下方),left(柱狀外的左邊),right(柱狀外的右邊)
} } }; //formatter: '{c}%', //柱形圖或者線形圖上方展現數值 let yAxisSplitLine = { show: true, lineStyle: { color: [AxisColor], width: 1, type: 'solid' } }; //設置公共網格線 let BackGroundColor = '#0d1c3d'; //圖表的背景顏色 let placeHoledStyle = { normal:{ barBorderColor:'rgba(0,0,0,0)', color:'rgba(0,0,0,0)' }, emphasis:{ barBorderColor:'rgba(0,0,0,0)', color:'rgba(0,0,0,0)' } }; let dataStyle = { normal: { label : { show: true, position: 'insideRight', formatter: '{c}' } } }; @Injectable({ providedIn: 'root' }) export class EchartsService { public placeHoledStyle = placeHoledStyle; public dataStyle = dataStyle; public itemStyle2:any;//多維條形圖文字顯示 public color2 = ['#FFFF00','#9426E6','#00B050','#FF9900','#FFCCFF','#FF0000','#00FFFF']; public LineColumnOption1: any; //折線柱狀圖公共模板1 橫向 public LineColumnOption2: any; //折線柱狀圖公共模板2 縱向 public multidimensionalBar: any; //多維條形圖 public doubleDefeatOption: any; //雙層圓圖表合體 public doubleDefeatOption2: any; //雙層圓圖表分開 public lasagnaOption: any; //千層餅圓 public normaCirclelOption: any; //正常圓 public ringOption: any; //空心圓 constructor() { //折線柱狀圖公共模板1 橫向 this.LineColumnOption1 = { backgroundColor: BackGroundColor, title: { top: '10', left: 'center', textStyle: titlestyle }, tooltip: { trigger: 'axis', axisPointer: { // 座標軸指示器,座標軸觸發有效 type: 'shadow' // 默認爲直線,可選爲:'line' | 'shadow' } }, color: COLOR, legend: { orient: 'horizontal', //vertical show:true, x: 'center', y: '30px', itemWidth: 20, itemHeight: 14, textStyle: { //圖例文字的樣式 color: fff7, fontSize: fs //統一設置顏色 }, data: [] }, toolbox: { show: true, orient: 'vertical', x: 'right', y: 'center', feature: { mark: { show: true }, dataView: { show: dataViewIshow, readOnly: false }, magicType: { show: true, type: ['line', 'bar', 'stack', 'tiled'] }, /*'stack', 'tiled'*/ restore: { show: true }, saveAsImage: { show: true } } }, grid: { x: "60px", y: "18%", x2: "40px", y2: "14%", borderWidth: 0 /*去除圖表邊框線*/ }, calculable: true, timeLine: [], xAxis: [{ type: 'category', boundaryGap: true, axisLabel: { rotate: 45, textStyle: { color: fff7 } }, axisTick: axisTick, axisLine: { type: 'solid', //設置軸線樣式 lineStyle: { color: AxisColor } //設置軸線顏色 }, splitLine: { show: false }, //去除網格線 data: [] }], yAxis: [{ type: 'value', name: '', nameLocation: 'end', //middle中間 start end nameTextStyle: { color: '#fff' }, //改變座標軸單位name的顏色 scale: true, splitLine: yAxisSplitLine, //設置網格線 axisTick: axisTick, axisLabel: { textStyle: { color: fff7 }, }, axisLine: { type: 'solid', //設置軸線樣式 lineStyle: { color: AxisColor } //設置軸線顏色 } }], series: [] }; //折線柱狀圖公共模板2 縱向 this.LineColumnOption2 = { backgroundColor: BackGroundColor, title: { top: '10', left: 'center', textStyle: titlestyle }, color: COLOR, tooltip: { trigger: 'axis' }, grid: { x: "16%", y: "18%", x2: "5%", y2: "14%", borderWidth: 0 /*去除圖表邊框線*/ }, legend: { orient: 'horizontal', //vertical x: 'center', y: '30px', itemWidth: 20, itemHeight: 14, textStyle: { //圖例文字的樣式 color: fff7, fontSize: fs //統一設置顏色 }, data: [] }, toolbox: { show: true, orient: 'vertical', //vertical horizontal y: 'center', color: toolboxColor, //設置工具欄的每一個圖標和文字的顏色,設置的顏色會循環設置 feature: { mark: { show: true }, dataView: { show: dataViewIshow, readOnly: false }, magicType: { show: true, type: ['line', 'bar'] }, restore: { show: true }, saveAsImage: { show: true } } }, calculable: true, xAxis: [{ type: 'value', position: 'top', boundaryGap: [0, 0.01], axisLabel: { textStyle: { color: fff7 } }, axisTick: axisTick, axisLine: { type: 'solid', //設置軸線樣式 lineStyle: { color: AxisColor } //設置軸線顏色 }, splitLine: { show: false }, //去除網格線 }], yAxis: [{ type: 'category', boundaryGap: true, axisLabel: { textStyle: { color: fff7 } }, axisTick: axisTick, axisLine: { type: 'solid', //設置軸線樣式 lineStyle: { color: AxisColor } //設置軸線顏色 }, splitLine: { show: false }, //去除網格線 data: [] }], series: [] };//多維條形圖 this.multidimensionalBar = { backgroundColor: BackGroundColor, title: { top: '10', left: 'center', textStyle: titlestyle }, color: COLOR, tooltip: { trigger: 'axis', formatter : function(param){ let strings = ''; strings = strings + param[0]['name']; for (let i = 0; i < param.length; i++) { if(i%2==0){ strings = strings + '<br/>' + param[i]['seriesName'] + ':' + param[i]['value'] } } return strings; } }, grid: { x: "8%", y: "30%", x2: "5%", y2: "4%", containLabel: true, borderWidth: 0 /*去除圖表邊框線*/ }, legend: { orient: 'horizontal', //vertical x: 'center', y: '60px', itemWidth: 20, itemHeight: 14, textStyle: { //圖例文字的樣式 color: fff7, fontSize: fs //統一設置顏色 }, data: [] }, toolbox: { show: true, orient: 'vertical', //vertical horizontal y: 'center', color: toolboxColor, //設置工具欄的每一個圖標和文字的顏色,設置的顏色會循環設置 feature : { mark : {show: true}, dataView : {show: true, readOnly: false}, restore : {show: true}, saveAsImage : {show: true} } }, xAxis : [{ type: 'value', position: 'top', boundaryGap : true, //座標軸兩邊留白策略,類目軸和非類目軸的設置和表現不同。 axisLabel: { show: false, textStyle: { color: fff7 } }, axisTick: {show: false}, axisLine: { type: 'solid', //設置軸線樣式 lineStyle: { color: AxisColor } //設置軸線顏色 }, splitLine: { show: false }, //去除網格線 data: [] }], yAxis : [{ type: 'category', boundaryGap: true, axisLabel: { textStyle: { color: fff7 } }, axisTick: {show: false}, axisLine: { type: 'solid', //設置軸線樣式 lineStyle: { color: AxisColor } //設置軸線顏色 }, splitLine: { show: false }, //去除網格線 data: [] }], series : [] }; //雙層圓圖表合體 this.doubleDefeatOption = { backgroundColor: BackGroundColor, title: { text: '', x: 'center', textStyle: titlestyle }, color: COLOR, tooltip: { trigger: 'item', formatter: "{a} <br/>{b} : {c} ({d}%)" }, legend: { orient: 'vertical', x: '10%', y: '20%', itemWidth: 50, itemHeight: 14, textStyle: { //圖例文字的樣式 color: fff7, fontSize: 14 //統一設置顏色 }, data: [] }, toolbox: { show: true, color: toolboxColor, //設置工具欄的每一個圖標和文字的顏色,設置的顏色會循環設置 orient: 'vertical', x: 'right', y: 'center', feature: { mark: { show: true }, dataView: { show: dataViewIshow, readOnly: false }, magicType: { show: true, type: ['pie', 'funnel'] }, restore: { show: true }, saveAsImage: { show: true } } }, calculable: false, series: [{ name: '所佔比例', type: 'pie', selectedMode: 'single', startAngle: 0, radius: [0, 50], x: '20%', width: '40%', funnelAlign: 'right', max: 1548, itemStyle: { normal: { label: { formatter: function(params) { return params.name + ':' + (params.percent - 0).toFixed(2) + '%' } }, labelLine: { show: true, length: 30 } } }, data: [] }, { name: '所佔比例', type: 'pie', startAngle: 90, radius: [70, 90], x: '60%', width: '35%', funnelAlign: 'left', max: 1048, itemStyle: { normal: { label: { formatter: function(params) { return params.name + ':' + (params.percent - 0).toFixed(2) + '%' } }, labelLine: { show: true, length: 15 } } }, data: [] } ] }; //雙層圓圖表分開 this.doubleDefeatOption2 = { backgroundColor: BackGroundColor, title: { text: '', subtext: '', x: 'center', textStyle: titlestyle }, color: COLOR, tooltip: { trigger: 'item', formatter: "{a} <br/>{b} : {c} ({d}%)" }, legend: { orient: 'horizontal', //horizontal vertical x: 'center', y: 'bottom', textStyle: { //圖例文字的樣式 color: fff7, fontSize: 14 //統一設置顏色 }, data: [] }, toolbox: { show: true, color: toolboxColor, //設置工具欄的每一個圖標和文字的顏色,設置的顏色會循環設置 feature: { mark: { show: true }, dataView: { show: dataViewIshow, readOnly: false }, magicType: { show: true, type: ['pie', 'funnel'] }, restore: { show: true }, saveAsImage: { show: true } } }, calculable: true, series: [{ name: '半徑模式', type: 'pie', radius: [20, 60], center: ['24%', 140], roseType: 'radius', width: '40%', // for funnel max: 40, itemStyle: { normal: { label: { formatter: function(params) { return params.name + ':' + (params.percent - 0).toFixed(2) + '%' } }, labelLine: { show: true, length: 10 } } }, data: [] }, { name: '半徑模式', type: 'pie', radius: [30, 70], center: ['76%', 140], roseType: 'radius', width: '40%', // for funnel max: 40, itemStyle: { normal: { label: { formatter: function(params) { return params.name + ':' + (params.percent - 0).toFixed(2) + '%' } }, labelLine: { show: true, length: 10 } } }, data: [] } // { // name:'面積模式', // type:'pie', // radius : [30,70], // center : ['76%', 140], // roseType : 'area', // x: '50%', // for funnel // max: 40, // for funnel // sort : 'ascending', // for funnel // itemStyle : { // normal : { // label : { // formatter : function (params) { // return params.name+':'+(params.percent - 0).toFixed(2) + '%' // } // }, // labelLine : { // show : true, // length:10 // } // } // // }, // data:[] // } ] }; //千層餅圓 this.lasagnaOption = { backgroundColor: BackGroundColor, title: { text: '', subtext: '', x: 'center', textStyle: titlestyle, y: 'top' }, color: COLOR, tooltip: { trigger: 'item', formatter: "{a} <br/>{b} : {c} ({d}%)" }, legend: { orient: 'vertical', x: 'left', y: 'center', textStyle: { //圖例文字的樣式 color: fff7, fontSize: 14 //統一設置顏色 }, data: [] }, toolbox: { show: true, color: toolboxColor, //設置工具欄的每一個圖標和文字的顏色,設置的顏色會循環設置 feature: { mark: { show: true }, dataView: { show: dataViewIshow, readOnly: false }, restore: { show: true }, saveAsImage: { show: true } } }, calculable: false, series: [] }; //正常圓 this.normaCirclelOption = { backgroundColor: BackGroundColor, title: { text: '', x: '20', textStyle: titlestyle }, color: COLOR, tooltip: { trigger: 'item', formatter: "{a} <br/>{b} : {c} ({d}%)" }, legend: { orient: 'vertical', x: 'left', y: '30', itemWidth: 50, itemHeight: 14, textStyle: { //圖例文字的樣式 color: fff7, fontSize: 14 //統一設置顏色 }, data: [] }, toolbox: { show: true, color: toolboxColor, //設置工具欄的每一個圖標和文字的顏色,設置的顏色會循環設置 feature: { mark: { show: true }, dataView: { show: dataViewIshow, readOnly: false }, magicType: { show: true, type: ['pie'], option: { funnel: { x: '25%', width: '50%', funnelAlign: 'left', max: 1548 } } }, restore: { show: true }, saveAsImage: { show: true } } }, calculable: true, series: [{ name: '', type: 'pie', radius: '55%', center: ['50%', '50%'], startAngle: 30, itemStyle: { normal: { label: { //position : 'inner', formatter: function(params) { return params.name + ':' + (params.percent - 0).toFixed(0) + '%' } }, labelLine: { show: true, length: 20 } } }, data: [] }] }; //空心圓 this.ringOption = { backgroundColor: BackGroundColor, title: { text: '', x: 'left', y: 'top', itemGap: 20, textStyle: titlestyle }, color: COLOR, tooltip: { trigger: 'item', formatter: "{a} <br/>{b} : {c} ({d}%)" }, legend: { orient: 'vertical', x: 'left', y: 'center', textStyle: { //圖例文字的樣式 color: fff7, fontSize: 14 //統一設置顏色 }, data: [] }, toolbox: { show: true, color: toolboxColor, //設置工具欄的每一個圖標和文字的顏色,設置的顏色會循環設置 feature: { mark: { show: true }, dataView: { show: dataViewIshow, readOnly: false }, magicType: { show: true, type: ['pie', 'funnel'], option: { funnel: { x: '25%', width: '50%', funnelAlign: 'center', max: 1548 } } }, restore: { show: true }, saveAsImage: { show: true } } }, calculable: true, series: [{ name: '信息化空間', type: 'pie', radius: ['50%', '70%'], itemStyle: { normal: { label: { //position : 'inner', formatter: function(params) { return params.name + ':' + (params.percent - 0).toFixed(0) + '%' } }, labelLine: { show: true, length: 20 } }, emphasis: { label: { show: false, textStyle: { fontSize: fs } } } }, data: [] }] } } //多維條形圖文字顯示 在每一個條形圖上要顯示兩個數字 getitemStyle2(arr){ return { normal: {label : { show: true, position: 'insideRight',//insideRight表示內部靠右 formatter:function(param){ //console.log(param) let a = arr.filter((item)=>{ return item['name'] === param['seriesName']}); return param['value']+'/'+a[0]['arrays'][param['dataIndex']]; } } } } } }
import { Injectable } from '@angular/core';//模板option通用let fff7 = '#fff'; //字體統一顏色rgba(255,255,255,0.7)let fs = 14; //圖表統一字體大小let COLOR = ['#FBA3BC', '#0C8AEB', '#2EEA07', '#D74D0A', '#BE8EDE', '#66cccc', '#ff6666', '#cc3399', '#499FD9']; //主體顏色//let COLOR = ['#8cc546', '#b3d3f0', '#f39e7a', '#f34d2f', '#42a3f5'];let toolboxColor = ['#fff', '#fff', '#fff']; //設置工具欄的每一個圖標和文字的顏色,設置的顏色會循環設置let titlestyle = {fontSize: 14,fontWeight:400,color: fff7}; //標題樣式let AxisColor = '#0F495C'; //#204f81 軸的統一顏色值let axisTick = { // 座標軸小標記show: true, // 屬性show控制顯示與否,默認不顯示interval: 'auto',inside: false, // 控制小標記是否在grid裏length: 6, // 屬性length控制線長lineStyle: { // 屬性lineStyle控制線條樣式color: AxisColor,width: 2}};let dataViewIshow = true; //是否顯示數據視圖let ItemStyle = {normal: {label: {show: true,position: 'top'}}}; //formatter: '{c}%', //柱形圖或者線形圖上方展現數值let yAxisSplitLine = {show: true,lineStyle: {color: [AxisColor],width: 1,type: 'solid'}}; //設置公共網格線
let BackGroundColor = '#0d1c3d'; //圖表的背景顏色let placeHoledStyle = { normal:{ barBorderColor:'rgba(0,0,0,0)', color:'rgba(0,0,0,0)' }, emphasis:{ barBorderColor:'rgba(0,0,0,0)', color:'rgba(0,0,0,0)' }};let dataStyle = { normal: { label : { show: true, position: 'insideRight', formatter: '{c}' } }};
@Injectable({providedIn: 'root'})export class EchartsService {public placeHoledStyle = placeHoledStyle;public dataStyle = dataStyle;public itemStyle2:any;//多維條形圖文字顯示public color2 = ['#FFFF00','#9426E6','#00B050','#FF9900','#FFCCFF','#FF0000','#00FFFF'];public LineColumnOption1: any; //折線柱狀圖公共模板1 橫向public LineColumnOption2: any; //折線柱狀圖公共模板2 縱向public LineColumnOption3: any; //多維條形圖縱向public multidimensionalBar: any; //多維條形圖public doubleDefeatOption: any; //雙層圓圖表合體public doubleDefeatOption2: any; //雙層圓圖表分開public lasagnaOption: any; //千層餅圓public normaCirclelOption: any; //正常圓public ringOption: any; //空心圓constructor() {//折線柱狀圖公共模板1 橫向this.LineColumnOption1 = {backgroundColor: BackGroundColor,title: {top: '10',left: 'center',textStyle: titlestyle},tooltip: {trigger: 'axis',axisPointer: { // 座標軸指示器,座標軸觸發有效type: 'shadow' // 默認爲直線,可選爲:'line' | 'shadow'}},color: COLOR,legend: {orient: 'horizontal', //verticalshow:true,x: 'center',y: '30px',itemWidth: 20,itemHeight: 14,textStyle: { //圖例文字的樣式color: fff7,fontSize: fs //統一設置顏色},data: []},toolbox: {show: true,orient: 'vertical',x: 'right',y: 'center',feature: {mark: {show: true},dataView: {show: dataViewIshow,readOnly: false},magicType: {show: true,type: ['line', 'bar', 'stack', 'tiled']},/*'stack', 'tiled'*/restore: {show: true},saveAsImage: {show: true}}},grid: {x: "60px",y: "18%",x2: "40px",y2: "14%",borderWidth: 0 /*去除圖表邊框線*/},calculable: true,timeLine: [],xAxis: [{type: 'category',boundaryGap: true,axisLabel: {rotate: 45,textStyle: {color: fff7}},axisTick: axisTick,axisLine: {type: 'solid', //設置軸線樣式lineStyle: {color: AxisColor} //設置軸線顏色},splitLine: {show: false}, //去除網格線data: []}],yAxis: [{type: 'value',name: '',nameLocation: 'end', //middle中間 start endnameTextStyle: {color: '#fff'}, //改變座標軸單位name的顏色scale: true,splitLine: yAxisSplitLine, //設置網格線axisTick: axisTick,axisLabel: {textStyle: {color: fff7},},axisLine: {type: 'solid', //設置軸線樣式lineStyle: {color: AxisColor} //設置軸線顏色}}],series: []};
//折線柱狀圖公共模板2 縱向this.LineColumnOption2 = {backgroundColor: BackGroundColor,title: {top: '10',left: 'center',textStyle: titlestyle},color: COLOR,tooltip: {trigger: 'axis'},grid: {x: "16%",y: "18%",x2: "5%",y2: "14%",borderWidth: 0 /*去除圖表邊框線*/},legend: {orient: 'horizontal', //verticalx: 'center',y: '30px',itemWidth: 20,itemHeight: 14,textStyle: { //圖例文字的樣式color: fff7,fontSize: fs //統一設置顏色},data: []},toolbox: {show: true,orient: 'vertical', //vertical horizontaly: 'center',color: toolboxColor, //設置工具欄的每一個圖標和文字的顏色,設置的顏色會循環設置feature: {mark: {show: true},dataView: {show: dataViewIshow,readOnly: false},magicType: {show: true,type: ['line', 'bar']},restore: {show: true},saveAsImage: {show: true}}},calculable: true,xAxis: [{type: 'value',position: 'top',boundaryGap: [0, 0.01],axisLabel: {textStyle: {color: fff7}},axisTick: axisTick,axisLine: {type: 'solid', //設置軸線樣式lineStyle: {color: AxisColor} //設置軸線顏色},splitLine: {show: false}, //去除網格線}],yAxis: [{type: 'category',boundaryGap: true,axisLabel: {textStyle: {color: fff7}},axisTick: axisTick,axisLine: {type: 'solid', //設置軸線樣式lineStyle: {color: AxisColor} //設置軸線顏色},splitLine: {show: false}, //去除網格線data: []}],series: []};//多維條形圖縱向this.LineColumnOption3 = {title: {top: '10',left: 'center',textStyle: titlestyle},tooltip: {trigger: 'axis',axisPointer: { // 座標軸指示器,座標軸觸發有效type: 'shadow' // 默認爲直線,可選爲:'line' | 'shadow'}},color: COLOR,legend: {orient: 'horizontal', //verticalx: 'center',y: '30px',itemWidth: 20,itemHeight: 14,show: false,textStyle: { //圖例文字的樣式color: fff7,fontSize: fs //統一設置顏色},data: []},toolbox: {show: true,feature: {mark: {show: true},dataView: {show: dataViewIshow,readOnly: false},restore: {show: true},saveAsImage: {show: true}}},grid: {y: 80,y2: 30},xAxis: [{type: 'value',position: 'top',boundaryGap: [0, 0.01],axisLabel: {textStyle: {color: fff7}},axisTick: axisTick,axisLine: {type: 'solid', //設置軸線樣式lineStyle: {color: AxisColor} //設置軸線顏色},splitLine: {show: false}, //去除網格線}],yAxis: [{type: 'category',boundaryGap: true,axisLabel: {textStyle: {color: fff7}},axisTick: axisTick,axisLine: {type: 'solid', //設置軸線樣式lineStyle: {color: AxisColor} //設置軸線顏色},splitLine: {show: false}, //去除網格線data: []}],series: [{name: '學習任務',type: 'bar',stack: '總量',//itemStyle : dataStyle,data: [38, 50, 33, 72]},{name: '學習任務',type: 'bar',stack: '總量',itemStyle: placeHoledStyle,data: [62, 50, 67, 28]},{name: '自主學習',type: 'bar',stack: '總量',//itemStyle : dataStyle,data: [61, 41, 42, 30]},{name: '自主學習',type: 'bar',stack: '總量',itemStyle: placeHoledStyle,data: [39, 59, 58, 70]},{name: '學情分析',type: 'bar',stack: '總量',//itemStyle : dataStyle,data: [37, 35, 44, 60]},{name: '學情分析',type: 'bar',stack: '總量',itemStyle: placeHoledStyle,data: [63, 65, 56, 40]},{name: '教材',type: 'bar',stack: '總量',//itemStyle : dataStyle,data: [71, 50, 31, 39]},{name: '教材',type: 'bar',stack: '總量',itemStyle: placeHoledStyle,data: [29, 50, 69, 61]}]};//多維條形圖this.multidimensionalBar = {backgroundColor: BackGroundColor, title: {top: '10',left: 'center',textStyle: titlestyle},color: COLOR,tooltip: {trigger: 'axis',formatter : function(param){let strings = '';strings = strings + param[0]['name'];for (let i = 0; i < param.length; i++) {if(i%2==0){strings = strings + '<br/>' + param[i]['seriesName'] + ':' + param[i]['value']}}return strings;}},grid: {x: "8%",y: "30%",x2: "5%",y2: "4%",containLabel: true,borderWidth: 0 /*去除圖表邊框線*/},legend: {orient: 'horizontal', //verticalx: 'center',y: '60px',itemWidth: 20,itemHeight: 14,textStyle: { //圖例文字的樣式color: fff7,fontSize: fs //統一設置顏色},data: []}, toolbox: { show: true,orient: 'vertical', //vertical horizontaly: 'center',color: toolboxColor, //設置工具欄的每一個圖標和文字的顏色,設置的顏色會循環設置 feature : { mark : {show: true}, dataView : {show: true, readOnly: false}, restore : {show: true}, saveAsImage : {show: true} } }, xAxis : [{type: 'value',position: 'top',boundaryGap : true, //座標軸兩邊留白策略,類目軸和非類目軸的設置和表現不同。axisLabel: {show: false,textStyle: {color: fff7}},axisTick: {show: false},axisLine: {type: 'solid', //設置軸線樣式lineStyle: {color: AxisColor} //設置軸線顏色},splitLine: {show: false}, //去除網格線data: []}], yAxis : [{type: 'category',boundaryGap: true,axisLabel: {textStyle: {color: fff7}},axisTick: {show: false},axisLine: {type: 'solid', //設置軸線樣式lineStyle: {color: AxisColor} //設置軸線顏色},splitLine: {show: false}, //去除網格線data: []}], series : []};//雙層圓圖表合體this.doubleDefeatOption = {backgroundColor: BackGroundColor,title: {text: '',x: 'center',textStyle: titlestyle},color: COLOR,tooltip: {trigger: 'item',formatter: "{a} <br/>{b} : {c} ({d}%)"},legend: {orient: 'vertical',x: '10%',y: '20%',itemWidth: 50,itemHeight: 14,textStyle: { //圖例文字的樣式color: fff7,fontSize: 14 //統一設置顏色},data: []},toolbox: {show: true,color: toolboxColor, //設置工具欄的每一個圖標和文字的顏色,設置的顏色會循環設置orient: 'vertical',x: 'right',y: 'center',feature: {mark: {show: true},dataView: {show: dataViewIshow,readOnly: false},magicType: {show: true,type: ['pie', 'funnel']},restore: {show: true},saveAsImage: {show: true}}},calculable: false,series: [{name: '所佔比例',type: 'pie',selectedMode: 'single',startAngle: 0,radius: [0, 50],x: '20%',width: '40%',funnelAlign: 'right',max: 1548,itemStyle: {normal: {label: {formatter: function(params) {return params.name + ':' + (params.percent - 0).toFixed(2) + '%'}},labelLine: {show: true,length: 30}}
},data: []},{name: '所佔比例',type: 'pie',startAngle: 90,radius: [70, 90],x: '60%',width: '35%',funnelAlign: 'left',max: 1048,itemStyle: {normal: {label: {formatter: function(params) {return params.name + ':' + (params.percent - 0).toFixed(2) + '%'}},labelLine: {show: true,length: 15}}
},data: []}]};
//雙層圓圖表分開this.doubleDefeatOption2 = {backgroundColor: BackGroundColor,title: {text: '',subtext: '',x: 'center',textStyle: titlestyle},color: COLOR,tooltip: {trigger: 'item',formatter: "{a} <br/>{b} : {c} ({d}%)"},legend: {orient: 'horizontal', //horizontal verticalx: 'center',y: 'bottom',textStyle: { //圖例文字的樣式color: fff7,fontSize: 14 //統一設置顏色},data: []},toolbox: {show: true,color: toolboxColor, //設置工具欄的每一個圖標和文字的顏色,設置的顏色會循環設置feature: {mark: {show: true},dataView: {show: dataViewIshow,readOnly: false},magicType: {show: true,type: ['pie', 'funnel']},restore: {show: true},saveAsImage: {show: true}}},calculable: true,series: [{name: '半徑模式',type: 'pie',radius: [20, 60],center: ['24%', 140],roseType: 'radius',width: '40%', // for funnelmax: 40,itemStyle: {normal: {label: {formatter: function(params) {return params.name + ':' + (params.percent - 0).toFixed(2) + '%'}},labelLine: {show: true,length: 10}}
},data: []},{name: '半徑模式',type: 'pie',radius: [30, 70],center: ['76%', 140],roseType: 'radius',width: '40%', // for funnelmax: 40,itemStyle: {normal: {label: {formatter: function(params) {return params.name + ':' + (params.percent - 0).toFixed(2) + '%'}},labelLine: {show: true,length: 10}}
},data: []}// {// name:'面積模式',// type:'pie',// radius : [30,70],// center : ['76%', 140],// roseType : 'area',// x: '50%', // for funnel// max: 40, // for funnel// sort : 'ascending', // for funnel// itemStyle : {// normal : {// label : {// formatter : function (params) {// return params.name+':'+(params.percent - 0).toFixed(2) + '%'// }// },// labelLine : {// show : true,// length:10// }// }//// },// data:[]// }]};
//千層餅圓this.lasagnaOption = {backgroundColor: BackGroundColor,title: {text: '',subtext: '',x: 'center',textStyle: titlestyle,y: 'top'},color: COLOR,tooltip: {trigger: 'item',formatter: "{a} <br/>{b} : {c} ({d}%)"},legend: {orient: 'vertical',x: 'left',y: 'center',textStyle: { //圖例文字的樣式color: fff7,fontSize: 14 //統一設置顏色},data: []},toolbox: {show: true,color: toolboxColor, //設置工具欄的每一個圖標和文字的顏色,設置的顏色會循環設置feature: {mark: {show: true},dataView: {show: dataViewIshow,readOnly: false},restore: {show: true},saveAsImage: {show: true}}},calculable: false,series: []};
//正常圓this.normaCirclelOption = {backgroundColor: BackGroundColor,title: {text: '',x: '20',textStyle: titlestyle},color: COLOR,tooltip: {trigger: 'item',formatter: "{a} <br/>{b} : {c} ({d}%)"},legend: {orient: 'vertical',x: 'left',y: '30',itemWidth: 50,itemHeight: 14,textStyle: { //圖例文字的樣式color: fff7,fontSize: 14 //統一設置顏色},data: []},toolbox: {show: true,color: toolboxColor, //設置工具欄的每一個圖標和文字的顏色,設置的顏色會循環設置feature: {mark: {show: true},dataView: {show: dataViewIshow,readOnly: false},magicType: {show: true,type: ['pie'],option: {funnel: {x: '25%',width: '50%',funnelAlign: 'left',max: 1548}}},restore: {show: true},saveAsImage: {show: true}}},calculable: true,series: [{name: '',type: 'pie',radius: '55%',center: ['50%', '50%'],startAngle: 30,itemStyle: {normal: {label: {//position : 'inner',formatter: function(params) {return params.name + ':' + (params.percent - 0).toFixed(0) + '%'}},labelLine: {show: true,length: 20}}
},data: []}]};
//空心圓this.ringOption = {backgroundColor: BackGroundColor,title: {text: '',x: 'left',y: 'top',itemGap: 20,textStyle: titlestyle},color: COLOR,tooltip: {trigger: 'item',formatter: "{a} <br/>{b} : {c} ({d}%)"},legend: {orient: 'vertical',x: 'left',y: 'center',textStyle: { //圖例文字的樣式color: fff7,fontSize: 14 //統一設置顏色},data: []},toolbox: {show: true,color: toolboxColor, //設置工具欄的每一個圖標和文字的顏色,設置的顏色會循環設置feature: {mark: {show: true},dataView: {show: dataViewIshow,readOnly: false},magicType: {show: true,type: ['pie', 'funnel'],option: {funnel: {x: '25%',width: '50%',funnelAlign: 'center',max: 1548}}},restore: {show: true},saveAsImage: {show: true}}},calculable: true,series: [{name: '信息化空間',type: 'pie',radius: ['50%', '70%'],itemStyle: {normal: {label: {//position : 'inner',formatter: function(params) {return params.name + ':' + (params.percent - 0).toFixed(0) + '%'}},labelLine: {show: true,length: 20}},emphasis: {label: {show: false,textStyle: {fontSize: fs}}}},data: []}]}}//多維條形圖文字顯示 在每一個條形圖上要顯示兩個數字getitemStyle2(arr){return { normal: {label : { show: true, position: 'insideRight',//insideRight表示內部靠右 formatter:function(param){ //console.log(param) let a = arr.filter((item)=>{ return item['name'] === param['seriesName']}); return param['value']+'/'+a[0]['arrays'][param['dataIndex']]; } }}}}}ide