123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808 |
- import EC from 'echarts'
- import eWordcloud from 'echarts-wordcloud'
- import { message } from 'ant-design-vue';
- const color = ["#00FFF0","#014EB5","#A800FF","#e82edb","#B5454C","#443bff","#e8cb25","#3dffb0","#e8a425","#ff7aab","#e84b1e","#552ce2","#ffae21","#e8861e","#d441ff","#35e8e4","#9c7aff","#e86fd8","#ffee38"];
- /*
- * 获取 自浮云 - 常用1
- * id: 元素ID
- * data: [{
- name: "发动机卡了", // 值
- value: 100, // 权重
- textStyle: {
- emphasis: {
- color: 'red' // 光标移入颜色
- }
- }
- },{
- name: "发动了", // 值
- value: 20, // 权重
- textStyle: {
- emphasis: {
- color: 'red' // 光标移入颜色
- }
- }
- }]
- * name: 提示框name
- * */
- export function getWordCloud(id, data) {
- if(data === undefined){
- message.error("没有找到报表数据,请检查!");
- return;
- }
- var myChart = EC.init(document.getElementById(id));
- let option = {
- tooltip: {},
- series: [{
- type: 'wordCloud',
- gridSize: 2,
- sizeRange: [12, 50],
- rotationRange: [-90, 90],
- shape: 'pentagon',
- width: 600,
- height: 400,
- drawOutOfBound: true,
- textStyle: {
- normal: {
- color: function() {
- return 'rgb(' + [
- Math.round(Math.random() * 160),
- Math.round(Math.random() * 160),
- Math.round(Math.random() * 160)
- ].join(',') + ')';
- }
- },
- emphasis: {
- shadowBlur: 10,
- shadowColor: '#333'
- }
- },
- data: data
- }]
- };
- myChart.setOption(option, true);
- }
- /*
- * 获取 雷达图 - 常用1
- * id: 元素ID
- * horn: [
- { name: '销售', max: 6500},
- { name: '管理', max: 16000},
- { name: '信息技术', max: 30000},
- { name: '客服', max: 38000},
- { name: '研发', max: 52000}
- ]
- * data: [
- {
- value: [4300, 10000, 28000, 35000, 50000],
- name: '完好率'
- }
- ]
- * name: 提示框name
- * */
- export function getRadar(id, horn, data, name) {
- if(name === undefined){
- name = "雷达数据";
- }
- if(data === undefined){
- message.error("没有找到报表数据,请检查!");
- return;
- }
- var myChart = EC.init(document.getElementById(id));
- let option = {
- tooltip: {},
- radar: {
- // shape: 'circle',
- radius: "60%",
- indicator: horn,
- axisLine: {
- lineStyle: {
- color: "#FFF"
- }
- },
- splitLine: {
- lineStyle: {
- color: "#2aafb7"
- }
- }
- },
- series: [{
- name: name,
- type: 'radar',
- // areaStyle: {normal: {}},
- data: data
- }]
- };
- myChart.setOption(option, true);
- }
- /*
- * 获取 雷达图 - 常用2 - 百分比
- * id: 元素ID
- * horn: [
- { name: '销售', max: 100},
- { name: '管理', max: 100},
- { name: '信息技术', max: 100},
- { name: '客服', max: 100},
- { name: '研发', max: 100}
- ]
- * data: [
- {
- value: [98, 98, 98, 98, 98],
- name: '完好率'
- }
- ]
- * name: 提示框name
- * */
- export function getRadar2(id, horn, data, name) {
- if(name === undefined){
- name = "雷达数据";
- }
- if(data === undefined){
- message.error("没有找到报表数据,请检查!");
- return;
- }
- var myChart = EC.init(document.getElementById(id));
- let option = {
- tooltip: {
- // formatter: '{b0}<br />{a}: {c0}'
- formatter: function (params, ticket, callback) {
- let value = params.data.name;
- horn.forEach((item, i)=>{
- value += '<br />'+item.name+':'+params.data.value[i]+"%"
- });
- return value;
- }
- },
- radar: {
- // shape: 'circle',
- radius: "60%",
- indicator: horn,
- axisLine: {
- lineStyle: {
- color: "#FFF"
- }
- },
- splitLine: {
- lineStyle: {
- color: "#2aafb7"
- }
- }
- },
- series: [{
- name: name,
- type: 'radar',
- // areaStyle: {normal: {}},
- data: data
- }]
- };
- myChart.setOption(option, true);
- }
- /*
- * 获取 柱状图 - 横向1
- * id: 元素ID
- * x: ['TOP6', 'TOP5', 'TOP4', 'TOP3', 'TOP2', 'TOP1']
- * data: [{
- value: 1000,
- itemStyle: {
- color: "#AAFAE0",
- barBorderRadius: [0, 3, 3, 0] // 柱子圆角
- }
- },{
- value: 2000,
- itemStyle: {
- color: "#FCCDBA",
- barBorderRadius: [0, 3, 3, 0] // 柱子圆角
- }
- },{
- value: 3000,
- itemStyle: {
- color: "#015EEA",
- barBorderRadius: [0, 3, 3, 0] // 柱子圆角
- }
- }]
- * name: 提示框name
- * */
- export function getBarHorizontal(id, x, data, name, tipX) {
- if(name === undefined){
- name = "数量";
- }
- if(data === undefined){
- message.error("没有找到报表数据,请检查!");
- return;
- }
- var myChart = EC.init(document.getElementById(id));
- let option = {
- tooltip: {
- // formatter: '{b0}<br />{a}: {c0}'
- formatter: function (params, ticket, callback) {
- if(tipX === undefined){
- return params.name+'<br />'+params.seriesName+': '+params.data.value;
- }else{
- return tipX[tipX.length - 1 - params.dataIndex]+'<br />'+params.seriesName+': '+params.data.value;
- }
- }
- },
- grid: {
- top: 10,
- left: 60,
- right: 40,
- bottom: 30,
- },
- xAxis: {
- type: 'value',
- boundaryGap: [0, 0.01],
- minInterval: 1, // 刻度不出现小数
- axisLine: {
- lineStyle: {
- color: "#011A3F"
- }
- },
- splitLine: {
- show: false
- },
- axisTick: {
- show: false
- },
- axisLabel: {
- fontSize: 12,
- color: "#FFF"
- },
- },
- yAxis: {
- type: 'category',
- data: x,
- axisLine: {
- lineStyle: {
- color: "#011A3F"
- }
- },
- axisTick: {
- show: false
- },
- axisLabel: {
- fontSize: 12,
- color: "#FFF"
- },
- splitLine: {
- show: false
- }
- },
- series: [
- {
- name: name,
- type: 'bar',
- barWidth: 6,
- data: data
- }
- ]
- };
- myChart.setOption(option, true);
- }
- /*
- * 获取 柱状图 - 纵向1
- * id: 元素ID
- * x: ['TOP3', 'TOP2', 'TOP1']
- * data: [{
- value: 1000,
- itemStyle: {
- color: "#AAFAE0",
- barBorderRadius: [3, 3, 0, 0] // 柱子圆角
- }
- },{
- value: 2000,
- itemStyle: {
- color: "#FCCDBA",
- barBorderRadius: [3, 3, 0, 0] // 柱子圆角
- }
- },{
- value: 3000,
- itemStyle: {
- color: "#015EEA",
- barBorderRadius: [3, 3, 0, 0] // 柱子圆角
- }
- }]
- * name: 提示框name
- * */
- export function getBarVertical(id, x, data, name) {
- if(name === undefined){
- name = "数量";
- }
- if(data === undefined){
- message.error("没有找到报表数据,请检查!");
- return;
- }
- var myChart = EC.init(document.getElementById(id));
- let option = {
- tooltip: {
- trigger: 'axis',
- axisPointer: {
- type: 'shadow'
- }
- },
- grid: {
- top: 15,
- left: 60,
- right: 40,
- bottom: 30,
- },
- yAxis: {
- type: 'value',
- boundaryGap: [0, 0.01],
- minInterval: 1, // 刻度不出现小数
- axisLine: {
- lineStyle: {
- color: "#011A3F"
- }
- },
- splitLine: {
- show: false
- },
- axisTick: {
- show: false
- },
- axisLabel: {
- fontSize: 12,
- color: "#FFF",
- // 改变纵坐标的单位,过大的时候处理成万
- formatter: function (value, index) {
- if(value >= 10000){
- return (value/10000).toFixed(0)+"万";
- }else{
- return value;
- }
- }
- },
- },
- xAxis: {
- type: 'category',
- data: x,
- axisLine: {
- lineStyle: {
- color: "#011A3F"
- }
- },
- axisTick: {
- show: false
- },
- axisLabel: {
- fontSize: 12,
- color: "#FFF"
- },
- splitLine: {
- show: false
- }
- },
- series: [
- {
- name: name,
- type: 'bar',
- barWidth: 6,
- data: data
- }
- ]
- };
- myChart.setOption(option, true);
- }
- /*
- * 获取 柱状图 - 纵向2 - 一轴多线
- * id: 元素ID
- * x: ['分中心1', '分中心2', '分中心3', '分中心4']
- *
- * data: [
- {
- name: '土建',
- type: 'bar',
- barWidth: 6,
- itemStyle: {
- color: "#4AB2EC",
- barBorderRadius: [3, 3, 0, 0] // 柱子圆角
- },
- data: [7.0, 23.2, 25.6, 76.7]
- },
- {
- name: '机电',
- type: 'bar',
- barWidth: 6,
- itemStyle: {
- color: "#F8CA9D",
- barBorderRadius: [3, 3, 0, 0] // 柱子圆角
- },
- data: [2.6, 5.9, 9.0, 26.4]
- },
- {
- name: '其他',
- type: 'bar',
- barWidth: 6,
- itemStyle: {
- color: "#8E6398",
- barBorderRadius: [3, 3, 0, 0] // 柱子圆角
- },
- data: [28.7, 70.7, 175.6, 182.2]
- },
- ]
- * */
- export function getBarVertical2(id, x, data) {
- if(data === undefined){
- message.error("没有找到报表数据,请检查!");
- return;
- }
- var myChart = EC.init(document.getElementById(id));
- let option = {
- tooltip: {
- trigger: 'axis',
- axisPointer: {
- type: 'shadow'
- }
- },
- grid: {
- top: 15,
- left: 60,
- right: 40,
- bottom: 30,
- },
- yAxis: {
- type: 'value',
- boundaryGap: [0, 0.01],
- axisLine: {
- lineStyle: {
- color: "#011A3F"
- }
- },
- splitLine: {
- show: false
- },
- axisTick: {
- show: false
- },
- axisLabel: {
- fontSize: 12,
- color: "#FFF",
- // 改变纵坐标的单位,过大的时候处理成万
- formatter: function (value, index) {
- if(value >= 10000){
- return (value/10000).toFixed(0)+"万";
- }else{
- return value;
- }
- }
- },
- },
- xAxis: {
- type: 'category',
- data: x,
- axisLine: {
- lineStyle: {
- color: "#011A3F"
- }
- },
- axisTick: {
- show: false
- },
- axisLabel: {
- fontSize: 12,
- color: "#FFF"
- },
- splitLine: {
- show: false
- }
- },
- series: data
- };
- myChart.setOption(option, true);
- }
- /*
- * 获取 柱状图 - 纵向2_1 - 一轴多线百分比
- * id: 元素ID
- * x: ['分中心1', '分中心2', '分中心3', '分中心4']
- *
- * data: [
- {
- name: '土建',
- type: 'bar',
- barWidth: 6,
- itemStyle: {
- color: "#4AB2EC",
- barBorderRadius: [3, 3, 0, 0] // 柱子圆角
- },
- data: [7.0, 23.2, 25.6, 76.7]
- },
- {
- name: '机电',
- type: 'bar',
- barWidth: 6,
- itemStyle: {
- color: "#F8CA9D",
- barBorderRadius: [3, 3, 0, 0] // 柱子圆角
- },
- data: [2.6, 5.9, 9.0, 26.4]
- },
- {
- name: '其他',
- type: 'bar',
- barWidth: 6,
- itemStyle: {
- color: "#8E6398",
- barBorderRadius: [3, 3, 0, 0] // 柱子圆角
- },
- data: [28.7, 70.7, 175.6, 182.2]
- },
- ]
- * */
- export function getBarVertical2_1(id, x, data) {
- if(data === undefined){
- message.error("没有找到报表数据,请检查!");
- return;
- }
- var myChart = EC.init(document.getElementById(id));
- let option = {
- tooltip: {
- trigger: 'axis',
- axisPointer: {
- type: 'shadow'
- },
- },
- grid: {
- top: 15,
- left: 60,
- right: 40,
- bottom: 30,
- },
- yAxis: {
- max: 100,
- type: 'value',
- boundaryGap: [0, 0.01],
- minInterval: 1, // 刻度不出现小数
- axisLine: {
- lineStyle: {
- color: "#011A3F"
- }
- },
- splitLine: {
- show: false
- },
- axisTick: {
- show: false
- },
- axisLabel: {
- fontSize: 12,
- color: "#FFF",
- formatter: '{value} %'
- },
- },
- xAxis: {
- type: 'category',
- data: x,
- axisLine: {
- lineStyle: {
- color: "#011A3F"
- }
- },
- axisTick: {
- show: false
- },
- axisLabel: {
- fontSize: 12,
- color: "#FFF"
- },
- splitLine: {
- show: false
- }
- },
- series: data
- };
- myChart.setOption(option, true);
- }
- /*
- * 获取 柱状图 - 纵向3
- * id: 元素ID
- * x: ['TOP6', 'TOP5', 'TOP4', 'TOP3', 'TOP2', 'TOP1']
- * data: [{
- value: 1000,
- itemStyle: {
- color: "#D8A0FE",
- barBorderRadius: [3, 3, 0, 0] // 柱子圆角
- }
- },{
- value: 2000,
- itemStyle: {
- color: "#D8A0FE",
- barBorderRadius: [3, 3, 0, 0] // 柱子圆角
- }
- },{
- value: 3000,
- itemStyle: {
- color: "#D8A0FE",
- barBorderRadius: [3, 3, 0, 0] // 柱子圆角
- }
- },{
- value: 4000,
- itemStyle: {
- color: "#D8A0FE",
- barBorderRadius: [3, 3, 0, 0] // 柱子圆角
- }
- },{
- value: 5000,
- itemStyle: {
- color: "#D8A0FE",
- barBorderRadius: [3, 3, 0, 0] // 柱子圆角
- }
- },{
- value: 5999,
- itemStyle: {
- color: "#D8A0FE",
- barBorderRadius: [3, 3, 0, 0] // 柱子圆角
- }
- },]
- * */
- export function getBarVertical3(id, x, data, name) {
- if(name === undefined){
- name = "数量";
- }
- if(data === undefined){
- message.error("没有找到报表数据,请检查!");
- return;
- }
- var myChart = EC.init(document.getElementById(id));
- let option = {
- tooltip: {
- trigger: 'axis',
- axisPointer: {
- type: 'shadow'
- }
- },
- grid: {
- top: 25,
- left: 80,
- right: 40,
- bottom: 30,
- },
- yAxis: {
- type: 'value',
- boundaryGap: [0, 0.01],
- minInterval: 1, // 刻度不出现小数
- axisLine: {
- lineStyle: {
- color: "#011A3F"
- }
- },
- splitLine: {
- show: false
- },
- axisTick: {
- show: false
- },
- axisLabel: {
- fontSize: 12,
- color: "#FFF",
- // 改变纵坐标的单位,过大的时候处理成万
- formatter: function (value, index) {
- if(value >= 10000){
- return (value/10000).toFixed(0)+"万";
- }else{
- return value;
- }
- }
- },
- },
- xAxis: {
- type: 'category',
- data: x,
- axisLine: {
- lineStyle: {
- color: "#011A3F"
- }
- },
- axisTick: {
- show: false
- },
- axisLabel: {
- fontSize: 12,
- color: "#FFF"
- },
- splitLine: {
- show: false
- }
- },
- series: [
- {
- name: name,
- type: 'bar',
- barWidth: 6,
- data: data
- }
- ]
- };
- myChart.setOption(option, true);
- }
- /*
- * 获取 饼图 - 常用1
- * id: 元素ID
- * data: 饼图数据
- * name: 提示框name
- * [
- {value: 335, name: '直接访问'},
- {value: 310, name: '邮件营销'},
- {value: 234, name: '联盟广告'},
- {value: 135, name: '视频广告'},
- {value: 1548, name: '搜索引擎'}
- ]
- * */
- export function getPie(id, data, name) {
- if(name === undefined){
- name = "占比";
- }
- if(data === undefined){
- message.error("没有找到报表数据,请检查!");
- return;
- }
- var myChart = EC.init(document.getElementById(id));
- let option = {
- tooltip: {
- trigger: 'item',
- formatter: "{a} <br/>{b} : {c} ({d}%)"
- },
- grid: {
- left: 44,
- right: 25,
- top: 56,
- bottom: 40
- },
- color: color,
- series: [{
- name: name,
- type: 'pie',
- radius: ['45%', '65%'],
- center: ['50%', '50%'],
- data: data,
- labelLine: {
- length: 10,
- length2: 10,
- lineStyle: {
- color: "#FFF"
- }
- },
- itemStyle: {
- emphasis: {
- shadowBlur: 10,
- shadowOffsetX: 0,
- shadowColor: 'rgba(0, 0, 0, 0.5)'
- },
- normal: {
- label: {
- textStyle: {
- color:'#FFF',
- fontSize: 14,
- }
- },
- },
- },
- label: {
- formatter: ['{b}','{d}%'].join('\n')
- }
- }]
- };
- myChart.setOption(option, true);
- }
- export default {
- getWordCloud,
- getRadar,
- getRadar2,
- getBarHorizontal,
- getBarVertical,
- getBarVertical2,
- getBarVertical2_1,
- getBarVertical3,
- getPie,
- color,
- }
|