go-viee-fetch-Demo/src/packages/components/Charts/IntegratedEnergy/CarbonEmission/config.ts

161 lines
3.4 KiB
TypeScript
Raw Normal View History

2025-09-04 11:56:00 +08:00
import { echartOptionProfixHandle, PublicConfigClass } from '@/packages/public'
2025-09-04 20:11:42 +08:00
import { CarbonEmissionConfig } from './index'
2025-09-04 11:56:00 +08:00
import { CreateComponentType } from '@/packages/index.d'
import { graphic } from 'echarts/core'
import { defaultTheme, chartColorsSearch } from '@/settings/chartThemes/index'
import cloneDeep from 'lodash/cloneDeep'
import dataJson from './data.json'
import { fontStyle } from 'html2canvas/dist/types/css/property-descriptors/font-style'
2025-09-05 15:06:15 +08:00
import {chartInitConfig} from "@/settings/designSetting";
2025-09-04 11:56:00 +08:00
export const includes = ['xAxis', 'yAxis']
2025-09-05 15:06:15 +08:00
const otherOption = {
sceneCode: '',
titleText: '碳排放',
unit: dataJson.unit,
}
2025-09-04 11:56:00 +08:00
const option = {
2025-09-05 15:06:15 +08:00
...otherOption,
grid: {
left: '3%',
right: '4%',
bottom: '3%',
top: '15%',
containLabel: true
},
2025-09-04 11:56:00 +08:00
legend: {
show: true,
top: '20',
right: '50',
itemStyle: {
2025-09-04 11:56:00 +08:00
borderType: 'dotted'
},
lineStyle: {
type: 'dashed',
cap: 'round',
opacity: 0.9,
2025-09-04 11:56:00 +08:00
},
// icon: 'rect',
data: [{
2025-09-04 11:56:00 +08:00
name: '电',
// 强制设置图形为圆。
icon: 'rect',
itemStyle: {
2025-09-04 11:56:00 +08:00
color: 'rgba(12, 109, 196,1)'
}, textStyle: {
color: '#eee'
2025-09-04 11:56:00 +08:00
},
}, {
2025-09-04 11:56:00 +08:00
name: '燃气',
textStyle: {
color: '#eee'
},
2025-09-04 11:56:00 +08:00
// 强制设置图形为圆。
icon: 'rect',
itemStyle: {
2025-09-04 11:56:00 +08:00
color: 'rgba(48, 189, 104,1)'
},
}],
},
tooltip: {
show: true,
trigger: 'axis',
axisPointer: {
type: 'line'
}
},
xAxis: {
show: true,
type: 'category'
},
yAxis: {
show: true,
type: 'value',
2025-09-04 14:39:31 +08:00
name: '单位:万/kwh',
nameGap: 30,
axisLine: {
2025-09-04 14:39:31 +08:00
show: false
},
splitLine: {
2025-09-04 11:56:00 +08:00
show: true,
lineStyle: {
2025-09-04 11:56:00 +08:00
type: 'dashed',
opacity: 0.5
2025-09-04 11:56:00 +08:00
}
}
},
dataset: { ...dataJson },
series: [
{
2025-09-04 11:56:00 +08:00
type: 'line',
smooth: true,
symbolSize: 0, //设定实心点的大小
label: {
show: false,
position: 'top',
color: '#fff',
fontSize: 12
},
lineStyle: {
width: 3,
type: 'solid',
color: 'rgba(12, 109, 196,1)'
},
areaStyle: {
opacity: 0.8,
color: new graphic.LinearGradient(0, 0, 0, 1, [
{
offset: 0,
color: chartColorsSearch[defaultTheme][3]
},
{
offset: 1,
color: 'rgba(12, 57, 68,0.5)'
}
])
}
},
{
type: 'line',
smooth: true,
symbolSize: 0, //设定实心点的大小
label: {
show: false,
position: 'top',
color: '#fff',
fontSize: 12
},
lineStyle: {
width: 3,
type: 'solid',
join: 'round',
color: 'rgba(48, 189, 104,1)'
},
areaStyle: {
opacity: 0.8,
color: new graphic.LinearGradient(0, 0, 0, 1, [
{
offset: 0,
color: chartColorsSearch[defaultTheme][4]
},
{
offset: 1,
color: 'rgba(8, 48, 85,0.5)'
}
])
}
}
]
}
export default class Config extends PublicConfigClass implements CreateComponentType {
2025-09-04 20:11:42 +08:00
public key: string = CarbonEmissionConfig.key
public chartConfig = cloneDeep(CarbonEmissionConfig)
2025-09-04 11:56:00 +08:00
// 图表配置项
public option = echartOptionProfixHandle(option, includes)
2025-09-05 15:06:15 +08:00
public attr = { ...chartInitConfig, x: 0, y: 0, w: 450, h: 320, zIndex: 1 }
2025-09-04 11:56:00 +08:00
}