diff --git a/docs/assets/guide/menu.json b/docs/assets/guide/menu.json index e4ebcf8e8..0aa1510a5 100644 --- a/docs/assets/guide/menu.json +++ b/docs/assets/guide/menu.json @@ -544,18 +544,25 @@ "en": "Theme" }, "children": [ + { + "path": "Theme_Concept_and_Design_Rules", + "title": { + "zh": "主题概念和设计规范", + "en": "Theme Concept and Design Rules" + } + }, { "path": "Theme", "title": { - "zh": "图表主题", - "en": "Chart Theme" + "zh": "主题配置", + "en": "Theme Configuration" } }, { "path": "Color_Theme", "title": { - "zh": "色板", - "en": "Color Palette" + "zh": "色板配置", + "en": "Color Palette Configuration" } }, { diff --git a/docs/assets/guide/zh/tutorial_docs/Theme/Theme.md b/docs/assets/guide/zh/tutorial_docs/Theme/Theme.md index 56efafb20..c38f0ed5f 100644 --- a/docs/assets/guide/zh/tutorial_docs/Theme/Theme.md +++ b/docs/assets/guide/zh/tutorial_docs/Theme/Theme.md @@ -1,6 +1,6 @@ -# 图表主题 +# 主题配置 -图表主题(Theme)是 VChart 的一种强大特性,它提供了统一的配置方式来控制图表的全局样式、色板、图元、系列和组件样式等。使用图表主题能够让你的图表样式在整个项目中更具有统一性和可复用性,提升开发效率。 +如上节所述,图表主题(Theme)是 VChart 的一种强大特性,它提供了统一的配置方式来控制图表的全局样式、色板、图元、系列和组件样式等。使用图表主题能够让你的图表样式在整个项目中更具有统一性和可复用性,提升开发效率。 下面将详细介绍 VChart 的图表主题配置。 @@ -120,7 +120,7 @@ interface ITheme { } ``` 在 VChart 内部逻辑中,`ITheme.mark`的每个成员将**按照图元类型**合并到每个系列的各个图元的 spec 中。 -- `ITheme.markByName`: 全局 mark 样式属性,按 mark 名称索引,优先级更高。 +- `ITheme.markByName`: 全局 mark 样式属性,按 mark 名称索引,优先级更高。 这个配置项十分便于对多个系列的一些公共配置进行修改。其类型`IGlobalMarkThemeByName`定义如下: ```ts diff --git a/docs/assets/guide/zh/tutorial_docs/Theme/Theme_Concept_and_Design_Rules.md b/docs/assets/guide/zh/tutorial_docs/Theme/Theme_Concept_and_Design_Rules.md new file mode 100644 index 000000000..9eddedc69 --- /dev/null +++ b/docs/assets/guide/zh/tutorial_docs/Theme/Theme_Concept_and_Design_Rules.md @@ -0,0 +1,2171 @@ +# 主题概念和设计规范 + +## 主题简介 + +VChart 支持对图表主题的整体配置和复用。在概念上,VChart 主题主要由图表布局参数、图表样式以及数据色板组成。 + +在配置了合适主题的情况下,用户只需要在 spec 中声明**图表类型**、**图表数据**以及**图表结构**(比如要显示的系列和组件等),就可以渲染出符合设计规范和目标风格的图表。 + +在具体接口定义上,VChart 主题的配置包含以下几个部分: + +- 主题信息(主题命名等) +- 图表层级样式(图表背景色、边距等) +- 全局样式(全局字体) +- 色板(包含数据色板、语义色板) +- 图元样式配置 +- 系列样式配置 +- 组件样式配置 + +在经验上,**色板**、**图元样式配置**、**组件样式配置**和**系列样式配置**是一个定义一个新主题最基本的配置。 + +## VChart 默认主题构成 + +VChart 默认主题的预设可以分为以下几部分: + +### 数据色板 + +color scheme + +数据色板是在图表中用于区分数据组的离散色板,也通常用于区分图例项。如以下两个图表中不同数据组的色板,在颜色队列中按顺序取色: + +
+ line chart + bar chart +
+ +数据色板也可以是动态的、渐进式的。比如默认色板会根据数据项数量的范围来动态调整: + +color scheme + +如以上规则,数据组不超过 10 个时,采用 10 色的色板;数据组超过 10 个时,采用 20 色的色板。如果数据组超过 20 个,则会重复应用色板颜色,从第 1 个开始。 + +### 语义色板 + +VChart 默认主题定义了一套语义色板,用于描述可以复用的颜色。语义色板的形式为从 token 到色值的映射表。 + +默认主题预设了一套 token,并根据这套 token 实现了亮色主题和暗色主题。下表以 1.6.3 版本为准: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

分类

序号

token(默认主题的语义色板)

描述、应用范围和默认色值

实际 case(截图来自默认主题真实图表)

图表层级样式

1

+

backgroundColor

+
+

背景色

+

用于图表背景、图元描边。

+

+ + light + + #ffffff + + + dark + + #202226 + +

+
+

图表背景色

+

+ light + dark +

+
+

point 图元描边颜色

+

+ light + dark +

+
+

数据标签描边颜色

+

+ light + dark +

+
+

播放器滑块描边颜色

+

+ light + dark +

+

2

+

borderColor

+
+

图表边框色

+

用于图表边框(图表内暂时没有实际应用,仅有指导意义)。

+

+ + light + + #e3e5e8 + + + dark + + #404349 + +

+
+

图表边框色

+

+ light + dark +

+

公共

3

+

shadowColor

+
+

默认阴影颜色

+

用于浮层、滑块等带高度属性的图元阴影。

+

+ + light + + rgba(33,37,44,0.1) + + + dark + + rgba(0,0,0,0.1) + +

+
+

提示信息阴影颜色

+

+ light + dark +

+
+

poptip 阴影颜色

+

+ light + dark +

+
+

颜色图例滑块阴影颜色

+

+ light + dark +

+

4

+

hoverBackgroundColor

+
+

鼠标 Hover 背景颜色

+

用于元素在鼠标 hover 状态的背景颜色。

+

+ + light + + #f1f2f5 + + + dark + + #404349 + +

+
+

图例项 hover 背景色

+

+ light + dark +

+

5

+

sliderRailColor

+
+

滑块类组件背景条填充颜色

+

用于滑块类组件背景条的填充颜色。

+

+ + light + + #f1f3f4 + + + dark + + #404349 + +

+
+

缩略轴背景区域颜色

+

+ light + dark +

+
+

播放器未播放轨道颜色

+

+ light + dark +

+
+

颜色图例轨道颜色

+

+ light + dark +

+
+

尺寸图例轨道颜色

+

+ light + dark +

+

6

+

sliderHandleColor

+
+

滑块类组件滑块填充颜色

+

用于滑块类组件滑块的填充颜色。

+

+ + light + + #ffffff + + + dark + + #202226 + +

+
+

缩略轴滑块填充颜色

+

+ light + dark +

+
+

尺寸图例滑块填充颜色

+

+ light + dark +

+

7

+

sliderTrackColor

+
+

滑块类组件已选范围填充颜色

+

用于滑块类组件已选范围的填充颜色。

+

+ + light + + #0040ff + + + dark + + #4284FF + +

+
+

缩略轴选择区域颜色

+

+ light + dark +

+
+

播放器已播放轨道颜色

+

+ light + dark +

+
+

尺寸图例选中部分轨道颜色

+

+ light + dark +

+

8

+

popupBackgroundColor

+
+

浮层背景区域颜色

+

用于浮层的背景区域颜色。

+

+ + light + + #ffffff + + + dark + + #404349 + +

+
+

提示信息背景框颜色

+

+ light + dark +

+
+

poptip 背景框颜色

+

+ light + dark +

+

字体颜色

9

+

primaryFontColor

+
+

主要字色

+

颜色和背景色差异最大的字色,用于最显要的信息展示。

+

+ + light + + #21252c + + + dark + + #fdfdfd + +

+
+

图表主标题字色

+

+ light + dark +

+
+

指标卡主要字色

+

+ light + dark +

+
+

poptip 标题字色

+

+ light + dark +

+
+

poptip 内容字色

+

+ light + dark +

+
+

提示信息标题字色

+

+ light + dark +

+
+

Mark-line 标签字色

+

+ light + dark +

+
+

Mark-area 标签字色

+

+ light + dark +

+
+

图例标题字色

+

+ light + dark +

+

10

+

secondaryFontColor

+
+

次要字色

+

颜色和背景色差异较小的字色,用于次要的信息展示。

+

+ + light + + #606773 + + + dark + + #888c93 + +

+
+

轴标题字色

+

+ light + dark +

+
+

图例标签字色

+

+ light + dark +

+
+

提示信息数据 key 字色

+

+ light + dark +

+
+

缩略轴标签字色

+

+ light + dark +

+

11

+

tertiaryFontColor

+
+

第三字色

+

颜色和背景色差异更小的字色,用于更次要的信息展示。

+

+ + light + + #89909d + + + dark + + #bbbdc3 + +

+
+

图表副标题字色

+

+ light + dark +

+
+

指标卡次要字色

+

+ light + dark +

+

12

+

axisLabelFontColor

+
+

轴标签字色

+

用于轴标签字色,默认与第三字色颜色相同。

+

+ + light + + #89909d + + + dark + + #bbbdc3 + +

+
+

轴标签字色

+

+ light + dark +

+

13

+

disableFontColor

+
+

禁用字色

+

用于禁用状态字色或非激活态字色。

+

+ + light + + #bcc1cb + + + dark + + #55595f + +

+
+

非激活态图例标签字色

+

+ light + dark +

+

14

+

axisMarkerFontColor

+
+

轴高亮标记字色

+

用于轴标签上的高亮标记字色。

+

+ + light + + #ffffff + + + dark + + #202226 + +

+
+

十字准星标签字色

+

+ light + dark +

+

轴样式

15

+

axisGridColor

+
+

轴网格线颜色

+

用于轴网格线颜色以及同级的颜色。

+

+ + light + + #f1f2f5 + + + dark + + #404349 + +

+
+

轴网格线颜色

+

+ light + dark +

+
+

十字准星矩形颜色

+

+ light + dark +

+

16

+

axisDomainColor

+
+

轴线颜色

+

用于轴线颜色以及同级的颜色。

+

+ + light + + #d9dde4 + + + dark + + #4b4f54 + +

+
+

轴线颜色

+

+ light + dark +

+

缩略轴

17

+

dataZoomHandlerStrokeColor

+
+

缩略轴滑块描边颜色

+

用于缩略轴滑块描边颜色以及同级的颜色。

+

+ + light + + #aeb5be + + + dark + + #888c93 + +

+
+

缩略轴滑块描边颜色

+

+ light + dark +

+

18

+

dataZoomChartColor

+
+

缩略轴图表区域颜色

+

用于缩略轴预览图表的颜色以及同级的颜色。

+

+ + light + + #c9ced8 + + + dark + + #55595F + +

+
+

缩略轴图表区域颜色

+

+ light + dark +

+
+

尺寸图例尺寸标识颜色

+

+ light + dark +

+

播放器

19

+

playerControllerColor

+
+

播放器控制器填充颜色

+

用于播放器控制器的填充颜色。

+

+ + light + + #0040ff + + + dark + + #0040ff + +

+
+

播放器按钮颜色

+

+ light + dark +

+
+

播放器滑块颜色

+

+ light + dark +

+

滚动条

20

+

scrollBarSliderColor

+
+

滚动条滑块颜色

+

用于滚动条滑块的填充颜色。

+

+ + light + + rgba(0,0,0,0.3) + + + dark + + rgba(255,255,255,0.3) + +

+
+

滚动条滑块颜色

+

+ light + dark +

+

标注

21

+

axisMarkerBackgroundColor

+
+

轴高亮标记背景色

+

用于轴标签上的高亮标记背景色。

+

+ + light + + #21252c + + + dark + + #fdfdfd + +

+
+

十字准星标签背景色

+

+ light + dark +

+

22

+

markLabelBackgroundColor

+
+

标注标签背景颜色

+

用于普通标注标签的背景颜色。

+

+ + light + + #f1f2f5 + + + dark + + #404349 + +

+
+

Mark-line 标签背景色

+

+ light + dark +

+
+

Mark-area 标签背景色

+

+ light + dark +

+

23

+

markLineStrokeColor

+
+

标注线颜色

+

用于普通标注线的颜色。

+

+ + light + + #606773 + + + dark + + #888c93 + +

+
+

Mark-line 线条颜色

+

+ light + dark +

+
+

十字准星线形颜色

+

+ light + dark +

+
+

Mark-point 线条颜色

+

+ light + dark +

+

功能色

24

+

dangerColor

+
+

危险色

+

危险、错误、失败、盈利、上升、女性。

+

+ + light + + #e33232 + + + dark + + #eb4b4b + +

+

无内置应用场景

25

+

warningColor

+
+

警告色

+

预警、警示。

+

+ + light + + #ffc528 + + + dark + + #f0bd30 + +

+

无内置应用场景

26

+

successColor

+
+

成功色

+

安全、正确、成功、亏损、下降。

+

+ + light + + #07a35a + + + dark + + #14b267 + +

+

无内置应用场景

27

+

infoColor

+
+

信息色

+

正常、寒冷、男性。

+

+ + light + + #3073f2 + + + dark + + #4284ff + +

+

无内置应用场景

+ +VChart 主题模块支持自定义语义色板,同时可以定义新的 token 集合,在主题或 spec 各处引用 token 以引用对应颜色,具体详见“色板”一节。 + +### 字色与字阶 + +在默认主题中,文字色大致分以下四档,具体应用可见上文的 token 列表。 + +text color + +同时,字号和行间距在官方主题中分为以下 6 阶: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

字阶

字重

字号

行高(仅作指导意义)

字间距(仅作指导意义)

应用范围(截图来自实际图表)

+

1

+

Medium

32px

1.5

-0.5

+

指标卡标题

+

+ light + dark +

+
+

2

+

Medium

20px

1.4

-0.4

+

指标卡内容

+

+ light + dark +

+
+

3

+

Medium

16px

1.5

-0.2

+

图表标题

+

+ light + dark +

+
+

4(默认)

+

Medium

14px

1.5

0

+

数据标签

+

+ light + dark +

+
+

Mark-line 标签

+

+ light + dark +

+
+

Mark-area 标签

+

+ light + dark +

+
+

提示信息

+

+ light + dark +

+
+

图表副标题

+

+ light + dark +

+
+

5

+

Regular

12px

1.3

0

+

poptip

+

+ light + dark +

+
+

图例标题

+

+ light + dark +

+
+

图例标签

+

+ light + dark +

+
+

颜色图例标签

+

+ light + dark +

+
+

尺寸图例标签

+

+ light + dark +

+
+

缩略轴标签

+

+ light + dark +

+
+

十字准星标签

+

+ light + dark +

+
+

轴标题

+

+ light + dark +

+
+

轴标签

+

+ light + dark +

+
+

一些其他系列的标签,如:时序图、旭日图、矩形树图、嵌套圆图系列等

+
+

6

+

Regular

10px

1.2

0

+

地图标签

+
+ +### 组件布局 + +默认主题规范中定义了组件和图表的布局参数。下面以带图例的图表在 pc 端的布局参数为例: + +color scheme + +color scheme + +color scheme + +color scheme + +目前默认主题中高频组件的布局参数如下: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

图表元素(组件)

+
+

位置和对齐

+
+

边距(padding)

+
+

示例

+
+

图表整体

+
+

+
+

20 20 20 20

+
+

+ light + dark +

+
+

标题

+
+

top,左对齐

+
+

4 0 20 0

+
+

离散图例

+
+

bottom,居中对齐

+
+

16 24 16 24

+
+

缩略轴

+
+

跟随轴

+
+

12 0 12 0

+
+

+ light + dark +

+
+

颜色图例

+
+

right,竖直居中对齐

+
+

16 24 16 24

+
+

+ light + dark +

+
+

尺寸图例

+
+

right,竖直居中对齐

+
+

16 24 16 24

+
+

+ light + dark +

+
+

播放器

+
+

bottom,左对齐

+
+

20 0 20 0

+
+ +## 扩展主题 ABC + +如果面向一个新的设计规范扩展 VChart 主题,需要解决哪些可能的问题? + +### 1. 产出一套或多套数据色板 + +通常面向组件库的设计规范并不会直接对图表的数据色板形成指导,因此这个问题可能是最复杂的。新的数据色板需要满足以下要求: + +1. 色板符合目标设计规范,符合目标业务场景的调性 +2. 色板颜色足够多(通常 10 种颜色左右或更多) +3. 相邻颜色区分度强,图表展现效果好 +4. 色板整体符合某个特定的风格 +5. 可访问性强,如对色弱人士友好等 + +数据色板是一个图表主题最容易被直观感受到的部分,因此尤为重要。 + +### 2. 将目标设计规范的 token 翻译为图表语义色板 token + +目前默认主题的语义色板中的颜色是由 Arco Design 定义的颜色转化而来,其中很多颜色可以用 Arco Design 的 token 来表示。 + +如果要面向新的设计规范扩展图表主题,也需要经历这个步骤,即用目标设计规范定义的颜色来填充上文中语义色板的表格,或者直接定义新的 token 集合(如果这个设计规范下有现成的图表 demo,将会大大方便这一步骤)。 + +### 3. 图表组件定制与布局调整 + +在新的设计规范所对应的业务场景中,可能会对部分组件的样式有定制需求。这时需要收集具体需求并在主题中进行定制。 + +图表布局往往也需要根据业务场景的特点进行调整。 + +### 4. 交互效果、跨端 + +默认交互效果以及跨端优化也有很大一部分可以通过图表主题来配置,属于对主题进一步的定制。这部分同样需要收集具体需求和已经落地的案例,在主题中抽象出最佳实践并进行沉淀。 + +下一节将详细讲述 VChart 的主题配置功能。 diff --git a/docs/public/vchart/guide/theme/0.png b/docs/public/vchart/guide/theme/0.png new file mode 100644 index 000000000..c9d73e845 Binary files /dev/null and b/docs/public/vchart/guide/theme/0.png differ diff --git a/docs/public/vchart/guide/theme/1.png b/docs/public/vchart/guide/theme/1.png new file mode 100644 index 000000000..d7d05fd26 Binary files /dev/null and b/docs/public/vchart/guide/theme/1.png differ diff --git a/docs/public/vchart/guide/theme/2.png b/docs/public/vchart/guide/theme/2.png new file mode 100644 index 000000000..e7c2c122b Binary files /dev/null and b/docs/public/vchart/guide/theme/2.png differ diff --git a/docs/public/vchart/guide/theme/3.png b/docs/public/vchart/guide/theme/3.png new file mode 100644 index 000000000..d1a5803a6 Binary files /dev/null and b/docs/public/vchart/guide/theme/3.png differ diff --git a/docs/public/vchart/guide/theme/bar-chart-dark.png b/docs/public/vchart/guide/theme/bar-chart-dark.png new file mode 100644 index 000000000..4cc587d41 Binary files /dev/null and b/docs/public/vchart/guide/theme/bar-chart-dark.png differ diff --git a/docs/public/vchart/guide/theme/bar-chart-light.png b/docs/public/vchart/guide/theme/bar-chart-light.png new file mode 100644 index 000000000..b9572b879 Binary files /dev/null and b/docs/public/vchart/guide/theme/bar-chart-light.png differ diff --git a/docs/public/vchart/guide/theme/color-legend-dark.png b/docs/public/vchart/guide/theme/color-legend-dark.png new file mode 100644 index 000000000..04e93a97d Binary files /dev/null and b/docs/public/vchart/guide/theme/color-legend-dark.png differ diff --git a/docs/public/vchart/guide/theme/color-legend-light.png b/docs/public/vchart/guide/theme/color-legend-light.png new file mode 100644 index 000000000..3984b6a93 Binary files /dev/null and b/docs/public/vchart/guide/theme/color-legend-light.png differ diff --git a/docs/public/vchart/guide/theme/column-chart-dark.png b/docs/public/vchart/guide/theme/column-chart-dark.png new file mode 100644 index 000000000..10808258f Binary files /dev/null and b/docs/public/vchart/guide/theme/column-chart-dark.png differ diff --git a/docs/public/vchart/guide/theme/column-chart-light.png b/docs/public/vchart/guide/theme/column-chart-light.png new file mode 100644 index 000000000..9058753e2 Binary files /dev/null and b/docs/public/vchart/guide/theme/column-chart-light.png differ diff --git a/docs/public/vchart/guide/theme/gauge-chart-dark.png b/docs/public/vchart/guide/theme/gauge-chart-dark.png new file mode 100644 index 000000000..758a098d3 Binary files /dev/null and b/docs/public/vchart/guide/theme/gauge-chart-dark.png differ diff --git a/docs/public/vchart/guide/theme/gauge-chart-light.png b/docs/public/vchart/guide/theme/gauge-chart-light.png new file mode 100644 index 000000000..f127b2aea Binary files /dev/null and b/docs/public/vchart/guide/theme/gauge-chart-light.png differ diff --git a/docs/public/vchart/guide/theme/heatmap-chart-dark.png b/docs/public/vchart/guide/theme/heatmap-chart-dark.png new file mode 100644 index 000000000..27d790554 Binary files /dev/null and b/docs/public/vchart/guide/theme/heatmap-chart-dark.png differ diff --git a/docs/public/vchart/guide/theme/heatmap-chart-light.png b/docs/public/vchart/guide/theme/heatmap-chart-light.png new file mode 100644 index 000000000..29ea12efe Binary files /dev/null and b/docs/public/vchart/guide/theme/heatmap-chart-light.png differ diff --git a/docs/public/vchart/guide/theme/layout-0.png b/docs/public/vchart/guide/theme/layout-0.png new file mode 100644 index 000000000..35bffd0a5 Binary files /dev/null and b/docs/public/vchart/guide/theme/layout-0.png differ diff --git a/docs/public/vchart/guide/theme/layout-1.png b/docs/public/vchart/guide/theme/layout-1.png new file mode 100644 index 000000000..fc70c9e17 Binary files /dev/null and b/docs/public/vchart/guide/theme/layout-1.png differ diff --git a/docs/public/vchart/guide/theme/layout-2.png b/docs/public/vchart/guide/theme/layout-2.png new file mode 100644 index 000000000..1df7f6a71 Binary files /dev/null and b/docs/public/vchart/guide/theme/layout-2.png differ diff --git a/docs/public/vchart/guide/theme/layout-3.png b/docs/public/vchart/guide/theme/layout-3.png new file mode 100644 index 000000000..33d5170fa Binary files /dev/null and b/docs/public/vchart/guide/theme/layout-3.png differ diff --git a/docs/public/vchart/guide/theme/line-chart-dark.png b/docs/public/vchart/guide/theme/line-chart-dark.png new file mode 100644 index 000000000..42e48b7b7 Binary files /dev/null and b/docs/public/vchart/guide/theme/line-chart-dark.png differ diff --git a/docs/public/vchart/guide/theme/line-chart-light.png b/docs/public/vchart/guide/theme/line-chart-light.png new file mode 100644 index 000000000..15f2bbcaa Binary files /dev/null and b/docs/public/vchart/guide/theme/line-chart-light.png differ diff --git a/docs/public/vchart/guide/theme/mark-area-dark.png b/docs/public/vchart/guide/theme/mark-area-dark.png new file mode 100644 index 000000000..dce949328 Binary files /dev/null and b/docs/public/vchart/guide/theme/mark-area-dark.png differ diff --git a/docs/public/vchart/guide/theme/mark-area-light.png b/docs/public/vchart/guide/theme/mark-area-light.png new file mode 100644 index 000000000..90b9403c9 Binary files /dev/null and b/docs/public/vchart/guide/theme/mark-area-light.png differ diff --git a/docs/public/vchart/guide/theme/mark-line-dark.png b/docs/public/vchart/guide/theme/mark-line-dark.png new file mode 100644 index 000000000..6660b64fa Binary files /dev/null and b/docs/public/vchart/guide/theme/mark-line-dark.png differ diff --git a/docs/public/vchart/guide/theme/mark-line-light.png b/docs/public/vchart/guide/theme/mark-line-light.png new file mode 100644 index 000000000..0096fa58d Binary files /dev/null and b/docs/public/vchart/guide/theme/mark-line-light.png differ diff --git a/docs/public/vchart/guide/theme/mark-point-dark.png b/docs/public/vchart/guide/theme/mark-point-dark.png new file mode 100644 index 000000000..ee84d86eb Binary files /dev/null and b/docs/public/vchart/guide/theme/mark-point-dark.png differ diff --git a/docs/public/vchart/guide/theme/mark-point-light.png b/docs/public/vchart/guide/theme/mark-point-light.png new file mode 100644 index 000000000..ee3b7512b Binary files /dev/null and b/docs/public/vchart/guide/theme/mark-point-light.png differ diff --git a/docs/public/vchart/guide/theme/pie-chart-dark.png b/docs/public/vchart/guide/theme/pie-chart-dark.png new file mode 100644 index 000000000..491973b7f Binary files /dev/null and b/docs/public/vchart/guide/theme/pie-chart-dark.png differ diff --git a/docs/public/vchart/guide/theme/pie-chart-light.png b/docs/public/vchart/guide/theme/pie-chart-light.png new file mode 100644 index 000000000..27a77a42a Binary files /dev/null and b/docs/public/vchart/guide/theme/pie-chart-light.png differ diff --git a/docs/public/vchart/guide/theme/player-dark.png b/docs/public/vchart/guide/theme/player-dark.png new file mode 100644 index 000000000..18d41225a Binary files /dev/null and b/docs/public/vchart/guide/theme/player-dark.png differ diff --git a/docs/public/vchart/guide/theme/player-light.png b/docs/public/vchart/guide/theme/player-light.png new file mode 100644 index 000000000..212bcce6d Binary files /dev/null and b/docs/public/vchart/guide/theme/player-light.png differ diff --git a/docs/public/vchart/guide/theme/point-dark.png b/docs/public/vchart/guide/theme/point-dark.png new file mode 100644 index 000000000..acc56f483 Binary files /dev/null and b/docs/public/vchart/guide/theme/point-dark.png differ diff --git a/docs/public/vchart/guide/theme/point-light.png b/docs/public/vchart/guide/theme/point-light.png new file mode 100644 index 000000000..5b0bc4011 Binary files /dev/null and b/docs/public/vchart/guide/theme/point-light.png differ diff --git a/docs/public/vchart/guide/theme/scatter-chart-dark.png b/docs/public/vchart/guide/theme/scatter-chart-dark.png new file mode 100644 index 000000000..4b717ba91 Binary files /dev/null and b/docs/public/vchart/guide/theme/scatter-chart-dark.png differ diff --git a/docs/public/vchart/guide/theme/scatter-chart-light.png b/docs/public/vchart/guide/theme/scatter-chart-light.png new file mode 100644 index 000000000..05279d1dd Binary files /dev/null and b/docs/public/vchart/guide/theme/scatter-chart-light.png differ diff --git a/docs/public/vchart/guide/theme/scroll-bar-dark.png b/docs/public/vchart/guide/theme/scroll-bar-dark.png new file mode 100644 index 000000000..b82fac4b6 Binary files /dev/null and b/docs/public/vchart/guide/theme/scroll-bar-dark.png differ diff --git a/docs/public/vchart/guide/theme/scroll-bar-light.png b/docs/public/vchart/guide/theme/scroll-bar-light.png new file mode 100644 index 000000000..ec84ca508 Binary files /dev/null and b/docs/public/vchart/guide/theme/scroll-bar-light.png differ diff --git a/docs/public/vchart/guide/theme/size-legend-dark.png b/docs/public/vchart/guide/theme/size-legend-dark.png new file mode 100644 index 000000000..6b2df4ddd Binary files /dev/null and b/docs/public/vchart/guide/theme/size-legend-dark.png differ diff --git a/docs/public/vchart/guide/theme/size-legend-light.png b/docs/public/vchart/guide/theme/size-legend-light.png new file mode 100644 index 000000000..f6baf83f6 Binary files /dev/null and b/docs/public/vchart/guide/theme/size-legend-light.png differ diff --git a/docs/public/vchart/guide/theme/text-color.png b/docs/public/vchart/guide/theme/text-color.png new file mode 100644 index 000000000..fa5137bf5 Binary files /dev/null and b/docs/public/vchart/guide/theme/text-color.png differ diff --git a/docs/public/vchart/guide/theme/tooltip-dark.png b/docs/public/vchart/guide/theme/tooltip-dark.png new file mode 100644 index 000000000..4db3bfd0d Binary files /dev/null and b/docs/public/vchart/guide/theme/tooltip-dark.png differ diff --git a/docs/public/vchart/guide/theme/tooltip-light.png b/docs/public/vchart/guide/theme/tooltip-light.png new file mode 100644 index 000000000..710583a9f Binary files /dev/null and b/docs/public/vchart/guide/theme/tooltip-light.png differ diff --git a/docs/src/markdown.tsx b/docs/src/markdown.tsx index 5f6a01342..2d4d5a881 100644 --- a/docs/src/markdown.tsx +++ b/docs/src/markdown.tsx @@ -9,6 +9,7 @@ import hljs from 'highlight.js'; import 'highlight.js/styles/atom-one-light.css'; const markdownParser = MarkdownIt({ + html: true, highlight: function (str, lang) { if (lang && hljs.getLanguage(lang)) { try { diff --git a/packages/vchart/__tests__/runtime/browser/test-page/pie.ts b/packages/vchart/__tests__/runtime/browser/test-page/pie.ts index d565257e1..f7a066b22 100644 --- a/packages/vchart/__tests__/runtime/browser/test-page/pie.ts +++ b/packages/vchart/__tests__/runtime/browser/test-page/pie.ts @@ -1,3 +1,4 @@ +import { isMobile } from 'react-device-detect'; import { default as VChart } from '../../../../src/index'; const spec = { @@ -317,296 +318,16 @@ const spec = { rose: { clipByLayout: true }, - dataKey: ['20001'] + dataKey: ['20001'], + tooltip: { + renderMode: 'canvas' + } }; -const vchart = new VChart(spec as any, { dom: document.getElementById('chart') as HTMLElement }); +const vchart = new VChart(spec as any, { + dom: document.getElementById('chart') as HTMLElement, + mode: isMobile ? 'mobile-browser' : 'desktop-browser' +}); vchart.renderAsync(); window['vchart'] = vchart; - -setTimeout(() => { - vchart.updateSpec({ - type: 'pie', - categoryField: '20001', - valueField: '230719190940041', - data: [ - { - id: 'data', - values: [ - { - '20001': '器具-东北', - '230719190940041': '407333.6141357422', - '230719190940044': '器具', - '230719190940047': '东北' - }, - { - '20001': '椅子-东北', - '230719190940041': '366799.0764160156', - '230719190940044': '椅子', - '230719190940047': '东北' - }, - { - '20001': '复印机-东北', - '230719190940041': '337993.04010009766', - '230719190940044': '复印机', - '230719190940047': '东北' - }, - { - '20001': '书架-东北', - '230719190940041': '295175.3292236328', - '230719190940044': '书架', - '230719190940047': '东北' - }, - { - '20001': '电话-东北', - '230719190940041': '280637.64530944824', - '230719190940044': '电话', - '230719190940047': '东北' - }, - { - '20001': '桌子-东北', - '230719190940041': '184567.76220703125', - '230719190940044': '桌子', - '230719190940047': '东北' - }, - { - '20001': '配件-东北', - '230719190940041': '180783.90380859375', - '230719190940044': '配件', - '230719190940047': '东北' - }, - { - '20001': '收纳具-东北', - '230719190940041': '162163.54042816162', - '230719190940044': '收纳具', - '230719190940047': '东北' - }, - { - '20001': '设备-东北', - '230719190940041': '136781.42694091797', - '230719190940044': '设备', - '230719190940047': '东北' - }, - { - '20001': '用具-东北', - '230719190940041': '74156.23627090454', - '230719190940044': '用具', - '230719190940047': '东北' - }, - { - '20001': '信封-东北', - '230719190940041': '50332.65993499756', - '230719190940044': '信封', - '230719190940047': '东北' - }, - { - '20001': '用品-东北', - '230719190940041': '47610.72386550903', - '230719190940044': '用品', - '230719190940047': '东北' - }, - { - '20001': '纸张-东北', - '230719190940041': '47254.48011779785', - '230719190940044': '纸张', - '230719190940047': '东北' - }, - { - '20001': '装订机-东北', - '230719190940041': '45179.95973491669', - '230719190940044': '装订机', - '230719190940047': '东北' - }, - { - '20001': '美术-东北', - '230719190940041': '25795.55990600586', - '230719190940044': '美术', - '230719190940047': '东北' - }, - { - '20001': '系固件-东北', - '230719190940041': '23673.776067733765', - '230719190940044': '系固件', - '230719190940047': '东北' - }, - { - '20001': '标签-东北', - '230719190940041': '15328.740070343018', - '230719190940044': '标签', - '230719190940047': '东北' - } - ], - transform: [ - { - type: 'fields', - options: { - fields: { - '20001': { - alias: '图例项 ', - domain: [ - '器具-东北', - '椅子-东北', - '复印机-东北', - '书架-东北', - '电话-东北', - '桌子-东北', - '配件-东北', - '收纳具-东北', - '设备-东北', - '用具-东北', - '信封-东北', - '用品-东北', - '纸张-东北', - '装订机-东北', - '美术-东北', - '系固件-东北', - '标签-东北' - ] - }, - '230719190940041': { - alias: '销售额' - }, - '230719190940044': { - alias: '子类别' - }, - '230719190940047': { - alias: '地区' - } - } - } - } - ] - } - ], - outerRadius: 0.75, - label: { - visible: true, - overlap: { - hideOnHit: true - }, - style: {}, - color: null, - strokeOpacity: 1, - strokeWidth: 0, - position: 'outside' - }, - color: { - field: '20001', - type: 'ordinal', - range: [ - '#2E62F1', - '#4DC36A', - '#FF8406', - '#FFCC00', - '#4F44CF', - '#5AC8FA', - '#003A8C', - '#B08AE2', - '#FF6341', - '#98DD62', - '#07A199', - '#87DBDD', - '#2E62F1', - '#4DC36A', - '#FF8406', - '#FFCC00', - '#4F44CF' - ], - specified: {} - }, - legends: [ - { - type: 'discrete', - orient: 'right', - position: 'start', - visible: true, - maxWidth: 257, - hover: false, - maxCol: 1, - title: { - textStyle: { - fontSize: 12, - fill: '#6F6F6F' - } - }, - item: { - spaceRow: 0, - spaceCol: 0, - padding: { - top: 4, - bottom: 4, - left: 4, - right: 22 - }, - background: { - style: { - fillOpacity: 0.001 - } - }, - label: { - style: { - fontSize: 12, - fill: '#6F6F6F' - } - }, - shape: { - style: { - symbolType: 'square' - } - } - }, - pager: { - textStyle: {}, - handler: { - style: {}, - state: { - disable: {} - } - } - }, - padding: { - top: 0, - bottom: 0, - left: 16, - right: 0 - } - } - ], - hover: { - enable: true - }, - select: { - enable: true - }, - pie: { - state: { - hover: { - cursor: 'pointer', - fillOpacity: 0.8, - stroke: '#58595B', - lineWidth: 1, - zIndex: 500, - outerRadius: 0.8 - }, - selected: { - cursor: 'pointer', - fillOpacity: 1, - stroke: '#58595B', - lineWidth: 1, - outerRadius: 0.8 - }, - selected_reverse: { - fillOpacity: 0.3, - strokeWidth: 0.3 - } - }, - clipByLayout: true - }, - background: 'rgba(255, 255, 255, 0)', - rose: { - clipByLayout: true - }, - dataKey: ['20001'] - }); -}, 1000);