|
@@ -1,4 +1,4 @@
|
|
|
-import echarts from "echarts";
|
|
|
+import echarts from 'echarts';
|
|
|
|
|
|
//从左往右颜色渐变
|
|
|
export const GradualChange = (color1, color2) => {
|
|
@@ -48,7 +48,7 @@ export const getItemStyle = (c1, c2) => {
|
|
|
};
|
|
|
};
|
|
|
export const defaultMonth = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12'];
|
|
|
-export const defaultmonthData = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
|
|
+export const defaultmonthData = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
|
|
export const defaultName = ['name1', 'name2', 'name3'];
|
|
|
|
|
|
const defaultColor = [
|
|
@@ -59,15 +59,181 @@ const defaultColor = [
|
|
|
GradualChange('#884DD2', '#DF63CC')
|
|
|
];
|
|
|
// 饼图
|
|
|
-export const ringType = (color = [], data = [], title = {}, legendFcuntion = {}, tops = 80) => {
|
|
|
+export const ringTypes = (color = [], data = [], title = {}, legendFcuntion = {}) => {
|
|
|
let legendFcuntionValue = (v) => {
|
|
|
let val = '';
|
|
|
data.map((item) => {
|
|
|
if (item.name == v) {
|
|
|
if (legendFcuntion.type == '%') {
|
|
|
- val = `{a|${v}}{b|${parseInt((item.value / legendFcuntion.total).toFixed(2) * 100) || 0}%}`;
|
|
|
+ val = `{a|${v}} · · · · · · {b|${parseInt((item.value / legendFcuntion.total).toFixed(2) * 100) || 0}%}`;
|
|
|
} else {
|
|
|
- val = `{a|${v}}{b|${item.value}}`;
|
|
|
+ if (v.length > 5 || v.length == 5) {
|
|
|
+ let va = v.substr(0, 3) + '…';
|
|
|
+ val = `{a|${va}} · · · · {b|${item.value}}`;
|
|
|
+ } else if (item.value.length == 4 || item.value.length > 4) {
|
|
|
+ let itval = item.value.substr(0, 4) + '…';
|
|
|
+ val = `{a|${v}} · · · · {b|${itval}}`;
|
|
|
+ } else if ((v.length > 5 || v.length == 5) && (item.value.length == 4 || item.value.length > 4)) {
|
|
|
+ let va = v.substr(0, 3) + '…';
|
|
|
+ let itval = item.value.substr(0, 4) + '…';
|
|
|
+ val = `{a|${va}} · · · · {b|${itval}}`;
|
|
|
+ } else {
|
|
|
+ val = `{a|${v}} · · · · {b|${item.value}}`;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return val;
|
|
|
+ };
|
|
|
+ return {
|
|
|
+ tooltip: {
|
|
|
+ trigger: 'item'
|
|
|
+ },
|
|
|
+ legend: {
|
|
|
+ orient: 'vertical',
|
|
|
+ right: 0,
|
|
|
+ top: 40,
|
|
|
+ itemGap: 10,
|
|
|
+ itemWidth: 12, // 图例图形宽度
|
|
|
+ itemHeight: 8,
|
|
|
+ type: 'scroll',
|
|
|
+ formatter: (v) => {
|
|
|
+ return legendFcuntionValue(v);
|
|
|
+ },
|
|
|
+ textStyle: {
|
|
|
+ rich: {
|
|
|
+ a: {
|
|
|
+ fontSize: 12,
|
|
|
+ color: '#858892',
|
|
|
+ padding: [0, 5, 0, 0]
|
|
|
+ },
|
|
|
+ b: {
|
|
|
+ fontSize: 14,
|
|
|
+ color: '#fff',
|
|
|
+ padding: [0, 0, 0, 5]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ title,
|
|
|
+ color: !!color.length ? color : defaultColor,
|
|
|
+ series: [
|
|
|
+ {
|
|
|
+ type: 'pie',
|
|
|
+ radius: ['60%', '75%'],
|
|
|
+ avoidLabelOverlap: false,
|
|
|
+ center: ['25%', '50%'],
|
|
|
+ label: {
|
|
|
+ show: false,
|
|
|
+ position: 'center'
|
|
|
+ },
|
|
|
+ labelLine: {
|
|
|
+ show: false
|
|
|
+ },
|
|
|
+ data: data
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ };
|
|
|
+};
|
|
|
+export const ringType = (color = [], data = [], title = {}, legendFcuntion = {}) => {
|
|
|
+ let legendFcuntionValue = (v) => {
|
|
|
+ let val = '';
|
|
|
+ data.map((item) => {
|
|
|
+ if (item.name == v) {
|
|
|
+ if (legendFcuntion.type == '%') {
|
|
|
+ val = `{a|${v}} · · · · · · {b|${parseInt((item.value / legendFcuntion.total).toFixed(2) * 100) || 0}%}`;
|
|
|
+ } else {
|
|
|
+ if (v.length > 5 || v.length == 5) {
|
|
|
+ let va = v.substr(0, 3) + '…';
|
|
|
+ val = `{a|${va}} · · · · {b|${item.value}}`;
|
|
|
+ } else if (item.value.length == 4 || item.value.length > 4) {
|
|
|
+ let itval = item.value.substr(0, 4) + '…';
|
|
|
+ val = `{a|${v}} · · · · {b|${itval}}`;
|
|
|
+ } else if ((v.length > 5 || v.length == 5) && (item.value.length == 4 || item.value.length > 4)) {
|
|
|
+ let va = v.substr(0, 3) + '…';
|
|
|
+ let itval = item.value.substr(0, 4) + '…';
|
|
|
+ val = `{a|${va}} · · · · {b|${itval}}`;
|
|
|
+ } else {
|
|
|
+ val = `{a|${v}} · · · · {b|${item.value}}`;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return val;
|
|
|
+ };
|
|
|
+ return {
|
|
|
+ tooltip: {
|
|
|
+ trigger: 'item'
|
|
|
+ },
|
|
|
+ legend: {
|
|
|
+ orient: 'vertical',
|
|
|
+ right: 0,
|
|
|
+ top: 80,
|
|
|
+ itemGap: 10,
|
|
|
+ itemWidth: 12, // 图例图形宽度
|
|
|
+ itemHeight: 8,
|
|
|
+ type: 'scroll',
|
|
|
+ formatter: (v) => {
|
|
|
+ return legendFcuntionValue(v);
|
|
|
+ },
|
|
|
+ textStyle: {
|
|
|
+ rich: {
|
|
|
+ a: {
|
|
|
+ fontSize: 12,
|
|
|
+ color: '#858892',
|
|
|
+ padding: [0, 5, 0, 0]
|
|
|
+ },
|
|
|
+ b: {
|
|
|
+ fontSize: 14,
|
|
|
+ color: '#fff',
|
|
|
+ padding: [0, 0, 0, 5]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ title,
|
|
|
+ color: !!color.length ? color : defaultColor,
|
|
|
+ series: [
|
|
|
+ {
|
|
|
+ type: 'pie',
|
|
|
+ radius: ['60%', '75%'],
|
|
|
+ avoidLabelOverlap: false,
|
|
|
+ center: ['25%', '50%'],
|
|
|
+ label: {
|
|
|
+ show: false,
|
|
|
+ position: 'center'
|
|
|
+ },
|
|
|
+ labelLine: {
|
|
|
+ show: false
|
|
|
+ },
|
|
|
+ data: data
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ };
|
|
|
+};
|
|
|
+
|
|
|
+// 饼图 2560
|
|
|
+export const ringTypeEnlarge = (color = [], data = [], title = {}, legendFcuntion = {}) => {
|
|
|
+ let legendFcuntionValue = (v) => {
|
|
|
+ let val = '';
|
|
|
+ data.map((item) => {
|
|
|
+ if (item.name == v) {
|
|
|
+ if (legendFcuntion.type == '%') {
|
|
|
+ val = `{a|${v}} · · · · · · {b|${parseInt((item.value / legendFcuntion.total).toFixed(2) * 100) || 0}%}`;
|
|
|
+ } else {
|
|
|
+ if (v.length > 5 || v.length == 5) {
|
|
|
+ let va = v.substr(0, 3) + '…';
|
|
|
+ val = `{a|${va}} · · · · {b|${item.value}}`;
|
|
|
+ } else if (item.value.length == 4 || item.value.length > 4) {
|
|
|
+ let itval = item.value.substr(0, 4) + '…';
|
|
|
+ val = `{a|${v}} · · · · {b|${itval}}`;
|
|
|
+ } else if ((v.length > 5 || v.length == 5) && (item.value.length == 4 || item.value.length > 4)) {
|
|
|
+ let va = v.substr(0, 3) + '…';
|
|
|
+ let itval = item.value.substr(0, 4) + '…';
|
|
|
+ val = `{a|${va}} · · · · {b|${itval}}`;
|
|
|
+ } else {
|
|
|
+ val = `{a|${v}} · · · · {b|${item.value}}`;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
});
|
|
@@ -79,8 +245,8 @@ export const ringType = (color = [], data = [], title = {}, legendFcuntion = {},
|
|
|
},
|
|
|
legend: {
|
|
|
orient: 'vertical',
|
|
|
- right: 10,
|
|
|
- top: tops,
|
|
|
+ right: 30,
|
|
|
+ top: 100,
|
|
|
itemGap: 10,
|
|
|
itemWidth: 12, // 图例图形宽度
|
|
|
itemHeight: 8,
|
|
@@ -135,7 +301,7 @@ export const discountedWave = (name = '', xAxis = [], series = [], legendShow =
|
|
|
},
|
|
|
formatter(param) {
|
|
|
let el = `<div class="dmp-echart-tooltip"><h4>${param[0].axisValue}月</h4>`;
|
|
|
- param.forEach(item => {
|
|
|
+ param.forEach((item) => {
|
|
|
el += `<p>
|
|
|
<span class="marker" style="display:inline-block;margin-right:4px;border-radius:10px;width:12px;height:8px;background-image: linear-gradient(to left,
|
|
|
${item.color.colorStops[0].color}, ${item.color.colorStops[1].color});"></span>
|
|
@@ -1231,3 +1397,187 @@ export const columnOptionsChartss = (name = '', xAxis = [], series = [], dataser
|
|
|
};
|
|
|
return option;
|
|
|
};
|
|
|
+
|
|
|
+// 仪表盘 1920
|
|
|
+export const quantitativeAnalysisDashboard = (name = [], data = [], color = []) => {
|
|
|
+ const percent = data[0]; // 数值
|
|
|
+ let option = {
|
|
|
+ // backgroundColor: 'rgba(8, 17, 67, 0.9)',
|
|
|
+ title: {
|
|
|
+ text: name,
|
|
|
+ left: '33%',
|
|
|
+ top: '30%',
|
|
|
+ textAlign: 'center',
|
|
|
+ textStyle: {
|
|
|
+ color: '#858892',
|
|
|
+ fontSize: 12,
|
|
|
+ fontWeight: 'lighter'
|
|
|
+ },
|
|
|
+ subtext: `${percent} %`,
|
|
|
+ subtextStyle: {
|
|
|
+ color: '#fff',
|
|
|
+ fontSize: 20
|
|
|
+ }
|
|
|
+ },
|
|
|
+ polar: {
|
|
|
+ radius: ['72%', '97%'],
|
|
|
+ center: ['35%', '50%']
|
|
|
+ },
|
|
|
+ // 极坐标角度轴
|
|
|
+ angleAxis: {
|
|
|
+ min: 0,
|
|
|
+ max: 100,
|
|
|
+ // startAngle: 0,
|
|
|
+ // endAngle: -0,
|
|
|
+ clockwise: true,
|
|
|
+ show: false // 隐藏刻度线
|
|
|
+ },
|
|
|
+ // 极坐标径向轴
|
|
|
+ radiusAxis: {
|
|
|
+ type: 'category',
|
|
|
+ // 隐藏极坐标轴线
|
|
|
+ axisLine: {
|
|
|
+ show: false
|
|
|
+ },
|
|
|
+ axisTick: {
|
|
|
+ show: false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ tooltip: {
|
|
|
+ show: true,
|
|
|
+ formatter: (val) => {
|
|
|
+ return `${val.seriesName}: ${val.data}%`;
|
|
|
+ }
|
|
|
+ // backgroundColor: 'rgba(31, 196, 225, 0.2)',
|
|
|
+ // borderColor: 'rgba(31, 196, 225, 0.6)'
|
|
|
+ },
|
|
|
+ series: [
|
|
|
+ {
|
|
|
+ // 进度条
|
|
|
+ type: 'bar',
|
|
|
+ name: name,
|
|
|
+ coordinateSystem: 'polar',
|
|
|
+ // 设置柱子背景灰色,需开启showBackground才能显示backgroundStyle
|
|
|
+ showBackground: true,
|
|
|
+ backgroundStyle: {
|
|
|
+ // 外圈颜色
|
|
|
+ // color: 'rgba(14, 61, 128,0.3)',
|
|
|
+ },
|
|
|
+ // 两端设置圆角
|
|
|
+ roundCap: true,
|
|
|
+ itemStyle: {
|
|
|
+ color: {
|
|
|
+ x: 0,
|
|
|
+ y: 0,
|
|
|
+ x1: 0,
|
|
|
+ y1: 1,
|
|
|
+ colorStops: [
|
|
|
+ {
|
|
|
+ offset: 0,
|
|
|
+ color: 'rgba(94, 237, 204,0.65)'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ offset: 1,
|
|
|
+ color: 'rgba(36,195,241,0.8)'
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ },
|
|
|
+ data: [percent]
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ };
|
|
|
+ return option;
|
|
|
+};
|
|
|
+
|
|
|
+// 仪表盘 2560
|
|
|
+export const quantitativeAnalysisDashboardEnlarge = (name = [], data = [], color = []) => {
|
|
|
+ const percent = data[0]; // 数值
|
|
|
+ let option = {
|
|
|
+ // backgroundColor: 'rgba(8, 17, 67, 0.9)',
|
|
|
+ title: {
|
|
|
+ text: name,
|
|
|
+ left: '33%',
|
|
|
+ top: '35%',
|
|
|
+ textAlign: 'center',
|
|
|
+ textStyle: {
|
|
|
+ color: '#858892',
|
|
|
+ fontSize: 14,
|
|
|
+ fontWeight: 'lighter'
|
|
|
+ },
|
|
|
+ subtext: `${percent} %`,
|
|
|
+ subtextStyle: {
|
|
|
+ color: '#fff',
|
|
|
+ fontSize: 20
|
|
|
+ }
|
|
|
+ },
|
|
|
+ polar: {
|
|
|
+ radius: ['52%', '72%'],
|
|
|
+ center: ['35%', '45%']
|
|
|
+ },
|
|
|
+ // 极坐标角度轴
|
|
|
+ angleAxis: {
|
|
|
+ min: 0,
|
|
|
+ max: 100,
|
|
|
+ // startAngle: 0,
|
|
|
+ // endAngle: -0,
|
|
|
+ clockwise: true,
|
|
|
+ show: false // 隐藏刻度线
|
|
|
+ },
|
|
|
+ // 极坐标径向轴
|
|
|
+ radiusAxis: {
|
|
|
+ type: 'category',
|
|
|
+ // 隐藏极坐标轴线
|
|
|
+ axisLine: {
|
|
|
+ show: false
|
|
|
+ },
|
|
|
+ axisTick: {
|
|
|
+ show: false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ tooltip: {
|
|
|
+ show: true,
|
|
|
+ formatter: (val) => {
|
|
|
+ return `${val.seriesName}: ${val.data}%`;
|
|
|
+ }
|
|
|
+ // backgroundColor: 'rgba(31, 196, 225, 0.2)',
|
|
|
+ // borderColor: 'rgba(31, 196, 225, 0.6)'
|
|
|
+ },
|
|
|
+ series: [
|
|
|
+ {
|
|
|
+ // 进度条
|
|
|
+ type: 'bar',
|
|
|
+ name: name,
|
|
|
+ coordinateSystem: 'polar',
|
|
|
+ // 设置柱子背景灰色,需开启showBackground才能显示backgroundStyle
|
|
|
+ showBackground: true,
|
|
|
+ backgroundStyle: {
|
|
|
+ // 外圈颜色
|
|
|
+ // color: 'rgba(14, 61, 128,0.3)',
|
|
|
+ },
|
|
|
+ // 两端设置圆角
|
|
|
+ roundCap: true,
|
|
|
+ itemStyle: {
|
|
|
+ color: {
|
|
|
+ x: 0,
|
|
|
+ y: 0,
|
|
|
+ x1: 0,
|
|
|
+ y1: 1,
|
|
|
+ colorStops: [
|
|
|
+ {
|
|
|
+ offset: 0,
|
|
|
+ color: 'rgba(94, 237, 204,0.65)'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ offset: 1,
|
|
|
+ color: 'rgba(36,195,241,0.8)'
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ },
|
|
|
+ data: [percent]
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ };
|
|
|
+ return option;
|
|
|
+};
|