@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,172 @@
|
|
|
1
|
+
import { Delaunay, bisector, sort } from 'd3';
|
|
2
|
+
import get from 'lodash/get';
|
|
3
|
+
import groupBy from 'lodash/groupBy';
|
|
4
|
+
function getClosestPointsByXValue(x, y, points) {
|
|
5
|
+
var _a, _b, _c, _d;
|
|
6
|
+
const sorted = sort(points, (p) => p.x);
|
|
7
|
+
const closestXIndex = bisector((p) => p.x).center(sorted, x);
|
|
8
|
+
if (closestXIndex === -1) {
|
|
9
|
+
return [];
|
|
10
|
+
}
|
|
11
|
+
const closestX = sorted[closestXIndex].x;
|
|
12
|
+
const closestPoints = sort(points.filter((p) => p.x === closestX), (p) => p.y0);
|
|
13
|
+
let closestYIndex = -1;
|
|
14
|
+
if (y < ((_a = closestPoints[0]) === null || _a === void 0 ? void 0 : _a.y0)) {
|
|
15
|
+
closestYIndex = 0;
|
|
16
|
+
}
|
|
17
|
+
else if (y > ((_b = closestPoints[closestPoints.length - 1]) === null || _b === void 0 ? void 0 : _b.y1)) {
|
|
18
|
+
closestYIndex = closestPoints.length - 1;
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
closestYIndex = closestPoints.findIndex((p) => y > p.y0 && y < p.y1);
|
|
22
|
+
if (closestYIndex === -1) {
|
|
23
|
+
const sortedY = sort(closestPoints.map((p, index) => ({ index, y: p.y1 + (p.y0 - p.y1) / 2 })), (p) => p.y);
|
|
24
|
+
const sortedYIndex = bisector((p) => p.y).center(sortedY, y);
|
|
25
|
+
closestYIndex = (_d = (_c = sortedY[sortedYIndex]) === null || _c === void 0 ? void 0 : _c.index) !== null && _d !== void 0 ? _d : -1;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return closestPoints.map((p, i) => ({
|
|
29
|
+
data: p.data,
|
|
30
|
+
series: p.series,
|
|
31
|
+
closest: i === closestYIndex,
|
|
32
|
+
}));
|
|
33
|
+
}
|
|
34
|
+
function getSeriesType(shapeData) {
|
|
35
|
+
return get(shapeData, 'series.type') || get(shapeData, 'point.series.type');
|
|
36
|
+
}
|
|
37
|
+
export function getClosestPoints(args) {
|
|
38
|
+
const { position, shapesData } = args;
|
|
39
|
+
const [pointerX, pointerY] = position;
|
|
40
|
+
const result = [];
|
|
41
|
+
const groups = groupBy(shapesData, getSeriesType);
|
|
42
|
+
Object.entries(groups).forEach(([seriesType, list]) => {
|
|
43
|
+
var _a, _b;
|
|
44
|
+
switch (seriesType) {
|
|
45
|
+
case 'bar-x': {
|
|
46
|
+
const points = list.map((d) => ({
|
|
47
|
+
data: d.data,
|
|
48
|
+
series: d.series,
|
|
49
|
+
x: d.x + d.width / 2,
|
|
50
|
+
y0: d.y,
|
|
51
|
+
y1: d.y + d.height,
|
|
52
|
+
}));
|
|
53
|
+
result.push(...getClosestPointsByXValue(pointerX, pointerY, points));
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
case 'waterfall': {
|
|
57
|
+
const points = list.map((d) => ({
|
|
58
|
+
data: d.data,
|
|
59
|
+
series: d.series,
|
|
60
|
+
x: d.x + d.width / 2,
|
|
61
|
+
y0: d.y,
|
|
62
|
+
y1: d.y + d.height,
|
|
63
|
+
}));
|
|
64
|
+
result.push(...getClosestPointsByXValue(pointerX, pointerY, points));
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
case 'area': {
|
|
68
|
+
const points = list.reduce((acc, d) => {
|
|
69
|
+
Array.prototype.push.apply(acc, d.points.map((p) => ({
|
|
70
|
+
data: p.data,
|
|
71
|
+
series: p.series,
|
|
72
|
+
x: p.x,
|
|
73
|
+
y0: p.y0,
|
|
74
|
+
y1: p.y,
|
|
75
|
+
})));
|
|
76
|
+
return acc;
|
|
77
|
+
}, []);
|
|
78
|
+
result.push(...getClosestPointsByXValue(pointerX, pointerY, points));
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
case 'line': {
|
|
82
|
+
const points = list.reduce((acc, d) => {
|
|
83
|
+
acc.push(...d.points.map((p) => ({
|
|
84
|
+
data: p.data,
|
|
85
|
+
series: p.series,
|
|
86
|
+
x: p.x,
|
|
87
|
+
y0: p.y,
|
|
88
|
+
y1: p.y,
|
|
89
|
+
})));
|
|
90
|
+
return acc;
|
|
91
|
+
}, []);
|
|
92
|
+
result.push(...getClosestPointsByXValue(pointerX, pointerY, points));
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
case 'bar-y': {
|
|
96
|
+
const points = list;
|
|
97
|
+
const sorted = sort(points, (p) => p.y);
|
|
98
|
+
const closestYIndex = bisector((p) => p.y).center(sorted, pointerY);
|
|
99
|
+
let closestPoints = [];
|
|
100
|
+
let closestXIndex = -1;
|
|
101
|
+
if (closestYIndex !== -1) {
|
|
102
|
+
const closestY = sorted[closestYIndex].y;
|
|
103
|
+
closestPoints = sort(points.filter((p) => p.y === closestY), (p) => p.x);
|
|
104
|
+
const lastPoint = closestPoints[closestPoints.length - 1];
|
|
105
|
+
if (pointerX < ((_a = closestPoints[0]) === null || _a === void 0 ? void 0 : _a.x)) {
|
|
106
|
+
closestXIndex = 0;
|
|
107
|
+
}
|
|
108
|
+
else if (lastPoint && pointerX > lastPoint.x + lastPoint.width) {
|
|
109
|
+
closestXIndex = closestPoints.length - 1;
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
closestXIndex = closestPoints.findIndex((p) => pointerX > p.x && pointerX < p.x + p.width);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
result.push(...closestPoints.map((p, i) => ({
|
|
116
|
+
data: p.data,
|
|
117
|
+
series: p.series,
|
|
118
|
+
closest: i === closestXIndex,
|
|
119
|
+
})));
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
case 'scatter': {
|
|
123
|
+
const points = list;
|
|
124
|
+
const delaunayX = Delaunay.from(points, (d) => d.point.x, (d) => d.point.y);
|
|
125
|
+
const closestPoint = points[delaunayX.find(pointerX, pointerY)];
|
|
126
|
+
if (closestPoint) {
|
|
127
|
+
result.push({
|
|
128
|
+
data: closestPoint.point.data,
|
|
129
|
+
series: closestPoint.point.series,
|
|
130
|
+
closest: true,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
case 'pie': {
|
|
136
|
+
const points = list.map((d) => d.segments).flat();
|
|
137
|
+
const closestPoint = points.find((p) => {
|
|
138
|
+
const { center, radius } = p.data.pie;
|
|
139
|
+
const x = pointerX - center[0];
|
|
140
|
+
const y = pointerY - center[1];
|
|
141
|
+
let angle = Math.atan2(y, x) + 0.5 * Math.PI;
|
|
142
|
+
angle = angle < 0 ? Math.PI * 2 + angle : angle;
|
|
143
|
+
const polarRadius = Math.sqrt(x * x + y * y);
|
|
144
|
+
return angle >= p.startAngle && angle <= p.endAngle && polarRadius < radius;
|
|
145
|
+
});
|
|
146
|
+
if (closestPoint) {
|
|
147
|
+
result.push({
|
|
148
|
+
data: closestPoint.data.series.data,
|
|
149
|
+
series: closestPoint.data.series,
|
|
150
|
+
closest: true,
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
case 'treemap': {
|
|
156
|
+
const data = list;
|
|
157
|
+
const closestPoint = (_b = data[0]) === null || _b === void 0 ? void 0 : _b.leaves.find((l) => {
|
|
158
|
+
return (pointerX >= l.x0 && pointerX <= l.x1 && pointerY >= l.y0 && pointerY <= l.y1);
|
|
159
|
+
});
|
|
160
|
+
if (closestPoint) {
|
|
161
|
+
result.push({
|
|
162
|
+
data: closestPoint.data,
|
|
163
|
+
series: data[0].series,
|
|
164
|
+
closest: true,
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
return result;
|
|
172
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { AxisDomain } from 'd3';
|
|
2
|
+
import type { PreparedAxis } from '../../hooks';
|
|
3
|
+
import type { BaseTextStyle, ChartSeries, ChartSeriesData } from '../../types';
|
|
4
|
+
export * from './math';
|
|
5
|
+
export * from './text';
|
|
6
|
+
export * from './time';
|
|
7
|
+
export * from './axis';
|
|
8
|
+
export * from './labels';
|
|
9
|
+
export * from './legend';
|
|
10
|
+
export * from './symbol';
|
|
11
|
+
export * from './series';
|
|
12
|
+
export * from './color';
|
|
13
|
+
export declare const CHART_SERIES_WITH_VOLUME_ON_Y_AXIS: ChartSeries['type'][];
|
|
14
|
+
export declare const CHART_SERIES_WITH_VOLUME_ON_X_AXIS: ChartSeries['type'][];
|
|
15
|
+
export type AxisDirection = 'x' | 'y';
|
|
16
|
+
type UnknownSeries = {
|
|
17
|
+
type: ChartSeries['type'];
|
|
18
|
+
data: unknown;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Checks whether the series should be drawn with axes.
|
|
22
|
+
*
|
|
23
|
+
* @param series - The series object to check.
|
|
24
|
+
* @returns `true` if the series should be drawn with axes, `false` otherwise.
|
|
25
|
+
*/
|
|
26
|
+
export declare function isAxisRelatedSeries(series: UnknownSeries): boolean;
|
|
27
|
+
export declare function isSeriesWithNumericalXValues(series: UnknownSeries): series is {
|
|
28
|
+
type: ChartSeries['type'];
|
|
29
|
+
data: {
|
|
30
|
+
x: number;
|
|
31
|
+
}[];
|
|
32
|
+
};
|
|
33
|
+
export declare function isSeriesWithNumericalYValues(series: UnknownSeries): series is {
|
|
34
|
+
type: ChartSeries['type'];
|
|
35
|
+
data: {
|
|
36
|
+
y: number;
|
|
37
|
+
}[];
|
|
38
|
+
};
|
|
39
|
+
export declare function isSeriesWithCategoryValues(series: UnknownSeries): series is {
|
|
40
|
+
type: ChartSeries['type'];
|
|
41
|
+
data: {
|
|
42
|
+
category: string;
|
|
43
|
+
}[];
|
|
44
|
+
};
|
|
45
|
+
export declare const getDomainDataXBySeries: (series: UnknownSeries[]) => unknown[];
|
|
46
|
+
export declare function getDefaultMaxXAxisValue(series: UnknownSeries[]): 0 | undefined;
|
|
47
|
+
export declare const getDomainDataYBySeries: (series: UnknownSeries[]) => unknown[];
|
|
48
|
+
export declare const getSeriesNames: (series: ChartSeries[]) => string[];
|
|
49
|
+
export declare const getOnlyVisibleSeries: <T extends {
|
|
50
|
+
visible: boolean;
|
|
51
|
+
}>(series: T[]) => T[];
|
|
52
|
+
export declare const parseTransformStyle: (style: string | null) => {
|
|
53
|
+
x?: number;
|
|
54
|
+
y?: number;
|
|
55
|
+
};
|
|
56
|
+
export declare const formatAxisTickLabel: (args: {
|
|
57
|
+
axis: PreparedAxis;
|
|
58
|
+
value: AxisDomain;
|
|
59
|
+
step?: number;
|
|
60
|
+
}) => string;
|
|
61
|
+
/**
|
|
62
|
+
* Calculates the height of a text element in a horizontal SVG layout.
|
|
63
|
+
*
|
|
64
|
+
* @param {Object} args - The arguments for the function.
|
|
65
|
+
* @param {string} args.text - The text to be measured.
|
|
66
|
+
* @param {Partial<BaseTextStyle>} args.style - Optional style properties for the text element.
|
|
67
|
+
* @return {number} The height of the text element.
|
|
68
|
+
*/
|
|
69
|
+
export declare const getHorisontalSvgTextHeight: (args: {
|
|
70
|
+
text: string;
|
|
71
|
+
style?: Partial<BaseTextStyle>;
|
|
72
|
+
}) => number;
|
|
73
|
+
export declare const getDataCategoryValue: (args: {
|
|
74
|
+
axisDirection: AxisDirection;
|
|
75
|
+
categories: string[];
|
|
76
|
+
data: ChartSeriesData;
|
|
77
|
+
}) => string;
|
|
78
|
+
export declare function getClosestPointsRange(axis: PreparedAxis, points: AxisDomain[]): number | undefined;
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { dateTime } from '@gravity-ui/date-utils';
|
|
2
|
+
import { group, select } from 'd3';
|
|
3
|
+
import get from 'lodash/get';
|
|
4
|
+
import isNil from 'lodash/isNil';
|
|
5
|
+
import { DEFAULT_AXIS_LABEL_FONT_SIZE } from '../../constants';
|
|
6
|
+
import { getSeriesStackId } from '../../hooks/useSeries/utils';
|
|
7
|
+
import { formatNumber, getNumberUnitRate } from '../../libs/format-number';
|
|
8
|
+
import { getDefaultDateFormat } from './time';
|
|
9
|
+
export * from './math';
|
|
10
|
+
export * from './text';
|
|
11
|
+
export * from './time';
|
|
12
|
+
export * from './axis';
|
|
13
|
+
export * from './labels';
|
|
14
|
+
export * from './legend';
|
|
15
|
+
export * from './symbol';
|
|
16
|
+
export * from './series';
|
|
17
|
+
export * from './color';
|
|
18
|
+
const CHARTS_WITHOUT_AXIS = ['pie', 'treemap'];
|
|
19
|
+
export const CHART_SERIES_WITH_VOLUME_ON_Y_AXIS = [
|
|
20
|
+
'bar-x',
|
|
21
|
+
'area',
|
|
22
|
+
'waterfall',
|
|
23
|
+
];
|
|
24
|
+
export const CHART_SERIES_WITH_VOLUME_ON_X_AXIS = ['bar-y'];
|
|
25
|
+
/**
|
|
26
|
+
* Checks whether the series should be drawn with axes.
|
|
27
|
+
*
|
|
28
|
+
* @param series - The series object to check.
|
|
29
|
+
* @returns `true` if the series should be drawn with axes, `false` otherwise.
|
|
30
|
+
*/
|
|
31
|
+
export function isAxisRelatedSeries(series) {
|
|
32
|
+
return !CHARTS_WITHOUT_AXIS.includes(series.type);
|
|
33
|
+
}
|
|
34
|
+
export function isSeriesWithNumericalXValues(series) {
|
|
35
|
+
return isAxisRelatedSeries(series);
|
|
36
|
+
}
|
|
37
|
+
export function isSeriesWithNumericalYValues(series) {
|
|
38
|
+
return isAxisRelatedSeries(series);
|
|
39
|
+
}
|
|
40
|
+
export function isSeriesWithCategoryValues(series) {
|
|
41
|
+
return isAxisRelatedSeries(series);
|
|
42
|
+
}
|
|
43
|
+
function getDomainDataForStackedSeries(seriesList, keyAttr = 'x', valueAttr = 'y') {
|
|
44
|
+
const acc = [];
|
|
45
|
+
const stackedSeries = group(seriesList, getSeriesStackId);
|
|
46
|
+
Array.from(stackedSeries).forEach(([_stackId, seriesStack]) => {
|
|
47
|
+
const values = {};
|
|
48
|
+
seriesStack.forEach((singleSeries) => {
|
|
49
|
+
const data = new Map();
|
|
50
|
+
singleSeries.data.forEach((point) => {
|
|
51
|
+
const key = String(point[keyAttr]);
|
|
52
|
+
let value = 0;
|
|
53
|
+
if (valueAttr in point && typeof point[valueAttr] === 'number') {
|
|
54
|
+
value = point[valueAttr];
|
|
55
|
+
}
|
|
56
|
+
if (data.has(key)) {
|
|
57
|
+
value = Math.max(value, data.get(key));
|
|
58
|
+
}
|
|
59
|
+
data.set(key, value);
|
|
60
|
+
});
|
|
61
|
+
Array.from(data).forEach(([key, value]) => {
|
|
62
|
+
values[key] = (values[key] || 0) + value;
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
acc.push(...Object.values(values));
|
|
66
|
+
});
|
|
67
|
+
return acc;
|
|
68
|
+
}
|
|
69
|
+
export const getDomainDataXBySeries = (series) => {
|
|
70
|
+
const groupedSeries = group(series, (item) => item.type);
|
|
71
|
+
return Array.from(groupedSeries).reduce((acc, [type, seriesList]) => {
|
|
72
|
+
switch (type) {
|
|
73
|
+
case 'bar-y': {
|
|
74
|
+
acc.push(...getDomainDataForStackedSeries(seriesList, 'y', 'x'));
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
default: {
|
|
78
|
+
seriesList.filter(isSeriesWithNumericalXValues).forEach((s) => {
|
|
79
|
+
acc.push(...s.data.map((d) => d.x));
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return acc;
|
|
84
|
+
}, []);
|
|
85
|
+
};
|
|
86
|
+
export function getDefaultMaxXAxisValue(series) {
|
|
87
|
+
if (series.some((s) => s.type === 'bar-y')) {
|
|
88
|
+
return 0;
|
|
89
|
+
}
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
export const getDomainDataYBySeries = (series) => {
|
|
93
|
+
const groupedSeries = group(series, (item) => item.type);
|
|
94
|
+
return Array.from(groupedSeries).reduce((acc, [type, seriesList]) => {
|
|
95
|
+
switch (type) {
|
|
96
|
+
case 'area':
|
|
97
|
+
case 'bar-x': {
|
|
98
|
+
acc.push(...getDomainDataForStackedSeries(seriesList));
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
case 'waterfall': {
|
|
102
|
+
let yValue = 0;
|
|
103
|
+
seriesList.forEach((s) => {
|
|
104
|
+
s.data.forEach((d) => {
|
|
105
|
+
yValue += Number(d.y) || 0;
|
|
106
|
+
acc.push(yValue);
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
default: {
|
|
112
|
+
seriesList.filter(isSeriesWithNumericalYValues).forEach((s) => {
|
|
113
|
+
acc.push(...s.data.map((d) => d.y));
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return acc;
|
|
118
|
+
}, []);
|
|
119
|
+
};
|
|
120
|
+
// Uses to get all series names array (except `pie` charts)
|
|
121
|
+
export const getSeriesNames = (series) => {
|
|
122
|
+
return series.reduce((acc, s) => {
|
|
123
|
+
if ('name' in s && typeof s.name === 'string') {
|
|
124
|
+
acc.push(s.name);
|
|
125
|
+
}
|
|
126
|
+
return acc;
|
|
127
|
+
}, []);
|
|
128
|
+
};
|
|
129
|
+
export const getOnlyVisibleSeries = (series) => {
|
|
130
|
+
return series.filter((s) => s.visible);
|
|
131
|
+
};
|
|
132
|
+
export const parseTransformStyle = (style) => {
|
|
133
|
+
var _a;
|
|
134
|
+
if (!style) {
|
|
135
|
+
return {};
|
|
136
|
+
}
|
|
137
|
+
const stringifiedValue = ((_a = style.match(/\((.*?)\)/)) === null || _a === void 0 ? void 0 : _a[1]) || '';
|
|
138
|
+
const [xString, yString] = stringifiedValue.split(',');
|
|
139
|
+
const x = Number.isNaN(Number(xString)) ? undefined : Number(xString);
|
|
140
|
+
const y = Number.isNaN(Number(yString)) ? undefined : Number(yString);
|
|
141
|
+
return { x, y };
|
|
142
|
+
};
|
|
143
|
+
export const formatAxisTickLabel = (args) => {
|
|
144
|
+
const { axis, value, step } = args;
|
|
145
|
+
switch (axis.type) {
|
|
146
|
+
case 'category': {
|
|
147
|
+
return value;
|
|
148
|
+
}
|
|
149
|
+
case 'datetime': {
|
|
150
|
+
const date = value;
|
|
151
|
+
const format = axis.labels.dateFormat || getDefaultDateFormat(step);
|
|
152
|
+
return dateTime({ input: date }).format(format);
|
|
153
|
+
}
|
|
154
|
+
case 'linear':
|
|
155
|
+
default: {
|
|
156
|
+
const numberFormat = Object.assign({ unitRate: value && step ? getNumberUnitRate(step) : undefined }, axis.labels.numberFormat);
|
|
157
|
+
return formatNumber(value, numberFormat);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
/**
|
|
162
|
+
* Calculates the height of a text element in a horizontal SVG layout.
|
|
163
|
+
*
|
|
164
|
+
* @param {Object} args - The arguments for the function.
|
|
165
|
+
* @param {string} args.text - The text to be measured.
|
|
166
|
+
* @param {Partial<BaseTextStyle>} args.style - Optional style properties for the text element.
|
|
167
|
+
* @return {number} The height of the text element.
|
|
168
|
+
*/
|
|
169
|
+
export const getHorisontalSvgTextHeight = (args) => {
|
|
170
|
+
var _a;
|
|
171
|
+
const { text, style } = args;
|
|
172
|
+
const container = select(document.body).append('svg');
|
|
173
|
+
const textSelection = container.append('text').text(text);
|
|
174
|
+
const fontSize = get(style, 'fontSize', DEFAULT_AXIS_LABEL_FONT_SIZE);
|
|
175
|
+
if (fontSize) {
|
|
176
|
+
textSelection.style('font-size', fontSize).style('alignment-baseline', 'after-edge');
|
|
177
|
+
}
|
|
178
|
+
const height = ((_a = textSelection.node()) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().height) || 0;
|
|
179
|
+
container.remove();
|
|
180
|
+
return height;
|
|
181
|
+
};
|
|
182
|
+
const extractCategoryValue = (args) => {
|
|
183
|
+
const { axisDirection, categories, data } = args;
|
|
184
|
+
const dataCategory = get(data, axisDirection);
|
|
185
|
+
let categoryValue;
|
|
186
|
+
if ('category' in data && data.category) {
|
|
187
|
+
categoryValue = data.category;
|
|
188
|
+
}
|
|
189
|
+
if (typeof dataCategory === 'string') {
|
|
190
|
+
categoryValue = dataCategory;
|
|
191
|
+
}
|
|
192
|
+
if (typeof dataCategory === 'number') {
|
|
193
|
+
categoryValue = categories[dataCategory];
|
|
194
|
+
}
|
|
195
|
+
if (isNil(categoryValue)) {
|
|
196
|
+
throw new Error('It seems you are trying to get non-existing category value');
|
|
197
|
+
}
|
|
198
|
+
return categoryValue;
|
|
199
|
+
};
|
|
200
|
+
export const getDataCategoryValue = (args) => {
|
|
201
|
+
const { axisDirection, categories, data } = args;
|
|
202
|
+
const categoryValue = extractCategoryValue({ axisDirection, categories, data });
|
|
203
|
+
return categoryValue;
|
|
204
|
+
};
|
|
205
|
+
export function getClosestPointsRange(axis, points) {
|
|
206
|
+
if (axis.type === 'category') {
|
|
207
|
+
return undefined;
|
|
208
|
+
}
|
|
209
|
+
return points[1] - points[0];
|
|
210
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { LabelData } from '../../types';
|
|
2
|
+
export declare function getLeftPosition(label: LabelData): number;
|
|
3
|
+
export declare function getOverlappingByX(rect1: LabelData, rect2: LabelData, gap?: number): number;
|
|
4
|
+
export declare function getOverlappingByY(rect1: LabelData, rect2: LabelData, gap?: number): number;
|
|
5
|
+
export declare function isLabelsOverlapping<T extends LabelData>(label1: T, label2: T, padding?: number): boolean;
|
|
6
|
+
export declare function filterOverlappingLabels<T extends LabelData>(labels: T[]): T[];
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import sortBy from 'lodash/sortBy';
|
|
2
|
+
export function getLeftPosition(label) {
|
|
3
|
+
switch (label.textAnchor) {
|
|
4
|
+
case 'start': {
|
|
5
|
+
return label.x;
|
|
6
|
+
}
|
|
7
|
+
case 'middle': {
|
|
8
|
+
return label.x - label.size.width / 2;
|
|
9
|
+
}
|
|
10
|
+
case 'end': {
|
|
11
|
+
return label.x - label.size.width;
|
|
12
|
+
}
|
|
13
|
+
default: {
|
|
14
|
+
return label.x;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export function getOverlappingByX(rect1, rect2, gap = 0) {
|
|
19
|
+
const left1 = getLeftPosition(rect1);
|
|
20
|
+
const right1 = left1 + rect1.size.width;
|
|
21
|
+
const left2 = getLeftPosition(rect2);
|
|
22
|
+
const right2 = left2 + rect2.size.width;
|
|
23
|
+
return Math.max(0, Math.min(right1, right2) - Math.max(left1, left2) + gap);
|
|
24
|
+
}
|
|
25
|
+
export function getOverlappingByY(rect1, rect2, gap = 0) {
|
|
26
|
+
const top1 = rect1.y - rect1.size.height;
|
|
27
|
+
const bottom1 = rect1.y;
|
|
28
|
+
const top2 = rect2.y - rect2.size.height;
|
|
29
|
+
const bottom2 = rect2.y;
|
|
30
|
+
return Math.max(0, Math.min(bottom1, bottom2) - Math.max(top1, top2) + gap);
|
|
31
|
+
}
|
|
32
|
+
export function isLabelsOverlapping(label1, label2, padding = 0) {
|
|
33
|
+
return Boolean(getOverlappingByX(label1, label2, padding) && getOverlappingByY(label1, label2, padding));
|
|
34
|
+
}
|
|
35
|
+
export function filterOverlappingLabels(labels) {
|
|
36
|
+
const result = [];
|
|
37
|
+
const sorted = sortBy(labels, (d) => d.y, getLeftPosition);
|
|
38
|
+
sorted.forEach((label) => {
|
|
39
|
+
if (!result.some((l) => isLabelsOverlapping(label, l))) {
|
|
40
|
+
result.push(label);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Selection } from 'd3';
|
|
2
|
+
export declare function createGradientRect(container: Selection<SVGGElement, unknown, null, undefined>, args: {
|
|
3
|
+
x?: number;
|
|
4
|
+
y?: number;
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
interpolator: (value: number) => string;
|
|
8
|
+
}): Selection<SVGImageElement, unknown, null, undefined>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export function createGradientRect(container, args) {
|
|
2
|
+
const { x = 0, y = 0, width, height, interpolator } = args;
|
|
3
|
+
const n = 256;
|
|
4
|
+
const canvas = document.createElement('canvas');
|
|
5
|
+
canvas.width = n;
|
|
6
|
+
canvas.height = 1;
|
|
7
|
+
const context = canvas.getContext('2d');
|
|
8
|
+
if (!context) {
|
|
9
|
+
throw Error("Couldn't get canvas context");
|
|
10
|
+
}
|
|
11
|
+
for (let i = 0, j = n - 1; i < n; ++i) {
|
|
12
|
+
context.fillStyle = interpolator(i / j);
|
|
13
|
+
context.fillRect(i, 0, 1, height);
|
|
14
|
+
}
|
|
15
|
+
return container
|
|
16
|
+
.append('image')
|
|
17
|
+
.attr('preserveAspectRatio', 'none')
|
|
18
|
+
.attr('height', height)
|
|
19
|
+
.attr('width', width)
|
|
20
|
+
.attr('x', x)
|
|
21
|
+
.attr('y', y)
|
|
22
|
+
.attr('xlink:href', canvas.toDataURL());
|
|
23
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculates a numeric property based on the given arguments.
|
|
3
|
+
*
|
|
4
|
+
* @param {Object} args - The arguments for the calculation.
|
|
5
|
+
* @param {string | number | null} args.value - The value to calculate the property for.
|
|
6
|
+
* @param {number} args.base - The base value to use in the calculation.
|
|
7
|
+
* @return {number | undefined} The calculated numeric property, or undefined if the value is invalid.
|
|
8
|
+
* @example
|
|
9
|
+
* const result1 = calculateNumericProperty({value: 1});
|
|
10
|
+
* console.log(result1); // Output: 1
|
|
11
|
+
* const result2 = calculateNumericProperty({value: '10px'});
|
|
12
|
+
* console.log(result2); // Output: 10
|
|
13
|
+
* const result3 = calculateNumericProperty({value: '50%', base: 200});
|
|
14
|
+
* console.log(result3); // Output: 100
|
|
15
|
+
* const result4 = calculateNumericProperty({value: '50%'});
|
|
16
|
+
* console.log(result4); // Output: undefined
|
|
17
|
+
* const result5 = calculateNumericProperty({value: 'invalid_value'});
|
|
18
|
+
* console.log(result5); // Output: undefined
|
|
19
|
+
*/
|
|
20
|
+
export declare const calculateNumericProperty: (args: {
|
|
21
|
+
value?: string | number | null;
|
|
22
|
+
base?: number;
|
|
23
|
+
}) => number | undefined;
|
|
24
|
+
export declare function calculateCos(deg: number, precision?: number): number;
|
|
25
|
+
export declare function calculateSin(deg: number, precision?: number): number;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import isNil from 'lodash/isNil';
|
|
2
|
+
const isStringValueInPercent = (value = '') => {
|
|
3
|
+
return value.endsWith('%') && !Number.isNaN(Number.parseFloat(value));
|
|
4
|
+
};
|
|
5
|
+
const isStringValueInPixel = (value = '') => {
|
|
6
|
+
return value.endsWith('px') && !Number.isNaN(Number.parseFloat(value));
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Calculates a numeric property based on the given arguments.
|
|
10
|
+
*
|
|
11
|
+
* @param {Object} args - The arguments for the calculation.
|
|
12
|
+
* @param {string | number | null} args.value - The value to calculate the property for.
|
|
13
|
+
* @param {number} args.base - The base value to use in the calculation.
|
|
14
|
+
* @return {number | undefined} The calculated numeric property, or undefined if the value is invalid.
|
|
15
|
+
* @example
|
|
16
|
+
* const result1 = calculateNumericProperty({value: 1});
|
|
17
|
+
* console.log(result1); // Output: 1
|
|
18
|
+
* const result2 = calculateNumericProperty({value: '10px'});
|
|
19
|
+
* console.log(result2); // Output: 10
|
|
20
|
+
* const result3 = calculateNumericProperty({value: '50%', base: 200});
|
|
21
|
+
* console.log(result3); // Output: 100
|
|
22
|
+
* const result4 = calculateNumericProperty({value: '50%'});
|
|
23
|
+
* console.log(result4); // Output: undefined
|
|
24
|
+
* const result5 = calculateNumericProperty({value: 'invalid_value'});
|
|
25
|
+
* console.log(result5); // Output: undefined
|
|
26
|
+
*/
|
|
27
|
+
export const calculateNumericProperty = (args) => {
|
|
28
|
+
const { value = '', base } = args;
|
|
29
|
+
if (isNil(value)) {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
if (typeof value === 'string') {
|
|
33
|
+
if (isStringValueInPercent(value) && typeof base === 'number') {
|
|
34
|
+
const fraction = Number.parseFloat(value) / 100;
|
|
35
|
+
return base * fraction;
|
|
36
|
+
}
|
|
37
|
+
if (isStringValueInPixel(value)) {
|
|
38
|
+
return Number.parseFloat(value);
|
|
39
|
+
}
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
return value;
|
|
43
|
+
};
|
|
44
|
+
export function calculateCos(deg, precision = 2) {
|
|
45
|
+
const factor = Math.pow(10, precision);
|
|
46
|
+
return Math.floor(Math.cos((Math.PI / 180) * deg) * factor) / factor;
|
|
47
|
+
}
|
|
48
|
+
export function calculateSin(deg, precision = 2) {
|
|
49
|
+
const factor = Math.pow(10, precision);
|
|
50
|
+
return Math.floor(Math.sin((Math.PI / 180) * deg) * factor) / factor;
|
|
51
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './waterfall';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './waterfall';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { PreparedWaterfallSeries } from '../../../hooks';
|
|
2
|
+
import type { WaterfallSeriesData } from '../../../types';
|
|
3
|
+
export declare function getWaterfallPointColor(point: WaterfallSeriesData, series: PreparedWaterfallSeries): string;
|
|
4
|
+
export declare function getWaterfallPointSubtotal(point: WaterfallSeriesData, series: PreparedWaterfallSeries): number | null;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export function getWaterfallPointColor(point, series) {
|
|
2
|
+
if (point.color) {
|
|
3
|
+
return point.color;
|
|
4
|
+
}
|
|
5
|
+
if (point.total) {
|
|
6
|
+
return series.color;
|
|
7
|
+
}
|
|
8
|
+
if (Number(point.y) > 0) {
|
|
9
|
+
return series.positiveColor;
|
|
10
|
+
}
|
|
11
|
+
return series.negativeColor;
|
|
12
|
+
}
|
|
13
|
+
export function getWaterfallPointSubtotal(point, series) {
|
|
14
|
+
const pointIndex = series.data.indexOf(point);
|
|
15
|
+
if (pointIndex === -1) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
return series.data.reduce((sum, d, index) => {
|
|
19
|
+
if (index <= pointIndex) {
|
|
20
|
+
const value = d.total ? 0 : Number(d.y);
|
|
21
|
+
return sum + value;
|
|
22
|
+
}
|
|
23
|
+
return sum;
|
|
24
|
+
}, 0);
|
|
25
|
+
}
|