@worm-print-platform/echarts 1.5.2 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,119 +1,105 @@
1
- <p align="center">
2
- <strong>@worm-print-platform/echarts</strong><br>
3
- <em>打印模板 ECharts 图表元素可选包</em>
4
- </p>
1
+ # 百度图表插件(@worm-print-platform/plugin-echarts)
5
2
 
6
- <p align="center">
7
- <img src="https://img.shields.io/badge/npm-v1.5.2-384BFF" alt="npm">
8
- <img src="https://img.shields.io/badge/license-MIT-9A9A9A" alt="license">
9
- </p>
3
+ worm-print-platform 插件市场的百度图表插件:**十类 ECharts 图表元素 + 设计器 UI,import 即注册**。
10
4
 
11
- > monorepo 根:[worm-print-platform](https://github.com/worm-longliu/worm-print-platform)
5
+ 本目录 `marketplace/plugins/echarts/` 是图表插件的**唯一源码真源**。同一份源码构建出两个 npm 包:
12
6
 
13
- 一个插件注册十个图表元素:提供 ECharts SSR SVG 渲染器、页面执行器、设计器画布 / 图形化属性面板与共享数据契约。主包 `@worm-print-platform/core` 与 `@worm-print-platform/canvas` **不依赖任何图表库**,只有本包引入 `echarts`(Apache-2.0)。
7
+ | 包名 | 定位 | 根入口行为 |
8
+ | --- | --- | --- |
9
+ | `@worm-print-platform/plugin-echarts` | 插件市场主口径(推荐) | 注册插件描述符 + 设计器 UI |
10
+ | `@worm-print-platform/echarts` | 兼容镜像,供存量依赖方零改动使用 | 仅注册插件描述符(原行为) |
14
11
 
15
- **「import 即注册」**:宿主不需要写任何注册代码,也不需要手写渲染器传参。
16
-
17
- ## 安装
12
+ ## 安装(插件市场口径,推荐)
18
13
 
19
14
  ```bash
20
- npm i @worm-print-platform/echarts
15
+ npx @worm-print-platform/marketplace install echarts
21
16
  ```
22
17
 
23
- 依赖:`echarts`(^6.1.0)、`@worm-print-platform/core`、`@worm-print-platform/plugin-kit`
18
+ 宿主按清单加载插件入口(import 即注册,无需额外调用):
24
19
 
25
- ## 十个元素
20
+ ```js
21
+ import '../.worm-print/plugins/echarts/dist/marketplace.js'
22
+ ```
26
23
 
27
- | type | 元素 | 默认尺寸 | 数据映射要点 |
28
- | --- | --- | --- | --- |
29
- | `barChart` | 柱状图 | 100×60mm | 类目 + 多数值字段(多值多系列) |
30
- | `barHChart` | 条形图(横向) | 100×60mm | 类目写 yAxis,xAxis 为数值 |
31
- | `lineChart` | 折线图 | 100×60mm | 同柱状图,series 为 line |
32
- | `areaChart` | 面积图 | 100×60mm | 折线 + areaStyle |
33
- | `pieChart` | 饼图 | 60×60mm | 类目 + 首数值 → `{ name, value }` |
34
- | `doughnutChart` | 环形图 | 60×60mm | 饼图 + 可配内径 |
35
- | `scatterChart` | 散点图 | 80×60mm | 类目作 x、首数值作 y;`chartBubble` 开启时第二数值作点大小 |
36
- | `radarChart` | 雷达图 | 70×60mm | 数值字段 = 维度,每行一个系列 |
37
- | `funnelChart` | 漏斗图 | 60×60mm | 类目 + 首数值,按数值降序 |
38
- | `gaugeChart` | 仪表盘 | 60×60mm | 取首行首值;min/max 面板可配 |
24
+ 插件安装后,素材台出现「图表」分组的十张卡片:柱状图、条形图、折线图、面积图、饼图、环形图、
25
+ 散点图、雷达图、漏斗图、仪表盘。
39
26
 
40
- 所有元素共用同一份数据契约:`chartOption` + `chartDataSource` / `chartCategoryField` / `chartValueFields` / `chartSeriesField`。模板只存 option 模板与字段映射,真实数据由 core 绑定阶段注入。
27
+ ## 作为 npm 包使用
41
28
 
42
- ## 用法
29
+ ```bash
30
+ npm install @worm-print-platform/plugin-echarts
31
+ ```
43
32
 
44
- ### 设计器 / 浏览器宿主
33
+ ```js
34
+ // 主入口:插件描述符 + 设计器 UI 一次注册完成
35
+ import '@worm-print-platform/plugin-echarts'
45
36
 
46
- ```ts
47
- // 一行副作用 import:素材卡、画布、属性面板、校验、绑定、出图全部生效
48
- import '@worm-print-platform/echarts'
37
+ // 按需子路径
38
+ import '@worm-print-platform/plugin-echarts/kit' // 仅框架无关插件描述符(无 UI)
39
+ import '@worm-print-platform/plugin-echarts/ui' // 仅设计器 UI
49
40
  ```
50
41
 
51
- ### 服务端 PDF / Electron 主进程
42
+ 服务端 PDF / Electron 静默打印使用 `@worm-print-platform/plugin-echarts/node` 与
43
+ `/browser/executor.iife`(页面执行器),浏览器直挂使用 `/browser` UMD 产物。
52
44
 
53
- ```ts
54
- // ① 部署白名单:显式 import 才允许该插件进入注册表
55
- import '@worm-print-platform/echarts/node'
45
+ 存量项目若仍依赖 `@worm-print-platform/echarts`,无需改动:兼容镜像保留全部原有子路径
46
+ (`.`、`/kit`、`/ui`、`/node`、`/browser`、`/browser/executor.iife`)与行为。
56
47
 
57
- // ② runtime 装配:执行器由注册表自动收集,新增插件无需改这行
58
- import { collectExecutorBundles, createDomHostRuntime } from '@worm-print-platform/core'
59
- createDomHostRuntime(factory, loadExecutorBundle(), collectExecutorBundles())
60
- ```
48
+ ## 数据标签
61
49
 
62
- ### 零框架宿主 / 自建设计器 UI(`/kit`)
50
+ 属性面板的「自定义属性」页签内含一个可折叠的「数据标签」分组,配置直接写入
51
+ `chartOption.series[].label`(仪表盘写 `series[].detail`),与模板里手写的标签是同一份数据。
63
52
 
64
- `/kit` 是**框架无关的纯 TS 出口**:不包含任何 `.vue` 组件、不读磁盘,import 即把十个 kind 注册到 core 插件注册表,但**不**注册设计器组件与执行器产物。
53
+ | 块 | 字段 | 控件 |
54
+ | --- | --- | --- |
55
+ | 内容 | 显示数据标签、数据标签内容(formatter)、溢出处理 | 开关、预设下拉 + 文本框、下拉 |
56
+ | 位置 | 标签位置、距离、旋转、水平 / 垂直偏移 | 下拉、数字 |
57
+ | 样式 | 字号、字重、文字颜色、背景色、边框色、边框宽度、圆角、内边距 | 数字、下拉、文本 |
58
+ | 引导线 | 显示引导线、引导线长度、第二段长度、平滑引导线 | 开关、数字(饼图 / 环形图 / 漏斗图) |
65
59
 
66
- ```ts
67
- import {
68
- CHART_KIND_DEFINITIONS, createDefaultChartOption, normalizeChartOption,
69
- previewChartOption, renderChartToSvg,
70
- } from '@worm-print-platform/echarts/kit'
71
- ```
60
+ 字段按图表能力分档:柱状 / 条形 / 折线 / 面积开放全部基础项,散点额外支持距离,
61
+ 雷达只给内容与字号 / 字重 / 颜色,仪表盘走 `detail`(数值文本)。
72
62
 
73
- ## 配置
74
-
75
- ```ts
76
- import { configureChartPlugin } from '@worm-print-platform/echarts'
77
-
78
- configureChartPlugin({
79
- defaultWidth: 120, // 新建图表元素的全局默认尺寸
80
- defaultHeight: 70,
81
- palettes: {
82
- default: { label: '企业蓝', colors: ['#165DFF', '#36B37E'] },
83
- brand: { label: '品牌色', colors: ['#F2704E', '#F7A35C'] },
84
- },
85
- sampleCategories: ['一季度', '二季度', '三季度'],
86
- components: [GaugeChart], // 追加 echarts.use 的图表/组件构造器
87
- })
88
- ```
63
+ formatter 预设:数值 `{c}`、名称: 数值 `{b}: {c}`、名称 `{b}`、百分比 `{d}%`;
64
+ 也可以直接手写 ECharts 字符串模板。预设与手写都只写 `formatter` 一个键。
65
+
66
+ 默认行为:
89
67
 
90
- 配置是**惰性**的:可在注册前调用、按键合并,不需要注销重注册。
68
+ - 未打开总开关时不写入任何 label 键,存量模板渲染结果不变。
69
+ - 打开总开关时按图表写入一套默认集(例:柱状图 `position: 'top'` + `fontSize: 12`;
70
+ 饼图额外写 `overflow: 'none'`,避免小尺寸下标签被 `truncate` 裁空),已有值不覆盖。
71
+ - 关闭总开关只写 `show: false`,字号 / 颜色 / formatter 等配置保留,重开即还原。
91
72
 
92
- ## 导出
73
+ 手写通道仍然有效,适合需要 `rich` 富文本等面板未覆盖的场景:
93
74
 
94
- | 子路径 | 内容 |
95
- | --- | --- |
96
- | `.` | `CHART_PLUGIN` / `CHART_KIND_DEFINITIONS` / `createDefaultChartOption` / `renderChartToSvg` / `configureChartPlugin` 等(注册副作用 + 纯 TS 能力) |
97
- | `/kit` | 框架无关纯 TS 出口(无 Vue、无 `node:fs`) |
98
- | `/node` | 注册副作用 + `render.executorBundle()`(惰性读取 IIFE 产物,服务端装配用) |
99
- | `/ui` | plugin-kit 设计器 UI(静态 SVG 画布 + 原生 DOM 属性面板) |
100
- | `/browser` | UMD bundle(`dist/echarts.js`) |
75
+ ```js
76
+ chartOption: {
77
+ series: [{
78
+ type: 'bar',
79
+ data: ['$data'],
80
+ label: { show: true, position: 'top', formatter: '{b}: {c}' },
81
+ }],
82
+ }
83
+ ```
101
84
 
102
- `type-augmentation.ts` 用声明合并把十个图表类型与 `chartOption` 等专属字段注入 core 的类型扩展点。
85
+ 不支持:`rich` 富文本、`emphasis.label`(SSR 导出只含 normal 态)、`labelLayout`
86
+ (防重叠会改变存量观感,后续单独立项)。
103
87
 
104
- ## 开发
88
+ ## 独立发布
89
+
90
+ 两个包均可单独 `npm publish`,且从同一源码生成:
105
91
 
106
92
  ```bash
107
- npm run build # vite + tsc + tsup
108
- npm test # vitest
93
+ cd marketplace/plugins/echarts
94
+ npm run build # vite + tsc + tsup + UMD + 兼容镜像同步
95
+ npm publish --registry=https://registry.npmjs.org --access public
96
+ # 根目录:npm publish -w @worm-print-platform/echarts(兼容镜像)
109
97
  ```
110
98
 
111
- ## 相关链接
112
-
113
- - [根 README](https://github.com/worm-longliu/worm-print-platform/blob/main/README.md)
114
- - [插件化自定义元素章节](https://github.com/worm-longliu/worm-print-platform/blob/main/README.md#插件化自定义元素)
115
- - [plugin-kit 契约](../plugin-kit/README.md)
99
+ 发版时同步 `marketplace.json`、`plugin.json`、本 `package.json` 的 `wormPrint.version`;市场 CLI
100
+ 通过本仓 tag `plugins/echarts/vX.Y.Z` 解析稳定版本。完整收录与版本规则见
101
+ [docs/plugin-marketplace.md](../../../docs/plugin-marketplace.md)。
116
102
 
117
- ## License
103
+ ## 信任边界
118
104
 
119
- [MIT](../../LICENSE)
105
+ 市场不做沙箱。插件代码在宿主进程内运行,等同于普通 npm 依赖;信任来自 PR 审核与版本锁定。
package/dist/bind.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @worm-print-platform/echarts v1.5.2
2
+ * @worm-print-platform/echarts v1.6.0
3
3
  * Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
4
4
  * SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
5
5
  * SPDX-License-Identifier: MIT
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @worm-print-platform/echarts v1.5.2
2
+ * @worm-print-platform/echarts v1.6.0
3
3
  * Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
4
4
  * SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
5
5
  * SPDX-License-Identifier: MIT
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @worm-print-platform/echarts v1.5.2
2
+ * @worm-print-platform/echarts v1.6.0
3
3
  * Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
4
4
  * SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
5
5
  * SPDX-License-Identifier: MIT
package/dist/config.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @worm-print-platform/echarts v1.5.2
2
+ * @worm-print-platform/echarts v1.6.0
3
3
  * Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
4
4
  * SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
5
5
  * SPDX-License-Identifier: MIT
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @worm-print-platform/echarts v1.5.2
2
+ * @worm-print-platform/echarts v1.6.0
3
3
  * Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
4
4
  * SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
5
5
  * SPDX-License-Identifier: MIT
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @worm-print-platform/echarts v1.5.2
2
+ * @worm-print-platform/echarts v1.6.0
3
3
  * Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
4
4
  * SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
5
5
  * SPDX-License-Identifier: MIT
package/dist/echarts.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @worm-print-platform/echarts v1.5.2
2
+ * @worm-print-platform/echarts v1.6.0
3
3
  * Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
4
4
  * SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
5
5
  * SPDX-License-Identifier: MIT