@wavemaker/react-native-echarts 1.0.0-dev.4 → 1.0.0-dev.8
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 +211 -39
- package/area/area-chart.d.ts +1 -1
- package/area/area-chart.d.ts.map +1 -1
- package/area/area-chart.js +48 -23
- package/area/area-chart.props.d.ts +4 -0
- package/area/area-chart.props.d.ts.map +1 -1
- package/area/index.d.ts +1 -1
- package/area/index.d.ts.map +1 -1
- package/bubble/bubble-chart.d.ts.map +1 -1
- package/bubble/bubble-chart.js +50 -31
- package/cartesian/tooltip/axis-tooltip-presets.d.ts +5 -0
- package/cartesian/tooltip/axis-tooltip-presets.d.ts.map +1 -0
- package/cartesian/tooltip/axis-tooltip-presets.js +46 -0
- package/cartesian/tooltip/axis-tooltip.types.d.ts +38 -0
- package/cartesian/tooltip/axis-tooltip.types.d.ts.map +1 -0
- package/cartesian/tooltip/axis-tooltip.types.js +4 -0
- package/cartesian/tooltip/axis-tooltip.utils.d.ts +10 -0
- package/cartesian/tooltip/axis-tooltip.utils.d.ts.map +1 -0
- package/cartesian/tooltip/axis-tooltip.utils.js +121 -0
- package/cartesian/tooltip/default-axis-tooltip.d.ts +9 -0
- package/cartesian/tooltip/default-axis-tooltip.d.ts.map +1 -0
- package/cartesian/tooltip/default-axis-tooltip.js +53 -0
- package/cartesian/tooltip/index.d.ts +7 -0
- package/cartesian/tooltip/index.d.ts.map +1 -0
- package/cartesian/tooltip/index.js +4 -0
- package/cartesian/tooltip/use-axis-tooltip.d.ts +38 -0
- package/cartesian/tooltip/use-axis-tooltip.d.ts.map +1 -0
- package/cartesian/tooltip/use-axis-tooltip.js +54 -0
- package/column/column-chart.d.ts.map +1 -1
- package/column/column-chart.js +73 -20
- package/geo/geo-chart.d.ts.map +1 -1
- package/geo/geo-chart.js +56 -24
- package/geo/geo-chart.props.d.ts +11 -5
- package/geo/geo-chart.props.d.ts.map +1 -1
- package/geo/index.d.ts +1 -0
- package/geo/index.d.ts.map +1 -1
- package/geo/index.js +1 -0
- package/geo/tooltip/default-geo-tooltip.d.ts +6 -0
- package/geo/tooltip/default-geo-tooltip.d.ts.map +1 -0
- package/geo/tooltip/default-geo-tooltip.js +47 -0
- package/geo/tooltip/geo-item-tooltip-presets.d.ts +5 -0
- package/geo/tooltip/geo-item-tooltip-presets.d.ts.map +1 -0
- package/geo/tooltip/geo-item-tooltip-presets.js +35 -0
- package/geo/tooltip/geo-item-tooltip.types.d.ts +19 -0
- package/geo/tooltip/geo-item-tooltip.types.d.ts.map +1 -0
- package/geo/tooltip/geo-item-tooltip.types.js +3 -0
- package/geo/tooltip/geo-item-tooltip.utils.d.ts +14 -0
- package/geo/tooltip/geo-item-tooltip.utils.d.ts.map +1 -0
- package/geo/tooltip/geo-item-tooltip.utils.js +220 -0
- package/geo/tooltip/index.d.ts +7 -0
- package/geo/tooltip/index.d.ts.map +1 -0
- package/geo/tooltip/index.js +4 -0
- package/geo/tooltip/use-geo-item-tooltip.d.ts +26 -0
- package/geo/tooltip/use-geo-item-tooltip.d.ts.map +1 -0
- package/geo/tooltip/use-geo-item-tooltip.js +59 -0
- package/geo/us-chart.js +1 -1
- package/geo/us-states.json +54 -0
- package/geo/world.json +1 -0
- package/index.d.ts +2 -0
- package/index.d.ts.map +1 -1
- package/index.js +2 -0
- package/line/index.d.ts +1 -1
- package/line/index.d.ts.map +1 -1
- package/line/line-chart.d.ts +1 -1
- package/line/line-chart.d.ts.map +1 -1
- package/line/line-chart.props.d.ts +5 -0
- package/line/line-chart.props.d.ts.map +1 -1
- package/package.json +7 -4
- package/pie/index.d.ts +1 -0
- package/pie/index.d.ts.map +1 -1
- package/pie/index.js +1 -0
- package/pie/pie-chart.d.ts.map +1 -1
- package/pie/pie-chart.js +59 -36
- package/pie/pie-chart.props.d.ts +12 -6
- package/pie/pie-chart.props.d.ts.map +1 -1
- package/pie/tooltip/default-pie-tooltip.d.ts +5 -0
- package/pie/tooltip/default-pie-tooltip.d.ts.map +1 -0
- package/pie/tooltip/default-pie-tooltip.js +57 -0
- package/pie/tooltip/index.d.ts +7 -0
- package/pie/tooltip/index.d.ts.map +1 -0
- package/pie/tooltip/index.js +4 -0
- package/pie/tooltip/pie-item-tooltip-presets.d.ts +5 -0
- package/pie/tooltip/pie-item-tooltip-presets.d.ts.map +1 -0
- package/pie/tooltip/pie-item-tooltip-presets.js +39 -0
- package/pie/tooltip/pie-item-tooltip.types.d.ts +28 -0
- package/pie/tooltip/pie-item-tooltip.types.d.ts.map +1 -0
- package/pie/tooltip/pie-item-tooltip.types.js +3 -0
- package/pie/tooltip/pie-item-tooltip.utils.d.ts +9 -0
- package/pie/tooltip/pie-item-tooltip.utils.d.ts.map +1 -0
- package/pie/tooltip/pie-item-tooltip.utils.js +139 -0
- package/pie/tooltip/use-pie-item-tooltip.d.ts +24 -0
- package/pie/tooltip/use-pie-item-tooltip.d.ts.map +1 -0
- package/pie/tooltip/use-pie-item-tooltip.js +45 -0
- package/props/cartesian.d.ts +18 -2
- package/props/cartesian.d.ts.map +1 -1
- package/radar/index.d.ts +1 -0
- package/radar/index.d.ts.map +1 -1
- package/radar/index.js +1 -0
- package/radar/radar-chart.d.ts.map +1 -1
- package/radar/radar-chart.js +52 -10
- package/radar/radar-chart.props.d.ts +13 -0
- package/radar/radar-chart.props.d.ts.map +1 -1
- package/radar/tooltip/default-radar-tooltip.d.ts +6 -0
- package/radar/tooltip/default-radar-tooltip.d.ts.map +1 -0
- package/radar/tooltip/default-radar-tooltip.js +47 -0
- package/radar/tooltip/index.d.ts +7 -0
- package/radar/tooltip/index.d.ts.map +1 -0
- package/radar/tooltip/index.js +4 -0
- package/radar/tooltip/radar-item-tooltip-presets.d.ts +5 -0
- package/radar/tooltip/radar-item-tooltip-presets.d.ts.map +1 -0
- package/radar/tooltip/radar-item-tooltip-presets.js +50 -0
- package/radar/tooltip/radar-item-tooltip.types.d.ts +28 -0
- package/radar/tooltip/radar-item-tooltip.types.d.ts.map +1 -0
- package/radar/tooltip/radar-item-tooltip.types.js +3 -0
- package/radar/tooltip/radar-item-tooltip.utils.d.ts +9 -0
- package/radar/tooltip/radar-item-tooltip.utils.d.ts.map +1 -0
- package/radar/tooltip/radar-item-tooltip.utils.js +77 -0
- package/radar/tooltip/use-radar-item-tooltip.d.ts +22 -0
- package/radar/tooltip/use-radar-item-tooltip.d.ts.map +1 -0
- package/radar/tooltip/use-radar-item-tooltip.js +43 -0
- package/radial/index.d.ts +1 -0
- package/radial/index.d.ts.map +1 -1
- package/radial/index.js +1 -0
- package/radial/radial-chart.d.ts.map +1 -1
- package/radial/radial-chart.js +42 -10
- package/radial/radial-chart.props.d.ts +14 -1
- package/radial/radial-chart.props.d.ts.map +1 -1
- package/radial/tooltip/default-radial-tooltip.d.ts +6 -0
- package/radial/tooltip/default-radial-tooltip.d.ts.map +1 -0
- package/radial/tooltip/default-radial-tooltip.js +52 -0
- package/radial/tooltip/index.d.ts +7 -0
- package/radial/tooltip/index.d.ts.map +1 -0
- package/radial/tooltip/index.js +4 -0
- package/radial/tooltip/radial-item-tooltip-presets.d.ts +5 -0
- package/radial/tooltip/radial-item-tooltip-presets.d.ts.map +1 -0
- package/radial/tooltip/radial-item-tooltip-presets.js +43 -0
- package/radial/tooltip/radial-item-tooltip.types.d.ts +23 -0
- package/radial/tooltip/radial-item-tooltip.types.d.ts.map +1 -0
- package/radial/tooltip/radial-item-tooltip.types.js +3 -0
- package/radial/tooltip/radial-item-tooltip.utils.d.ts +9 -0
- package/radial/tooltip/radial-item-tooltip.utils.d.ts.map +1 -0
- package/radial/tooltip/radial-item-tooltip.utils.js +122 -0
- package/radial/tooltip/use-radial-item-tooltip.d.ts +22 -0
- package/radial/tooltip/use-radial-item-tooltip.d.ts.map +1 -0
- package/radial/tooltip/use-radial-item-tooltip.js +43 -0
- package/scatter/index.d.ts +1 -0
- package/scatter/index.d.ts.map +1 -1
- package/scatter/index.js +1 -0
- package/scatter/scatter-chart.d.ts.map +1 -1
- package/scatter/scatter-chart.js +46 -12
- package/scatter/scatter-chart.props.d.ts +7 -1
- package/scatter/scatter-chart.props.d.ts.map +1 -1
- package/scatter/tooltip/default-scatter-tooltip.d.ts +8 -0
- package/scatter/tooltip/default-scatter-tooltip.d.ts.map +1 -0
- package/scatter/tooltip/default-scatter-tooltip.js +57 -0
- package/scatter/tooltip/index.d.ts +7 -0
- package/scatter/tooltip/index.d.ts.map +1 -0
- package/scatter/tooltip/index.js +4 -0
- package/scatter/tooltip/scatter-item-tooltip-presets.d.ts +5 -0
- package/scatter/tooltip/scatter-item-tooltip-presets.d.ts.map +1 -0
- package/scatter/tooltip/scatter-item-tooltip-presets.js +49 -0
- package/scatter/tooltip/scatter-item-tooltip.types.d.ts +22 -0
- package/scatter/tooltip/scatter-item-tooltip.types.d.ts.map +1 -0
- package/scatter/tooltip/scatter-item-tooltip.types.js +3 -0
- package/scatter/tooltip/scatter-item-tooltip.utils.d.ts +9 -0
- package/scatter/tooltip/scatter-item-tooltip.utils.d.ts.map +1 -0
- package/scatter/tooltip/scatter-item-tooltip.utils.js +83 -0
- package/scatter/tooltip/use-scatter-item-tooltip.d.ts +25 -0
- package/scatter/tooltip/use-scatter-item-tooltip.d.ts.map +1 -0
- package/scatter/tooltip/use-scatter-item-tooltip.js +46 -0
- package/tooltip/chart-pointer-tooltip-overlay.d.ts +11 -0
- package/tooltip/chart-pointer-tooltip-overlay.d.ts.map +1 -0
- package/tooltip/chart-pointer-tooltip-overlay.js +88 -0
- package/tooltip/chart-tooltip-preset-shells.d.ts +66 -0
- package/tooltip/chart-tooltip-preset-shells.d.ts.map +1 -0
- package/tooltip/chart-tooltip-preset-shells.js +409 -0
- package/tooltip/index.d.ts +7 -0
- package/tooltip/index.d.ts.map +1 -0
- package/tooltip/index.js +1 -0
package/index.d.ts
CHANGED
package/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../components/chart/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AACnE,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC;AACvB,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../components/chart/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AACnE,cAAc,qBAAqB,CAAC;AACpC,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC;AACvB,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC"}
|
package/index.js
CHANGED
package/line/index.d.ts
CHANGED
package/line/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/chart/line/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/chart/line/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,YAAY,EACV,cAAc,EACd,0BAA0B,EAC1B,0BAA0B,GAC3B,MAAM,oBAAoB,CAAC"}
|
package/line/line-chart.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { LineChartProps } from './line-chart.props';
|
|
3
3
|
/** common -> cartesian -> area -> line */
|
|
4
|
-
export type { LineChartProps } from './line-chart.props';
|
|
4
|
+
export type { LineChartProps, LineChartAxisTooltipParams, LineChartTooltipSeriesItem, } from './line-chart.props';
|
|
5
5
|
declare function LineChartComponent(props: LineChartProps): React.JSX.Element;
|
|
6
6
|
export declare const LineChart: typeof LineChartComponent & {
|
|
7
7
|
displayName: string;
|
package/line/line-chart.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"line-chart.d.ts","sourceRoot":"","sources":["../../../../components/chart/line/line-chart.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,0CAA0C;AAC1C,YAAY,
|
|
1
|
+
{"version":3,"file":"line-chart.d.ts","sourceRoot":"","sources":["../../../../components/chart/line/line-chart.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,0CAA0C;AAC1C,YAAY,EACV,cAAc,EACd,0BAA0B,EAC1B,0BAA0B,GAC3B,MAAM,oBAAoB,CAAC;AAE5B,iBAAS,kBAAkB,CAAC,KAAK,EAAE,cAAc,qBAEhD;AAED,eAAO,MAAM,SAAS;;CAEpB,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AreaChartProps } from '../area/area-chart.props';
|
|
2
2
|
import type { CartesianChartSelectEvent } from '../props/cartesian';
|
|
3
|
+
import type { AxisTooltipParams, AxisTooltipSeriesItem } from '../cartesian/tooltip/axis-tooltip.types';
|
|
3
4
|
/**
|
|
4
5
|
* Props for LineChart.
|
|
5
6
|
* Line chart is AreaChart with no fill (areaOpacity=0, areaFill='transparent').
|
|
@@ -7,6 +8,10 @@ import type { CartesianChartSelectEvent } from '../props/cartesian';
|
|
|
7
8
|
* common -> cartesian -> area -> line
|
|
8
9
|
*/
|
|
9
10
|
export type LineChartProps = Omit<AreaChartProps, 'areaOpacity' | 'areaFill'>;
|
|
11
|
+
/** Per-series row in axis tooltip params for {@link LineChartProps#renderTooltip}. */
|
|
12
|
+
export type LineChartTooltipSeriesItem = AxisTooltipSeriesItem;
|
|
13
|
+
/** Axis tooltip params for {@link LineChartProps#renderTooltip}. */
|
|
14
|
+
export type LineChartAxisTooltipParams = AxisTooltipParams;
|
|
10
15
|
/** Selection payload for {@link LineChartProps} / `onSelect` (same as {@link CartesianChartSelectEvent}). */
|
|
11
16
|
export type LineChartSelectEvent = CartesianChartSelectEvent;
|
|
12
17
|
//# sourceMappingURL=line-chart.props.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"line-chart.props.d.ts","sourceRoot":"","sources":["../../../../components/chart/line/line-chart.props.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"line-chart.props.d.ts","sourceRoot":"","sources":["../../../../components/chart/line/line-chart.props.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AAExG;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,cAAc,EAAE,aAAa,GAAG,UAAU,CAAC,CAAC;AAE9E,sFAAsF;AACtF,MAAM,MAAM,0BAA0B,GAAG,qBAAqB,CAAC;AAE/D,oEAAoE;AACpE,MAAM,MAAM,0BAA0B,GAAG,iBAAiB,CAAC;AAE3D,6GAA6G;AAC7G,MAAM,MAAM,oBAAoB,GAAG,yBAAyB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wavemaker/react-native-echarts",
|
|
3
|
-
"version": "1.0.0-dev.
|
|
3
|
+
"version": "1.0.0-dev.8",
|
|
4
4
|
"description": "React Native chart components built on using e-charts library.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -33,11 +33,14 @@
|
|
|
33
33
|
"react": "*",
|
|
34
34
|
"react-native": "*",
|
|
35
35
|
"@shopify/react-native-skia": "*",
|
|
36
|
-
"@wuba/react-native-echarts": "
|
|
37
|
-
"echarts": "
|
|
36
|
+
"@wuba/react-native-echarts": "^3.0.1",
|
|
37
|
+
"echarts": "^6.0.0",
|
|
38
38
|
"zrender": "*",
|
|
39
39
|
"react-native-svg": "*"
|
|
40
40
|
},
|
|
41
|
-
"dependencies": {
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@wuba/react-native-echarts": "^3.0.1",
|
|
43
|
+
"echarts": "^6.0.0"
|
|
44
|
+
},
|
|
42
45
|
"private": false
|
|
43
46
|
}
|
package/pie/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { PieChart } from './pie-chart';
|
|
2
2
|
export { isConcentricPieData } from './pie-chart.props';
|
|
3
3
|
export type { PieChartProps, PieChartData, PieChartSelectEvent, PieDataItem, PieRingData, } from './pie-chart.props';
|
|
4
|
+
export * from './tooltip';
|
|
4
5
|
//# sourceMappingURL=index.d.ts.map
|
package/pie/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/chart/pie/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,YAAY,EACV,aAAa,EACb,YAAY,EACZ,mBAAmB,EACnB,WAAW,EACX,WAAW,GACZ,MAAM,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/chart/pie/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,YAAY,EACV,aAAa,EACb,YAAY,EACZ,mBAAmB,EACnB,WAAW,EACX,WAAW,GACZ,MAAM,mBAAmB,CAAC;AAC3B,cAAc,WAAW,CAAC"}
|
package/pie/index.js
CHANGED
package/pie/pie-chart.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pie-chart.d.ts","sourceRoot":"","sources":["../../../../components/chart/pie/pie-chart.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pie-chart.d.ts","sourceRoot":"","sources":["../../../../components/chart/pie/pie-chart.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,aAAa,EAId,MAAM,mBAAmB,CAAC;AAW3B,OAAO,KAAqC,MAAM,OAAO,CAAC;AAI1D,YAAY,EACV,aAAa,EACb,mBAAmB,EACnB,WAAW,EACX,WAAW,EACX,YAAY,GACb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AA2RxD,eAAO,MAAM,QAAQ;;;;;;;CAEnB,CAAC"}
|
package/pie/pie-chart.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { withResponsiveContainer } from '../chart-container';
|
|
2
2
|
import { useChartTheme, withChartTheme } from '../chart-theme.context';
|
|
3
|
+
import { axisTooltipShowContentFlag } from '../cartesian/tooltip';
|
|
3
4
|
import { isConcentricPieData } from './pie-chart.props';
|
|
5
|
+
import { createPieTooltipPreset, usePieItemTooltip } from './tooltip';
|
|
4
6
|
import { SkiaChart, SkiaRenderer } from '@wuba/react-native-echarts';
|
|
5
7
|
import { PieChart as EChartsPieChart } from 'echarts/charts';
|
|
6
8
|
import { LegendComponent, TooltipComponent, } from 'echarts/components';
|
|
7
9
|
import * as echarts from 'echarts/core';
|
|
8
10
|
import React, { useEffect, useMemo, useRef } from 'react';
|
|
11
|
+
import { View } from 'react-native';
|
|
9
12
|
export { isConcentricPieData } from './pie-chart.props';
|
|
10
13
|
echarts.use([
|
|
11
14
|
TooltipComponent,
|
|
@@ -13,11 +16,44 @@ echarts.use([
|
|
|
13
16
|
SkiaRenderer,
|
|
14
17
|
EChartsPieChart,
|
|
15
18
|
]);
|
|
16
|
-
const ChartComponent = ({ data, width = 220, height = 350, radius = '75%', showLegend = false, showLabel = true, labelPosition = 'outside', showLabelLine = true, showHighlighter = true,
|
|
19
|
+
const ChartComponent = ({ data, width = 220, height = 350, radius = '75%', showLegend = false, showLabel = true, labelPosition = 'outside', showLabelLine = true, showHighlighter = true, tooltip = 'card', renderTooltip, onSelect, ...props }) => {
|
|
17
20
|
const { theme } = useChartTheme(props.theme, props.colors);
|
|
18
21
|
const chartRef = useRef(null);
|
|
19
22
|
const onSelectRef = useRef(onSelect);
|
|
20
23
|
onSelectRef.current = onSelect;
|
|
24
|
+
const pieContextRef = useRef({ normalizedSeries: [] });
|
|
25
|
+
const themeSeriesRef = useRef(theme.series);
|
|
26
|
+
themeSeriesRef.current = theme.series;
|
|
27
|
+
const tooltipOverlayActive = renderTooltip != null || tooltip !== 'none';
|
|
28
|
+
const renderTooltipFn = useMemo(() => {
|
|
29
|
+
if (renderTooltip != null)
|
|
30
|
+
return renderTooltip;
|
|
31
|
+
if (tooltip === 'none')
|
|
32
|
+
return () => null;
|
|
33
|
+
return createPieTooltipPreset(tooltip);
|
|
34
|
+
}, [renderTooltip, tooltip]);
|
|
35
|
+
const { attachPieItemTooltipListeners, renderPieTooltipOverlay } = usePieItemTooltip({
|
|
36
|
+
active: tooltipOverlayActive,
|
|
37
|
+
renderTooltip: renderTooltipFn,
|
|
38
|
+
contextRef: pieContextRef,
|
|
39
|
+
themeSeriesRef,
|
|
40
|
+
width,
|
|
41
|
+
height,
|
|
42
|
+
});
|
|
43
|
+
const normalizedSeries = useMemo(() => {
|
|
44
|
+
if (!Array.isArray(data) || data.length === 0)
|
|
45
|
+
return [];
|
|
46
|
+
if (isConcentricPieData(data)) {
|
|
47
|
+
const rings = data;
|
|
48
|
+
return rings.map((ring) => ({
|
|
49
|
+
name: ring.name,
|
|
50
|
+
data: ring.data.map((d) => ({ name: d.name, value: d.value })),
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
const flat = data;
|
|
54
|
+
return [{ data: flat.map((d) => ({ name: d.name, value: d.value })) }];
|
|
55
|
+
}, [data]);
|
|
56
|
+
pieContextRef.current = { normalizedSeries };
|
|
21
57
|
const option = useMemo(() => {
|
|
22
58
|
if (!Array.isArray(data) || data.length === 0) {
|
|
23
59
|
return { series: [] };
|
|
@@ -52,6 +88,7 @@ const ChartComponent = ({ data, width = 220, height = 350, radius = '75%', showL
|
|
|
52
88
|
},
|
|
53
89
|
emphasis: showHighlighter
|
|
54
90
|
? {
|
|
91
|
+
focus: 'none',
|
|
55
92
|
scale: true,
|
|
56
93
|
scaleSize: 5,
|
|
57
94
|
itemStyle: {
|
|
@@ -79,22 +116,12 @@ const ChartComponent = ({ data, width = 220, height = 350, radius = '75%', showL
|
|
|
79
116
|
const legendData = showLegend
|
|
80
117
|
? Array.from(new Set(rings.flatMap((r) => r.data.map((d) => d.name))))
|
|
81
118
|
: undefined;
|
|
82
|
-
const tooltipConfig =
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
padding: theme.tooltip.padding,
|
|
89
|
-
textStyle: { color: theme.tooltip.valueColor },
|
|
90
|
-
formatter: tooltipFormatter
|
|
91
|
-
? (params) => tooltipFormatter({
|
|
92
|
-
name: params.name,
|
|
93
|
-
value: params.value,
|
|
94
|
-
percent: params.percent,
|
|
95
|
-
})
|
|
96
|
-
: undefined,
|
|
97
|
-
};
|
|
119
|
+
const tooltipConfig = tooltipOverlayActive
|
|
120
|
+
? {
|
|
121
|
+
trigger: 'item',
|
|
122
|
+
...axisTooltipShowContentFlag(true),
|
|
123
|
+
}
|
|
124
|
+
: { show: false };
|
|
98
125
|
const config = {
|
|
99
126
|
tooltip: tooltipConfig,
|
|
100
127
|
series: seriesConfigs,
|
|
@@ -120,22 +147,12 @@ const ChartComponent = ({ data, width = 220, height = 350, radius = '75%', showL
|
|
|
120
147
|
: { color: seriesColors[index % seriesColors.length] },
|
|
121
148
|
}));
|
|
122
149
|
const seriesConfig = buildSeriesConfig(pieData, radius);
|
|
123
|
-
const tooltipConfig =
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
padding: theme.tooltip.padding,
|
|
130
|
-
textStyle: { color: theme.tooltip.valueColor },
|
|
131
|
-
formatter: tooltipFormatter
|
|
132
|
-
? (params) => tooltipFormatter({
|
|
133
|
-
name: params.name,
|
|
134
|
-
value: params.value,
|
|
135
|
-
percent: params.percent,
|
|
136
|
-
})
|
|
137
|
-
: undefined,
|
|
138
|
-
};
|
|
150
|
+
const tooltipConfig = tooltipOverlayActive
|
|
151
|
+
? {
|
|
152
|
+
trigger: 'item',
|
|
153
|
+
...axisTooltipShowContentFlag(true),
|
|
154
|
+
}
|
|
155
|
+
: { show: false };
|
|
139
156
|
const legendConfig = showLegend
|
|
140
157
|
? {
|
|
141
158
|
orient: 'horizontal',
|
|
@@ -162,11 +179,12 @@ const ChartComponent = ({ data, width = 220, height = 350, radius = '75%', showL
|
|
|
162
179
|
labelPosition,
|
|
163
180
|
showLabelLine,
|
|
164
181
|
showHighlighter,
|
|
165
|
-
|
|
182
|
+
tooltipOverlayActive,
|
|
166
183
|
theme,
|
|
167
184
|
]);
|
|
168
185
|
useEffect(() => {
|
|
169
186
|
let chart;
|
|
187
|
+
let detachPieTooltip = () => { };
|
|
170
188
|
if (chartRef.current) {
|
|
171
189
|
try {
|
|
172
190
|
chart = echarts.init(chartRef.current, 'light', {
|
|
@@ -174,6 +192,7 @@ const ChartComponent = ({ data, width = 220, height = 350, radius = '75%', showL
|
|
|
174
192
|
height,
|
|
175
193
|
});
|
|
176
194
|
chart.setOption(option);
|
|
195
|
+
detachPieTooltip = attachPieItemTooltipListeners(chart);
|
|
177
196
|
const handlePieClick = (params) => {
|
|
178
197
|
const cb = onSelectRef.current;
|
|
179
198
|
if (typeof cb !== 'function')
|
|
@@ -204,6 +223,7 @@ const ChartComponent = ({ data, width = 220, height = 350, radius = '75%', showL
|
|
|
204
223
|
}
|
|
205
224
|
}
|
|
206
225
|
return () => {
|
|
226
|
+
detachPieTooltip();
|
|
207
227
|
if (chart) {
|
|
208
228
|
try {
|
|
209
229
|
chart.dispose();
|
|
@@ -213,8 +233,11 @@ const ChartComponent = ({ data, width = 220, height = 350, radius = '75%', showL
|
|
|
213
233
|
}
|
|
214
234
|
}
|
|
215
235
|
};
|
|
216
|
-
}, [option, width, height]);
|
|
217
|
-
return <
|
|
236
|
+
}, [option, width, height, attachPieItemTooltipListeners]);
|
|
237
|
+
return (<View style={{ width, height, position: 'relative' }}>
|
|
238
|
+
<SkiaChart ref={chartRef} useRNGH/>
|
|
239
|
+
{renderPieTooltipOverlay()}
|
|
240
|
+
</View>);
|
|
218
241
|
};
|
|
219
242
|
const PieChartComponent = withResponsiveContainer(withChartTheme(ChartComponent), 'data');
|
|
220
243
|
export const PieChart = Object.assign(PieChartComponent, {
|
package/pie/pie-chart.props.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import type { CommonChartProps } from '../props/common';
|
|
2
|
+
import type { ChartTooltipOption } from '../tooltip';
|
|
3
|
+
import type { PieItemTooltipParams } from './tooltip/pie-item-tooltip.types';
|
|
4
|
+
import type { ReactNode } from 'react';
|
|
2
5
|
/** Emitted when the user taps/clicks a pie slice. */
|
|
3
6
|
export interface PieChartSelectEvent {
|
|
4
7
|
seriesIndex: number;
|
|
@@ -82,13 +85,16 @@ export interface PieChartProps extends CommonChartProps {
|
|
|
82
85
|
*/
|
|
83
86
|
showHighlighter?: boolean;
|
|
84
87
|
/**
|
|
85
|
-
*
|
|
88
|
+
* Built-in item tooltip preset when `renderTooltip` is omitted. Use `none` to hide the overlay.
|
|
89
|
+
* When `renderTooltip` is set, it replaces the preset body. Overlay hidden only when `tooltip` is `none` and `renderTooltip` is omitted.
|
|
90
|
+
* @default 'card'
|
|
86
91
|
*/
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
+
tooltip?: ChartTooltipOption;
|
|
93
|
+
/**
|
|
94
|
+
* Overrides the default React Native **item** tooltip body for pie slices (see {@link PieItemTooltipParams}).
|
|
95
|
+
* Takes precedence over {@link tooltip}.
|
|
96
|
+
*/
|
|
97
|
+
renderTooltip?: (params: PieItemTooltipParams) => ReactNode;
|
|
92
98
|
/**
|
|
93
99
|
* Called when the user selects (taps/clicks) a slice.
|
|
94
100
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pie-chart.props.d.ts","sourceRoot":"","sources":["../../../../components/chart/pie/pie-chart.props.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"pie-chart.props.d.ts","sourceRoot":"","sources":["../../../../components/chart/pie/pie-chart.props.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAC7E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,qDAAqD;AACrD,MAAM,WAAW,mBAAmB;IAClC,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,0DAA0D;IAC1D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,iCAAiC;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,4CAA4C;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd,uCAAuC;IACvC,SAAS,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAChC;AAED;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,oDAAoD;IACpD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,sFAAsF;IACtF,MAAM,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;IAC5B,gCAAgC;IAChC,IAAI,EAAE,WAAW,EAAE,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,WAAW,EAAE,GAAG,WAAW,EAAE,CAAC;AAEzD;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,YAAY,GACjB,IAAI,IAAI,WAAW,EAAE,CASvB;AAED;;;GAGG;AACH,MAAM,WAAW,aAAc,SAAQ,gBAAgB;IACrD;;OAEG;IACH,IAAI,EAAE,YAAY,CAAC;IACnB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;IAC/C;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,aAAa,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAC;IAChD;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;OAIG;IACH,OAAO,CAAC,EAAE,kBAAkB,CAAC;IAC7B;;;OAGG;IACH,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,oBAAoB,KAAK,SAAS,CAAC;IAC5D;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI,CAAC;CACjD"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ChartTheme } from '../../chart-theme.context';
|
|
3
|
+
import type { PieItemTooltipParams } from './pie-item-tooltip.types';
|
|
4
|
+
export declare function createDefaultPieTooltip(theme: Pick<ChartTheme, 'tooltip'>): (params: PieItemTooltipParams) => React.ReactElement;
|
|
5
|
+
//# sourceMappingURL=default-pie-tooltip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-pie-tooltip.d.ts","sourceRoot":"","sources":["../../../../../components/chart/pie/tooltip/default-pie-tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAErE,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,IAAI,CAAC,UAAU,EAAE,SAAS,CAAC,GACjC,CAAC,MAAM,EAAE,oBAAoB,KAAK,KAAK,CAAC,YAAY,CAoCtD"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StyleSheet, Text, View } from 'react-native';
|
|
3
|
+
export function createDefaultPieTooltip(theme) {
|
|
4
|
+
const t = theme.tooltip;
|
|
5
|
+
return function DefaultPieTooltip(params) {
|
|
6
|
+
const { name, value, percent, color, ringName } = params;
|
|
7
|
+
return (<View style={{
|
|
8
|
+
backgroundColor: t.backgroundColor,
|
|
9
|
+
borderColor: t.borderColor,
|
|
10
|
+
borderWidth: t.borderWidth,
|
|
11
|
+
borderRadius: t.borderRadius,
|
|
12
|
+
padding: t.padding,
|
|
13
|
+
}}>
|
|
14
|
+
{ringName != null && ringName !== '' ? (<Text style={[styles.ring, { color: t.labelColor }]}>{ringName}</Text>) : null}
|
|
15
|
+
<View style={{ flexDirection: 'row', alignItems: 'center', marginBottom: 4 }}>
|
|
16
|
+
{color != null && color !== '' ? (<View style={[styles.swatch, { backgroundColor: color }]}/>) : (<View style={styles.swatchPlaceholder}/>)}
|
|
17
|
+
<Text style={[styles.title, { color: t.labelColor }]}>{name}</Text>
|
|
18
|
+
</View>
|
|
19
|
+
<Text style={[styles.line, { color: t.valueColor }]}>
|
|
20
|
+
<Text style={{ color: t.labelColor }}>value: </Text>
|
|
21
|
+
{String(value)}
|
|
22
|
+
</Text>
|
|
23
|
+
<Text style={[styles.line, { color: t.valueColor }]}>
|
|
24
|
+
<Text style={{ color: t.labelColor }}>share: </Text>
|
|
25
|
+
{percent.toFixed(1)}%
|
|
26
|
+
</Text>
|
|
27
|
+
</View>);
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
const styles = StyleSheet.create({
|
|
31
|
+
ring: {
|
|
32
|
+
fontSize: 11,
|
|
33
|
+
fontWeight: '600',
|
|
34
|
+
marginBottom: 4,
|
|
35
|
+
textTransform: 'uppercase',
|
|
36
|
+
},
|
|
37
|
+
title: {
|
|
38
|
+
fontWeight: '600',
|
|
39
|
+
fontSize: 13,
|
|
40
|
+
flex: 1,
|
|
41
|
+
},
|
|
42
|
+
line: {
|
|
43
|
+
fontSize: 12,
|
|
44
|
+
marginTop: 2,
|
|
45
|
+
},
|
|
46
|
+
swatch: {
|
|
47
|
+
width: 8,
|
|
48
|
+
height: 8,
|
|
49
|
+
borderRadius: 4,
|
|
50
|
+
marginRight: 6,
|
|
51
|
+
},
|
|
52
|
+
swatchPlaceholder: {
|
|
53
|
+
width: 8,
|
|
54
|
+
height: 8,
|
|
55
|
+
marginRight: 6,
|
|
56
|
+
},
|
|
57
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { createDefaultPieTooltip } from './default-pie-tooltip';
|
|
2
|
+
export { createPieTooltipPreset } from './pie-item-tooltip-presets';
|
|
3
|
+
export type { PieItemTooltipContext, PieItemTooltipParams } from './pie-item-tooltip.types';
|
|
4
|
+
export { pieItemParamsFromShowTip } from './pie-item-tooltip.utils';
|
|
5
|
+
export { usePieItemTooltip } from './use-pie-item-tooltip';
|
|
6
|
+
export type { UsePieItemTooltipOptions, UsePieItemTooltipResult } from './use-pie-item-tooltip';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../components/chart/pie/tooltip/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,YAAY,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAC5F,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,YAAY,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ChartTooltipPreset } from '../../tooltip';
|
|
3
|
+
import type { PieItemTooltipParams } from './pie-item-tooltip.types';
|
|
4
|
+
export declare function createPieTooltipPreset(preset: ChartTooltipPreset): (params: PieItemTooltipParams) => React.ReactElement;
|
|
5
|
+
//# sourceMappingURL=pie-item-tooltip-presets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pie-item-tooltip-presets.d.ts","sourceRoot":"","sources":["../../../../../components/chart/pie/tooltip/pie-item-tooltip-presets.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAOxD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AA+CrE,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,kBAAkB,GACzB,CAAC,MAAM,EAAE,oBAAoB,KAAK,KAAK,CAAC,YAAY,CAYtD"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Text } from 'react-native';
|
|
3
|
+
import { TooltipPresetCard, TooltipPresetCompact, TooltipPresetKpi, TooltipPresetStriped, } from '../../tooltip/chart-tooltip-preset-shells';
|
|
4
|
+
function pieCardFromParams(p) {
|
|
5
|
+
const { name, value, percent, color, ringName } = p;
|
|
6
|
+
return (<TooltipPresetCard eyebrow={ringName != null && ringName !== '' ? ringName : undefined} header={{ swatchColor: color, title: name, marginBottom: 6 }}>
|
|
7
|
+
<Text style={{ fontSize: 14, fontWeight: '700', color: '#0f172a' }}>
|
|
8
|
+
{value} <Text style={{ fontWeight: '500', color: '#64748b' }}>({percent.toFixed(1)}%)</Text>
|
|
9
|
+
</Text>
|
|
10
|
+
</TooltipPresetCard>);
|
|
11
|
+
}
|
|
12
|
+
function pieCompactFromParams(p) {
|
|
13
|
+
const { name, value, percent } = p;
|
|
14
|
+
return <TooltipPresetCompact emphasis={name} detail={`${value} (${percent.toFixed(1)}%)`} wrap/>;
|
|
15
|
+
}
|
|
16
|
+
function pieKpiFromParams(p) {
|
|
17
|
+
const { name, value, percent, color } = p;
|
|
18
|
+
return (<TooltipPresetKpi accentColor={color ?? '#3b82f6'} minWidth={140} overline={name} metric={String(value)} caption={`${percent.toFixed(1)}% of total`}/>);
|
|
19
|
+
}
|
|
20
|
+
function pieStripedFromParams(p) {
|
|
21
|
+
const { name, value, percent, color } = p;
|
|
22
|
+
return (<TooltipPresetStriped headerSwatch={{ color: color ?? '#64748b', title: name }} rows={[
|
|
23
|
+
{ key: 'value', leftLabel: 'value', right: String(value) },
|
|
24
|
+
{ key: 'share', leftLabel: 'share', right: `${percent.toFixed(1)}%` },
|
|
25
|
+
]}/>);
|
|
26
|
+
}
|
|
27
|
+
export function createPieTooltipPreset(preset) {
|
|
28
|
+
switch (preset) {
|
|
29
|
+
case 'card':
|
|
30
|
+
return (p) => pieCardFromParams(p);
|
|
31
|
+
case 'compact':
|
|
32
|
+
return (p) => pieCompactFromParams(p);
|
|
33
|
+
case 'kpi':
|
|
34
|
+
return (p) => pieKpiFromParams(p);
|
|
35
|
+
case 'striped':
|
|
36
|
+
return (p) => pieStripedFromParams(p);
|
|
37
|
+
}
|
|
38
|
+
throw new Error(`Unknown tooltip preset: ${String(preset)}`);
|
|
39
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Item tooltip payload for pie / donut (ECharts `trigger: 'item'`, `showTip` without `dataByCoordSys`).
|
|
3
|
+
*/
|
|
4
|
+
export interface PieItemTooltipParams {
|
|
5
|
+
pointerX: number;
|
|
6
|
+
pointerY: number;
|
|
7
|
+
seriesIndex: number;
|
|
8
|
+
dataIndex: number;
|
|
9
|
+
/** Slice label */
|
|
10
|
+
name: string;
|
|
11
|
+
value: number;
|
|
12
|
+
/** Share of this pie ring (0–100). */
|
|
13
|
+
percent: number;
|
|
14
|
+
color?: string;
|
|
15
|
+
/** Ring / series display name when concentric or `name` is set on the series. */
|
|
16
|
+
ringName?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface PieItemTooltipContext {
|
|
19
|
+
/** One entry per pie series (single chart has one; concentric has one per ring). */
|
|
20
|
+
normalizedSeries: Array<{
|
|
21
|
+
name?: string;
|
|
22
|
+
data: Array<{
|
|
23
|
+
name: string;
|
|
24
|
+
value: number;
|
|
25
|
+
}>;
|
|
26
|
+
}>;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=pie-item-tooltip.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pie-item-tooltip.types.d.ts","sourceRoot":"","sources":["../../../../../components/chart/pie/tooltip/pie-item-tooltip.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,kBAAkB;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,sCAAsC;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iFAAiF;IACjF,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,qBAAqB;IACpC,oFAAoF;IACpF,gBAAgB,EAAE,KAAK,CAAC;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE,CAAC,CAAC;CAC1F"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { PieItemTooltipContext, PieItemTooltipParams } from './pie-item-tooltip.types';
|
|
2
|
+
/**
|
|
3
|
+
* Build pie item tooltip params from an ECharts `showTip` payload and chart instance.
|
|
4
|
+
* Ignores axis-style payloads (`dataByCoordSys`).
|
|
5
|
+
*/
|
|
6
|
+
export declare function pieItemParamsFromShowTip(chart: any, evt: any, ctx: PieItemTooltipContext, themeSeries: Array<{
|
|
7
|
+
color: string;
|
|
8
|
+
}>): PieItemTooltipParams | null;
|
|
9
|
+
//# sourceMappingURL=pie-item-tooltip.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pie-item-tooltip.utils.d.ts","sourceRoot":"","sources":["../../../../../components/chart/pie/tooltip/pie-item-tooltip.utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAyE5F;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,GAAG,EACV,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,qBAAqB,EAC1B,WAAW,EAAE,KAAK,CAAC;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,GACpC,oBAAoB,GAAG,IAAI,CA4D7B"}
|