@visactor/react-vchart 0.0.1-alpha.1 → 0.10.0-alpha.2
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 +33 -5
- package/cjs/VChart.d.ts +4 -2
- package/cjs/VChart.js +11 -3
- package/cjs/VChart.js.map +1 -1
- package/cjs/VChartSimple.d.ts +6 -0
- package/cjs/VChartSimple.js +10 -0
- package/cjs/VChartSimple.js.map +1 -0
- package/cjs/charts/AreaChart.d.ts +7 -2
- package/cjs/charts/AreaChart.js +11 -2
- package/cjs/charts/AreaChart.js.map +1 -1
- package/cjs/charts/BarChart.d.ts +7 -2
- package/cjs/charts/BarChart.js +11 -2
- package/cjs/charts/BarChart.js.map +1 -1
- package/cjs/charts/BaseChart.d.ts +10 -6
- package/cjs/charts/BaseChart.js +57 -34
- package/cjs/charts/BaseChart.js.map +1 -1
- package/cjs/charts/BoxPlotChart.d.ts +6 -1
- package/cjs/charts/BoxPlotChart.js +11 -2
- package/cjs/charts/BoxPlotChart.js.map +1 -1
- package/cjs/charts/CircularProgressChart.d.ts +6 -1
- package/cjs/charts/CircularProgressChart.js +11 -2
- package/cjs/charts/CircularProgressChart.js.map +1 -1
- package/cjs/charts/CommonChart.d.ts +6 -1
- package/cjs/charts/CommonChart.js +11 -2
- package/cjs/charts/CommonChart.js.map +1 -1
- package/cjs/charts/FunnelChart.d.ts +6 -1
- package/cjs/charts/FunnelChart.js +11 -2
- package/cjs/charts/FunnelChart.js.map +1 -1
- package/cjs/charts/HistogramChart.d.ts +6 -1
- package/cjs/charts/HistogramChart.js +11 -2
- package/cjs/charts/HistogramChart.js.map +1 -1
- package/cjs/charts/LineChart.d.ts +7 -2
- package/cjs/charts/LineChart.js +11 -2
- package/cjs/charts/LineChart.js.map +1 -1
- package/cjs/charts/LinearProgressChart.d.ts +6 -1
- package/cjs/charts/LinearProgressChart.js +11 -2
- package/cjs/charts/LinearProgressChart.js.map +1 -1
- package/cjs/charts/MapChart.d.ts +7 -2
- package/cjs/charts/MapChart.js +12 -2
- package/cjs/charts/MapChart.js.map +1 -1
- package/cjs/charts/PieChart.d.ts +7 -2
- package/cjs/charts/PieChart.js +11 -2
- package/cjs/charts/PieChart.js.map +1 -1
- package/cjs/charts/RadarChart.d.ts +7 -2
- package/cjs/charts/RadarChart.js +11 -2
- package/cjs/charts/RadarChart.js.map +1 -1
- package/cjs/charts/RangeColumnChart.d.ts +7 -2
- package/cjs/charts/RangeColumnChart.js +11 -2
- package/cjs/charts/RangeColumnChart.js.map +1 -1
- package/cjs/charts/RoseChart.d.ts +7 -2
- package/cjs/charts/RoseChart.js +11 -3
- package/cjs/charts/RoseChart.js.map +1 -1
- package/cjs/charts/ScatterChart.d.ts +7 -2
- package/cjs/charts/ScatterChart.js +11 -2
- package/cjs/charts/ScatterChart.js.map +1 -1
- package/cjs/charts/SequenceChart.d.ts +7 -2
- package/cjs/charts/SequenceChart.js +11 -2
- package/cjs/charts/SequenceChart.js.map +1 -1
- package/cjs/charts/WordCloudChart.d.ts +7 -2
- package/cjs/charts/WordCloudChart.js +11 -2
- package/cjs/charts/WordCloudChart.js.map +1 -1
- package/cjs/charts/index.d.ts +18 -16
- package/cjs/charts/index.js +24 -146
- package/cjs/charts/index.js.map +1 -1
- package/cjs/components/Axis.d.ts +4 -5
- package/cjs/components/Axis.js.map +1 -1
- package/cjs/components/BaseComponent.d.ts +2 -1
- package/cjs/components/BaseComponent.js +14 -35
- package/cjs/components/BaseComponent.js.map +1 -1
- package/cjs/components/Brush.d.ts +5 -0
- package/cjs/components/Brush.js +10 -0
- package/cjs/components/Brush.js.map +1 -0
- package/cjs/components/Crosshair.d.ts +4 -0
- package/cjs/components/Crosshair.js +10 -0
- package/cjs/components/Crosshair.js.map +1 -0
- package/cjs/components/DataZoom.d.ts +5 -0
- package/cjs/components/DataZoom.js +10 -0
- package/cjs/components/DataZoom.js.map +1 -0
- package/cjs/components/Indicator.d.ts +4 -0
- package/cjs/components/Indicator.js +10 -0
- package/cjs/components/Indicator.js.map +1 -0
- package/cjs/components/Legend.d.ts +4 -8
- package/cjs/components/Legend.js.map +1 -1
- package/cjs/components/Mark.d.ts +4 -14
- package/cjs/components/Mark.js +2 -60
- package/cjs/components/Mark.js.map +1 -1
- package/cjs/components/MarkArea.d.ts +4 -0
- package/cjs/components/MarkArea.js +10 -0
- package/cjs/components/MarkArea.js.map +1 -0
- package/cjs/components/MarkLine.d.ts +4 -0
- package/cjs/components/MarkLine.js +10 -0
- package/cjs/components/MarkLine.js.map +1 -0
- package/cjs/components/MarkPoint.d.ts +4 -0
- package/cjs/components/MarkPoint.js +10 -0
- package/cjs/components/MarkPoint.js.map +1 -0
- package/cjs/components/Player.d.ts +5 -0
- package/cjs/components/Player.js +10 -0
- package/cjs/components/Player.js.map +1 -0
- package/cjs/components/Region.d.ts +4 -4
- package/cjs/components/Region.js +1 -2
- package/cjs/components/Region.js.map +1 -1
- package/cjs/components/ScrollBar.d.ts +5 -0
- package/cjs/components/ScrollBar.js +10 -0
- package/cjs/components/ScrollBar.js.map +1 -0
- package/cjs/components/Title.d.ts +4 -0
- package/cjs/components/Title.js +10 -0
- package/cjs/components/Title.js.map +1 -0
- package/cjs/components/Tooltip.d.ts +4 -0
- package/cjs/components/Tooltip.js +10 -0
- package/cjs/components/Tooltip.js.map +1 -0
- package/cjs/components/index.d.ts +11 -0
- package/cjs/components/index.js +8 -2
- package/cjs/components/index.js.map +1 -1
- package/cjs/constants.js +1 -1
- package/cjs/constants.js.map +1 -1
- package/cjs/containers/withContainer.d.ts +2 -2
- package/cjs/containers/withContainer.js.map +1 -1
- package/cjs/context/chart.d.ts +2 -3
- package/cjs/context/chart.js.map +1 -1
- package/cjs/context/stage.d.ts +2 -2
- package/cjs/context/stage.js.map +1 -1
- package/cjs/context/view.d.ts +2 -2
- package/cjs/context/view.js.map +1 -1
- package/cjs/eventsUtils.d.ts +148 -47
- package/cjs/eventsUtils.js +35 -5
- package/cjs/eventsUtils.js.map +1 -1
- package/cjs/index.d.ts +4 -3
- package/cjs/index.js +4 -19
- package/cjs/index.js.map +1 -1
- package/cjs/series/Area.d.ts +6 -5
- package/cjs/series/Area.js.map +1 -1
- package/cjs/series/Bar.d.ts +6 -5
- package/cjs/series/Bar.js.map +1 -1
- package/cjs/series/BaseSeries.d.ts +2 -1
- package/cjs/series/BaseSeries.js +22 -49
- package/cjs/series/BaseSeries.js.map +1 -1
- package/cjs/series/BoxPlot.d.ts +6 -5
- package/cjs/series/BoxPlot.js.map +1 -1
- package/cjs/series/CircularProgress.d.ts +6 -5
- package/cjs/series/CircularProgress.js.map +1 -1
- package/cjs/series/Dot.d.ts +6 -5
- package/cjs/series/Dot.js.map +1 -1
- package/cjs/series/Funnel.d.ts +6 -5
- package/cjs/series/Funnel.js.map +1 -1
- package/cjs/series/Line.d.ts +6 -5
- package/cjs/series/Line.js.map +1 -1
- package/cjs/series/LinearProgress.d.ts +6 -5
- package/cjs/series/LinearProgress.js.map +1 -1
- package/cjs/series/Link.d.ts +6 -5
- package/cjs/series/Link.js.map +1 -1
- package/cjs/series/Map.d.ts +6 -5
- package/cjs/series/Map.js.map +1 -1
- package/cjs/series/Pie.d.ts +6 -5
- package/cjs/series/Pie.js.map +1 -1
- package/cjs/series/Radar.d.ts +6 -5
- package/cjs/series/Radar.js.map +1 -1
- package/cjs/series/RangeColumn.d.ts +6 -5
- package/cjs/series/RangeColumn.js.map +1 -1
- package/cjs/series/Rose.d.ts +6 -5
- package/cjs/series/Rose.js.map +1 -1
- package/cjs/series/Scatter.d.ts +6 -5
- package/cjs/series/Scatter.js.map +1 -1
- package/cjs/series/Series.d.ts +6 -6
- package/cjs/series/Series.js +1 -1
- package/cjs/series/Series.js.map +1 -1
- package/cjs/series/WordCloud.d.ts +6 -5
- package/cjs/series/WordCloud.js +1 -1
- package/cjs/series/WordCloud.js.map +1 -1
- package/cjs/series/index.js +1 -1
- package/cjs/series/index.js.map +1 -1
- package/cjs/util.js +1 -1
- package/cjs/util.js.map +1 -1
- package/esm/VChart.d.ts +4 -2
- package/esm/VChart.js +7 -1
- package/esm/VChart.js.map +1 -1
- package/esm/VChartSimple.d.ts +6 -0
- package/esm/VChartSimple.js +4 -0
- package/esm/VChartSimple.js.map +1 -0
- package/esm/charts/AreaChart.d.ts +7 -2
- package/esm/charts/AreaChart.js +6 -1
- package/esm/charts/AreaChart.js.map +1 -1
- package/esm/charts/BarChart.d.ts +7 -2
- package/esm/charts/BarChart.js +6 -1
- package/esm/charts/BarChart.js.map +1 -1
- package/esm/charts/BaseChart.d.ts +10 -6
- package/esm/charts/BaseChart.js +56 -35
- package/esm/charts/BaseChart.js.map +1 -1
- package/esm/charts/BoxPlotChart.d.ts +6 -1
- package/esm/charts/BoxPlotChart.js +6 -1
- package/esm/charts/BoxPlotChart.js.map +1 -1
- package/esm/charts/CircularProgressChart.d.ts +6 -1
- package/esm/charts/CircularProgressChart.js +6 -1
- package/esm/charts/CircularProgressChart.js.map +1 -1
- package/esm/charts/CommonChart.d.ts +6 -1
- package/esm/charts/CommonChart.js +6 -1
- package/esm/charts/CommonChart.js.map +1 -1
- package/esm/charts/FunnelChart.d.ts +6 -1
- package/esm/charts/FunnelChart.js +6 -1
- package/esm/charts/FunnelChart.js.map +1 -1
- package/esm/charts/HistogramChart.d.ts +6 -1
- package/esm/charts/HistogramChart.js +6 -1
- package/esm/charts/HistogramChart.js.map +1 -1
- package/esm/charts/LineChart.d.ts +7 -2
- package/esm/charts/LineChart.js +6 -1
- package/esm/charts/LineChart.js.map +1 -1
- package/esm/charts/LinearProgressChart.d.ts +6 -1
- package/esm/charts/LinearProgressChart.js +6 -1
- package/esm/charts/LinearProgressChart.js.map +1 -1
- package/esm/charts/MapChart.d.ts +7 -2
- package/esm/charts/MapChart.js +7 -1
- package/esm/charts/MapChart.js.map +1 -1
- package/esm/charts/PieChart.d.ts +7 -2
- package/esm/charts/PieChart.js +6 -1
- package/esm/charts/PieChart.js.map +1 -1
- package/esm/charts/RadarChart.d.ts +7 -2
- package/esm/charts/RadarChart.js +6 -1
- package/esm/charts/RadarChart.js.map +1 -1
- package/esm/charts/RangeColumnChart.d.ts +7 -2
- package/esm/charts/RangeColumnChart.js +6 -1
- package/esm/charts/RangeColumnChart.js.map +1 -1
- package/esm/charts/RoseChart.d.ts +7 -2
- package/esm/charts/RoseChart.js +6 -2
- package/esm/charts/RoseChart.js.map +1 -1
- package/esm/charts/ScatterChart.d.ts +7 -2
- package/esm/charts/ScatterChart.js +6 -1
- package/esm/charts/ScatterChart.js.map +1 -1
- package/esm/charts/SequenceChart.d.ts +7 -2
- package/esm/charts/SequenceChart.js +6 -1
- package/esm/charts/SequenceChart.js.map +1 -1
- package/esm/charts/WordCloudChart.d.ts +7 -2
- package/esm/charts/WordCloudChart.js +6 -1
- package/esm/charts/WordCloudChart.js.map +1 -1
- package/esm/charts/index.d.ts +18 -16
- package/esm/charts/index.js +17 -17
- package/esm/charts/index.js.map +1 -1
- package/esm/components/Axis.d.ts +4 -5
- package/esm/components/Axis.js.map +1 -1
- package/esm/components/BaseComponent.d.ts +2 -1
- package/esm/components/BaseComponent.js +14 -35
- package/esm/components/BaseComponent.js.map +1 -1
- package/esm/components/Brush.d.ts +5 -0
- package/esm/components/Brush.js +6 -0
- package/esm/components/Brush.js.map +1 -0
- package/esm/components/Crosshair.d.ts +4 -0
- package/esm/components/Crosshair.js +4 -0
- package/esm/components/Crosshair.js.map +1 -0
- package/esm/components/DataZoom.d.ts +5 -0
- package/esm/components/DataZoom.js +6 -0
- package/esm/components/DataZoom.js.map +1 -0
- package/esm/components/Indicator.d.ts +4 -0
- package/esm/components/Indicator.js +4 -0
- package/esm/components/Indicator.js.map +1 -0
- package/esm/components/Legend.d.ts +4 -8
- package/esm/components/Legend.js.map +1 -1
- package/esm/components/Mark.d.ts +4 -14
- package/esm/components/Mark.js +2 -38
- package/esm/components/Mark.js.map +1 -1
- package/esm/components/MarkArea.d.ts +4 -0
- package/esm/components/MarkArea.js +4 -0
- package/esm/components/MarkArea.js.map +1 -0
- package/esm/components/MarkLine.d.ts +4 -0
- package/esm/components/MarkLine.js +4 -0
- package/esm/components/MarkLine.js.map +1 -0
- package/esm/components/MarkPoint.d.ts +4 -0
- package/esm/components/MarkPoint.js +4 -0
- package/esm/components/MarkPoint.js.map +1 -0
- package/esm/components/Player.d.ts +5 -0
- package/esm/components/Player.js +6 -0
- package/esm/components/Player.js.map +1 -0
- package/esm/components/Region.d.ts +4 -4
- package/esm/components/Region.js +1 -2
- package/esm/components/Region.js.map +1 -1
- package/esm/components/ScrollBar.d.ts +5 -0
- package/esm/components/ScrollBar.js +6 -0
- package/esm/components/ScrollBar.js.map +1 -0
- package/esm/components/Title.d.ts +4 -0
- package/esm/components/Title.js +4 -0
- package/esm/components/Title.js.map +1 -0
- package/esm/components/Tooltip.d.ts +4 -0
- package/esm/components/Tooltip.js +4 -0
- package/esm/components/Tooltip.js.map +1 -0
- package/esm/components/index.d.ts +11 -0
- package/esm/components/index.js +23 -1
- package/esm/components/index.js.map +1 -1
- package/esm/constants.js +1 -1
- package/esm/constants.js.map +1 -1
- package/esm/containers/withContainer.d.ts +2 -2
- package/esm/containers/withContainer.js.map +1 -1
- package/esm/context/chart.d.ts +2 -3
- package/esm/context/chart.js.map +1 -1
- package/esm/context/stage.d.ts +2 -2
- package/esm/context/stage.js.map +1 -1
- package/esm/context/view.d.ts +2 -2
- package/esm/context/view.js.map +1 -1
- package/esm/eventsUtils.d.ts +148 -47
- package/esm/eventsUtils.js +48 -4
- package/esm/eventsUtils.js.map +1 -1
- package/esm/index.d.ts +4 -3
- package/esm/index.js +4 -3
- package/esm/index.js.map +1 -1
- package/esm/series/Area.d.ts +6 -5
- package/esm/series/Area.js.map +1 -1
- package/esm/series/Bar.d.ts +6 -5
- package/esm/series/Bar.js.map +1 -1
- package/esm/series/BaseSeries.d.ts +2 -1
- package/esm/series/BaseSeries.js +22 -50
- package/esm/series/BaseSeries.js.map +1 -1
- package/esm/series/BoxPlot.d.ts +6 -5
- package/esm/series/BoxPlot.js.map +1 -1
- package/esm/series/CircularProgress.d.ts +6 -5
- package/esm/series/CircularProgress.js.map +1 -1
- package/esm/series/Dot.d.ts +6 -5
- package/esm/series/Dot.js.map +1 -1
- package/esm/series/Funnel.d.ts +6 -5
- package/esm/series/Funnel.js.map +1 -1
- package/esm/series/Line.d.ts +6 -5
- package/esm/series/Line.js.map +1 -1
- package/esm/series/LinearProgress.d.ts +6 -5
- package/esm/series/LinearProgress.js.map +1 -1
- package/esm/series/Link.d.ts +6 -5
- package/esm/series/Link.js.map +1 -1
- package/esm/series/Map.d.ts +6 -5
- package/esm/series/Map.js.map +1 -1
- package/esm/series/Pie.d.ts +6 -5
- package/esm/series/Pie.js.map +1 -1
- package/esm/series/Radar.d.ts +6 -5
- package/esm/series/Radar.js.map +1 -1
- package/esm/series/RangeColumn.d.ts +6 -5
- package/esm/series/RangeColumn.js.map +1 -1
- package/esm/series/Rose.d.ts +6 -5
- package/esm/series/Rose.js.map +1 -1
- package/esm/series/Scatter.d.ts +6 -5
- package/esm/series/Scatter.js.map +1 -1
- package/esm/series/Series.d.ts +6 -6
- package/esm/series/Series.js +1 -1
- package/esm/series/Series.js.map +1 -1
- package/esm/series/WordCloud.d.ts +6 -5
- package/esm/series/WordCloud.js +1 -1
- package/esm/series/WordCloud.js.map +1 -1
- package/esm/series/index.js +1 -1
- package/esm/series/index.js.map +1 -1
- package/esm/util.js +1 -1
- package/esm/util.js.map +1 -1
- package/package.json +11 -9
package/README.md
CHANGED
|
@@ -1,17 +1,27 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @visactor/react-vchart
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`@visactor/react-vchart` 是由 [VisActor](visactor.io) 为您提供的 React 封装版本 VChart 图表库。它提供了一系列易于使用的 React 组件,用于方便的在 React 开发环境中创建各种类型的图表,包括折线图、柱状图、饼图等。`@visactor/react-vchart` 的组件具有高度的可定制性和可扩展性,可以通过传递不同的参数和配置来实现不同的图表效果。
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
`@visactor/react-vchart` 的主要特点包括:
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
- **易于使用**:`@visactor/react-vchart` 提供了一系列易于使用的 React 组件,可以快速创建各种类型的图表。
|
|
8
|
+
- **可定制性强**:`@visactor/react-vchart` 的组件具有高度的可定制性,可以通过传递不同的参数和配置来实现不同的图表效果。
|
|
9
|
+
- **可扩展性强**:`@visactor/react-vchart` 的组件可以轻松地扩展和定制,可以根据需要添加新的功能和特性。
|
|
10
|
+
- **兼容性好**:`@visactor/react-vchart` 完全继承了 VChart 的可视化能力,可以在不同的浏览器和设备上运行。
|
|
11
|
+
- **支持多种图表类型**:`@visactor/react-vchart` 支持多种类型的图表,包括折线图、柱状图、饼图、雷达图等。
|
|
12
|
+
|
|
13
|
+
`@visactor/react-vchart` 在能力上完全对齐 VChart,并且 API 配置也与 VChart 几乎一致,关于图表的定义和配置可参考[VChart](https://www.visactor.io/vchart)。
|
|
14
|
+
|
|
15
|
+
## 开发指引
|
|
16
|
+
|
|
17
|
+
### Build
|
|
8
18
|
|
|
9
19
|
```bash
|
|
10
20
|
# root directory
|
|
11
21
|
$ rush build
|
|
12
22
|
```
|
|
13
23
|
|
|
14
|
-
###
|
|
24
|
+
### Development
|
|
15
25
|
|
|
16
26
|
```bash
|
|
17
27
|
# root directory
|
|
@@ -24,3 +34,21 @@ or
|
|
|
24
34
|
$ cd packages/react-vchart
|
|
25
35
|
$ rushx start
|
|
26
36
|
```
|
|
37
|
+
|
|
38
|
+
## 文档指引
|
|
39
|
+
|
|
40
|
+
项目文档位于 `@visactor/react-vchart` 目录中的 [docs](./docs) 路径。
|
|
41
|
+
|
|
42
|
+
1. [快速开始](./docs/1.%20%E5%BF%AB%E9%80%9F%E5%BC%80%E5%A7%8B.md)
|
|
43
|
+
- 环境要求
|
|
44
|
+
- 安装
|
|
45
|
+
- 引入 `@visactor/react-vchart`
|
|
46
|
+
- 绘制一个简单的柱状图
|
|
47
|
+
2. 入门
|
|
48
|
+
- [API 设计](./docs/2.1%20API%E8%AE%BE%E8%AE%A1.md)
|
|
49
|
+
- [统一图表标签](./docs//2.2%20%E7%BB%9F%E4%B8%80%E5%9B%BE%E8%A1%A8%E6%A0%87%E7%AD%BE.md)
|
|
50
|
+
- [语法化标签](./docs/2.3%20%E8%AF%AD%E6%B3%95%E5%8C%96%E6%A0%87%E7%AD%BE.md)
|
|
51
|
+
3. [事件交互](./docs/3.%20%E4%BA%8B%E4%BB%B6%E4%BA%A4%E4%BA%92.md)
|
|
52
|
+
4. [主题样式](./docs/4.%20%E4%B8%BB%E9%A2%98%E6%A0%B7%E5%BC%8F.md)
|
|
53
|
+
5. [FAQ](./docs/5.%20FAQ.md)
|
|
54
|
+
6. [更新日志](./docs/6.%20%E6%9B%B4%E6%96%B0%E6%97%A5%E5%BF%97.md)
|
package/cjs/VChart.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { BaseChartProps } from './charts/BaseChart';
|
|
2
|
-
|
|
3
|
-
export
|
|
2
|
+
import VChartCore from '@visactor/vchart';
|
|
3
|
+
export { VChartCore };
|
|
4
|
+
export type VChartProps = Omit<BaseChartProps, 'container' | 'data' | 'width' | 'height' | 'type'>;
|
|
5
|
+
export declare const VChart: import("react").ForwardRefExoticComponent<VChartProps & import("./containers/withContainer").ContainerProps & import("react").RefAttributes<any>>;
|
package/cjs/VChart.js
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var __importDefault = this && this.__importDefault || function(mod) {
|
|
4
|
+
return mod && mod.__esModule ? mod : {
|
|
5
|
+
default: mod
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
|
|
3
9
|
Object.defineProperty(exports, "__esModule", {
|
|
4
10
|
value: !0
|
|
5
|
-
}), exports.VChart = void 0;
|
|
11
|
+
}), exports.VChart = exports.VChartCore = void 0;
|
|
6
12
|
|
|
7
|
-
const BaseChart_1 = require("./charts/BaseChart");
|
|
13
|
+
const BaseChart_1 = require("./charts/BaseChart"), vchart_1 = __importDefault(require("@visactor/vchart"));
|
|
8
14
|
|
|
9
|
-
exports.VChart = (0, BaseChart_1.createChart)("VChart"
|
|
15
|
+
exports.VChartCore = vchart_1.default, exports.VChart = (0, BaseChart_1.createChart)("VChart", {
|
|
16
|
+
vchartConstrouctor: vchart_1.default
|
|
17
|
+
});
|
package/cjs/VChart.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["VChart.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/VChart.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAAiE;AAEjE,8DAA0C;AACjC,qBADF,gBAAU,CACE;AAIN,QAAA,MAAM,GAAG,IAAA,uBAAW,EAAc,QAAQ,EAAE;IACvD,kBAAkB,EAAE,gBAAU;CAC/B,CAAC,CAAC","file":"VChart.js","sourcesContent":["import { BaseChartProps, createChart } from './charts/BaseChart';\nimport type { IVChartConstructor } from '@visactor/vchart';\nimport VChartCore from '@visactor/vchart';\nexport { VChartCore };\n\nexport type VChartProps = Omit<BaseChartProps, 'container' | 'data' | 'width' | 'height' | 'type'>;\n\nexport const VChart = createChart<VChartProps>('VChart', {\n vchartConstrouctor: VChartCore\n});\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { IVChartConstructor } from '@visactor/vchart';
|
|
2
|
+
import { BaseChartProps } from './charts/BaseChart';
|
|
3
|
+
export type VChartSimpleProps = Omit<BaseChartProps, 'container' | 'data' | 'width' | 'height' | 'vchartConstrouctor'>;
|
|
4
|
+
export declare const VChartSimple: import("react").ForwardRefExoticComponent<VChartSimpleProps & {
|
|
5
|
+
vchartConstrouctor: IVChartConstructor;
|
|
6
|
+
} & import("./containers/withContainer").ContainerProps & import("react").RefAttributes<any>>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: !0
|
|
5
|
+
}), exports.VChartSimple = void 0;
|
|
6
|
+
|
|
7
|
+
const BaseChart_1 = require("./charts/BaseChart");
|
|
8
|
+
|
|
9
|
+
exports.VChartSimple = (0, BaseChart_1.createChart)("VChartSimple");
|
|
10
|
+
//# sourceMappingURL=VChartSimple.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/VChartSimple.tsx"],"names":[],"mappings":";;;AACA,kDAAiE;AAIpD,QAAA,YAAY,GAAG,IAAA,uBAAW,EAAiE,cAAc,CAAC,CAAC","file":"VChartSimple.js","sourcesContent":["import type { IVChartConstructor } from '@visactor/vchart';\nimport { BaseChartProps, createChart } from './charts/BaseChart';\n\nexport type VChartSimpleProps = Omit<BaseChartProps, 'container' | 'data' | 'width' | 'height' | 'vchartConstrouctor'>;\n\nexport const VChartSimple = createChart<VChartSimpleProps & { vchartConstrouctor: IVChartConstructor }>('VChartSimple');\n"]}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { IAreaChartSpec } from '@visactor/vchart';
|
|
2
3
|
import { BaseChartProps } from './BaseChart';
|
|
3
4
|
export interface AreaChartProps extends Omit<BaseChartProps, 'spec' | 'container' | 'type'>, Omit<IAreaChartSpec, 'type'> {
|
|
4
5
|
}
|
|
5
|
-
export declare const AreaChart:
|
|
6
|
+
export declare const AreaChart: React.ForwardRefExoticComponent<AreaChartProps & {
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
} & {
|
|
9
|
+
type: 'area';
|
|
10
|
+
} & import("../containers/withContainer").ContainerProps & React.RefAttributes<any>>;
|
package/cjs/charts/AreaChart.js
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var __importDefault = this && this.__importDefault || function(mod) {
|
|
4
|
+
return mod && mod.__esModule ? mod : {
|
|
5
|
+
default: mod
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
|
|
3
9
|
Object.defineProperty(exports, "__esModule", {
|
|
4
10
|
value: !0
|
|
5
11
|
}), exports.AreaChart = void 0;
|
|
6
12
|
|
|
7
|
-
const BaseChart_1 = require("./BaseChart");
|
|
13
|
+
const vchart_1 = __importDefault(require("@visactor/vchart")), BaseChart_1 = require("./BaseChart");
|
|
8
14
|
|
|
9
|
-
exports.AreaChart = (0, BaseChart_1.createChart)("AreaChart",
|
|
15
|
+
exports.AreaChart = (0, BaseChart_1.createChart)("AreaChart", {
|
|
16
|
+
type: "area",
|
|
17
|
+
vchartConstrouctor: vchart_1.default
|
|
18
|
+
});
|
|
10
19
|
//# sourceMappingURL=AreaChart.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["charts/AreaChart.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/charts/AreaChart.tsx"],"names":[],"mappings":";;;;;;AAEA,8DAAqD;AACrD,2CAA0D;AAM7C,QAAA,SAAS,GAAG,IAAA,uBAAW,EAA6D,WAAW,EAAE;IAC5G,IAAI,EAAE,MAAM;IACZ,kBAAkB,EAAE,gBAAM;CAC3B,CAAC,CAAC","file":"AreaChart.js","sourcesContent":["import React from 'react';\nimport type { IAreaChartSpec } from '@visactor/vchart';\nimport { default as VChart } from '@visactor/vchart';\nimport { BaseChartProps, createChart } from './BaseChart';\n\nexport interface AreaChartProps\n extends Omit<BaseChartProps, 'spec' | 'container' | 'type'>,\n Omit<IAreaChartSpec, 'type'> {}\n\nexport const AreaChart = createChart<React.PropsWithChildren<AreaChartProps> & { type: 'area' }>('AreaChart', {\n type: 'area',\n vchartConstrouctor: VChart\n});\n"]}
|
package/cjs/charts/BarChart.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { IBarChartSpec } from '@visactor/vchart';
|
|
2
3
|
import { BaseChartProps } from './BaseChart';
|
|
3
4
|
export interface BarChartProps extends Omit<BaseChartProps, 'spec' | 'container' | 'type'>, Omit<IBarChartSpec, 'type'> {
|
|
4
5
|
}
|
|
5
|
-
export declare const BarChart:
|
|
6
|
+
export declare const BarChart: React.ForwardRefExoticComponent<BarChartProps & {
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
} & {
|
|
9
|
+
type: 'bar';
|
|
10
|
+
} & import("../containers/withContainer").ContainerProps & React.RefAttributes<any>>;
|
package/cjs/charts/BarChart.js
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var __importDefault = this && this.__importDefault || function(mod) {
|
|
4
|
+
return mod && mod.__esModule ? mod : {
|
|
5
|
+
default: mod
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
|
|
3
9
|
Object.defineProperty(exports, "__esModule", {
|
|
4
10
|
value: !0
|
|
5
11
|
}), exports.BarChart = void 0;
|
|
6
12
|
|
|
7
|
-
const BaseChart_1 = require("./BaseChart");
|
|
13
|
+
const vchart_1 = __importDefault(require("@visactor/vchart")), BaseChart_1 = require("./BaseChart");
|
|
8
14
|
|
|
9
|
-
exports.BarChart = (0, BaseChart_1.createChart)("BarChart",
|
|
15
|
+
exports.BarChart = (0, BaseChart_1.createChart)("BarChart", {
|
|
16
|
+
type: "bar",
|
|
17
|
+
vchartConstrouctor: vchart_1.default
|
|
18
|
+
});
|
|
10
19
|
//# sourceMappingURL=BarChart.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["charts/BarChart.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/charts/BarChart.tsx"],"names":[],"mappings":";;;;;;AAEA,8DAAqD;AACrD,2CAA0D;AAQ7C,QAAA,QAAQ,GAAG,IAAA,uBAAW,EAA2D,UAAU,EAAE;IACxG,IAAI,EAAE,KAAK;IACX,kBAAkB,EAAE,gBAAM;CAC3B,CAAC,CAAC","file":"BarChart.js","sourcesContent":["import React from 'react';\nimport type { IBarChartSpec } from '@visactor/vchart';\nimport { default as VChart } from '@visactor/vchart';\nimport { BaseChartProps, createChart } from './BaseChart';\n\nexport interface BarChartProps\n extends Omit<BaseChartProps, 'spec' | 'container' | 'type'>,\n Omit<IBarChartSpec, 'type'> {\n //\n}\n\nexport const BarChart = createChart<React.PropsWithChildren<BarChartProps> & { type: 'bar' }>('BarChart', {\n type: 'bar',\n vchartConstrouctor: VChart\n});\n"]}
|
|
@@ -1,18 +1,22 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { IVChart, IData, IInitOption, ISpec, IVChartConstructor } from '@visactor/vchart';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { ContainerProps } from '../containers/withContainer';
|
|
4
|
-
import { EventsProps } from '../eventsUtils';
|
|
4
|
+
import { EventsProps, LegendEventProps, ScrollBarEventProps, BrushEventProps, DataZoomEventProps, PlayerEventProps, DimensionEventProps, HierarchyEventProps, ChartLifeCycleEventProps } from '../eventsUtils';
|
|
5
5
|
export type ChartOptions = Omit<IInitOption, 'dom'>;
|
|
6
|
-
export interface BaseChartProps extends EventsProps {
|
|
6
|
+
export interface BaseChartProps extends EventsProps, LegendEventProps, ScrollBarEventProps, BrushEventProps, DataZoomEventProps, PlayerEventProps, DimensionEventProps, HierarchyEventProps, ChartLifeCycleEventProps {
|
|
7
|
+
vchartConstrouctor?: IVChartConstructor;
|
|
7
8
|
type?: string;
|
|
8
9
|
container?: HTMLDivElement;
|
|
9
|
-
spec?:
|
|
10
|
+
spec?: ISpec;
|
|
10
11
|
data?: IData;
|
|
11
12
|
width?: number;
|
|
12
13
|
height?: number;
|
|
13
14
|
options?: ChartOptions;
|
|
14
|
-
|
|
15
|
+
skipFunctionDiff?: boolean;
|
|
16
|
+
onReady?: (instance: IVChart, isInitial: boolean) => void;
|
|
17
|
+
onError?: (err: Error) => void;
|
|
18
|
+
useSyncRender?: boolean;
|
|
15
19
|
}
|
|
16
20
|
type Props = React.PropsWithChildren<BaseChartProps>;
|
|
17
|
-
export declare const createChart: <T extends Props>(componentName: string,
|
|
21
|
+
export declare const createChart: <T extends Props>(componentName: string, defaultProps?: Partial<T>, callback?: (props: T, defaultProps?: Partial<T>) => T) => React.ForwardRefExoticComponent<React.PropsWithoutRef<T & ContainerProps> & React.RefAttributes<any>>;
|
|
18
22
|
export {};
|
package/cjs/charts/BaseChart.js
CHANGED
|
@@ -33,60 +33,83 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
33
33
|
value: !0
|
|
34
34
|
}), exports.createChart = void 0;
|
|
35
35
|
|
|
36
|
-
const
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
const react_1 = __importStar(require("react")), withContainer_1 = __importDefault(require("../containers/withContainer")), chart_1 = __importDefault(require("../context/chart")), vutils_1 = require("@visactor/vutils"), view_1 = __importDefault(require("../context/view")), util_1 = require("../util"), constants_1 = require("../constants"), eventsUtils_1 = require("../eventsUtils"), notSpecKeys = [ ...constants_1.REACT_PRIVATE_PROPS, ...eventsUtils_1.CHART_EVENTS_KEYS, "vchartConstrouctor", "useSyncRender", "skipFunctionDiff", "onError", "onReady", "spec", "container", "options" ], parseSpecFromChildren = props => {
|
|
37
|
+
const specFromChildren = {};
|
|
38
|
+
return (0, util_1.toArray)(props.children).map((child => {
|
|
39
|
+
const parseSpec = child && child.type && child.type.parseSpec;
|
|
40
|
+
if (parseSpec && child.props) {
|
|
41
|
+
const specResult = parseSpec(child.props);
|
|
42
|
+
specResult.isSingle ? specFromChildren[specResult.specName] = specResult.spec : (specFromChildren[specResult.specName] || (specFromChildren[specResult.specName] = []),
|
|
43
|
+
specFromChildren[specResult.specName].push(specResult.spec));
|
|
44
|
+
}
|
|
45
|
+
})), specFromChildren;
|
|
46
|
+
}, BaseChart = react_1.default.forwardRef(((props, ref) => {
|
|
47
|
+
const [updateId, setUpdateId] = (0, react_1.useState)(0), chartContext = (0, react_1.useRef)({});
|
|
48
|
+
(0, react_1.useImperativeHandle)(ref, (() => {
|
|
49
|
+
var _a;
|
|
50
|
+
return null === (_a = chartContext.current) || void 0 === _a ? void 0 : _a.chart;
|
|
51
|
+
}));
|
|
41
52
|
const hasSpec = !!props.spec, [view, setView] = (0, react_1.useState)(null), isUnmount = (0,
|
|
42
|
-
react_1.useRef)(!1), prevSpec = (0, react_1.useRef)((0, vutils_1.pickWithout)(props, notSpecKeys)),
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
53
|
+
react_1.useRef)(!1), prevSpec = (0, react_1.useRef)((0, vutils_1.pickWithout)(props, notSpecKeys)), specFromChildren = (0,
|
|
54
|
+
react_1.useRef)(null), eventsBinded = react_1.default.useRef(null), skipFunctionDiff = !!props.skipFunctionDiff, parseSpec = props => hasSpec && props.spec ? props.spec : Object.assign(Object.assign({}, prevSpec.current), specFromChildren.current), handleChartRender = () => {
|
|
55
|
+
if (!isUnmount.current) {
|
|
56
|
+
if (!chartContext.current || !chartContext.current.chart) return;
|
|
57
|
+
(0, eventsUtils_1.bindEventsToChart)(chartContext.current.chart, props, eventsBinded.current, eventsUtils_1.CHART_EVENTS);
|
|
58
|
+
const newView = chartContext.current.chart.getCompiler().getVGrammarView();
|
|
59
|
+
setUpdateId(updateId + 1), props.onReady && props.onReady(chartContext.current.chart, 0 === updateId),
|
|
60
|
+
setView(newView);
|
|
61
|
+
}
|
|
46
62
|
};
|
|
47
63
|
return (0, react_1.useEffect)((() => {
|
|
48
|
-
|
|
49
|
-
|
|
64
|
+
var _a;
|
|
65
|
+
const newSpecFromChildren = hasSpec ? null : parseSpecFromChildren(props);
|
|
66
|
+
if (!(null === (_a = chartContext.current) || void 0 === _a ? void 0 : _a.chart)) return hasSpec || (specFromChildren.current = newSpecFromChildren),
|
|
67
|
+
(props => {
|
|
68
|
+
const cs = new props.vchartConstrouctor(parseSpec(props), Object.assign(Object.assign({}, props.options), {
|
|
69
|
+
onError: props.onError,
|
|
50
70
|
autoFit: !0,
|
|
51
|
-
mode: "desktop-browser",
|
|
52
71
|
dom: props.container
|
|
53
72
|
}));
|
|
54
73
|
chartContext.current = Object.assign(Object.assign({}, chartContext.current), {
|
|
55
74
|
chart: cs
|
|
56
75
|
});
|
|
57
|
-
})(props), chartContext.current.chart && chartContext.current.chart.
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
76
|
+
})(props), chartContext.current.chart && (chartContext.current.chart.renderSync({
|
|
77
|
+
reuse: !1
|
|
78
|
+
}), handleChartRender()), (0, eventsUtils_1.bindEventsToChart)(chartContext.current.chart, props, null, eventsUtils_1.CHART_EVENTS),
|
|
79
|
+
void (eventsBinded.current = props);
|
|
80
|
+
if (hasSpec) return void ((0, vutils_1.isEqual)(eventsBinded.current.spec, props.spec, {
|
|
81
|
+
skipFunction: skipFunctionDiff
|
|
82
|
+
}) || (eventsBinded.current = props, chartContext.current.chart.updateSpecSync(parseSpec(props), void 0, {
|
|
83
|
+
morph: !1,
|
|
84
|
+
enableExitAnimation: !1
|
|
85
|
+
}), handleChartRender()));
|
|
64
86
|
const newSpec = (0, vutils_1.pickWithout)(props, notSpecKeys);
|
|
65
|
-
(0, vutils_1.isEqual)(newSpec, prevSpec.current
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
87
|
+
(0, vutils_1.isEqual)(newSpec, prevSpec.current, {
|
|
88
|
+
skipFunction: skipFunctionDiff
|
|
89
|
+
}) && (0, vutils_1.isEqual)(newSpecFromChildren, specFromChildren.current) || (prevSpec.current = newSpec,
|
|
90
|
+
specFromChildren.current = newSpecFromChildren, chartContext.current.chart.updateSpecSync(parseSpec(props), void 0, {
|
|
91
|
+
morph: !1,
|
|
92
|
+
enableExitAnimation: !1
|
|
93
|
+
}), handleChartRender());
|
|
70
94
|
}), [ props ]), (0, react_1.useEffect)((() => () => {
|
|
71
|
-
chartContext &&
|
|
72
|
-
chartContext.current = null), isUnmount.current = !0;
|
|
95
|
+
chartContext && chartContext.current && chartContext.current.chart && (chartContext.current.chart.release(),
|
|
96
|
+
chartContext.current.chart = null), isUnmount.current = !0;
|
|
73
97
|
}), []), react_1.default.createElement(chart_1.default.Provider, {
|
|
74
98
|
value: chartContext.current
|
|
75
99
|
}, react_1.default.createElement(view_1.default.Provider, {
|
|
76
100
|
value: view
|
|
77
101
|
}, (0, util_1.toArray)(props.children).map(((child, index) => {
|
|
78
|
-
|
|
102
|
+
if ("string" == typeof child) return;
|
|
103
|
+
const childId = `${child && child.type && (child.type.displayName || child.type.name)}-${index}`;
|
|
79
104
|
return react_1.default.createElement(react_1.default.Fragment, {
|
|
80
|
-
key:
|
|
105
|
+
key: childId
|
|
81
106
|
}, react_1.default.cloneElement(child, {
|
|
82
|
-
updateId: updateId
|
|
107
|
+
updateId: updateId,
|
|
108
|
+
componentId: childId
|
|
83
109
|
}));
|
|
84
110
|
}))));
|
|
85
|
-
})), createChart = (componentName,
|
|
86
|
-
const Com = (0, withContainer_1.default)(BaseChart, componentName, (props => (props
|
|
87
|
-
callback ? callback(props) : type ? Object.assign(Object.assign({}, props), {
|
|
88
|
-
type: type
|
|
89
|
-
}) : props)));
|
|
111
|
+
})), createChart = (componentName, defaultProps, callback) => {
|
|
112
|
+
const Com = (0, withContainer_1.default)(BaseChart, componentName, (props => callback ? callback(props, defaultProps) : defaultProps ? Object.assign(props, defaultProps) : props));
|
|
90
113
|
return Com.displayName = componentName, Com;
|
|
91
114
|
};
|
|
92
115
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["charts/BaseChart.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8DAA8D;AAC9D,+CAAgF;AAChF,gFAA4E;AAC5E,6DAAsE;AAEtE,6CAAwD;AACxD,2DAA0C;AAC1C,kCAAkC;AAClC,4CAAmD;AAEnD,gDAAiG;AA2BjG,MAAM,WAAW,GAAG,CAAC,GAAG,+BAAmB,EAAE,GAAG,+BAA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C,QAAQ,IAAC,KAAK,EAAE,YAAY,CAAC,OAAO;QACpD,8BAAC,cAAW,CAAC,QAAQ,IAAC,KAAK,EAAE,IAAI,IAC9B,IAAA,cAAO,EAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;;YAC5C,OAAO,CACL,8BAAC,eAAK,CAAC,QAAQ,IAAC,GAAG,EAAE,MAAA,MAAA,MAAC,KAAa,aAAb,KAAK,uBAAL,KAAK,CAAU,KAAK,0CAAE,EAAE,mCAAK,KAAa,aAAb,KAAK,uBAAL,KAAK,CAAU,EAAE,mCAAI,SAAS,KAAK,EAAE,IACrF,eAAK,CAAC,YAAY,CAAC,KAAqB,EAAE;gBACzC,QAAQ,EAAE,QAAQ;aACnB,CAAC,CACa,CAClB,CAAC;QACJ,CAAC,CAAC,CACmB,CACG,CAC7B,CAAC;AACJ,CAAC,CAAC,CAAC;AAEI,MAAM,WAAW,GAAG,CAAkB,aAAqB,EAAE,IAAa,EAAE,QAA0B,EAAE,EAAE;IAC/G,MAAM,GAAG,GAAG,IAAA,uBAAa,EAAoB,SAAgB,EAAE,aAAa,EAAE,CAAC,KAAU,EAAE,EAAE;QAC3F,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC;QAElB,IAAI,QAAQ,EAAE;YACZ,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAC;SACxB;QAED,IAAI,IAAI,EAAE;YACR,uCAAY,KAAK,KAAE,IAAI,IAAG;SAC3B;QACD,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;IACH,GAAG,CAAC,WAAW,GAAG,aAAa,CAAC;IAChC,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AAfW,QAAA,WAAW,eAetB","file":"BaseChart.js","sourcesContent":["import VChart, { IData, IInitOption } from '@visactor/vchart';\nimport React, { useState, useEffect, useRef, useImperativeHandle } from 'react';\nimport withContainer, { ContainerProps } from '../containers/withContainer';\nimport RootChartContext, { ChartContextType } from '../context/chart';\nimport type { IView } from '@visactor/vgrammar';\nimport { isEqual, pickWithout } from '@visactor/vutils';\nimport ViewContext from '../context/view';\nimport { toArray } from '../util';\nimport { REACT_PRIVATE_PROPS } from '../constants';\nimport { IMarkElement } from '../components';\nimport { bindEventsToChart, EventsProps, CHART_EVENTS_KEYS, CHART_EVENTS } from '../eventsUtils';\n\nexport type ChartOptions = Omit<IInitOption, 'dom'>;\n\nexport interface BaseChartProps extends EventsProps {\n type?: string;\n /** 上层container */\n container?: HTMLDivElement;\n /**\n * used only by <VChart />\n */\n spec?: any;\n /** 数据 */\n data?: IData;\n /** 画布宽度 */\n width?: number;\n /** 画布高度 */\n height?: number;\n /** 图表配置 */\n options?: ChartOptions;\n\n /** 图表渲染完成事件 */\n onReady?: (instance: VChart, isInitial: boolean) => void;\n}\n\ntype Props = React.PropsWithChildren<BaseChartProps>;\n\nconst notSpecKeys = [...REACT_PRIVATE_PROPS, ...CHART_EVENTS_KEYS, 'spec', 'container', 'options'];\n\nconst BaseChart: React.FC<Props> = React.forwardRef((props, ref) => {\n const [updateId, setUpdateId] = useState<number>(0);\n const chartContext = useRef<ChartContextType>({\n specFromChildren: {}\n });\n\n useImperativeHandle(ref, () => chartContext.current.chart);\n\n const hasSpec = !!props.spec;\n const [view, setView] = useState<IView>(null);\n const isUnmount = useRef<boolean>(false);\n const prevSpec = useRef(pickWithout(props, notSpecKeys));\n const eventsBinded = React.useRef<BaseChartProps>(null);\n\n const parseSpec = (props: Props) => {\n if (hasSpec && props.spec) {\n return props.spec;\n }\n\n return {\n ...prevSpec.current,\n ...chartContext.current.specFromChildren\n };\n };\n\n const createChart = (props: Props) => {\n const cs = new VChart(parseSpec(props), {\n ...props.options,\n autoFit: true,\n mode: 'desktop-browser',\n dom: props.container\n });\n chartContext.current = { ...chartContext.current, chart: cs };\n };\n\n const handleChartRender = () => {\n const newView = chartContext.current.chart.getCompiler().getVGrammarView();\n if (newView !== view && !isUnmount.current) {\n setUpdateId(updateId + 1);\n if (props.onReady) {\n props.onReady(chartContext.current.chart, updateId === 0);\n }\n }\n setView(newView);\n };\n\n const renderChart = () => {\n if (chartContext.current.chart) {\n // eslint-disable-next-line promise/catch-or-return\n chartContext.current.chart.renderAsync().then(handleChartRender);\n }\n };\n\n useEffect(() => {\n if (!chartContext.current.chart) {\n createChart(props);\n renderChart();\n bindEventsToChart(chartContext.current.chart, props, null, CHART_EVENTS);\n chartContext.current = {\n ...chartContext.current,\n isChildrenUpdated: false\n };\n eventsBinded.current = props;\n return;\n }\n\n bindEventsToChart(chartContext.current.chart, props, eventsBinded.current, CHART_EVENTS);\n\n if (hasSpec) {\n if (!isEqual(eventsBinded.current.spec, props.spec)) {\n // eslint-disable-next-line promise/catch-or-return\n chartContext.current.chart.updateSpec(parseSpec(props)).then(handleChartRender);\n }\n return;\n }\n\n const newSpec = pickWithout(props, notSpecKeys);\n\n if (!isEqual(newSpec, prevSpec.current) || chartContext.current.isChildrenUpdated) {\n prevSpec.current = newSpec;\n // eslint-disable-next-line promise/catch-or-return\n chartContext.current.chart.updateSpec(parseSpec(props)).then(handleChartRender);\n }\n chartContext.current = {\n ...chartContext.current,\n isChildrenUpdated: false\n };\n }, [props]);\n\n useEffect(() => {\n return () => {\n if (chartContext) {\n if (chartContext.current.chart) {\n chartContext.current.chart.release();\n }\n chartContext.current = null;\n }\n isUnmount.current = true;\n };\n }, []);\n\n return (\n <RootChartContext.Provider value={chartContext.current}>\n <ViewContext.Provider value={view}>\n {toArray(props.children).map((child, index) => {\n return (\n <React.Fragment key={(child as any)?.props?.id ?? (child as any)?.id ?? `child-${index}`}>\n {React.cloneElement(child as IMarkElement, {\n updateId: updateId\n })}\n </React.Fragment>\n );\n })}\n </ViewContext.Provider>\n </RootChartContext.Provider>\n );\n});\n\nexport const createChart = <T extends Props>(componentName: string, type?: string, callback?: (props: T) => T) => {\n const Com = withContainer<ContainerProps, T>(BaseChart as any, componentName, (props: any) => {\n props.type = type;\n\n if (callback) {\n return callback(props);\n }\n\n if (type) {\n return { ...props, type };\n }\n return props;\n });\n Com.displayName = componentName;\n return Com;\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/charts/BaseChart.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,+CAAgF;AAChF,gFAA4E;AAC5E,6DAAsE;AAEtE,6CAAwD;AACxD,2DAA0C;AAC1C,kCAAkC;AAClC,4CAAmD;AACnD,gDAawB;AA+CxB,MAAM,WAAW,GAAG;IAClB,GAAG,+BAAmB;IACtB,GAAG,+BAAiB;IACpB,oBAAoB;IACpB,eAAe;IACf,kBAAkB;IAClB,SAAS;IACT,SAAS;IACT,MAAM;IACN,WAAW;IACX,SAAS;CACV,CAAC;AAEF,MAAM,qBAAqB,GAAG,CAAC,KAAY,EAAE,EAAE;IAC7C,MAAM,gBAAgB,GAAsD,EAAE,CAAC;IAE/E,IAAA,cAAO,EAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;QAClC,MAAM,SAAS,GAAG,KAAK,IAAK,KAAa,CAAC,IAAI,IAAK,KAAa,CAAC,IAAI,CAAC,SAAS,CAAC;QAEhF,IAAI,SAAS,IAAK,KAAa,CAAC,KAAK,EAAE;YACrC,MAAM,UAAU,GAAG,SAAS,CAAE,KAAa,CAAC,KAAK,CAAC,CAAC;YAEnD,IAAI,UAAU,CAAC,QAAQ,EAAE;gBACvB,gBAAgB,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC;aACzD;iBAAM;gBACL,IAAI,CAAC,gBAAgB,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE;oBAC1C,gBAAgB,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;iBAC5C;gBAED,gBAAgB,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;aAC7D;SACF;IACH,CAA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AAC,YAAY,CAAC,KAAkE,EAAE;gBACtF,QAAQ,EAAE,QAAQ;gBAClB,WAAW,EAAE,OAAO;aACrB,CAAC,CACa,CAClB,CAAC;QACJ,CAAC,CAAC,CACmB,CACG,CAC7B,CAAC;AACJ,CAAC,CAAC,CAAC;AAEI,MAAM,WAAW,GAAG,CACzB,aAAqB,EACrB,YAAyB,EACzB,QAAqD,EACrD,EAAE;IACF,MAAM,GAAG,GAAG,IAAA,uBAAa,EAAoB,SAAgB,EAAE,aAAa,EAAE,CAAC,KAAQ,EAAE,EAAE;QACzF,IAAI,QAAQ,EAAE;YACZ,OAAO,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;SACtC;QAED,IAAI,YAAY,EAAE;YAChB,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;SAC3C;QACD,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;IACH,GAAG,CAAC,WAAW,GAAG,aAAa,CAAC;IAChC,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AAjBW,QAAA,WAAW,eAiBtB","file":"BaseChart.js","sourcesContent":["import type { IVChart, IData, IInitOption, ISpec, IVChartConstructor } from '@visactor/vchart';\nimport React, { useState, useEffect, useRef, useImperativeHandle } from 'react';\nimport withContainer, { ContainerProps } from '../containers/withContainer';\nimport RootChartContext, { ChartContextType } from '../context/chart';\nimport type { IView } from '@visactor/vgrammar-core';\nimport { isEqual, pickWithout } from '@visactor/vutils';\nimport ViewContext from '../context/view';\nimport { toArray } from '../util';\nimport { REACT_PRIVATE_PROPS } from '../constants';\nimport {\n bindEventsToChart,\n EventsProps,\n CHART_EVENTS_KEYS,\n CHART_EVENTS,\n LegendEventProps,\n ScrollBarEventProps,\n BrushEventProps,\n DataZoomEventProps,\n PlayerEventProps,\n DimensionEventProps,\n HierarchyEventProps,\n ChartLifeCycleEventProps\n} from '../eventsUtils';\n\nexport type ChartOptions = Omit<IInitOption, 'dom'>;\n\nexport interface BaseChartProps\n extends EventsProps,\n LegendEventProps,\n ScrollBarEventProps,\n BrushEventProps,\n DataZoomEventProps,\n PlayerEventProps,\n DimensionEventProps,\n HierarchyEventProps,\n ChartLifeCycleEventProps {\n vchartConstrouctor?: IVChartConstructor;\n type?: string;\n /** 上层container */\n container?: HTMLDivElement;\n /**\n * used only by <VChart />\n */\n spec?: ISpec;\n /** 数据 */\n data?: IData;\n /** 画布宽度 */\n width?: number;\n /** 画布高度 */\n height?: number;\n /** 图表配置 */\n options?: ChartOptions;\n /** skip function diff when component update */\n skipFunctionDiff?: boolean;\n /** 图表渲染完成事件 */\n onReady?: (instance: IVChart, isInitial: boolean) => void;\n /** throw error when chart run into an error */\n onError?: (err: Error) => void;\n /**\n * use sync render\n *\n * @since 1.8.3\n * @deprecated 1.9.0\n **/\n useSyncRender?: boolean;\n}\n\ntype Props = React.PropsWithChildren<BaseChartProps>;\n\nconst notSpecKeys = [\n ...REACT_PRIVATE_PROPS,\n ...CHART_EVENTS_KEYS,\n 'vchartConstrouctor',\n 'useSyncRender',\n 'skipFunctionDiff',\n 'onError',\n 'onReady',\n 'spec',\n 'container',\n 'options'\n];\n\nconst parseSpecFromChildren = (props: Props) => {\n const specFromChildren: Omit<ISpec, 'type' | 'data' | 'width' | 'height'> = {};\n\n toArray(props.children).map(child => {\n const parseSpec = child && (child as any).type && (child as any).type.parseSpec;\n\n if (parseSpec && (child as any).props) {\n const specResult = parseSpec((child as any).props);\n\n if (specResult.isSingle) {\n specFromChildren[specResult.specName] = specResult.spec;\n } else {\n if (!specFromChildren[specResult.specName]) {\n specFromChildren[specResult.specName] = [];\n }\n\n specFromChildren[specResult.specName].push(specResult.spec);\n }\n }\n });\n\n return specFromChildren;\n};\n\nconst BaseChart: React.FC<Props> = React.forwardRef((props, ref) => {\n const [updateId, setUpdateId] = useState<number>(0);\n const chartContext = useRef<ChartContextType>({});\n useImperativeHandle(ref, () => chartContext.current?.chart);\n const hasSpec = !!props.spec;\n const [view, setView] = useState<IView>(null);\n const isUnmount = useRef<boolean>(false);\n const prevSpec = useRef(pickWithout(props, notSpecKeys));\n const specFromChildren = useRef<Omit<ISpec, 'type' | 'data' | 'width' | 'height'>>(null);\n const eventsBinded = React.useRef<BaseChartProps>(null);\n const skipFunctionDiff = !!props.skipFunctionDiff;\n\n const parseSpec = (props: Props) => {\n if (hasSpec && props.spec) {\n return props.spec;\n }\n\n return {\n ...prevSpec.current,\n ...specFromChildren.current\n } as ISpec;\n };\n\n const createChart = (props: Props) => {\n const cs = new props.vchartConstrouctor(parseSpec(props), {\n ...props.options,\n onError: props.onError,\n autoFit: true,\n dom: props.container\n });\n chartContext.current = { ...chartContext.current, chart: cs };\n };\n\n const handleChartRender = () => {\n // rebind events after render\n if (!isUnmount.current) {\n if (!chartContext.current || !chartContext.current.chart) {\n return;\n }\n\n bindEventsToChart(chartContext.current.chart, props, eventsBinded.current, CHART_EVENTS);\n\n const newView = chartContext.current.chart.getCompiler().getVGrammarView();\n\n setUpdateId(updateId + 1);\n if (props.onReady) {\n props.onReady(chartContext.current.chart, updateId === 0);\n }\n setView(newView);\n }\n };\n\n const renderChart = () => {\n if (chartContext.current.chart) {\n chartContext.current.chart.renderSync({\n reuse: false\n });\n handleChartRender();\n }\n };\n\n useEffect(() => {\n const newSpecFromChildren = hasSpec ? null : parseSpecFromChildren(props);\n\n if (!chartContext.current?.chart) {\n if (!hasSpec) {\n specFromChildren.current = newSpecFromChildren;\n }\n\n createChart(props);\n renderChart();\n bindEventsToChart(chartContext.current.chart, props, null, CHART_EVENTS);\n eventsBinded.current = props;\n return;\n }\n\n if (hasSpec) {\n if (!isEqual(eventsBinded.current.spec, props.spec, { skipFunction: skipFunctionDiff })) {\n eventsBinded.current = props;\n chartContext.current.chart.updateSpecSync(parseSpec(props), undefined, {\n morph: false,\n enableExitAnimation: false\n });\n handleChartRender();\n }\n return;\n }\n\n const newSpec = pickWithout(props, notSpecKeys);\n\n if (\n !isEqual(newSpec, prevSpec.current, { skipFunction: skipFunctionDiff }) ||\n !isEqual(newSpecFromChildren, specFromChildren.current)\n ) {\n prevSpec.current = newSpec;\n specFromChildren.current = newSpecFromChildren;\n\n chartContext.current.chart.updateSpecSync(parseSpec(props), undefined, {\n morph: false,\n enableExitAnimation: false\n });\n handleChartRender();\n }\n }, [props]);\n\n useEffect(() => {\n return () => {\n if (chartContext) {\n if (chartContext.current && chartContext.current.chart) {\n chartContext.current.chart.release();\n chartContext.current.chart = null;\n }\n }\n isUnmount.current = true;\n };\n }, []);\n\n return (\n <RootChartContext.Provider value={chartContext.current}>\n <ViewContext.Provider value={view}>\n {toArray(props.children).map((child, index) => {\n if (typeof child === 'string') {\n return;\n }\n\n const componentName =\n child && (child as any).type && ((child as any).type.displayName || (child as any).type.name);\n const childId = `${componentName}-${index}`;\n\n return (\n <React.Fragment key={childId}>\n {React.cloneElement(child as React.ReactElement<any, React.JSXElementConstructor<any>>, {\n updateId: updateId,\n componentId: childId\n })}\n </React.Fragment>\n );\n })}\n </ViewContext.Provider>\n </RootChartContext.Provider>\n );\n});\n\nexport const createChart = <T extends Props>(\n componentName: string,\n defaultProps?: Partial<T>,\n callback?: (props: T, defaultProps?: Partial<T>) => T\n) => {\n const Com = withContainer<ContainerProps, T>(BaseChart as any, componentName, (props: T) => {\n if (callback) {\n return callback(props, defaultProps);\n }\n\n if (defaultProps) {\n return Object.assign(props, defaultProps);\n }\n return props;\n });\n Com.displayName = componentName;\n return Com;\n};\n"]}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import { IBoxPlotChartSpec } from '@visactor/vchart';
|
|
2
3
|
import { BaseChartProps } from './BaseChart';
|
|
3
4
|
export interface BoxPlotChartProps extends Omit<BaseChartProps, 'spec' | 'container' | 'type'>, Omit<IBoxPlotChartSpec, 'type'> {
|
|
4
5
|
}
|
|
5
|
-
export declare const BoxPlotChart:
|
|
6
|
+
export declare const BoxPlotChart: React.ForwardRefExoticComponent<BoxPlotChartProps & {
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
} & {
|
|
9
|
+
type: 'boxPlot';
|
|
10
|
+
} & import("../containers/withContainer").ContainerProps & React.RefAttributes<any>>;
|
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var __importDefault = this && this.__importDefault || function(mod) {
|
|
4
|
+
return mod && mod.__esModule ? mod : {
|
|
5
|
+
default: mod
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
|
|
3
9
|
Object.defineProperty(exports, "__esModule", {
|
|
4
10
|
value: !0
|
|
5
11
|
}), exports.BoxPlotChart = void 0;
|
|
6
12
|
|
|
7
|
-
const BaseChart_1 = require("./BaseChart");
|
|
13
|
+
const vchart_1 = __importDefault(require("@visactor/vchart")), BaseChart_1 = require("./BaseChart");
|
|
8
14
|
|
|
9
|
-
exports.BoxPlotChart = (0, BaseChart_1.createChart)("BoxPlotChart",
|
|
15
|
+
exports.BoxPlotChart = (0, BaseChart_1.createChart)("BoxPlotChart", {
|
|
16
|
+
type: "boxPlot",
|
|
17
|
+
vchartConstrouctor: vchart_1.default
|
|
18
|
+
});
|
|
10
19
|
//# sourceMappingURL=BoxPlotChart.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["charts/BoxPlotChart.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/charts/BoxPlotChart.tsx"],"names":[],"mappings":";;;;;;AAEA,8DAAqD;AACrD,2CAA0D;AAM7C,QAAA,YAAY,GAAG,IAAA,uBAAW,EACrC,cAAc,EACd;IACE,IAAI,EAAE,SAAS;IACf,kBAAkB,EAAE,gBAAM;CAC3B,CACF,CAAC","file":"BoxPlotChart.js","sourcesContent":["import React from 'react';\nimport { IBoxPlotChartSpec } from '@visactor/vchart';\nimport { default as VChart } from '@visactor/vchart';\nimport { BaseChartProps, createChart } from './BaseChart';\n\nexport interface BoxPlotChartProps\n extends Omit<BaseChartProps, 'spec' | 'container' | 'type'>,\n Omit<IBoxPlotChartSpec, 'type'> {}\n\nexport const BoxPlotChart = createChart<React.PropsWithChildren<BoxPlotChartProps> & { type: 'boxPlot' }>(\n 'BoxPlotChart',\n {\n type: 'boxPlot',\n vchartConstrouctor: VChart\n }\n);\n"]}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import { ICircularProgressChartSpec } from '@visactor/vchart';
|
|
2
3
|
import { BaseChartProps } from './BaseChart';
|
|
3
4
|
export interface CircularProgressChartProps extends Omit<BaseChartProps, 'spec' | 'container' | 'type'>, Omit<ICircularProgressChartSpec, 'type'> {
|
|
4
5
|
}
|
|
5
|
-
export declare const CircularProgressChart:
|
|
6
|
+
export declare const CircularProgressChart: React.ForwardRefExoticComponent<CircularProgressChartProps & {
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
} & {
|
|
9
|
+
type: 'circularProgress';
|
|
10
|
+
} & import("../containers/withContainer").ContainerProps & React.RefAttributes<any>>;
|
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var __importDefault = this && this.__importDefault || function(mod) {
|
|
4
|
+
return mod && mod.__esModule ? mod : {
|
|
5
|
+
default: mod
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
|
|
3
9
|
Object.defineProperty(exports, "__esModule", {
|
|
4
10
|
value: !0
|
|
5
11
|
}), exports.CircularProgressChart = void 0;
|
|
6
12
|
|
|
7
|
-
const BaseChart_1 = require("./BaseChart");
|
|
13
|
+
const vchart_1 = __importDefault(require("@visactor/vchart")), BaseChart_1 = require("./BaseChart");
|
|
8
14
|
|
|
9
|
-
exports.CircularProgressChart = (0, BaseChart_1.createChart)("CircularProgressChart",
|
|
15
|
+
exports.CircularProgressChart = (0, BaseChart_1.createChart)("CircularProgressChart", {
|
|
16
|
+
type: "circularProgress",
|
|
17
|
+
vchartConstrouctor: vchart_1.default
|
|
18
|
+
});
|
|
10
19
|
//# sourceMappingURL=CircularProgressChart.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["charts/CircularProgressChart.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/charts/CircularProgressChart.tsx"],"names":[],"mappings":";;;;;;AAEA,8DAAqD;AACrD,2CAA0D;AAM7C,QAAA,qBAAqB,GAAG,IAAA,uBAAW,EAE9C,uBAAuB,EAAE;IACzB,IAAI,EAAE,kBAAkB;IACxB,kBAAkB,EAAE,gBAAM;CAC3B,CAAC,CAAC","file":"CircularProgressChart.js","sourcesContent":["import React from 'react';\nimport { ICircularProgressChartSpec } from '@visactor/vchart';\nimport { default as VChart } from '@visactor/vchart';\nimport { BaseChartProps, createChart } from './BaseChart';\n\nexport interface CircularProgressChartProps\n extends Omit<BaseChartProps, 'spec' | 'container' | 'type'>,\n Omit<ICircularProgressChartSpec, 'type'> {}\n\nexport const CircularProgressChart = createChart<\n React.PropsWithChildren<CircularProgressChartProps> & { type: 'circularProgress' }\n>('CircularProgressChart', {\n type: 'circularProgress',\n vchartConstrouctor: VChart\n});\n"]}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import { ICommonChartSpec } from '@visactor/vchart';
|
|
2
3
|
import { BaseChartProps } from './BaseChart';
|
|
3
4
|
export interface CommonChartProps extends Omit<BaseChartProps, 'spec' | 'container' | 'type'>, Omit<ICommonChartSpec, 'type'> {
|
|
4
5
|
}
|
|
5
|
-
export declare const CommonChart:
|
|
6
|
+
export declare const CommonChart: React.ForwardRefExoticComponent<CommonChartProps & {
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
} & {
|
|
9
|
+
type: 'common';
|
|
10
|
+
} & import("../containers/withContainer").ContainerProps & React.RefAttributes<any>>;
|
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var __importDefault = this && this.__importDefault || function(mod) {
|
|
4
|
+
return mod && mod.__esModule ? mod : {
|
|
5
|
+
default: mod
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
|
|
3
9
|
Object.defineProperty(exports, "__esModule", {
|
|
4
10
|
value: !0
|
|
5
11
|
}), exports.CommonChart = void 0;
|
|
6
12
|
|
|
7
|
-
const BaseChart_1 = require("./BaseChart");
|
|
13
|
+
const vchart_1 = __importDefault(require("@visactor/vchart")), BaseChart_1 = require("./BaseChart");
|
|
8
14
|
|
|
9
|
-
exports.CommonChart = (0, BaseChart_1.createChart)("CommonChart",
|
|
15
|
+
exports.CommonChart = (0, BaseChart_1.createChart)("CommonChart", {
|
|
16
|
+
type: "common",
|
|
17
|
+
vchartConstrouctor: vchart_1.default
|
|
18
|
+
});
|
|
10
19
|
//# sourceMappingURL=CommonChart.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["charts/CommonChart.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/charts/CommonChart.tsx"],"names":[],"mappings":";;;;;;AAEA,8DAAqD;AACrD,2CAA0D;AAM7C,QAAA,WAAW,GAAG,IAAA,uBAAW,EAAiE,aAAa,EAAE;IACpH,IAAI,EAAE,QAAQ;IACd,kBAAkB,EAAE,gBAAM;CAC3B,CAAC,CAAC","file":"CommonChart.js","sourcesContent":["import React from 'react';\nimport { ICommonChartSpec } from '@visactor/vchart';\nimport { default as VChart } from '@visactor/vchart';\nimport { BaseChartProps, createChart } from './BaseChart';\n\nexport interface CommonChartProps\n extends Omit<BaseChartProps, 'spec' | 'container' | 'type'>,\n Omit<ICommonChartSpec, 'type'> {}\n\nexport const CommonChart = createChart<React.PropsWithChildren<CommonChartProps> & { type: 'common' }>('CommonChart', {\n type: 'common',\n vchartConstrouctor: VChart\n});\n"]}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import { IFunnelChartSpec } from '@visactor/vchart';
|
|
2
3
|
import { BaseChartProps } from './BaseChart';
|
|
3
4
|
export interface FunnelChartProps extends Omit<BaseChartProps, 'spec' | 'container' | 'type'>, Omit<IFunnelChartSpec, 'type'> {
|
|
4
5
|
}
|
|
5
|
-
export declare const FunnelChart:
|
|
6
|
+
export declare const FunnelChart: React.ForwardRefExoticComponent<FunnelChartProps & {
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
} & {
|
|
9
|
+
type: 'funnel';
|
|
10
|
+
} & import("../containers/withContainer").ContainerProps & React.RefAttributes<any>>;
|
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var __importDefault = this && this.__importDefault || function(mod) {
|
|
4
|
+
return mod && mod.__esModule ? mod : {
|
|
5
|
+
default: mod
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
|
|
3
9
|
Object.defineProperty(exports, "__esModule", {
|
|
4
10
|
value: !0
|
|
5
11
|
}), exports.FunnelChart = void 0;
|
|
6
12
|
|
|
7
|
-
const BaseChart_1 = require("./BaseChart");
|
|
13
|
+
const vchart_1 = __importDefault(require("@visactor/vchart")), BaseChart_1 = require("./BaseChart");
|
|
8
14
|
|
|
9
|
-
exports.FunnelChart = (0, BaseChart_1.createChart)("FunnelChart",
|
|
15
|
+
exports.FunnelChart = (0, BaseChart_1.createChart)("FunnelChart", {
|
|
16
|
+
type: "funnel",
|
|
17
|
+
vchartConstrouctor: vchart_1.default
|
|
18
|
+
});
|
|
10
19
|
//# sourceMappingURL=FunnelChart.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["charts/FunnelChart.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/charts/FunnelChart.tsx"],"names":[],"mappings":";;;;;;AAEA,8DAAqD;AACrD,2CAA0D;AAM7C,QAAA,WAAW,GAAG,IAAA,uBAAW,EAAiE,aAAa,EAAE;IACpH,IAAI,EAAE,QAAQ;IACd,kBAAkB,EAAE,gBAAM;CAC3B,CAAC,CAAC","file":"FunnelChart.js","sourcesContent":["import React from 'react';\nimport { IFunnelChartSpec } from '@visactor/vchart';\nimport { default as VChart } from '@visactor/vchart';\nimport { BaseChartProps, createChart } from './BaseChart';\n\nexport interface FunnelChartProps\n extends Omit<BaseChartProps, 'spec' | 'container' | 'type'>,\n Omit<IFunnelChartSpec, 'type'> {}\n\nexport const FunnelChart = createChart<React.PropsWithChildren<FunnelChartProps> & { type: 'funnel' }>('FunnelChart', {\n type: 'funnel',\n vchartConstrouctor: VChart\n});\n"]}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import { IHistogramChartSpec } from '@visactor/vchart';
|
|
2
3
|
import { BaseChartProps } from './BaseChart';
|
|
3
4
|
export interface HistogramChartProps extends Omit<BaseChartProps, 'spec' | 'container' | 'type'>, Omit<IHistogramChartSpec, 'type'> {
|
|
4
5
|
}
|
|
5
|
-
export declare const HistogramChart:
|
|
6
|
+
export declare const HistogramChart: React.ForwardRefExoticComponent<HistogramChartProps & {
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
} & {
|
|
9
|
+
type: 'histogram';
|
|
10
|
+
} & import("../containers/withContainer").ContainerProps & React.RefAttributes<any>>;
|