go-viee-fetch-Demo/src/packages/components/Charts/ConfinedSpace/Map/config.ts

146 lines
2.9 KiB
TypeScript
Raw Normal View History

2025-08-25 20:27:25 +08:00
import { echartOptionProfixHandle, PublicConfigClass } from '@/packages/public'
import { MapConfig } from './index'
import { chartInitConfig } from '@/settings/designSetting'
import { CreateComponentType } from '@/packages/index.d'
import cloneDeep from 'lodash/cloneDeep'
export const includes = []
const BAR_ITEM_DEFAULT_COLORS = [
{ color: "#00CF28", wfColor: "#03D61A" },
{ color: "#AF380E", wfColor: "#BD1408" },
{ color: "#047DB0", wfColor: "#02BBD1" },
{ color: "#01E5A9", wfColor: "#01C97F" },
];
/**
*
*/
class BarItem {
/**
*
* @default 10
*/
tall: number = 10;
/**
* ()
*/
color?: string;
/**
* 线 ()
*/
wfColor?: string;
constructor(options?: Partial<BarItem>) {
if (options) {
Object.assign(this, options);
}
}
}
/**
*
*/
export class BarOption {
/**
* 线
* @default "湖北省"
*/
location: string = "湖北省";
/**
*
* @default 15
*/
width: number = 15;
/**
*
* @default -45
*/
rotation: number = -45;
/**
* X方向偏移
* @default 5
*/
offsetX: number = 5;
/**
* Y方向偏移
* @default 0
*/
offsetY: number = 0;
/**
* Z方向偏移()
* @default 0
*/
offsetZ: number = 0;
/**
*
*/
onClick: (node: any, item: BarItem) => void = (node, item) => {
console.log("click ->", node, item);
};
/**
*
*/
onEnter: (node: any, item: BarItem) => void = (node, item) => {
console.log("enter ->", node, item);
};
/**
*
*/
onLeave: (node: any, item: BarItem) => void = (node, item) => {
console.log("leave ->", node, item);
};
/**
*
* @default []
*/
items: BarItem[] = [];
/**
*
* @param options Partial<BarOption>
*/
constructor(options?: Partial<BarOption>) {
const opts = { ...options };
if (opts.items) {
this.items = opts.items.map((item, index) => {
const defaultColorSet = BAR_ITEM_DEFAULT_COLORS[index % BAR_ITEM_DEFAULT_COLORS.length];
const finalColor = item.color ?? defaultColorSet.color;
const finalWfColor = item.wfColor ?? defaultColorSet.wfColor;
// 3. 创建一个新的 BarItem 实例,包含所有信息
return new BarItem({
...item,
color: finalColor,
wfColor: finalWfColor,
});
});
delete opts.items;
}
Object.assign(this, opts);
}
}
const option = {
}
export const MapDefaultConfig = { ...option }
export default class Config extends PublicConfigClass implements CreateComponentType {
public key: string = MapConfig.key
public attr = { ...chartInitConfig, w: 1300, h: 900, zIndex: -1 }
public chartConfig = cloneDeep(MapConfig)
public option = echartOptionProfixHandle(option, includes)
// public option = option
}