129 lines
2.9 KiB
TypeScript
129 lines
2.9 KiB
TypeScript
|
import { echartOptionProfixHandle, PublicConfigClass } from '@/packages/public'
|
||
|
import { FiniteSpatialDistributionConfig } from './index'
|
||
|
import { CreateComponentType } from '@/packages/index.d'
|
||
|
import cloneDeep from 'lodash/cloneDeep'
|
||
|
import dataJson from './data.json'
|
||
|
import { getParametricEquation, getPie3D } from './3dPie'
|
||
|
|
||
|
export const includes = ['legend']
|
||
|
|
||
|
// 其它配置
|
||
|
const otherConfig = {
|
||
|
dateTime: {
|
||
|
selectValue: 'day',
|
||
|
dataset: [
|
||
|
{
|
||
|
label: '当天',
|
||
|
value: 'day'
|
||
|
},
|
||
|
{
|
||
|
label: '本周',
|
||
|
value: 'week'
|
||
|
},
|
||
|
{
|
||
|
label: '当月',
|
||
|
value: 'month'
|
||
|
},
|
||
|
{
|
||
|
label: '本季度',
|
||
|
value: 'quarter'
|
||
|
},
|
||
|
{
|
||
|
label: '当年',
|
||
|
value: 'year'
|
||
|
}
|
||
|
]
|
||
|
},
|
||
|
|
||
|
}
|
||
|
|
||
|
let total = 0
|
||
|
dataJson.source.forEach(item => {
|
||
|
total += item.value;
|
||
|
})
|
||
|
|
||
|
const series = getPie3D(dataJson.source.map(item => {
|
||
|
item.value = Number((item.value / total * 100).toFixed(2))
|
||
|
return item
|
||
|
}), 0.8);
|
||
|
|
||
|
|
||
|
const option = {
|
||
|
...otherConfig,
|
||
|
renderer: 'canvas',
|
||
|
backgroundColor: 'transparent',
|
||
|
legend: {
|
||
|
data: dataJson.source.map(item => item.name),
|
||
|
top: '84%',
|
||
|
left: 'center',
|
||
|
icon: 'rect',
|
||
|
textStyle: {
|
||
|
color: '#fff',
|
||
|
// fontSize: 16,
|
||
|
},
|
||
|
},
|
||
|
// color: ['rgba(255, 215, 0, 1)', 'rgba(74, 144, 226, 1)', 'rgba(80, 227, 194, 1)', 'rgba(126, 211, 33, 1)', 'rgba(144, 19, 254, 1)'],
|
||
|
dataset: { ...dataJson },
|
||
|
labelLine: {
|
||
|
show: true,
|
||
|
lineStyle: {
|
||
|
color: '#7BC0CB',
|
||
|
},
|
||
|
},
|
||
|
title: [
|
||
|
{
|
||
|
x: 'center',
|
||
|
top: '35%',
|
||
|
text: total,
|
||
|
textStyle: {
|
||
|
color: '#eee',
|
||
|
fontSize: 32,
|
||
|
fontWeight: 'bold'
|
||
|
},
|
||
|
},
|
||
|
{
|
||
|
x: 'center',
|
||
|
top: '48%',
|
||
|
text: '总数',
|
||
|
textStyle: {
|
||
|
color: '#ccc',
|
||
|
fontSize: 16,
|
||
|
fontWeight: 400
|
||
|
},
|
||
|
},
|
||
|
],
|
||
|
label: {
|
||
|
show: false,
|
||
|
},
|
||
|
xAxis3D: {
|
||
|
min: -0.8,
|
||
|
max: 0.8,
|
||
|
},
|
||
|
yAxis3D: {
|
||
|
min: -0.8,
|
||
|
max: 0.8,
|
||
|
},
|
||
|
zAxis3D: {
|
||
|
min: -1,
|
||
|
max: 1,
|
||
|
},
|
||
|
grid3D: {
|
||
|
show: false,
|
||
|
boxHeight: 4,
|
||
|
top: '-10%',
|
||
|
viewControl: {
|
||
|
distance: 180,
|
||
|
alpha: 30,
|
||
|
beta: 60,
|
||
|
autoRotate: false, // 自动旋转
|
||
|
},
|
||
|
},
|
||
|
|
||
|
series: series,
|
||
|
}
|
||
|
|
||
|
export default class Config extends PublicConfigClass implements CreateComponentType {
|
||
|
public key: string = FiniteSpatialDistributionConfig.key
|
||
|
public chartConfig = cloneDeep(FiniteSpatialDistributionConfig)
|
||
|
public option = echartOptionProfixHandle(option, includes)
|
||
|
}
|