@gravity-ui/charts 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +15 -0
- package/dist/cjs/components/Axis/AxisX.d.ts +20 -0
- package/dist/cjs/components/Axis/AxisX.js +108 -0
- package/dist/cjs/components/Axis/AxisY.d.ts +12 -0
- package/dist/cjs/components/Axis/AxisY.js +199 -0
- package/dist/cjs/components/Axis/index.d.ts +2 -0
- package/dist/cjs/components/Axis/index.js +2 -0
- package/dist/cjs/components/Axis/styles.css +17 -0
- package/dist/cjs/components/ChartInner/index.d.ts +10 -0
- package/dist/cjs/components/ChartInner/index.js +143 -0
- package/dist/cjs/components/ChartInner/styles.css +10 -0
- package/dist/cjs/components/Legend/index.d.ts +13 -0
- package/dist/cjs/components/Legend/index.js +278 -0
- package/dist/cjs/components/Legend/styles.css +47 -0
- package/dist/cjs/components/PlotTitle/index.d.ts +8 -0
- package/dist/cjs/components/PlotTitle/index.js +13 -0
- package/dist/cjs/components/PlotTitle/styles.css +5 -0
- package/dist/cjs/components/Title/index.d.ts +8 -0
- package/dist/cjs/components/Title/index.js +9 -0
- package/dist/cjs/components/Title/styles.css +5 -0
- package/dist/cjs/components/Tooltip/DefaultContent.d.ts +10 -0
- package/dist/cjs/components/Tooltip/DefaultContent.js +101 -0
- package/dist/cjs/components/Tooltip/index.d.ts +13 -0
- package/dist/cjs/components/Tooltip/index.js +29 -0
- package/dist/cjs/components/Tooltip/styles.css +29 -0
- package/dist/cjs/components/index.d.ts +18 -0
- package/dist/cjs/components/index.js +66 -0
- package/dist/cjs/constants/defaults/axis.d.ts +14 -0
- package/dist/cjs/constants/defaults/axis.js +18 -0
- package/dist/cjs/constants/defaults/index.d.ts +3 -0
- package/dist/cjs/constants/defaults/index.js +3 -0
- package/dist/cjs/constants/defaults/legend.d.ts +13 -0
- package/dist/cjs/constants/defaults/legend.js +12 -0
- package/dist/cjs/constants/defaults/series-options.d.ts +24 -0
- package/dist/cjs/constants/defaults/series-options.js +106 -0
- package/dist/cjs/constants/index.d.ts +46 -0
- package/dist/cjs/constants/index.js +71 -0
- package/dist/cjs/hooks/index.d.ts +10 -0
- package/dist/cjs/hooks/index.js +10 -0
- package/dist/cjs/hooks/useAxisScales/index.d.ts +25 -0
- package/dist/cjs/hooks/useAxisScales/index.js +183 -0
- package/dist/cjs/hooks/useChartDimensions/index.d.ts +16 -0
- package/dist/cjs/hooks/useChartDimensions/index.js +34 -0
- package/dist/cjs/hooks/useChartDimensions/utils.d.ts +10 -0
- package/dist/cjs/hooks/useChartDimensions/utils.js +32 -0
- package/dist/cjs/hooks/useChartOptions/chart.d.ts +6 -0
- package/dist/cjs/hooks/useChartOptions/chart.js +28 -0
- package/dist/cjs/hooks/useChartOptions/index.d.ts +7 -0
- package/dist/cjs/hooks/useChartOptions/index.js +21 -0
- package/dist/cjs/hooks/useChartOptions/title.d.ts +5 -0
- package/dist/cjs/hooks/useChartOptions/title.js +18 -0
- package/dist/cjs/hooks/useChartOptions/tooltip.d.ts +5 -0
- package/dist/cjs/hooks/useChartOptions/tooltip.js +5 -0
- package/dist/cjs/hooks/useChartOptions/types.d.ts +47 -0
- package/dist/cjs/hooks/useChartOptions/types.js +1 -0
- package/dist/cjs/hooks/useChartOptions/x-axis.d.ts +7 -0
- package/dist/cjs/hooks/useChartOptions/x-axis.js +115 -0
- package/dist/cjs/hooks/useChartOptions/y-axis.d.ts +7 -0
- package/dist/cjs/hooks/useChartOptions/y-axis.js +117 -0
- package/dist/cjs/hooks/useSeries/constants.d.ts +8 -0
- package/dist/cjs/hooks/useSeries/constants.js +19 -0
- package/dist/cjs/hooks/useSeries/index.d.ts +29 -0
- package/dist/cjs/hooks/useSeries/index.js +82 -0
- package/dist/cjs/hooks/useSeries/prepare-area.d.ts +19 -0
- package/dist/cjs/hooks/useSeries/prepare-area.js +63 -0
- package/dist/cjs/hooks/useSeries/prepare-bar-x.d.ts +10 -0
- package/dist/cjs/hooks/useSeries/prepare-bar-x.js +38 -0
- package/dist/cjs/hooks/useSeries/prepare-bar-y.d.ts +10 -0
- package/dist/cjs/hooks/useSeries/prepare-bar-y.js +48 -0
- package/dist/cjs/hooks/useSeries/prepare-legend.d.ts +27 -0
- package/dist/cjs/hooks/useSeries/prepare-legend.js +144 -0
- package/dist/cjs/hooks/useSeries/prepare-line.d.ts +22 -0
- package/dist/cjs/hooks/useSeries/prepare-line.js +82 -0
- package/dist/cjs/hooks/useSeries/prepare-options.d.ts +3 -0
- package/dist/cjs/hooks/useSeries/prepare-options.js +5 -0
- package/dist/cjs/hooks/useSeries/prepare-pie.d.ts +9 -0
- package/dist/cjs/hooks/useSeries/prepare-pie.js +62 -0
- package/dist/cjs/hooks/useSeries/prepare-scatter.d.ts +11 -0
- package/dist/cjs/hooks/useSeries/prepare-scatter.js +46 -0
- package/dist/cjs/hooks/useSeries/prepare-treemap.d.ts +11 -0
- package/dist/cjs/hooks/useSeries/prepare-treemap.js +38 -0
- package/dist/cjs/hooks/useSeries/prepare-waterfall.d.ts +10 -0
- package/dist/cjs/hooks/useSeries/prepare-waterfall.js +37 -0
- package/dist/cjs/hooks/useSeries/prepareSeries.d.ts +10 -0
- package/dist/cjs/hooks/useSeries/prepareSeries.js +65 -0
- package/dist/cjs/hooks/useSeries/types.d.ts +253 -0
- package/dist/cjs/hooks/useSeries/types.js +1 -0
- package/dist/cjs/hooks/useSeries/utils.d.ts +7 -0
- package/dist/cjs/hooks/useSeries/utils.js +33 -0
- package/dist/cjs/hooks/useShapes/HtmlLayer.d.ts +8 -0
- package/dist/cjs/hooks/useShapes/HtmlLayer.js +22 -0
- package/dist/cjs/hooks/useShapes/area/index.d.ts +12 -0
- package/dist/cjs/hooks/useShapes/area/index.js +143 -0
- package/dist/cjs/hooks/useShapes/area/prepare-data.d.ts +12 -0
- package/dist/cjs/hooks/useShapes/area/prepare-data.js +158 -0
- package/dist/cjs/hooks/useShapes/area/types.d.ts +27 -0
- package/dist/cjs/hooks/useShapes/area/types.js +1 -0
- package/dist/cjs/hooks/useShapes/bar-x/index.d.ts +13 -0
- package/dist/cjs/hooks/useShapes/bar-x/index.js +95 -0
- package/dist/cjs/hooks/useShapes/bar-x/prepare-data.d.ts +13 -0
- package/dist/cjs/hooks/useShapes/bar-x/prepare-data.js +160 -0
- package/dist/cjs/hooks/useShapes/bar-x/types.d.ts +12 -0
- package/dist/cjs/hooks/useShapes/bar-x/types.js +1 -0
- package/dist/cjs/hooks/useShapes/bar-y/index.d.ts +12 -0
- package/dist/cjs/hooks/useShapes/bar-y/index.js +84 -0
- package/dist/cjs/hooks/useShapes/bar-y/prepare-data.d.ts +12 -0
- package/dist/cjs/hooks/useShapes/bar-y/prepare-data.js +169 -0
- package/dist/cjs/hooks/useShapes/bar-y/types.d.ts +13 -0
- package/dist/cjs/hooks/useShapes/bar-y/types.js +1 -0
- package/dist/cjs/hooks/useShapes/constants.d.ts +3 -0
- package/dist/cjs/hooks/useShapes/constants.js +3 -0
- package/dist/cjs/hooks/useShapes/index.d.ts +33 -0
- package/dist/cjs/hooks/useShapes/index.js +154 -0
- package/dist/cjs/hooks/useShapes/line/index.d.ts +12 -0
- package/dist/cjs/hooks/useShapes/line/index.js +130 -0
- package/dist/cjs/hooks/useShapes/line/prepare-data.d.ts +13 -0
- package/dist/cjs/hooks/useShapes/line/prepare-data.js +91 -0
- package/dist/cjs/hooks/useShapes/line/types.d.ts +29 -0
- package/dist/cjs/hooks/useShapes/line/types.js +1 -0
- package/dist/cjs/hooks/useShapes/marker.d.ts +14 -0
- package/dist/cjs/hooks/useShapes/marker.js +75 -0
- package/dist/cjs/hooks/useShapes/pie/index.d.ts +13 -0
- package/dist/cjs/hooks/useShapes/pie/index.js +171 -0
- package/dist/cjs/hooks/useShapes/pie/prepare-data.d.ts +9 -0
- package/dist/cjs/hooks/useShapes/pie/prepare-data.js +186 -0
- package/dist/cjs/hooks/useShapes/pie/types.d.ts +41 -0
- package/dist/cjs/hooks/useShapes/pie/types.js +1 -0
- package/dist/cjs/hooks/useShapes/pie/utils.d.ts +4 -0
- package/dist/cjs/hooks/useShapes/pie/utils.js +15 -0
- package/dist/cjs/hooks/useShapes/scatter/index.d.ts +12 -0
- package/dist/cjs/hooks/useShapes/scatter/index.js +69 -0
- package/dist/cjs/hooks/useShapes/scatter/prepare-data.d.ts +11 -0
- package/dist/cjs/hooks/useShapes/scatter/prepare-data.js +31 -0
- package/dist/cjs/hooks/useShapes/scatter/types.d.ts +17 -0
- package/dist/cjs/hooks/useShapes/scatter/types.js +1 -0
- package/dist/cjs/hooks/useShapes/styles.css +35 -0
- package/dist/cjs/hooks/useShapes/treemap/index.d.ts +12 -0
- package/dist/cjs/hooks/useShapes/treemap/index.js +98 -0
- package/dist/cjs/hooks/useShapes/treemap/prepare-data.d.ts +7 -0
- package/dist/cjs/hooks/useShapes/treemap/prepare-data.js +114 -0
- package/dist/cjs/hooks/useShapes/treemap/types.d.ts +16 -0
- package/dist/cjs/hooks/useShapes/treemap/types.js +1 -0
- package/dist/cjs/hooks/useShapes/utils.d.ts +29 -0
- package/dist/cjs/hooks/useShapes/utils.js +53 -0
- package/dist/cjs/hooks/useShapes/waterfall/index.d.ts +13 -0
- package/dist/cjs/hooks/useShapes/waterfall/index.js +127 -0
- package/dist/cjs/hooks/useShapes/waterfall/prepare-data.d.ts +12 -0
- package/dist/cjs/hooks/useShapes/waterfall/prepare-data.js +133 -0
- package/dist/cjs/hooks/useShapes/waterfall/types.d.ts +14 -0
- package/dist/cjs/hooks/useShapes/waterfall/types.js +1 -0
- package/dist/cjs/hooks/useSplit/index.d.ts +14 -0
- package/dist/cjs/hooks/useSplit/index.js +57 -0
- package/dist/cjs/hooks/useSplit/types.d.ts +17 -0
- package/dist/cjs/hooks/useSplit/types.js +1 -0
- package/dist/cjs/hooks/useTooltip/index.d.ts +13 -0
- package/dist/cjs/hooks/useTooltip/index.js +17 -0
- package/dist/cjs/hooks/useTooltip/types.d.ts +1 -0
- package/dist/cjs/hooks/useTooltip/types.js +1 -0
- package/dist/cjs/i18n/index.d.ts +8 -0
- package/dist/cjs/i18n/index.js +10 -0
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/libs/chart-error/index.d.ts +16 -0
- package/dist/cjs/libs/chart-error/index.js +19 -0
- package/dist/cjs/libs/format-number/i18n/en.json +17 -0
- package/dist/cjs/libs/format-number/i18n/i18n.d.ts +5 -0
- package/dist/cjs/libs/format-number/i18n/i18n.js +8 -0
- package/dist/cjs/libs/format-number/i18n/ru.json +17 -0
- package/dist/cjs/libs/format-number/index.d.ts +5 -0
- package/dist/cjs/libs/format-number/index.js +87 -0
- package/dist/cjs/libs/format-number/types.d.ts +14 -0
- package/dist/cjs/libs/format-number/types.js +1 -0
- package/dist/cjs/libs/index.d.ts +2 -0
- package/dist/cjs/libs/index.js +2 -0
- package/dist/cjs/types/chart/area.d.ts +76 -0
- package/dist/cjs/types/chart/area.js +1 -0
- package/dist/cjs/types/chart/axis.d.ts +85 -0
- package/dist/cjs/types/chart/axis.js +1 -0
- package/dist/cjs/types/chart/bar-x.d.ts +67 -0
- package/dist/cjs/types/chart/bar-x.js +1 -0
- package/dist/cjs/types/chart/bar-y.d.ts +60 -0
- package/dist/cjs/types/chart/bar-y.js +1 -0
- package/dist/cjs/types/chart/base.d.ts +48 -0
- package/dist/cjs/types/chart/base.js +1 -0
- package/dist/cjs/types/chart/chart.d.ts +15 -0
- package/dist/cjs/types/chart/chart.js +1 -0
- package/dist/cjs/types/chart/halo.d.ts +9 -0
- package/dist/cjs/types/chart/halo.js +1 -0
- package/dist/cjs/types/chart/legend.d.ts +92 -0
- package/dist/cjs/types/chart/legend.js +1 -0
- package/dist/cjs/types/chart/line.d.ts +57 -0
- package/dist/cjs/types/chart/line.js +1 -0
- package/dist/cjs/types/chart/marker.d.ts +12 -0
- package/dist/cjs/types/chart/marker.js +1 -0
- package/dist/cjs/types/chart/pie.d.ts +88 -0
- package/dist/cjs/types/chart/pie.js +1 -0
- package/dist/cjs/types/chart/scatter.d.ts +46 -0
- package/dist/cjs/types/chart/scatter.js +1 -0
- package/dist/cjs/types/chart/series.d.ts +226 -0
- package/dist/cjs/types/chart/series.js +1 -0
- package/dist/cjs/types/chart/split.d.ts +13 -0
- package/dist/cjs/types/chart/split.js +1 -0
- package/dist/cjs/types/chart/title.d.ts +5 -0
- package/dist/cjs/types/chart/title.js +1 -0
- package/dist/cjs/types/chart/tooltip.d.ts +67 -0
- package/dist/cjs/types/chart/tooltip.js +1 -0
- package/dist/cjs/types/chart/treemap.d.ts +46 -0
- package/dist/cjs/types/chart/treemap.js +1 -0
- package/dist/cjs/types/chart/waterfall.d.ts +40 -0
- package/dist/cjs/types/chart/waterfall.js +1 -0
- package/dist/cjs/types/chart-ui.d.ts +24 -0
- package/dist/cjs/types/chart-ui.js +1 -0
- package/dist/cjs/types/formatter.d.ts +14 -0
- package/dist/cjs/types/formatter.js +1 -0
- package/dist/cjs/types/index.d.ts +42 -0
- package/dist/cjs/types/index.js +19 -0
- package/dist/cjs/types/misc.d.ts +4 -0
- package/dist/cjs/types/misc.js +1 -0
- package/dist/cjs/utils/chart/axis-generators/bottom.d.ts +24 -0
- package/dist/cjs/utils/chart/axis-generators/bottom.js +126 -0
- package/dist/cjs/utils/chart/axis-generators/index.d.ts +1 -0
- package/dist/cjs/utils/chart/axis-generators/index.js +1 -0
- package/dist/cjs/utils/chart/axis.d.ts +31 -0
- package/dist/cjs/utils/chart/axis.js +71 -0
- package/dist/cjs/utils/chart/color.d.ts +10 -0
- package/dist/cjs/utils/chart/color.js +43 -0
- package/dist/cjs/utils/chart/get-closest-data.d.ts +15 -0
- package/dist/cjs/utils/chart/get-closest-data.js +172 -0
- package/dist/cjs/utils/chart/index.d.ts +78 -0
- package/dist/cjs/utils/chart/index.js +210 -0
- package/dist/cjs/utils/chart/labels.d.ts +6 -0
- package/dist/cjs/utils/chart/labels.js +44 -0
- package/dist/cjs/utils/chart/legend.d.ts +8 -0
- package/dist/cjs/utils/chart/legend.js +23 -0
- package/dist/cjs/utils/chart/math.d.ts +25 -0
- package/dist/cjs/utils/chart/math.js +51 -0
- package/dist/cjs/utils/chart/series/index.d.ts +1 -0
- package/dist/cjs/utils/chart/series/index.js +1 -0
- package/dist/cjs/utils/chart/series/waterfall.d.ts +4 -0
- package/dist/cjs/utils/chart/series/waterfall.js +25 -0
- package/dist/cjs/utils/chart/symbol.d.ts +3 -0
- package/dist/cjs/utils/chart/symbol.js +36 -0
- package/dist/cjs/utils/chart/text.d.ts +29 -0
- package/dist/cjs/utils/chart/text.js +139 -0
- package/dist/cjs/utils/chart/time.d.ts +3 -0
- package/dist/cjs/utils/chart/time.js +34 -0
- package/dist/cjs/utils/chart-ui/index.d.ts +4 -0
- package/dist/cjs/utils/chart-ui/index.js +4 -0
- package/dist/cjs/utils/chart-ui/pie-center-text.d.ts +7 -0
- package/dist/cjs/utils/chart-ui/pie-center-text.js +23 -0
- package/dist/cjs/utils/cn.d.ts +3 -0
- package/dist/cjs/utils/cn.js +4 -0
- package/dist/cjs/utils/d3-dispatcher.d.ts +1 -0
- package/dist/cjs/utils/d3-dispatcher.js +4 -0
- package/dist/cjs/utils/index.d.ts +5 -0
- package/dist/cjs/utils/index.js +5 -0
- package/dist/cjs/utils/misc.d.ts +2 -0
- package/dist/cjs/utils/misc.js +8 -0
- package/dist/cjs/validation/index.d.ts +2 -0
- package/dist/cjs/validation/index.js +220 -0
- package/dist/esm/components/Axis/AxisX.d.ts +20 -0
- package/dist/esm/components/Axis/AxisX.js +108 -0
- package/dist/esm/components/Axis/AxisY.d.ts +12 -0
- package/dist/esm/components/Axis/AxisY.js +199 -0
- package/dist/esm/components/Axis/index.d.ts +2 -0
- package/dist/esm/components/Axis/index.js +2 -0
- package/dist/esm/components/Axis/styles.css +17 -0
- package/dist/esm/components/ChartInner/index.d.ts +10 -0
- package/dist/esm/components/ChartInner/index.js +143 -0
- package/dist/esm/components/ChartInner/styles.css +10 -0
- package/dist/esm/components/Legend/index.d.ts +13 -0
- package/dist/esm/components/Legend/index.js +278 -0
- package/dist/esm/components/Legend/styles.css +47 -0
- package/dist/esm/components/PlotTitle/index.d.ts +8 -0
- package/dist/esm/components/PlotTitle/index.js +13 -0
- package/dist/esm/components/PlotTitle/styles.css +5 -0
- package/dist/esm/components/Title/index.d.ts +8 -0
- package/dist/esm/components/Title/index.js +9 -0
- package/dist/esm/components/Title/styles.css +5 -0
- package/dist/esm/components/Tooltip/DefaultContent.d.ts +10 -0
- package/dist/esm/components/Tooltip/DefaultContent.js +101 -0
- package/dist/esm/components/Tooltip/index.d.ts +13 -0
- package/dist/esm/components/Tooltip/index.js +29 -0
- package/dist/esm/components/Tooltip/styles.css +29 -0
- package/dist/esm/components/index.d.ts +18 -0
- package/dist/esm/components/index.js +66 -0
- package/dist/esm/constants/defaults/axis.d.ts +14 -0
- package/dist/esm/constants/defaults/axis.js +18 -0
- package/dist/esm/constants/defaults/index.d.ts +3 -0
- package/dist/esm/constants/defaults/index.js +3 -0
- package/dist/esm/constants/defaults/legend.d.ts +13 -0
- package/dist/esm/constants/defaults/legend.js +12 -0
- package/dist/esm/constants/defaults/series-options.d.ts +24 -0
- package/dist/esm/constants/defaults/series-options.js +106 -0
- package/dist/esm/constants/index.d.ts +46 -0
- package/dist/esm/constants/index.js +71 -0
- package/dist/esm/hooks/index.d.ts +10 -0
- package/dist/esm/hooks/index.js +10 -0
- package/dist/esm/hooks/useAxisScales/index.d.ts +25 -0
- package/dist/esm/hooks/useAxisScales/index.js +183 -0
- package/dist/esm/hooks/useChartDimensions/index.d.ts +16 -0
- package/dist/esm/hooks/useChartDimensions/index.js +34 -0
- package/dist/esm/hooks/useChartDimensions/utils.d.ts +10 -0
- package/dist/esm/hooks/useChartDimensions/utils.js +32 -0
- package/dist/esm/hooks/useChartOptions/chart.d.ts +6 -0
- package/dist/esm/hooks/useChartOptions/chart.js +28 -0
- package/dist/esm/hooks/useChartOptions/index.d.ts +7 -0
- package/dist/esm/hooks/useChartOptions/index.js +21 -0
- package/dist/esm/hooks/useChartOptions/title.d.ts +5 -0
- package/dist/esm/hooks/useChartOptions/title.js +18 -0
- package/dist/esm/hooks/useChartOptions/tooltip.d.ts +5 -0
- package/dist/esm/hooks/useChartOptions/tooltip.js +5 -0
- package/dist/esm/hooks/useChartOptions/types.d.ts +47 -0
- package/dist/esm/hooks/useChartOptions/types.js +1 -0
- package/dist/esm/hooks/useChartOptions/x-axis.d.ts +7 -0
- package/dist/esm/hooks/useChartOptions/x-axis.js +115 -0
- package/dist/esm/hooks/useChartOptions/y-axis.d.ts +7 -0
- package/dist/esm/hooks/useChartOptions/y-axis.js +117 -0
- package/dist/esm/hooks/useSeries/constants.d.ts +8 -0
- package/dist/esm/hooks/useSeries/constants.js +19 -0
- package/dist/esm/hooks/useSeries/index.d.ts +29 -0
- package/dist/esm/hooks/useSeries/index.js +82 -0
- package/dist/esm/hooks/useSeries/prepare-area.d.ts +19 -0
- package/dist/esm/hooks/useSeries/prepare-area.js +63 -0
- package/dist/esm/hooks/useSeries/prepare-bar-x.d.ts +10 -0
- package/dist/esm/hooks/useSeries/prepare-bar-x.js +38 -0
- package/dist/esm/hooks/useSeries/prepare-bar-y.d.ts +10 -0
- package/dist/esm/hooks/useSeries/prepare-bar-y.js +48 -0
- package/dist/esm/hooks/useSeries/prepare-legend.d.ts +27 -0
- package/dist/esm/hooks/useSeries/prepare-legend.js +144 -0
- package/dist/esm/hooks/useSeries/prepare-line.d.ts +22 -0
- package/dist/esm/hooks/useSeries/prepare-line.js +82 -0
- package/dist/esm/hooks/useSeries/prepare-options.d.ts +3 -0
- package/dist/esm/hooks/useSeries/prepare-options.js +5 -0
- package/dist/esm/hooks/useSeries/prepare-pie.d.ts +9 -0
- package/dist/esm/hooks/useSeries/prepare-pie.js +62 -0
- package/dist/esm/hooks/useSeries/prepare-scatter.d.ts +11 -0
- package/dist/esm/hooks/useSeries/prepare-scatter.js +46 -0
- package/dist/esm/hooks/useSeries/prepare-treemap.d.ts +11 -0
- package/dist/esm/hooks/useSeries/prepare-treemap.js +38 -0
- package/dist/esm/hooks/useSeries/prepare-waterfall.d.ts +10 -0
- package/dist/esm/hooks/useSeries/prepare-waterfall.js +37 -0
- package/dist/esm/hooks/useSeries/prepareSeries.d.ts +10 -0
- package/dist/esm/hooks/useSeries/prepareSeries.js +65 -0
- package/dist/esm/hooks/useSeries/types.d.ts +253 -0
- package/dist/esm/hooks/useSeries/types.js +1 -0
- package/dist/esm/hooks/useSeries/utils.d.ts +7 -0
- package/dist/esm/hooks/useSeries/utils.js +33 -0
- package/dist/esm/hooks/useShapes/HtmlLayer.d.ts +8 -0
- package/dist/esm/hooks/useShapes/HtmlLayer.js +22 -0
- package/dist/esm/hooks/useShapes/area/index.d.ts +12 -0
- package/dist/esm/hooks/useShapes/area/index.js +143 -0
- package/dist/esm/hooks/useShapes/area/prepare-data.d.ts +12 -0
- package/dist/esm/hooks/useShapes/area/prepare-data.js +158 -0
- package/dist/esm/hooks/useShapes/area/types.d.ts +27 -0
- package/dist/esm/hooks/useShapes/area/types.js +1 -0
- package/dist/esm/hooks/useShapes/bar-x/index.d.ts +13 -0
- package/dist/esm/hooks/useShapes/bar-x/index.js +95 -0
- package/dist/esm/hooks/useShapes/bar-x/prepare-data.d.ts +13 -0
- package/dist/esm/hooks/useShapes/bar-x/prepare-data.js +160 -0
- package/dist/esm/hooks/useShapes/bar-x/types.d.ts +12 -0
- package/dist/esm/hooks/useShapes/bar-x/types.js +1 -0
- package/dist/esm/hooks/useShapes/bar-y/index.d.ts +12 -0
- package/dist/esm/hooks/useShapes/bar-y/index.js +84 -0
- package/dist/esm/hooks/useShapes/bar-y/prepare-data.d.ts +12 -0
- package/dist/esm/hooks/useShapes/bar-y/prepare-data.js +169 -0
- package/dist/esm/hooks/useShapes/bar-y/types.d.ts +13 -0
- package/dist/esm/hooks/useShapes/bar-y/types.js +1 -0
- package/dist/esm/hooks/useShapes/constants.d.ts +3 -0
- package/dist/esm/hooks/useShapes/constants.js +3 -0
- package/dist/esm/hooks/useShapes/index.d.ts +33 -0
- package/dist/esm/hooks/useShapes/index.js +154 -0
- package/dist/esm/hooks/useShapes/line/index.d.ts +12 -0
- package/dist/esm/hooks/useShapes/line/index.js +130 -0
- package/dist/esm/hooks/useShapes/line/prepare-data.d.ts +13 -0
- package/dist/esm/hooks/useShapes/line/prepare-data.js +91 -0
- package/dist/esm/hooks/useShapes/line/types.d.ts +29 -0
- package/dist/esm/hooks/useShapes/line/types.js +1 -0
- package/dist/esm/hooks/useShapes/marker.d.ts +14 -0
- package/dist/esm/hooks/useShapes/marker.js +75 -0
- package/dist/esm/hooks/useShapes/pie/index.d.ts +13 -0
- package/dist/esm/hooks/useShapes/pie/index.js +171 -0
- package/dist/esm/hooks/useShapes/pie/prepare-data.d.ts +9 -0
- package/dist/esm/hooks/useShapes/pie/prepare-data.js +186 -0
- package/dist/esm/hooks/useShapes/pie/types.d.ts +41 -0
- package/dist/esm/hooks/useShapes/pie/types.js +1 -0
- package/dist/esm/hooks/useShapes/pie/utils.d.ts +4 -0
- package/dist/esm/hooks/useShapes/pie/utils.js +15 -0
- package/dist/esm/hooks/useShapes/scatter/index.d.ts +12 -0
- package/dist/esm/hooks/useShapes/scatter/index.js +69 -0
- package/dist/esm/hooks/useShapes/scatter/prepare-data.d.ts +11 -0
- package/dist/esm/hooks/useShapes/scatter/prepare-data.js +31 -0
- package/dist/esm/hooks/useShapes/scatter/types.d.ts +17 -0
- package/dist/esm/hooks/useShapes/scatter/types.js +1 -0
- package/dist/esm/hooks/useShapes/styles.css +35 -0
- package/dist/esm/hooks/useShapes/treemap/index.d.ts +12 -0
- package/dist/esm/hooks/useShapes/treemap/index.js +98 -0
- package/dist/esm/hooks/useShapes/treemap/prepare-data.d.ts +7 -0
- package/dist/esm/hooks/useShapes/treemap/prepare-data.js +114 -0
- package/dist/esm/hooks/useShapes/treemap/types.d.ts +16 -0
- package/dist/esm/hooks/useShapes/treemap/types.js +1 -0
- package/dist/esm/hooks/useShapes/utils.d.ts +29 -0
- package/dist/esm/hooks/useShapes/utils.js +53 -0
- package/dist/esm/hooks/useShapes/waterfall/index.d.ts +13 -0
- package/dist/esm/hooks/useShapes/waterfall/index.js +127 -0
- package/dist/esm/hooks/useShapes/waterfall/prepare-data.d.ts +12 -0
- package/dist/esm/hooks/useShapes/waterfall/prepare-data.js +133 -0
- package/dist/esm/hooks/useShapes/waterfall/types.d.ts +14 -0
- package/dist/esm/hooks/useShapes/waterfall/types.js +1 -0
- package/dist/esm/hooks/useSplit/index.d.ts +14 -0
- package/dist/esm/hooks/useSplit/index.js +57 -0
- package/dist/esm/hooks/useSplit/types.d.ts +17 -0
- package/dist/esm/hooks/useSplit/types.js +1 -0
- package/dist/esm/hooks/useTooltip/index.d.ts +13 -0
- package/dist/esm/hooks/useTooltip/index.js +17 -0
- package/dist/esm/hooks/useTooltip/types.d.ts +1 -0
- package/dist/esm/hooks/useTooltip/types.js +1 -0
- package/dist/esm/i18n/index.d.ts +8 -0
- package/dist/esm/i18n/index.js +10 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/libs/chart-error/index.d.ts +16 -0
- package/dist/esm/libs/chart-error/index.js +19 -0
- package/dist/esm/libs/format-number/i18n/en.json +17 -0
- package/dist/esm/libs/format-number/i18n/i18n.d.ts +5 -0
- package/dist/esm/libs/format-number/i18n/i18n.js +8 -0
- package/dist/esm/libs/format-number/i18n/ru.json +17 -0
- package/dist/esm/libs/format-number/index.d.ts +5 -0
- package/dist/esm/libs/format-number/index.js +87 -0
- package/dist/esm/libs/format-number/types.d.ts +14 -0
- package/dist/esm/libs/format-number/types.js +1 -0
- package/dist/esm/libs/index.d.ts +2 -0
- package/dist/esm/libs/index.js +2 -0
- package/dist/esm/types/chart/area.d.ts +76 -0
- package/dist/esm/types/chart/area.js +1 -0
- package/dist/esm/types/chart/axis.d.ts +85 -0
- package/dist/esm/types/chart/axis.js +1 -0
- package/dist/esm/types/chart/bar-x.d.ts +67 -0
- package/dist/esm/types/chart/bar-x.js +1 -0
- package/dist/esm/types/chart/bar-y.d.ts +60 -0
- package/dist/esm/types/chart/bar-y.js +1 -0
- package/dist/esm/types/chart/base.d.ts +48 -0
- package/dist/esm/types/chart/base.js +1 -0
- package/dist/esm/types/chart/chart.d.ts +15 -0
- package/dist/esm/types/chart/chart.js +1 -0
- package/dist/esm/types/chart/halo.d.ts +9 -0
- package/dist/esm/types/chart/halo.js +1 -0
- package/dist/esm/types/chart/legend.d.ts +92 -0
- package/dist/esm/types/chart/legend.js +1 -0
- package/dist/esm/types/chart/line.d.ts +57 -0
- package/dist/esm/types/chart/line.js +1 -0
- package/dist/esm/types/chart/marker.d.ts +12 -0
- package/dist/esm/types/chart/marker.js +1 -0
- package/dist/esm/types/chart/pie.d.ts +88 -0
- package/dist/esm/types/chart/pie.js +1 -0
- package/dist/esm/types/chart/scatter.d.ts +46 -0
- package/dist/esm/types/chart/scatter.js +1 -0
- package/dist/esm/types/chart/series.d.ts +226 -0
- package/dist/esm/types/chart/series.js +1 -0
- package/dist/esm/types/chart/split.d.ts +13 -0
- package/dist/esm/types/chart/split.js +1 -0
- package/dist/esm/types/chart/title.d.ts +5 -0
- package/dist/esm/types/chart/title.js +1 -0
- package/dist/esm/types/chart/tooltip.d.ts +67 -0
- package/dist/esm/types/chart/tooltip.js +1 -0
- package/dist/esm/types/chart/treemap.d.ts +46 -0
- package/dist/esm/types/chart/treemap.js +1 -0
- package/dist/esm/types/chart/waterfall.d.ts +40 -0
- package/dist/esm/types/chart/waterfall.js +1 -0
- package/dist/esm/types/chart-ui.d.ts +24 -0
- package/dist/esm/types/chart-ui.js +1 -0
- package/dist/esm/types/formatter.d.ts +14 -0
- package/dist/esm/types/formatter.js +1 -0
- package/dist/esm/types/index.d.ts +42 -0
- package/dist/esm/types/index.js +19 -0
- package/dist/esm/types/misc.d.ts +4 -0
- package/dist/esm/types/misc.js +1 -0
- package/dist/esm/utils/chart/axis-generators/bottom.d.ts +24 -0
- package/dist/esm/utils/chart/axis-generators/bottom.js +126 -0
- package/dist/esm/utils/chart/axis-generators/index.d.ts +1 -0
- package/dist/esm/utils/chart/axis-generators/index.js +1 -0
- package/dist/esm/utils/chart/axis.d.ts +31 -0
- package/dist/esm/utils/chart/axis.js +71 -0
- package/dist/esm/utils/chart/color.d.ts +10 -0
- package/dist/esm/utils/chart/color.js +43 -0
- package/dist/esm/utils/chart/get-closest-data.d.ts +15 -0
- package/dist/esm/utils/chart/get-closest-data.js +172 -0
- package/dist/esm/utils/chart/index.d.ts +78 -0
- package/dist/esm/utils/chart/index.js +210 -0
- package/dist/esm/utils/chart/labels.d.ts +6 -0
- package/dist/esm/utils/chart/labels.js +44 -0
- package/dist/esm/utils/chart/legend.d.ts +8 -0
- package/dist/esm/utils/chart/legend.js +23 -0
- package/dist/esm/utils/chart/math.d.ts +25 -0
- package/dist/esm/utils/chart/math.js +51 -0
- package/dist/esm/utils/chart/series/index.d.ts +1 -0
- package/dist/esm/utils/chart/series/index.js +1 -0
- package/dist/esm/utils/chart/series/waterfall.d.ts +4 -0
- package/dist/esm/utils/chart/series/waterfall.js +25 -0
- package/dist/esm/utils/chart/symbol.d.ts +3 -0
- package/dist/esm/utils/chart/symbol.js +36 -0
- package/dist/esm/utils/chart/text.d.ts +29 -0
- package/dist/esm/utils/chart/text.js +139 -0
- package/dist/esm/utils/chart/time.d.ts +3 -0
- package/dist/esm/utils/chart/time.js +34 -0
- package/dist/esm/utils/chart-ui/index.d.ts +4 -0
- package/dist/esm/utils/chart-ui/index.js +4 -0
- package/dist/esm/utils/chart-ui/pie-center-text.d.ts +7 -0
- package/dist/esm/utils/chart-ui/pie-center-text.js +23 -0
- package/dist/esm/utils/cn.d.ts +3 -0
- package/dist/esm/utils/cn.js +4 -0
- package/dist/esm/utils/d3-dispatcher.d.ts +1 -0
- package/dist/esm/utils/d3-dispatcher.js +4 -0
- package/dist/esm/utils/index.d.ts +5 -0
- package/dist/esm/utils/index.js +5 -0
- package/dist/esm/utils/misc.d.ts +2 -0
- package/dist/esm/utils/misc.js +8 -0
- package/dist/esm/validation/index.d.ts +2 -0
- package/dist/esm/validation/index.js +220 -0
- package/package.json +140 -0
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { arc, color, select } from 'd3';
|
|
3
|
+
import get from 'lodash/get';
|
|
4
|
+
import { block, setEllipsisForOverflowTexts } from '../../../utils';
|
|
5
|
+
import { HtmlLayer } from '../HtmlLayer';
|
|
6
|
+
import { setActiveState } from '../utils';
|
|
7
|
+
const b = block('d3-pie');
|
|
8
|
+
export function getHaloVisibility(d) {
|
|
9
|
+
const enabled = d.data.pie.halo.enabled && d.data.hovered;
|
|
10
|
+
return enabled ? '' : 'hidden';
|
|
11
|
+
}
|
|
12
|
+
export function PieSeriesShapes(args) {
|
|
13
|
+
const { dispatcher, preparedData, seriesOptions, htmlLayout } = args;
|
|
14
|
+
const ref = React.useRef(null);
|
|
15
|
+
React.useEffect(() => {
|
|
16
|
+
if (!ref.current) {
|
|
17
|
+
return () => { };
|
|
18
|
+
}
|
|
19
|
+
const svgElement = select(ref.current);
|
|
20
|
+
svgElement.selectAll('*').remove();
|
|
21
|
+
const segmentSelector = `.${b('segment')}`;
|
|
22
|
+
const connectorSelector = `.${b('connector')}`;
|
|
23
|
+
const shapesSelection = svgElement
|
|
24
|
+
.selectAll('pie')
|
|
25
|
+
.data(preparedData)
|
|
26
|
+
.join('g')
|
|
27
|
+
.attr('id', (pieData) => pieData.id)
|
|
28
|
+
.attr('class', b('item'))
|
|
29
|
+
.attr('transform', (pieData) => {
|
|
30
|
+
const [x, y] = pieData.center;
|
|
31
|
+
return `translate(${x}, ${y})`;
|
|
32
|
+
})
|
|
33
|
+
.style('stroke', (pieData) => pieData.borderColor)
|
|
34
|
+
.style('stroke-width', (pieData) => pieData.borderWidth)
|
|
35
|
+
.attr('cursor', (pieData) => pieData.series.cursor);
|
|
36
|
+
// Render halo appearing outside the hovered slice
|
|
37
|
+
shapesSelection
|
|
38
|
+
.selectAll('halo')
|
|
39
|
+
.data((pieData) => {
|
|
40
|
+
if (pieData.halo.enabled) {
|
|
41
|
+
return pieData.segments;
|
|
42
|
+
}
|
|
43
|
+
return [];
|
|
44
|
+
})
|
|
45
|
+
.join('path')
|
|
46
|
+
.attr('d', (d) => {
|
|
47
|
+
const arcGenerator = arc()
|
|
48
|
+
.innerRadius(d.data.pie.innerRadius)
|
|
49
|
+
.outerRadius(d.data.pie.radius + d.data.pie.halo.size)
|
|
50
|
+
.cornerRadius(d.data.pie.borderRadius);
|
|
51
|
+
return arcGenerator(d);
|
|
52
|
+
})
|
|
53
|
+
.attr('class', b('halo'))
|
|
54
|
+
.attr('fill', (d) => d.data.color)
|
|
55
|
+
.attr('opacity', (d) => d.data.pie.halo.opacity)
|
|
56
|
+
.attr('z-index', -1)
|
|
57
|
+
.attr('visibility', getHaloVisibility);
|
|
58
|
+
// Render segments
|
|
59
|
+
shapesSelection
|
|
60
|
+
.selectAll(segmentSelector)
|
|
61
|
+
.data((pieData) => pieData.segments)
|
|
62
|
+
.join('path')
|
|
63
|
+
.attr('d', (d) => {
|
|
64
|
+
const arcGenerator = arc()
|
|
65
|
+
.innerRadius(d.data.pie.innerRadius)
|
|
66
|
+
.outerRadius(d.data.pie.radius)
|
|
67
|
+
.cornerRadius(d.data.pie.borderRadius);
|
|
68
|
+
return arcGenerator(d);
|
|
69
|
+
})
|
|
70
|
+
.attr('class', b('segment'))
|
|
71
|
+
.attr('fill', (d) => d.data.color)
|
|
72
|
+
.attr('opacity', (d) => d.data.opacity);
|
|
73
|
+
// render Labels
|
|
74
|
+
shapesSelection
|
|
75
|
+
.selectAll('text')
|
|
76
|
+
.data((pieData) => pieData.labels)
|
|
77
|
+
.join('text')
|
|
78
|
+
.text((d) => d.text)
|
|
79
|
+
.attr('class', b('label'))
|
|
80
|
+
.attr('x', (d) => d.x)
|
|
81
|
+
.attr('y', (d) => d.y)
|
|
82
|
+
.attr('text-anchor', (d) => d.textAnchor)
|
|
83
|
+
.style('font-size', (d) => d.style.fontSize)
|
|
84
|
+
.style('font-weight', (d) => d.style.fontWeight || null)
|
|
85
|
+
.style('fill', (d) => d.style.fontColor || null)
|
|
86
|
+
.call(setEllipsisForOverflowTexts, (d) => d.size.width > d.maxWidth ? d.maxWidth : Infinity);
|
|
87
|
+
// Add the polyline between chart and labels
|
|
88
|
+
shapesSelection
|
|
89
|
+
.selectAll(connectorSelector)
|
|
90
|
+
.data((pieData) => pieData.connectors)
|
|
91
|
+
.enter()
|
|
92
|
+
.append('path')
|
|
93
|
+
.attr('class', b('connector'))
|
|
94
|
+
.attr('d', (d) => d.path)
|
|
95
|
+
.attr('stroke', (d) => d.color)
|
|
96
|
+
.attr('stroke-width', 1)
|
|
97
|
+
.attr('stroke-linejoin', 'round')
|
|
98
|
+
.attr('stroke-linecap', 'round')
|
|
99
|
+
.style('fill', 'none');
|
|
100
|
+
// Render custom shapes if defined
|
|
101
|
+
shapesSelection.each(function (d, index, nodes) {
|
|
102
|
+
var _a, _b;
|
|
103
|
+
const customShape = (_b = (_a = d.series).renderCustomShape) === null || _b === void 0 ? void 0 : _b.call(_a, {
|
|
104
|
+
series: {
|
|
105
|
+
innerRadius: d.innerRadius,
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
if (customShape) {
|
|
109
|
+
nodes[index].append(customShape);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
const eventName = `hover-shape.pie`;
|
|
113
|
+
const hoverOptions = get(seriesOptions, 'pie.states.hover');
|
|
114
|
+
const inactiveOptions = get(seriesOptions, 'pie.states.inactive');
|
|
115
|
+
dispatcher.on(eventName, (data) => {
|
|
116
|
+
var _a, _b;
|
|
117
|
+
const selectedSeriesId = (_b = (_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.series) === null || _b === void 0 ? void 0 : _b.id;
|
|
118
|
+
const hoverEnabled = hoverOptions === null || hoverOptions === void 0 ? void 0 : hoverOptions.enabled;
|
|
119
|
+
const inactiveEnabled = inactiveOptions === null || inactiveOptions === void 0 ? void 0 : inactiveOptions.enabled;
|
|
120
|
+
shapesSelection.datum((_d, index, list) => {
|
|
121
|
+
const pieSelection = select(list[index]);
|
|
122
|
+
const haloSelection = pieSelection.selectAll(`.${b('halo')}`);
|
|
123
|
+
pieSelection
|
|
124
|
+
.selectAll(segmentSelector)
|
|
125
|
+
.datum((d, i, elements) => {
|
|
126
|
+
const hovered = Boolean(hoverEnabled && d.data.series.id === selectedSeriesId);
|
|
127
|
+
if (d.data.hovered !== hovered) {
|
|
128
|
+
d.data.hovered = hovered;
|
|
129
|
+
select(elements[i]).attr('fill', () => {
|
|
130
|
+
var _a;
|
|
131
|
+
const initialColor = d.data.color;
|
|
132
|
+
if (d.data.hovered) {
|
|
133
|
+
return (((_a = color(initialColor)) === null || _a === void 0 ? void 0 : _a.brighter(hoverOptions === null || hoverOptions === void 0 ? void 0 : hoverOptions.brightness).toString()) || initialColor);
|
|
134
|
+
}
|
|
135
|
+
return initialColor;
|
|
136
|
+
});
|
|
137
|
+
const currentSegmentHalo = haloSelection.nodes()[i];
|
|
138
|
+
select(currentSegmentHalo).attr('visibility', getHaloVisibility);
|
|
139
|
+
}
|
|
140
|
+
setActiveState({
|
|
141
|
+
element: elements[i],
|
|
142
|
+
state: inactiveOptions,
|
|
143
|
+
active: Boolean(!inactiveEnabled ||
|
|
144
|
+
!selectedSeriesId ||
|
|
145
|
+
selectedSeriesId === d.data.series.id),
|
|
146
|
+
datum: d.data,
|
|
147
|
+
});
|
|
148
|
+
return d;
|
|
149
|
+
});
|
|
150
|
+
const labelSelection = pieSelection.selectAll('tspan');
|
|
151
|
+
const connectorSelection = pieSelection.selectAll(connectorSelector);
|
|
152
|
+
labelSelection.merge(connectorSelection).datum((d, i, elements) => {
|
|
153
|
+
return setActiveState({
|
|
154
|
+
element: elements[i],
|
|
155
|
+
state: inactiveOptions,
|
|
156
|
+
active: Boolean(!inactiveEnabled ||
|
|
157
|
+
!selectedSeriesId ||
|
|
158
|
+
selectedSeriesId === d.series.id),
|
|
159
|
+
datum: d,
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
return () => {
|
|
165
|
+
dispatcher.on(eventName, null);
|
|
166
|
+
};
|
|
167
|
+
}, [dispatcher, preparedData, seriesOptions]);
|
|
168
|
+
return (React.createElement(React.Fragment, null,
|
|
169
|
+
React.createElement("g", { ref: ref, className: b(), style: { zIndex: 9 } }),
|
|
170
|
+
React.createElement(HtmlLayer, { preparedData: preparedData, htmlLayout: htmlLayout })));
|
|
171
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { PreparedPieSeries } from '../../useSeries/types';
|
|
2
|
+
import type { PreparedPieData } from './types';
|
|
3
|
+
type Args = {
|
|
4
|
+
series: PreparedPieSeries[];
|
|
5
|
+
boundsWidth: number;
|
|
6
|
+
boundsHeight: number;
|
|
7
|
+
};
|
|
8
|
+
export declare function preparePieData(args: Args): PreparedPieData[];
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { arc, group, line as lineGenerator } from 'd3';
|
|
2
|
+
import { calculateNumericProperty, getLabelsSize, getLeftPosition, isLabelsOverlapping, } from '../../../utils';
|
|
3
|
+
import { getCurveFactory, pieGenerator } from './utils';
|
|
4
|
+
const FULL_CIRCLE = Math.PI * 2;
|
|
5
|
+
const getCenter = (boundsWidth, boundsHeight, center) => {
|
|
6
|
+
var _a, _b;
|
|
7
|
+
const defaultX = boundsWidth * 0.5;
|
|
8
|
+
const defaultY = boundsHeight * 0.5;
|
|
9
|
+
if (!center) {
|
|
10
|
+
return [defaultX, defaultY];
|
|
11
|
+
}
|
|
12
|
+
const [x, y] = center;
|
|
13
|
+
const resultX = (_a = calculateNumericProperty({ value: x, base: boundsWidth })) !== null && _a !== void 0 ? _a : defaultX;
|
|
14
|
+
const resultY = (_b = calculateNumericProperty({ value: y, base: boundsHeight })) !== null && _b !== void 0 ? _b : defaultY;
|
|
15
|
+
return [resultX, resultY];
|
|
16
|
+
};
|
|
17
|
+
export function preparePieData(args) {
|
|
18
|
+
const { series: preparedSeries, boundsWidth, boundsHeight } = args;
|
|
19
|
+
const maxRadius = Math.min(boundsWidth, boundsHeight) / 2;
|
|
20
|
+
const groupedPieSeries = group(preparedSeries, (pieSeries) => pieSeries.stackId);
|
|
21
|
+
return Array.from(groupedPieSeries).map(([stackId, items]) => {
|
|
22
|
+
var _a, _b, _c;
|
|
23
|
+
const series = items[0];
|
|
24
|
+
const { center, borderWidth, borderColor, borderRadius, radius: seriesRadius, innerRadius: seriesInnerRadius, dataLabels, } = series;
|
|
25
|
+
const radius = (_a = calculateNumericProperty({ value: seriesRadius, base: maxRadius })) !== null && _a !== void 0 ? _a : maxRadius;
|
|
26
|
+
const data = {
|
|
27
|
+
id: stackId,
|
|
28
|
+
center: getCenter(boundsWidth, boundsHeight, center),
|
|
29
|
+
innerRadius: (_b = calculateNumericProperty({ value: seriesInnerRadius, base: radius })) !== null && _b !== void 0 ? _b : 0,
|
|
30
|
+
radius,
|
|
31
|
+
segments: [],
|
|
32
|
+
labels: [],
|
|
33
|
+
connectors: [],
|
|
34
|
+
borderColor,
|
|
35
|
+
borderWidth,
|
|
36
|
+
borderRadius,
|
|
37
|
+
series: items[0],
|
|
38
|
+
connectorCurve: dataLabels.connectorCurve,
|
|
39
|
+
halo: {
|
|
40
|
+
enabled: series.states.hover.halo.enabled,
|
|
41
|
+
opacity: series.states.hover.halo.opacity,
|
|
42
|
+
size: series.states.hover.halo.size,
|
|
43
|
+
},
|
|
44
|
+
htmlElements: [],
|
|
45
|
+
};
|
|
46
|
+
const segments = items.map((item) => {
|
|
47
|
+
return {
|
|
48
|
+
value: item.value,
|
|
49
|
+
color: item.color,
|
|
50
|
+
opacity: item.opacity,
|
|
51
|
+
series: item,
|
|
52
|
+
hovered: false,
|
|
53
|
+
active: true,
|
|
54
|
+
pie: data,
|
|
55
|
+
};
|
|
56
|
+
});
|
|
57
|
+
data.segments = pieGenerator(segments);
|
|
58
|
+
let line = lineGenerator();
|
|
59
|
+
const curveFactory = getCurveFactory(data);
|
|
60
|
+
if (curveFactory) {
|
|
61
|
+
line = line.curve(curveFactory);
|
|
62
|
+
}
|
|
63
|
+
if (dataLabels.enabled) {
|
|
64
|
+
const { style, connectorPadding, distance } = dataLabels;
|
|
65
|
+
const { maxHeight: labelHeight } = getLabelsSize({ labels: ['Some Label'], style });
|
|
66
|
+
const minSegmentRadius = maxRadius - connectorPadding - distance - labelHeight;
|
|
67
|
+
if (data.radius > minSegmentRadius) {
|
|
68
|
+
data.radius = minSegmentRadius;
|
|
69
|
+
data.innerRadius =
|
|
70
|
+
(_c = calculateNumericProperty({ value: seriesInnerRadius, base: data.radius })) !== null && _c !== void 0 ? _c : 0;
|
|
71
|
+
}
|
|
72
|
+
const connectorStartPointGenerator = arc()
|
|
73
|
+
.innerRadius(data.radius)
|
|
74
|
+
.outerRadius(data.radius);
|
|
75
|
+
const connectorMidPointRadius = data.radius + distance / 2;
|
|
76
|
+
const connectorMidPointGenerator = arc()
|
|
77
|
+
.innerRadius(connectorMidPointRadius)
|
|
78
|
+
.outerRadius(connectorMidPointRadius);
|
|
79
|
+
const connectorArcRadius = data.radius + distance;
|
|
80
|
+
const connectorEndPointGenerator = arc()
|
|
81
|
+
.innerRadius(connectorArcRadius)
|
|
82
|
+
.outerRadius(connectorArcRadius);
|
|
83
|
+
const labelArcRadius = connectorArcRadius + connectorPadding;
|
|
84
|
+
const labelArcGenerator = arc()
|
|
85
|
+
.innerRadius(labelArcRadius)
|
|
86
|
+
.outerRadius(labelArcRadius);
|
|
87
|
+
const labels = [];
|
|
88
|
+
items.forEach((d, index) => {
|
|
89
|
+
const prevLabel = labels[labels.length - 1];
|
|
90
|
+
const text = String(d.data.label || d.data.value);
|
|
91
|
+
const shouldUseHtml = dataLabels.html;
|
|
92
|
+
const labelSize = getLabelsSize({ labels: [text], style, html: shouldUseHtml });
|
|
93
|
+
const labelWidth = labelSize.maxWidth;
|
|
94
|
+
const relatedSegment = data.segments[index];
|
|
95
|
+
const getLabelPosition = (angle) => {
|
|
96
|
+
let [x, y] = labelArcGenerator.centroid(Object.assign(Object.assign({}, relatedSegment), { startAngle: angle, endAngle: angle }));
|
|
97
|
+
y = y < 0 ? y - labelHeight : y;
|
|
98
|
+
if (shouldUseHtml) {
|
|
99
|
+
x = x < 0 ? x - labelWidth : x;
|
|
100
|
+
}
|
|
101
|
+
x = Math.max(-boundsWidth / 2, x);
|
|
102
|
+
return [x, y];
|
|
103
|
+
};
|
|
104
|
+
const getConnectorPoints = (angle) => {
|
|
105
|
+
const connectorStartPoint = connectorStartPointGenerator.centroid(relatedSegment);
|
|
106
|
+
const connectorEndPoint = connectorEndPointGenerator.centroid(Object.assign(Object.assign({}, relatedSegment), { startAngle: angle, endAngle: angle }));
|
|
107
|
+
if (dataLabels.connectorShape === 'straight-line') {
|
|
108
|
+
return [connectorStartPoint, connectorEndPoint];
|
|
109
|
+
}
|
|
110
|
+
const connectorMidPoint = connectorMidPointGenerator.centroid(relatedSegment);
|
|
111
|
+
return [connectorStartPoint, connectorMidPoint, connectorEndPoint];
|
|
112
|
+
};
|
|
113
|
+
const midAngle = Math.max((prevLabel === null || prevLabel === void 0 ? void 0 : prevLabel.angle) || 0, relatedSegment.startAngle +
|
|
114
|
+
(relatedSegment.endAngle - relatedSegment.startAngle) / 2);
|
|
115
|
+
const [x, y] = getLabelPosition(midAngle);
|
|
116
|
+
const label = {
|
|
117
|
+
text,
|
|
118
|
+
x,
|
|
119
|
+
y,
|
|
120
|
+
style,
|
|
121
|
+
size: { width: labelWidth, height: labelHeight },
|
|
122
|
+
maxWidth: labelWidth,
|
|
123
|
+
textAnchor: midAngle < Math.PI ? 'start' : 'end',
|
|
124
|
+
series: { id: d.id },
|
|
125
|
+
active: true,
|
|
126
|
+
segment: relatedSegment.data,
|
|
127
|
+
angle: midAngle,
|
|
128
|
+
};
|
|
129
|
+
let overlap = false;
|
|
130
|
+
if (prevLabel) {
|
|
131
|
+
overlap = isLabelsOverlapping(prevLabel, label, dataLabels.padding);
|
|
132
|
+
if (overlap) {
|
|
133
|
+
let shouldAdjustAngle = true;
|
|
134
|
+
const step = Math.PI / 180;
|
|
135
|
+
while (shouldAdjustAngle) {
|
|
136
|
+
const newAngle = label.angle + step;
|
|
137
|
+
if (newAngle > FULL_CIRCLE &&
|
|
138
|
+
newAngle % FULL_CIRCLE > labels[0].angle) {
|
|
139
|
+
shouldAdjustAngle = false;
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
label.angle = newAngle;
|
|
143
|
+
const [newX, newY] = getLabelPosition(newAngle);
|
|
144
|
+
label.x = newX;
|
|
145
|
+
label.y = newY;
|
|
146
|
+
if (!isLabelsOverlapping(prevLabel, label, dataLabels.padding)) {
|
|
147
|
+
shouldAdjustAngle = false;
|
|
148
|
+
overlap = false;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
if (dataLabels.allowOverlap || !overlap) {
|
|
155
|
+
const left = getLeftPosition(label);
|
|
156
|
+
if (Math.abs(left) > boundsWidth / 2) {
|
|
157
|
+
label.maxWidth = label.size.width - (Math.abs(left) - boundsWidth / 2);
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
const right = left + label.size.width;
|
|
161
|
+
if (right > boundsWidth / 2) {
|
|
162
|
+
label.maxWidth = label.size.width - (right - boundsWidth / 2);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
if (shouldUseHtml) {
|
|
166
|
+
data.htmlElements.push({
|
|
167
|
+
x: boundsWidth / 2 + label.x,
|
|
168
|
+
y: boundsHeight / 2 + label.y,
|
|
169
|
+
content: label.text,
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
labels.push(label);
|
|
174
|
+
}
|
|
175
|
+
const connector = {
|
|
176
|
+
path: line(getConnectorPoints(midAngle)),
|
|
177
|
+
color: relatedSegment.data.color,
|
|
178
|
+
};
|
|
179
|
+
data.connectors.push(connector);
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
data.labels = labels;
|
|
183
|
+
}
|
|
184
|
+
return data;
|
|
185
|
+
});
|
|
186
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { PieArcDatum } from 'd3';
|
|
2
|
+
import type { ConnectorCurve, HtmlItem, LabelData } from '../../../types';
|
|
3
|
+
import type { PreparedPieSeries } from '../../useSeries/types';
|
|
4
|
+
export type SegmentData = {
|
|
5
|
+
value: number;
|
|
6
|
+
color: string;
|
|
7
|
+
opacity: number | null;
|
|
8
|
+
series: PreparedPieSeries;
|
|
9
|
+
hovered: boolean;
|
|
10
|
+
active: boolean;
|
|
11
|
+
pie: PreparedPieData;
|
|
12
|
+
};
|
|
13
|
+
export type PieLabelData = LabelData & {
|
|
14
|
+
segment: SegmentData;
|
|
15
|
+
angle: number;
|
|
16
|
+
maxWidth: number;
|
|
17
|
+
};
|
|
18
|
+
export type PieConnectorData = {
|
|
19
|
+
path: string | null;
|
|
20
|
+
color: string;
|
|
21
|
+
};
|
|
22
|
+
export type PreparedPieData = {
|
|
23
|
+
id: string;
|
|
24
|
+
segments: PieArcDatum<SegmentData>[];
|
|
25
|
+
labels: PieLabelData[];
|
|
26
|
+
connectors: PieConnectorData[];
|
|
27
|
+
center: [number, number];
|
|
28
|
+
radius: number;
|
|
29
|
+
innerRadius: number;
|
|
30
|
+
borderRadius: number;
|
|
31
|
+
borderWidth: number;
|
|
32
|
+
borderColor: string;
|
|
33
|
+
series: PreparedPieSeries;
|
|
34
|
+
connectorCurve: ConnectorCurve;
|
|
35
|
+
halo: {
|
|
36
|
+
enabled: boolean;
|
|
37
|
+
opacity: number;
|
|
38
|
+
size: number;
|
|
39
|
+
};
|
|
40
|
+
htmlElements: HtmlItem[];
|
|
41
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { curveBasis, curveLinear, pie } from 'd3';
|
|
2
|
+
export const pieGenerator = pie()
|
|
3
|
+
.value((d) => d.value)
|
|
4
|
+
.sort(null);
|
|
5
|
+
export function getCurveFactory(data) {
|
|
6
|
+
switch (data.connectorCurve) {
|
|
7
|
+
case 'basic': {
|
|
8
|
+
return curveBasis;
|
|
9
|
+
}
|
|
10
|
+
case 'linear': {
|
|
11
|
+
return curveLinear;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Dispatch } from 'd3';
|
|
3
|
+
import type { PreparedSeriesOptions } from '../../useSeries/types';
|
|
4
|
+
import type { PreparedScatterData } from './types';
|
|
5
|
+
export { prepareScatterData } from './prepare-data';
|
|
6
|
+
type ScatterSeriesShapeProps = {
|
|
7
|
+
dispatcher: Dispatch<object>;
|
|
8
|
+
preparedData: PreparedScatterData[];
|
|
9
|
+
seriesOptions: PreparedSeriesOptions;
|
|
10
|
+
htmlLayout: HTMLElement | null;
|
|
11
|
+
};
|
|
12
|
+
export declare function ScatterSeriesShape(props: ScatterSeriesShapeProps): React.JSX.Element;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { select } from 'd3';
|
|
3
|
+
import get from 'lodash/get';
|
|
4
|
+
import { block } from '../../../utils';
|
|
5
|
+
import { HtmlLayer } from '../HtmlLayer';
|
|
6
|
+
import { getMarkerHaloVisibility, renderMarker, selectMarkerHalo, selectMarkerSymbol, setMarker, } from '../marker';
|
|
7
|
+
import { setActiveState, shapeKey } from '../utils';
|
|
8
|
+
export { prepareScatterData } from './prepare-data';
|
|
9
|
+
const b = block('d3-scatter');
|
|
10
|
+
export function ScatterSeriesShape(props) {
|
|
11
|
+
const { dispatcher, preparedData, seriesOptions, htmlLayout } = props;
|
|
12
|
+
const ref = React.useRef(null);
|
|
13
|
+
React.useEffect(() => {
|
|
14
|
+
if (!ref.current) {
|
|
15
|
+
return () => { };
|
|
16
|
+
}
|
|
17
|
+
const svgElement = select(ref.current);
|
|
18
|
+
const hoverOptions = get(seriesOptions, 'scatter.states.hover');
|
|
19
|
+
const inactiveOptions = get(seriesOptions, 'scatter.states.inactive');
|
|
20
|
+
svgElement.selectAll('*').remove();
|
|
21
|
+
const selection = svgElement
|
|
22
|
+
.selectAll('path')
|
|
23
|
+
.data(preparedData, shapeKey)
|
|
24
|
+
.join('g')
|
|
25
|
+
.call(renderMarker)
|
|
26
|
+
.attr('fill', (d) => d.point.data.color || d.point.series.color || '')
|
|
27
|
+
.attr('opacity', (d) => d.point.opacity)
|
|
28
|
+
.attr('cursor', (d) => d.point.series.cursor);
|
|
29
|
+
const hoverEnabled = hoverOptions === null || hoverOptions === void 0 ? void 0 : hoverOptions.enabled;
|
|
30
|
+
const inactiveEnabled = inactiveOptions === null || inactiveOptions === void 0 ? void 0 : inactiveOptions.enabled;
|
|
31
|
+
dispatcher.on('hover-shape.scatter', (data) => {
|
|
32
|
+
var _a;
|
|
33
|
+
const selected = data === null || data === void 0 ? void 0 : data.find((d) => d.series.type === 'scatter');
|
|
34
|
+
const selectedDataItem = selected === null || selected === void 0 ? void 0 : selected.data;
|
|
35
|
+
const selectedSeriesId = (_a = selected === null || selected === void 0 ? void 0 : selected.series) === null || _a === void 0 ? void 0 : _a.id;
|
|
36
|
+
selection.datum((d, index, list) => {
|
|
37
|
+
const elementSelection = select(list[index]);
|
|
38
|
+
const hovered = Boolean(hoverEnabled && d.point.data === selectedDataItem);
|
|
39
|
+
if (d.hovered !== hovered) {
|
|
40
|
+
d.hovered = hovered;
|
|
41
|
+
elementSelection.attr('z-index', hovered ? 999 : null);
|
|
42
|
+
selectMarkerHalo(elementSelection).attr('visibility', getMarkerHaloVisibility);
|
|
43
|
+
selectMarkerSymbol(elementSelection).call(setMarker, hovered ? 'hover' : 'normal');
|
|
44
|
+
}
|
|
45
|
+
if (hovered) {
|
|
46
|
+
elementSelection.raise();
|
|
47
|
+
}
|
|
48
|
+
if (d.point.series.marker.states.normal.enabled) {
|
|
49
|
+
const isActive = Boolean(!inactiveEnabled ||
|
|
50
|
+
!selectedSeriesId ||
|
|
51
|
+
selectedSeriesId === d.point.series.id);
|
|
52
|
+
setActiveState({
|
|
53
|
+
element: list[index],
|
|
54
|
+
state: inactiveOptions,
|
|
55
|
+
active: isActive,
|
|
56
|
+
datum: d,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
return d;
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
return () => {
|
|
63
|
+
dispatcher.on('hover-shape.scatter', null);
|
|
64
|
+
};
|
|
65
|
+
}, [dispatcher, preparedData, seriesOptions]);
|
|
66
|
+
return (React.createElement(React.Fragment, null,
|
|
67
|
+
React.createElement("g", { ref: ref, className: b() }),
|
|
68
|
+
React.createElement(HtmlLayer, { preparedData: preparedData, htmlLayout: htmlLayout })));
|
|
69
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ChartScale } from '../../useAxisScales';
|
|
2
|
+
import type { PreparedAxis } from '../../useChartOptions/types';
|
|
3
|
+
import type { PreparedScatterSeries } from '../../useSeries/types';
|
|
4
|
+
import type { PreparedScatterData } from './types';
|
|
5
|
+
export declare const prepareScatterData: (args: {
|
|
6
|
+
series: PreparedScatterSeries[];
|
|
7
|
+
xAxis: PreparedAxis;
|
|
8
|
+
xScale: ChartScale;
|
|
9
|
+
yAxis: PreparedAxis[];
|
|
10
|
+
yScale: ChartScale[];
|
|
11
|
+
}) => PreparedScatterData[];
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import get from 'lodash/get';
|
|
2
|
+
import { getXValue, getYValue } from '../utils';
|
|
3
|
+
const getFilteredLinearScatterData = (data) => {
|
|
4
|
+
return data.filter((d) => typeof d.x === 'number' && typeof d.y === 'number');
|
|
5
|
+
};
|
|
6
|
+
export const prepareScatterData = (args) => {
|
|
7
|
+
const { series, xAxis, xScale, yAxis, yScale } = args;
|
|
8
|
+
return series.reduce((acc, s) => {
|
|
9
|
+
const yAxisIndex = get(s, 'yAxis', 0);
|
|
10
|
+
const seriesYAxis = yAxis[yAxisIndex];
|
|
11
|
+
const seriesYScale = yScale[yAxisIndex];
|
|
12
|
+
const filteredData = xAxis.type === 'category' || seriesYAxis.type === 'category'
|
|
13
|
+
? s.data
|
|
14
|
+
: getFilteredLinearScatterData(s.data);
|
|
15
|
+
filteredData.forEach((d) => {
|
|
16
|
+
acc.push({
|
|
17
|
+
point: {
|
|
18
|
+
data: d,
|
|
19
|
+
series: s,
|
|
20
|
+
x: getXValue({ point: d, xAxis, xScale }),
|
|
21
|
+
y: getYValue({ point: d, yAxis: seriesYAxis, yScale: seriesYScale }),
|
|
22
|
+
opacity: get(d, 'opacity', null),
|
|
23
|
+
},
|
|
24
|
+
hovered: false,
|
|
25
|
+
active: true,
|
|
26
|
+
htmlElements: [],
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
return acc;
|
|
30
|
+
}, []);
|
|
31
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { HtmlItem, ScatterSeriesData } from '../../../types';
|
|
2
|
+
import type { PreparedScatterSeries } from '../../useSeries/types';
|
|
3
|
+
type PointData = {
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
opacity: number | null;
|
|
7
|
+
data: ScatterSeriesData;
|
|
8
|
+
series: PreparedScatterSeries;
|
|
9
|
+
};
|
|
10
|
+
export type MarkerData = {
|
|
11
|
+
point: PointData;
|
|
12
|
+
active: boolean;
|
|
13
|
+
hovered: boolean;
|
|
14
|
+
htmlElements: HtmlItem[];
|
|
15
|
+
};
|
|
16
|
+
export type PreparedScatterData = MarkerData;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
.gcharts-d3-scatter__point {
|
|
2
|
+
stroke-width: 1px;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.gcharts-d3-pie__segment {
|
|
6
|
+
stroke: var(--g-color-base-background);
|
|
7
|
+
}
|
|
8
|
+
.gcharts-d3-pie__label {
|
|
9
|
+
font-size: 11px;
|
|
10
|
+
font-weight: bold;
|
|
11
|
+
fill: var(--g-color-text-complementary);
|
|
12
|
+
alignment-baseline: before-edge;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.gcharts-d3-bar-x__label {
|
|
16
|
+
user-select: none;
|
|
17
|
+
fill: var(--g-color-text-complementary);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.gcharts-d3-bar-y__label {
|
|
21
|
+
user-select: none;
|
|
22
|
+
fill: var(--g-color-text-complementary);
|
|
23
|
+
alignment-baseline: after-edge;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.gcharts-d3-treemap__label {
|
|
27
|
+
user-select: none;
|
|
28
|
+
pointer-events: none;
|
|
29
|
+
fill: var(--g-color-text-complementary);
|
|
30
|
+
alignment-baseline: text-before-edge;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.gcharts-d3-waterfall__connector {
|
|
34
|
+
stroke: var(--g-color-line-generic-active);
|
|
35
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Dispatch } from 'd3';
|
|
3
|
+
import type { PreparedSeriesOptions } from '../../useSeries/types';
|
|
4
|
+
import type { PreparedTreemapData } from './types';
|
|
5
|
+
type ShapeProps = {
|
|
6
|
+
dispatcher: Dispatch<object>;
|
|
7
|
+
preparedData: PreparedTreemapData;
|
|
8
|
+
seriesOptions: PreparedSeriesOptions;
|
|
9
|
+
htmlLayout: HTMLElement | null;
|
|
10
|
+
};
|
|
11
|
+
export declare const TreemapSeriesShape: (props: ShapeProps) => React.JSX.Element;
|
|
12
|
+
export {};
|