|
@@ -19,13 +19,18 @@ let chartInstance: any = null;
|
|
|
const initChart = () => {
|
|
|
if (!chartRef.value) return;
|
|
|
chartInstance = echarts.init(chartRef.value);
|
|
|
-
|
|
|
+ const paidsTotal: any = props.paid.reduce((a: any, b: any) => a + b);
|
|
|
+ const naturalTotal: any = props.natural.reduce((a: any, b: any) => a + b);
|
|
|
+ console.log('paidsTotal, naturalTotal', paidsTotal, naturalTotal);
|
|
|
const option = {
|
|
|
+ tooltip: {
|
|
|
+ trigger: 'axis'
|
|
|
+ },
|
|
|
title: {
|
|
|
text: '网站历史数据',
|
|
|
left: 18,
|
|
|
top: 0,
|
|
|
- textStyle: { fontSize: 20, fontWeight: 'bold', color: '#282E30' }
|
|
|
+ textStyle: { fontSize: 16, fontWeight: 'bold', color: '#282E30' }
|
|
|
},
|
|
|
legend: {
|
|
|
data: ['自然', '付费'],
|
|
@@ -34,7 +39,7 @@ const initChart = () => {
|
|
|
top: 0,
|
|
|
textStyle: {
|
|
|
color: '#282E30', // 图例文字颜色
|
|
|
- fontSize: 24
|
|
|
+ fontSize: 16
|
|
|
}
|
|
|
},
|
|
|
graphic: [
|
|
@@ -119,7 +124,7 @@ const initChart = () => {
|
|
|
shadowColor: 'rgba(126, 206, 244, 0.4)',
|
|
|
shadowBlur: 10
|
|
|
},
|
|
|
- areaStyle: null,
|
|
|
+ areaStyle: null
|
|
|
},
|
|
|
{
|
|
|
name: '付费',
|
|
@@ -138,13 +143,13 @@ const initChart = () => {
|
|
|
shadowColor: 'rgba(3, 110, 184, 0.4)',
|
|
|
shadowBlur: 10
|
|
|
},
|
|
|
- areaStyle: null,
|
|
|
+ areaStyle: null
|
|
|
},
|
|
|
// 白色圆形背景
|
|
|
{
|
|
|
type: 'pie',
|
|
|
radius: ['48%'], // 半径比主环形图小一点或相同
|
|
|
- center: ['50%', '50%'],
|
|
|
+ center: ['45%', '50%'],
|
|
|
data: [{ value: 1, name: 'background' }],
|
|
|
silent: true, // 不响应鼠标事件
|
|
|
label: { show: false }, // 不显示文字
|
|
@@ -155,20 +160,31 @@ const initChart = () => {
|
|
|
{
|
|
|
type: 'pie',
|
|
|
radius: ['35%', '45%'],
|
|
|
- center: ['50%', '50%'],
|
|
|
- data: [{ value: 100, name: props.centerText }],
|
|
|
+ center: ['45%', '50%'],
|
|
|
+ data: [
|
|
|
+ { value: paidsTotal, name: '付费', itemStyle: { color: '#036EB8' } },
|
|
|
+ { value: naturalTotal, name: '自然', itemStyle: { color: '#7ECEF4' } }
|
|
|
+ ],
|
|
|
label: {
|
|
|
- show: true,
|
|
|
- position: 'center',
|
|
|
- formatter: props.centerText,
|
|
|
- fontSize: 16,
|
|
|
- fontWeight: 'bold'
|
|
|
+ // show: true,
|
|
|
+ // position: 'center',
|
|
|
+ // // formatter: () => paidsTotal + naturalTotal, // 默认显示总数
|
|
|
+ // fontSize: 16,
|
|
|
+ // fontWeight: 'bold'
|
|
|
},
|
|
|
- itemStyle: {
|
|
|
- color: '#7ECEF4'
|
|
|
+ emphasis: {
|
|
|
+ // label: {
|
|
|
+ // show: true,
|
|
|
+ // formatter: '{c}', // 鼠标移入时显示当前数值
|
|
|
+ // fontSize: 18,
|
|
|
+ // fontWeight: 'bold'
|
|
|
+ // }
|
|
|
+ },
|
|
|
+ tooltip: {
|
|
|
+ trigger: 'item',
|
|
|
+ // formatter: '{b}: {c}' // 付费: 120
|
|
|
},
|
|
|
z: 10
|
|
|
- // tooltip: { show: false }
|
|
|
}
|
|
|
]
|
|
|
};
|