|
@@ -4,7 +4,7 @@
|
|
|
<script lang="ts" setup>
|
|
<script lang="ts" setup>
|
|
|
import { ref, Ref, watch } from 'vue';
|
|
import { ref, Ref, watch } from 'vue';
|
|
|
import { useECharts } from '/@/hooks/web/useECharts';
|
|
import { useECharts } from '/@/hooks/web/useECharts';
|
|
|
- import { get } from 'lodash-es';
|
|
|
|
|
|
|
+ import { get, merge } from 'lodash-es';
|
|
|
import { ModuleDataChart } from '../types';
|
|
import { ModuleDataChart } from '../types';
|
|
|
import { EChartsOption, graphic } from 'echarts';
|
|
import { EChartsOption, graphic } from 'echarts';
|
|
|
import { getData, getFormattedText } from '../hooks/helper';
|
|
import { getData, getFormattedText } from '../hooks/helper';
|
|
@@ -33,10 +33,6 @@
|
|
|
const domWidth = inst ? inst.getWidth() : 500;
|
|
const domWidth = inst ? inst.getWidth() : 500;
|
|
|
// 依据每一个图表配置生成图表选项
|
|
// 依据每一个图表配置生成图表选项
|
|
|
const { yAxis = [], xAxis = [], legend, order, type, sortBy, series, dataZoom = [] } = props.chartConfig;
|
|
const { yAxis = [], xAxis = [], legend, order, type, sortBy, series, dataZoom = [] } = props.chartConfig;
|
|
|
- const textStyle = get(props.chartOption, 'textStyle', {
|
|
|
|
|
- color: '#fff',
|
|
|
|
|
- // color: '#fff',
|
|
|
|
|
- });
|
|
|
|
|
|
|
|
|
|
let sorttedData: any[] = [];
|
|
let sorttedData: any[] = [];
|
|
|
if (Array.isArray(props.chartData)) {
|
|
if (Array.isArray(props.chartData)) {
|
|
@@ -86,7 +82,6 @@
|
|
|
|
|
|
|
|
if (type === 'scatter') {
|
|
if (type === 'scatter') {
|
|
|
return {
|
|
return {
|
|
|
- textStyle,
|
|
|
|
|
legend: {
|
|
legend: {
|
|
|
show: legend.show,
|
|
show: legend.show,
|
|
|
top: 0,
|
|
top: 0,
|
|
@@ -253,9 +248,7 @@
|
|
|
|
|
|
|
|
if (type === 'pie') {
|
|
if (type === 'pie') {
|
|
|
return {
|
|
return {
|
|
|
- textStyle,
|
|
|
|
|
legend: {
|
|
legend: {
|
|
|
- textStyle,
|
|
|
|
|
show: legend.show,
|
|
show: legend.show,
|
|
|
},
|
|
},
|
|
|
tooltip: {
|
|
tooltip: {
|
|
@@ -354,9 +347,7 @@
|
|
|
const color = ['#70F081', '#EEE780', '#F07070', '#ffe000', '#ffa800', '#ff5b00', '#ff3000'];
|
|
const color = ['#70F081', '#EEE780', '#F07070', '#ffe000', '#ffa800', '#ff5b00', '#ff3000'];
|
|
|
|
|
|
|
|
return {
|
|
return {
|
|
|
- textStyle,
|
|
|
|
|
legend: {
|
|
legend: {
|
|
|
- textStyle,
|
|
|
|
|
show: legend.show,
|
|
show: legend.show,
|
|
|
},
|
|
},
|
|
|
tooltip: {
|
|
tooltip: {
|
|
@@ -507,7 +498,6 @@
|
|
|
// 柱状图
|
|
// 柱状图
|
|
|
if (type === 'bar') {
|
|
if (type === 'bar') {
|
|
|
return {
|
|
return {
|
|
|
- textStyle,
|
|
|
|
|
grid: {
|
|
grid: {
|
|
|
top: 50,
|
|
top: 50,
|
|
|
bottom: dataZoom.length ? 70 : 30,
|
|
bottom: dataZoom.length ? 70 : 30,
|
|
@@ -515,7 +505,6 @@
|
|
|
right: 30, // 缩小右侧边距
|
|
right: 30, // 缩小右侧边距
|
|
|
},
|
|
},
|
|
|
legend: {
|
|
legend: {
|
|
|
- textStyle,
|
|
|
|
|
show: legend.show,
|
|
show: legend.show,
|
|
|
},
|
|
},
|
|
|
tooltip: {
|
|
tooltip: {
|
|
@@ -571,7 +560,6 @@
|
|
|
barGap: '100%',
|
|
barGap: '100%',
|
|
|
label: {
|
|
label: {
|
|
|
show: true,
|
|
show: true,
|
|
|
- textStyle,
|
|
|
|
|
position: 'top',
|
|
position: 'top',
|
|
|
},
|
|
},
|
|
|
itemStyle: {
|
|
itemStyle: {
|
|
@@ -592,12 +580,10 @@
|
|
|
// 折线图和上面的柱状图类似
|
|
// 折线图和上面的柱状图类似
|
|
|
if (type === 'line') {
|
|
if (type === 'line') {
|
|
|
return {
|
|
return {
|
|
|
- textStyle,
|
|
|
|
|
legend: {
|
|
legend: {
|
|
|
show: legend.show,
|
|
show: legend.show,
|
|
|
top: 10,
|
|
top: 10,
|
|
|
right: 10,
|
|
right: 10,
|
|
|
- textStyle,
|
|
|
|
|
},
|
|
},
|
|
|
grid: {
|
|
grid: {
|
|
|
left: 60,
|
|
left: 60,
|
|
@@ -637,12 +623,10 @@
|
|
|
|
|
|
|
|
if (type === 'line_enhance') {
|
|
if (type === 'line_enhance') {
|
|
|
return {
|
|
return {
|
|
|
- textStyle,
|
|
|
|
|
legend: {
|
|
legend: {
|
|
|
show: legend.show,
|
|
show: legend.show,
|
|
|
top: 10,
|
|
top: 10,
|
|
|
right: 10,
|
|
right: 10,
|
|
|
- textStyle,
|
|
|
|
|
},
|
|
},
|
|
|
tooltip: {
|
|
tooltip: {
|
|
|
trigger: 'item',
|
|
trigger: 'item',
|
|
@@ -692,11 +676,9 @@
|
|
|
// 平滑曲线图
|
|
// 平滑曲线图
|
|
|
if (type === 'line_smooth') {
|
|
if (type === 'line_smooth') {
|
|
|
return {
|
|
return {
|
|
|
- textStyle,
|
|
|
|
|
legend: {
|
|
legend: {
|
|
|
show: legend.show,
|
|
show: legend.show,
|
|
|
top: 10,
|
|
top: 10,
|
|
|
- textStyle,
|
|
|
|
|
},
|
|
},
|
|
|
grid: {
|
|
grid: {
|
|
|
left: 60,
|
|
left: 60,
|
|
@@ -746,9 +728,7 @@
|
|
|
// 折线区域图,即折线下面的区域填满
|
|
// 折线区域图,即折线下面的区域填满
|
|
|
if (type === 'line_area') {
|
|
if (type === 'line_area') {
|
|
|
return {
|
|
return {
|
|
|
- textStyle,
|
|
|
|
|
legend: {
|
|
legend: {
|
|
|
- textStyle,
|
|
|
|
|
show: legend.show,
|
|
show: legend.show,
|
|
|
},
|
|
},
|
|
|
grid: {
|
|
grid: {
|
|
@@ -809,9 +789,7 @@
|
|
|
|
|
|
|
|
if (type === 'line_bar') {
|
|
if (type === 'line_bar') {
|
|
|
return {
|
|
return {
|
|
|
- textStyle,
|
|
|
|
|
legend: {
|
|
legend: {
|
|
|
- textStyle,
|
|
|
|
|
show: legend.show,
|
|
show: legend.show,
|
|
|
top: 10,
|
|
top: 10,
|
|
|
right: 10,
|
|
right: 10,
|
|
@@ -849,7 +827,6 @@
|
|
|
// 堆叠柱状图
|
|
// 堆叠柱状图
|
|
|
if (type === 'bar_stack') {
|
|
if (type === 'bar_stack') {
|
|
|
return {
|
|
return {
|
|
|
- textStyle,
|
|
|
|
|
tooltip: {
|
|
tooltip: {
|
|
|
trigger: 'axis',
|
|
trigger: 'axis',
|
|
|
axisPointer: {
|
|
axisPointer: {
|
|
@@ -861,7 +838,6 @@
|
|
|
bottom: 30,
|
|
bottom: 30,
|
|
|
},
|
|
},
|
|
|
legend: {
|
|
legend: {
|
|
|
- textStyle,
|
|
|
|
|
show: legend.show,
|
|
show: legend.show,
|
|
|
},
|
|
},
|
|
|
xAxis: xAxis.map((e) => {
|
|
xAxis: xAxis.map((e) => {
|
|
@@ -908,13 +884,11 @@
|
|
|
// 柱状图,圆柱形样式
|
|
// 柱状图,圆柱形样式
|
|
|
if (type === 'bar_cylinder') {
|
|
if (type === 'bar_cylinder') {
|
|
|
return {
|
|
return {
|
|
|
- textStyle,
|
|
|
|
|
grid: {
|
|
grid: {
|
|
|
top: 40,
|
|
top: 40,
|
|
|
bottom: 30,
|
|
bottom: 30,
|
|
|
},
|
|
},
|
|
|
legend: {
|
|
legend: {
|
|
|
- textStyle,
|
|
|
|
|
show: legend.show,
|
|
show: legend.show,
|
|
|
},
|
|
},
|
|
|
tooltip: {
|
|
tooltip: {
|
|
@@ -1010,13 +984,11 @@
|
|
|
// 柱状图,圆柱形样式
|
|
// 柱状图,圆柱形样式
|
|
|
if (type === 'bar_cylinder_wide') {
|
|
if (type === 'bar_cylinder_wide') {
|
|
|
return {
|
|
return {
|
|
|
- textStyle,
|
|
|
|
|
grid: {
|
|
grid: {
|
|
|
top: 40,
|
|
top: 40,
|
|
|
bottom: 30,
|
|
bottom: 30,
|
|
|
},
|
|
},
|
|
|
legend: {
|
|
legend: {
|
|
|
- textStyle,
|
|
|
|
|
show: legend.show,
|
|
show: legend.show,
|
|
|
},
|
|
},
|
|
|
tooltip: {
|
|
tooltip: {
|
|
@@ -1123,7 +1095,8 @@
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
function initCharts() {
|
|
function initCharts() {
|
|
|
- const o = genChartOption();
|
|
|
|
|
- setOptions(o as EChartsOption, Boolean(props.chartConfig.clear));
|
|
|
|
|
|
|
+ const generatedOption = genChartOption();
|
|
|
|
|
+ const mergedOption = props.chartOption ? merge({}, generatedOption, props.chartOption) : generatedOption;
|
|
|
|
|
+ setOptions(mergedOption as EChartsOption, Boolean(props.chartConfig.clear));
|
|
|
}
|
|
}
|
|
|
</script>
|
|
</script>
|