@idux/charts-core 1.1.0 → 1.2.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @idux/charts-core
2
2
 
3
+ ## 1.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - ab38e82: Fix gradient tooltip markers and preserve light and dark tooltip styles when mounting outside the chart. Correct multi-axis and time-axis units, respect injected line themes, and align Gauge, Radar, and rose-chart presentation.
8
+
9
+ ## 1.2.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 879376a: Add CHART_THEME_TOKEN for reactive application-wide chart themes, with explicit per-chart themes taking precedence.
14
+
15
+ Use a dark loading mask for dark chart themes while retaining explicit loading overrides.
16
+
17
+ Let chart tooltips inherit theme surfaces, retaining the light Seer background.
18
+
3
19
  ## 1.1.0
4
20
 
5
21
  ### Minor Changes
package/README.md ADDED
@@ -0,0 +1,84 @@
1
+ # @idux/charts-core
2
+
3
+ English | [简体中文](README.zh.md)
4
+
5
+ The foundation of iDux Charts: the generic `IxChart` component, chart lifecycle composables, themes, types, and utilities. Use it for direct ECharts options or custom chart components.
6
+
7
+ For the unified entry point and shared tooltip styles, use [`@idux/charts`](https://github.com/IDuxFE/idux-charts/blob/main/packages/charts/README.md).
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ npm install @idux/charts-core echarts
13
+ ```
14
+
15
+ Supports Vue 2 (including Vue 2.6) and Vue 3. Use in an existing Vue project with peer dependencies Vue `^2.6.0 || ^3.2.5` and ECharts `^5.4.3 || ^6.0.0`. Vue 2.6 also requires `@vue/composition-api >=1.6.2` and plugin registration before creating the application.
16
+
17
+ ```bash
18
+ npm install @vue/composition-api
19
+ ```
20
+
21
+ ```ts
22
+ // Vue 2.6
23
+ import Vue from 'vue'
24
+ import VueCompositionAPI from '@vue/composition-api'
25
+
26
+ Vue.use(VueCompositionAPI)
27
+ ```
28
+
29
+ ## Quick start
30
+
31
+ This example uses Vue 3 `<script setup>` with a locally imported component. The container must have a nonzero width and height.
32
+
33
+ ```vue
34
+ <script setup lang="ts">
35
+ import { use } from 'echarts/core'
36
+ import { LineChart } from 'echarts/charts'
37
+ import { IxChart, type ChartProps } from '@idux/charts-core'
38
+
39
+ use([LineChart])
40
+
41
+ const option: ChartProps = {
42
+ xAxis: { type: 'category', data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'] },
43
+ yAxis: { type: 'value' },
44
+ series: [{ type: 'line', data: [123, 324, 156, 244, 188] }],
45
+ }
46
+ </script>
47
+
48
+ <template>
49
+ <div style="height: 320px">
50
+ <IxChart v-bind="option" />
51
+ </div>
52
+ </template>
53
+ ```
54
+
55
+ `IxChart` takes ECharts options directly through `v-bind`, rather than a separate `option` prop. It registers the SVG renderer, Grid, Legend, Tooltip, Title, DataZoom, LabelLayout, and UniversalTransition. Register custom series or additional components with `use` from `echarts/core`. For Canvas, also register `CanvasRenderer` and pass `initOption: { renderer: 'canvas' }`.
56
+
57
+ ## Core API
58
+
59
+ - `IxChart`: supports `autoResize` (enabled by default), `loading`, `theme`, `group`, `initOption`, `setOptionOpts`, and `onReady`.
60
+ - `useChart(options, listeners?)`: manages initialization, reactive updates, events, resizing, and disposal. Call it in component `setup`; it returns `containerRef` and `chartRef`.
61
+ - `seerTheme`: the built-in theme, registered as the default theme `seer`.
62
+ - `useTooltipsFormatter`, `useReactiveAttrs`, `createInstall`, and `withChartProps`: helpers for custom charts.
63
+ - `ChartProps`, `ChartPublicProps`, and `ChartOption`: public configuration types.
64
+
65
+ This package does not ship a separate CSS file. Shared HTML tooltip styles are provided by `@idux/charts/dist/style.css`.
66
+
67
+ ## Application themes
68
+
69
+ Use `CHART_THEME_TOKEN` to provide an application-wide theme name/object or a reactive ref. Explicit `theme` props override it; otherwise charts fall back to `seer`. Changing the inherited theme recreates the chart, following the existing theme lifecycle. For generated plot labels and graphics, also configure `PLOT_THEME_TOKEN` from `@idux/charts-plots` (or `@idux/charts`).
70
+
71
+ ## TypeScript
72
+
73
+ `*ChartProps` types describe chart configuration and allow extension fields. `*ChartPublicProps` expose named public properties while preserving their types and optionality for component type adapters. See the [repository README](https://github.com/IDuxFE/idux-charts/blob/main/README.md#typescript-prop-types) for adapter details.
74
+
75
+ ## Documentation
76
+
77
+ - [iDux Charts](https://charts.idux.site)
78
+ - [Configuration guide](https://github.com/IDuxFE/idux-charts/blob/main/packages/site/src/0-guide/GettingStarted.page.md)
79
+ - [Vue 2 / Vue 3 playgrounds](https://github.com/IDuxFE/idux-charts/blob/main/playgrounds/README.md)
80
+ - [Repository and development](https://github.com/IDuxFE/idux-charts/blob/main/README.md)
81
+
82
+ ## License
83
+
84
+ MIT © 2023-present IDuxFE
package/README.zh.md ADDED
@@ -0,0 +1,84 @@
1
+ # @idux/charts-core
2
+
3
+ [English](README.md) | 简体中文
4
+
5
+ iDux Charts 的基础层,提供通用 `IxChart`、图表生命周期组合式函数、主题、类型及工具,适合直接使用 ECharts 配置或开发自定义图表组件。
6
+
7
+ 如需统一入口及共享提示框样式,可使用 [`@idux/charts`](https://github.com/IDuxFE/idux-charts/blob/main/packages/charts/README.zh.md)。
8
+
9
+ ## 安装
10
+
11
+ ```bash
12
+ npm install @idux/charts-core echarts
13
+ ```
14
+
15
+ 支持 Vue 2(含 Vue 2.6)和 Vue 3。在已有 Vue 项目中使用,依赖版本为 Vue `^2.6.0 || ^3.2.5` 和 ECharts `^5.4.3 || ^6.0.0`。Vue 2.6 还需安装 `@vue/composition-api >=1.6.2`,并在创建应用前注册插件。
16
+
17
+ ```bash
18
+ npm install @vue/composition-api
19
+ ```
20
+
21
+ ```ts
22
+ // Vue 2.6
23
+ import Vue from 'vue'
24
+ import VueCompositionAPI from '@vue/composition-api'
25
+
26
+ Vue.use(VueCompositionAPI)
27
+ ```
28
+
29
+ ## 快速上手
30
+
31
+ 以下示例使用 Vue 3 的 `<script setup>`,局部导入组件即可使用。容器必须具有有效的宽度和高度。
32
+
33
+ ```vue
34
+ <script setup lang="ts">
35
+ import { use } from 'echarts/core'
36
+ import { LineChart } from 'echarts/charts'
37
+ import { IxChart, type ChartProps } from '@idux/charts-core'
38
+
39
+ use([LineChart])
40
+
41
+ const option: ChartProps = {
42
+ xAxis: { type: 'category', data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'] },
43
+ yAxis: { type: 'value' },
44
+ series: [{ type: 'line', data: [123, 324, 156, 244, 188] }],
45
+ }
46
+ </script>
47
+
48
+ <template>
49
+ <div style="height: 320px">
50
+ <IxChart v-bind="option" />
51
+ </div>
52
+ </template>
53
+ ```
54
+
55
+ `IxChart` 的 ECharts 配置通过 `v-bind` 直接传入,不使用单独的 `option` 属性。默认注册 SVG 渲染器、Grid、Legend、Tooltip、Title、DataZoom,以及 LabelLayout、UniversalTransition。自定义系列或额外组件需要通过 `echarts/core` 的 `use` 注册;使用 Canvas 时也需注册 `CanvasRenderer`,并传入 `initOption: { renderer: 'canvas' }`。
56
+
57
+ ## 核心 API
58
+
59
+ - `IxChart`:支持 `autoResize`(默认开启)、`loading`、`theme`、`group`、`initOption`、`setOptionOpts` 和 `onReady`。
60
+ - `useChart(options, listeners?)`:管理初始化、响应式更新、事件、尺寸变化和销毁,返回 `containerRef` 与 `chartRef`;在组件 `setup` 中调用。
61
+ - `seerTheme`:内置主题,默认主题名称为 `seer`。
62
+ - `useTooltipsFormatter`、`useReactiveAttrs`、`createInstall`、`withChartProps`:自定义图表开发工具。
63
+ - `ChartProps`、`ChartPublicProps`、`ChartOption`:公开配置类型。
64
+
65
+ 此包不提供独立 CSS 文件;共享 HTML 提示框样式由 `@idux/charts/dist/style.css` 提供。
66
+
67
+ ## 应用级主题
68
+
69
+ 可用 `CHART_THEME_TOKEN` 提供应用级主题名称、对象或响应式 ref。显式 `theme` 属性优先,未配置时回退到 `seer`。注入主题变化沿用已有主题生命周期,重新创建图表实例。对于配置生成器绘制的文字和辅助图形,还需配置 `@idux/charts-plots`(或 `@idux/charts`)导出的 `PLOT_THEME_TOKEN`。
70
+
71
+ ## TypeScript
72
+
73
+ `*ChartProps` 用于图表配置,允许扩展字段;`*ChartPublicProps` 提供具名公开属性类型,保留属性的类型及可选性,便于编写组件类型适配。具体适配说明见[仓库 README](https://github.com/IDuxFE/idux-charts/blob/main/README.zh.md#typescript-属性类型)。
74
+
75
+ ## 文档
76
+
77
+ - [iDux Charts](https://charts.idux.site)
78
+ - [配置指南](https://github.com/IDuxFE/idux-charts/blob/main/packages/site/src/0-guide/GettingStarted.page.md)
79
+ - [Vue 2 / Vue 3 示例项目](https://github.com/IDuxFE/idux-charts/blob/main/playgrounds/README.zh.md)
80
+ - [仓库与开发指南](https://github.com/IDuxFE/idux-charts/blob/main/README.zh.md)
81
+
82
+ ## 许可证
83
+
84
+ MIT © 2023-present IDuxFE
@@ -1,4 +1,4 @@
1
1
  export { useChart } from './useChart';
2
- export { useTooltipsFormatter } from './useTooltips';
2
+ export { useTooltipsFormatter, getTooltipsColor } from './useTooltips';
3
3
  export * from './useStripe';
4
4
  export { useReactiveAttrs } from './useReactiveAttrs';
@@ -0,0 +1,8 @@
1
+ import { EChartsType } from 'echarts/core';
2
+ import { ChartProps } from '../types';
3
+ /** Keep theme state on the tooltip itself, including portals created by appendTo. */
4
+ export declare function createTooltipTheme(getContainer: () => HTMLElement | undefined): {
5
+ prepare(options: ChartProps): ChartProps;
6
+ sync(instance: EChartsType): void;
7
+ rendered: () => void;
8
+ };
@@ -1,6 +1,27 @@
1
+ import { Color } from 'echarts';
2
+ interface GradientColorStop {
3
+ offset?: number;
4
+ color?: string;
5
+ }
6
+ interface GradientLikeColor {
7
+ colorStops?: GradientColorStop[];
8
+ }
1
9
  export interface TooltipsFormatItem {
2
10
  name: string;
3
11
  value: string | number;
4
- color?: string;
12
+ /**
13
+ * 图例色块颜色,支持普通颜色字符串(如 `#458FFF`)
14
+ * 或渐变对象(如 `itemStyle.color` 配置的 linear 渐变),
15
+ * 传入渐变时优先取最不透明的色标,同透明度下取更深的颜色。
16
+ */
17
+ color?: string | GradientLikeColor;
5
18
  }
19
+ /**
20
+ * 提取用于 tooltip 色块展示的颜色。
21
+ *
22
+ * 柱体、折线等图形常配置为线性渐变,此时 hover 提示中的竖杠
23
+ * 需要与图形中更深的颜色保持一致,因此优先选择最不透明的色标,同透明度时取亮度最低的颜色。
24
+ */
25
+ export declare function getTooltipsColor(color?: Color | GradientLikeColor | null): string;
6
26
  export declare function useTooltipsFormatter(title: string, list: TooltipsFormatItem[]): string;
27
+ export {};