diff --git a/src/packages/components/Charts/ConfinedSpace/Map/config.ts b/src/packages/components/Charts/ConfinedSpace/Map/config.ts new file mode 100644 index 0000000..6c3dd70 --- /dev/null +++ b/src/packages/components/Charts/ConfinedSpace/Map/config.ts @@ -0,0 +1,145 @@ +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) { + 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 + */ + constructor(options?: Partial) { + 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 +} diff --git a/src/packages/components/Charts/ConfinedSpace/Map/config.vue b/src/packages/components/Charts/ConfinedSpace/Map/config.vue new file mode 100644 index 0000000..1c5c3ce --- /dev/null +++ b/src/packages/components/Charts/ConfinedSpace/Map/config.vue @@ -0,0 +1,9 @@ + + + diff --git a/src/packages/components/Charts/ConfinedSpace/Map/data.json b/src/packages/components/Charts/ConfinedSpace/Map/data.json new file mode 100644 index 0000000..096773d --- /dev/null +++ b/src/packages/components/Charts/ConfinedSpace/Map/data.json @@ -0,0 +1,7 @@ +{ + "barOptions": [ + {"location": "湖北省", "items":[{"tall":60},{"tall":40},{"tall":20},{"tall":10}]}, + {"location": "湖南省", "items":[{"tall":60},{"tall":40},{"tall":20},{"tall":10}]}, + {"location": "北京市", "items":[{"tall":60},{"tall":40},{"tall":20},{"tall":10}]} + ] +} diff --git a/src/packages/components/Charts/ConfinedSpace/Map/index.ts b/src/packages/components/Charts/ConfinedSpace/Map/index.ts new file mode 100644 index 0000000..d727651 --- /dev/null +++ b/src/packages/components/Charts/ConfinedSpace/Map/index.ts @@ -0,0 +1,14 @@ +import { ConfigType, PackagesCategoryEnum, ChartFrameEnum } from '@/packages/index.d' +import { ChatCategoryEnum, ChatCategoryEnumName } from '../../index.d' + +export const MapConfig: ConfigType = { + key: 'Map', + chartKey: 'VMap', + conKey: 'VCMap', + title: '无无敌大地图', + category: 'ConfinedSpace', + categoryName: '有限空间', + package: PackagesCategoryEnum.CHARTS, + chartFrame: ChartFrameEnum.COMMON, + image: 'map1.png' +} \ No newline at end of file diff --git a/src/packages/components/Charts/ConfinedSpace/Map/index.vue b/src/packages/components/Charts/ConfinedSpace/Map/index.vue new file mode 100644 index 0000000..9b58c01 --- /dev/null +++ b/src/packages/components/Charts/ConfinedSpace/Map/index.vue @@ -0,0 +1,92 @@ + + + + + \ No newline at end of file diff --git a/src/packages/components/Charts/ConfinedSpace/index.ts b/src/packages/components/Charts/ConfinedSpace/index.ts new file mode 100644 index 0000000..54b5e8b --- /dev/null +++ b/src/packages/components/Charts/ConfinedSpace/index.ts @@ -0,0 +1,4 @@ +import {MapConfig} from './Map' + + +export default [MapConfig] \ No newline at end of file diff --git a/src/packages/components/Charts/index.d.ts b/src/packages/components/Charts/index.d.ts index f0d4666..13a06a6 100644 --- a/src/packages/components/Charts/index.d.ts +++ b/src/packages/components/Charts/index.d.ts @@ -6,6 +6,7 @@ export enum ChatCategoryEnum { SCATTER = 'Scatters', MAP = 'Maps', MyComponets='MyComponets', + ConfinedSpace='ConfinedSpace', MORE = 'Mores' } @@ -16,6 +17,7 @@ export enum ChatCategoryEnumName { SCATTER = '散点图', MAP = '地图', MyComponets='我的混合组件', + ConfinedSpace='有限空间', COMBINATION = '组合图', MORE = '更多' } diff --git a/src/packages/components/Charts/index.ts b/src/packages/components/Charts/index.ts index e56712f..4725c01 100644 --- a/src/packages/components/Charts/index.ts +++ b/src/packages/components/Charts/index.ts @@ -5,6 +5,9 @@ import Scatters from './Scatters' import Mores from './Mores' import Maps from './Maps' import MyComponets from './MyComponents' +import ConfinedSpace from './ConfinedSpace' -export const ChartList = [...Bars, ...Lines, ...Pies, ...Scatters, ...Maps, ...Mores, ...MyComponets] +export const ChartList = [...Bars, ...Lines, ...Pies, ...Scatters, ...Maps, ...Mores, ...MyComponets + , ...ConfinedSpace +]