@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,154 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { group } from 'd3';
|
|
3
|
+
import { getOnlyVisibleSeries } from '../../utils';
|
|
4
|
+
import { AreaSeriesShapes } from './area';
|
|
5
|
+
import { prepareAreaData } from './area/prepare-data';
|
|
6
|
+
import { BarXSeriesShapes, prepareBarXData } from './bar-x';
|
|
7
|
+
import { BarYSeriesShapes, prepareBarYData } from './bar-y';
|
|
8
|
+
import { LineSeriesShapes } from './line';
|
|
9
|
+
import { prepareLineData } from './line/prepare-data';
|
|
10
|
+
import { PieSeriesShapes } from './pie';
|
|
11
|
+
import { preparePieData } from './pie/prepare-data';
|
|
12
|
+
import { ScatterSeriesShape, prepareScatterData } from './scatter';
|
|
13
|
+
import { TreemapSeriesShape } from './treemap';
|
|
14
|
+
import { prepareTreemapData } from './treemap/prepare-data';
|
|
15
|
+
import { WaterfallSeriesShapes, prepareWaterfallData } from './waterfall';
|
|
16
|
+
import './styles.css';
|
|
17
|
+
export const useShapes = (args) => {
|
|
18
|
+
const { boundsWidth, boundsHeight, dispatcher, series, seriesOptions, xAxis, xScale, yAxis, yScale, split, htmlLayout, } = args;
|
|
19
|
+
const shapesComponents = React.useMemo(() => {
|
|
20
|
+
const visibleSeries = getOnlyVisibleSeries(series);
|
|
21
|
+
const groupedSeries = group(visibleSeries, (item) => item.type);
|
|
22
|
+
const shapesData = [];
|
|
23
|
+
// eslint-disable-next-line complexity
|
|
24
|
+
const shapes = Array.from(groupedSeries).reduce((acc, item) => {
|
|
25
|
+
const [seriesType, chartSeries] = item;
|
|
26
|
+
switch (seriesType) {
|
|
27
|
+
case 'bar-x': {
|
|
28
|
+
if (xScale && yScale) {
|
|
29
|
+
const preparedData = prepareBarXData({
|
|
30
|
+
series: chartSeries,
|
|
31
|
+
seriesOptions,
|
|
32
|
+
xAxis,
|
|
33
|
+
xScale,
|
|
34
|
+
yAxis,
|
|
35
|
+
yScale,
|
|
36
|
+
boundsHeight,
|
|
37
|
+
});
|
|
38
|
+
acc.push(React.createElement(BarXSeriesShapes, { key: "bar-x", dispatcher: dispatcher, seriesOptions: seriesOptions, preparedData: preparedData, htmlLayout: htmlLayout }));
|
|
39
|
+
shapesData.push(...preparedData);
|
|
40
|
+
}
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
case 'bar-y': {
|
|
44
|
+
if (xScale && yScale) {
|
|
45
|
+
const preparedData = prepareBarYData({
|
|
46
|
+
series: chartSeries,
|
|
47
|
+
seriesOptions,
|
|
48
|
+
xAxis,
|
|
49
|
+
xScale,
|
|
50
|
+
yAxis,
|
|
51
|
+
yScale,
|
|
52
|
+
});
|
|
53
|
+
acc.push(React.createElement(BarYSeriesShapes, { key: "bar-y", dispatcher: dispatcher, seriesOptions: seriesOptions, preparedData: preparedData, htmlLayout: htmlLayout }));
|
|
54
|
+
shapesData.push(...preparedData);
|
|
55
|
+
}
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
case 'waterfall': {
|
|
59
|
+
if (xScale && yScale) {
|
|
60
|
+
const preparedData = prepareWaterfallData({
|
|
61
|
+
series: chartSeries,
|
|
62
|
+
seriesOptions,
|
|
63
|
+
xAxis,
|
|
64
|
+
xScale,
|
|
65
|
+
yAxis,
|
|
66
|
+
yScale,
|
|
67
|
+
});
|
|
68
|
+
acc.push(React.createElement(WaterfallSeriesShapes, { key: "waterfall", dispatcher: dispatcher, seriesOptions: seriesOptions, preparedData: preparedData, htmlLayout: htmlLayout }));
|
|
69
|
+
shapesData.push(...preparedData);
|
|
70
|
+
}
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
case 'line': {
|
|
74
|
+
if (xScale && yScale) {
|
|
75
|
+
const preparedData = prepareLineData({
|
|
76
|
+
series: chartSeries,
|
|
77
|
+
xAxis,
|
|
78
|
+
xScale,
|
|
79
|
+
yAxis,
|
|
80
|
+
yScale,
|
|
81
|
+
split,
|
|
82
|
+
});
|
|
83
|
+
acc.push(React.createElement(LineSeriesShapes, { key: "line", dispatcher: dispatcher, seriesOptions: seriesOptions, preparedData: preparedData, htmlLayout: htmlLayout }));
|
|
84
|
+
shapesData.push(...preparedData);
|
|
85
|
+
}
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
case 'area': {
|
|
89
|
+
if (xScale && yScale) {
|
|
90
|
+
const preparedData = prepareAreaData({
|
|
91
|
+
series: chartSeries,
|
|
92
|
+
xAxis,
|
|
93
|
+
xScale,
|
|
94
|
+
yAxis,
|
|
95
|
+
yScale,
|
|
96
|
+
boundsHeight,
|
|
97
|
+
});
|
|
98
|
+
acc.push(React.createElement(AreaSeriesShapes, { key: "area", dispatcher: dispatcher, seriesOptions: seriesOptions, preparedData: preparedData, htmlLayout: htmlLayout }));
|
|
99
|
+
shapesData.push(...preparedData);
|
|
100
|
+
}
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
case 'scatter': {
|
|
104
|
+
if (xScale && yScale) {
|
|
105
|
+
const preparedData = prepareScatterData({
|
|
106
|
+
series: chartSeries,
|
|
107
|
+
xAxis,
|
|
108
|
+
xScale,
|
|
109
|
+
yAxis,
|
|
110
|
+
yScale,
|
|
111
|
+
});
|
|
112
|
+
acc.push(React.createElement(ScatterSeriesShape, { key: "scatter", dispatcher: dispatcher, preparedData: preparedData, seriesOptions: seriesOptions, htmlLayout: htmlLayout }));
|
|
113
|
+
shapesData.push(...preparedData);
|
|
114
|
+
}
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
case 'pie': {
|
|
118
|
+
const preparedData = preparePieData({
|
|
119
|
+
series: chartSeries,
|
|
120
|
+
boundsWidth,
|
|
121
|
+
boundsHeight,
|
|
122
|
+
});
|
|
123
|
+
acc.push(React.createElement(PieSeriesShapes, { key: "pie", dispatcher: dispatcher, preparedData: preparedData, seriesOptions: seriesOptions, htmlLayout: htmlLayout }));
|
|
124
|
+
shapesData.push(...preparedData);
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
case 'treemap': {
|
|
128
|
+
const preparedData = prepareTreemapData({
|
|
129
|
+
// We should have exactly one series with "treemap" type
|
|
130
|
+
// Otherwise data validation should emit an error
|
|
131
|
+
series: chartSeries[0],
|
|
132
|
+
width: boundsWidth,
|
|
133
|
+
height: boundsHeight,
|
|
134
|
+
});
|
|
135
|
+
acc.push(React.createElement(TreemapSeriesShape, { key: "treemap", dispatcher: dispatcher, preparedData: preparedData, seriesOptions: seriesOptions, htmlLayout: htmlLayout }));
|
|
136
|
+
shapesData.push(preparedData);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return acc;
|
|
140
|
+
}, []);
|
|
141
|
+
return { shapes, shapesData };
|
|
142
|
+
}, [
|
|
143
|
+
boundsWidth,
|
|
144
|
+
boundsHeight,
|
|
145
|
+
dispatcher,
|
|
146
|
+
series,
|
|
147
|
+
seriesOptions,
|
|
148
|
+
xAxis,
|
|
149
|
+
xScale,
|
|
150
|
+
yAxis,
|
|
151
|
+
yScale,
|
|
152
|
+
]);
|
|
153
|
+
return { shapes: shapesComponents.shapes, shapesData: shapesComponents.shapesData };
|
|
154
|
+
};
|
|
@@ -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 { PreparedLineData } from './types';
|
|
5
|
+
type Args = {
|
|
6
|
+
dispatcher: Dispatch<object>;
|
|
7
|
+
preparedData: PreparedLineData[];
|
|
8
|
+
seriesOptions: PreparedSeriesOptions;
|
|
9
|
+
htmlLayout: HTMLElement | null;
|
|
10
|
+
};
|
|
11
|
+
export declare const LineSeriesShapes: (args: Args) => React.JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { color, line as lineGenerator, select } from 'd3';
|
|
3
|
+
import get from 'lodash/get';
|
|
4
|
+
import { block, filterOverlappingLabels } from '../../../utils';
|
|
5
|
+
import { HtmlLayer } from '../HtmlLayer';
|
|
6
|
+
import { getMarkerHaloVisibility, getMarkerVisibility, renderMarker, selectMarkerHalo, selectMarkerSymbol, setMarker, } from '../marker';
|
|
7
|
+
import { getLineDashArray, setActiveState } from '../utils';
|
|
8
|
+
const b = block('d3-line');
|
|
9
|
+
export const LineSeriesShapes = (args) => {
|
|
10
|
+
const { dispatcher, preparedData, seriesOptions, htmlLayout } = args;
|
|
11
|
+
const ref = React.useRef(null);
|
|
12
|
+
React.useEffect(() => {
|
|
13
|
+
var _a;
|
|
14
|
+
if (!ref.current) {
|
|
15
|
+
return () => { };
|
|
16
|
+
}
|
|
17
|
+
const svgElement = select(ref.current);
|
|
18
|
+
const hoverOptions = get(seriesOptions, 'line.states.hover');
|
|
19
|
+
const inactiveOptions = get(seriesOptions, 'line.states.inactive');
|
|
20
|
+
const line = lineGenerator()
|
|
21
|
+
.x((d) => d.x)
|
|
22
|
+
.y((d) => d.y);
|
|
23
|
+
svgElement.selectAll('*').remove();
|
|
24
|
+
const lineSelection = svgElement
|
|
25
|
+
.selectAll('path')
|
|
26
|
+
.data(preparedData)
|
|
27
|
+
.join('path')
|
|
28
|
+
.attr('d', (d) => line(d.points))
|
|
29
|
+
.attr('fill', 'none')
|
|
30
|
+
.attr('stroke', (d) => d.color)
|
|
31
|
+
.attr('stroke-width', (d) => d.width)
|
|
32
|
+
.attr('stroke-linejoin', (d) => d.linecap)
|
|
33
|
+
.attr('stroke-linecap', (d) => d.linecap)
|
|
34
|
+
.attr('stroke-dasharray', (d) => getLineDashArray(d.dashStyle, d.width))
|
|
35
|
+
.attr('opacity', (d) => d.opacity)
|
|
36
|
+
.attr('cursor', (d) => d.series.cursor);
|
|
37
|
+
let dataLabels = preparedData.reduce((acc, d) => {
|
|
38
|
+
return acc.concat(d.labels);
|
|
39
|
+
}, []);
|
|
40
|
+
if (!((_a = preparedData[0]) === null || _a === void 0 ? void 0 : _a.series.dataLabels.allowOverlap)) {
|
|
41
|
+
dataLabels = filterOverlappingLabels(dataLabels);
|
|
42
|
+
}
|
|
43
|
+
const labelsSelection = svgElement
|
|
44
|
+
.selectAll('text')
|
|
45
|
+
.data(dataLabels)
|
|
46
|
+
.join('text')
|
|
47
|
+
.text((d) => d.text)
|
|
48
|
+
.attr('class', b('label'))
|
|
49
|
+
.attr('x', (d) => d.x)
|
|
50
|
+
.attr('y', (d) => d.y)
|
|
51
|
+
.attr('text-anchor', (d) => d.textAnchor)
|
|
52
|
+
.style('font-size', (d) => d.style.fontSize)
|
|
53
|
+
.style('font-weight', (d) => d.style.fontWeight || null)
|
|
54
|
+
.style('fill', (d) => d.style.fontColor || null);
|
|
55
|
+
const markers = preparedData.reduce((acc, d) => acc.concat(d.markers), []);
|
|
56
|
+
const markerSelection = svgElement
|
|
57
|
+
.selectAll('marker')
|
|
58
|
+
.data(markers)
|
|
59
|
+
.join('g')
|
|
60
|
+
.call(renderMarker);
|
|
61
|
+
const hoverEnabled = hoverOptions === null || hoverOptions === void 0 ? void 0 : hoverOptions.enabled;
|
|
62
|
+
const inactiveEnabled = inactiveOptions === null || inactiveOptions === void 0 ? void 0 : inactiveOptions.enabled;
|
|
63
|
+
dispatcher.on('hover-shape.line', (data) => {
|
|
64
|
+
const selected = (data === null || data === void 0 ? void 0 : data.filter((d) => d.series.type === 'line')) || [];
|
|
65
|
+
const selectedDataItems = selected.map((d) => d.data);
|
|
66
|
+
const selectedSeriesIds = selected.map((d) => { var _a; return (_a = d.series) === null || _a === void 0 ? void 0 : _a.id; });
|
|
67
|
+
lineSelection.datum((d, index, list) => {
|
|
68
|
+
const elementSelection = select(list[index]);
|
|
69
|
+
const hovered = Boolean(hoverEnabled && selectedSeriesIds.includes(d.id));
|
|
70
|
+
if (d.hovered !== hovered) {
|
|
71
|
+
d.hovered = hovered;
|
|
72
|
+
elementSelection.attr('stroke', (d) => {
|
|
73
|
+
var _a;
|
|
74
|
+
const initialColor = d.color || '';
|
|
75
|
+
if (d.hovered) {
|
|
76
|
+
return (((_a = color(initialColor)) === null || _a === void 0 ? void 0 : _a.brighter(hoverOptions === null || hoverOptions === void 0 ? void 0 : hoverOptions.brightness).toString()) || initialColor);
|
|
77
|
+
}
|
|
78
|
+
return initialColor;
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
return setActiveState({
|
|
82
|
+
element: list[index],
|
|
83
|
+
state: inactiveOptions,
|
|
84
|
+
active: Boolean(!inactiveEnabled ||
|
|
85
|
+
!selectedSeriesIds.length ||
|
|
86
|
+
selectedSeriesIds.includes(d.id)),
|
|
87
|
+
datum: d,
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
labelsSelection.datum((d, index, list) => {
|
|
91
|
+
return setActiveState({
|
|
92
|
+
element: list[index],
|
|
93
|
+
state: inactiveOptions,
|
|
94
|
+
active: Boolean(!inactiveEnabled ||
|
|
95
|
+
!selectedSeriesIds.length ||
|
|
96
|
+
selectedSeriesIds.includes(d.series.id)),
|
|
97
|
+
datum: d,
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
markerSelection.datum((d, index, list) => {
|
|
101
|
+
const elementSelection = select(list[index]);
|
|
102
|
+
const hovered = Boolean(hoverEnabled && selectedDataItems.includes(d.point.data));
|
|
103
|
+
if (d.hovered !== hovered) {
|
|
104
|
+
d.hovered = hovered;
|
|
105
|
+
elementSelection.attr('visibility', getMarkerVisibility(d));
|
|
106
|
+
selectMarkerHalo(elementSelection).attr('visibility', getMarkerHaloVisibility);
|
|
107
|
+
selectMarkerSymbol(elementSelection).call(setMarker, hovered ? 'hover' : 'normal');
|
|
108
|
+
}
|
|
109
|
+
if (d.point.series.marker.states.normal.enabled) {
|
|
110
|
+
const isActive = Boolean(!inactiveEnabled ||
|
|
111
|
+
!selectedSeriesIds.length ||
|
|
112
|
+
selectedSeriesIds.includes(d.point.series.id));
|
|
113
|
+
setActiveState({
|
|
114
|
+
element: list[index],
|
|
115
|
+
state: inactiveOptions,
|
|
116
|
+
active: isActive,
|
|
117
|
+
datum: d,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
return d;
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
return () => {
|
|
124
|
+
dispatcher.on('hover-shape.line', null);
|
|
125
|
+
};
|
|
126
|
+
}, [dispatcher, preparedData, seriesOptions]);
|
|
127
|
+
return (React.createElement(React.Fragment, null,
|
|
128
|
+
React.createElement("g", { ref: ref, className: b() }),
|
|
129
|
+
React.createElement(HtmlLayer, { preparedData: preparedData, htmlLayout: htmlLayout })));
|
|
130
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ChartScale } from '../../useAxisScales';
|
|
2
|
+
import type { PreparedAxis } from '../../useChartOptions/types';
|
|
3
|
+
import type { PreparedLineSeries } from '../../useSeries/types';
|
|
4
|
+
import type { PreparedSplit } from '../../useSplit/types';
|
|
5
|
+
import type { PreparedLineData } from './types';
|
|
6
|
+
export declare const prepareLineData: (args: {
|
|
7
|
+
series: PreparedLineSeries[];
|
|
8
|
+
xAxis: PreparedAxis;
|
|
9
|
+
xScale: ChartScale;
|
|
10
|
+
yAxis: PreparedAxis[];
|
|
11
|
+
yScale: ChartScale[];
|
|
12
|
+
split: PreparedSplit;
|
|
13
|
+
}) => PreparedLineData[];
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { getLabelsSize, getLeftPosition } from '../../../utils';
|
|
2
|
+
import { getXValue, getYValue } from '../utils';
|
|
3
|
+
function getLabelData(point, series, xMax) {
|
|
4
|
+
const text = String(point.data.label || point.data.y);
|
|
5
|
+
const style = series.dataLabels.style;
|
|
6
|
+
const size = getLabelsSize({ labels: [text], style });
|
|
7
|
+
const labelData = {
|
|
8
|
+
text,
|
|
9
|
+
x: point.x,
|
|
10
|
+
y: point.y - series.dataLabels.padding,
|
|
11
|
+
style,
|
|
12
|
+
size: { width: size.maxWidth, height: size.maxHeight },
|
|
13
|
+
textAnchor: 'middle',
|
|
14
|
+
series: series,
|
|
15
|
+
active: true,
|
|
16
|
+
};
|
|
17
|
+
const left = getLeftPosition(labelData);
|
|
18
|
+
if (left < 0) {
|
|
19
|
+
labelData.x = labelData.x + Math.abs(left);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
const right = left + labelData.size.width;
|
|
23
|
+
if (right > xMax) {
|
|
24
|
+
labelData.x = labelData.x - xMax - right;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return labelData;
|
|
28
|
+
}
|
|
29
|
+
function getHtmlLabel(point, series, xMax) {
|
|
30
|
+
const content = String(point.data.label || point.data.y);
|
|
31
|
+
const size = getLabelsSize({ labels: [content], html: true });
|
|
32
|
+
return {
|
|
33
|
+
x: Math.min(xMax - size.maxWidth, Math.max(0, point.x)),
|
|
34
|
+
y: Math.max(0, point.y - series.dataLabels.padding - size.maxHeight),
|
|
35
|
+
content,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export const prepareLineData = (args) => {
|
|
39
|
+
const { series, xAxis, yAxis, xScale, yScale, split } = args;
|
|
40
|
+
const [_xMin, xRangeMax] = xScale.range();
|
|
41
|
+
const xMax = xRangeMax / (1 - xAxis.maxPadding);
|
|
42
|
+
return series.reduce((acc, s) => {
|
|
43
|
+
var _a;
|
|
44
|
+
const yAxisIndex = s.yAxis;
|
|
45
|
+
const seriesYAxis = yAxis[yAxisIndex];
|
|
46
|
+
const yAxisTop = ((_a = split.plots[seriesYAxis.plotIndex]) === null || _a === void 0 ? void 0 : _a.top) || 0;
|
|
47
|
+
const seriesYScale = yScale[s.yAxis];
|
|
48
|
+
const points = s.data.map((d) => ({
|
|
49
|
+
x: getXValue({ point: d, xAxis, xScale }),
|
|
50
|
+
y: yAxisTop + getYValue({ point: d, yAxis: seriesYAxis, yScale: seriesYScale }),
|
|
51
|
+
active: true,
|
|
52
|
+
data: d,
|
|
53
|
+
series: s,
|
|
54
|
+
}));
|
|
55
|
+
const htmlElements = [];
|
|
56
|
+
let labels = [];
|
|
57
|
+
if (s.dataLabels.enabled) {
|
|
58
|
+
if (s.dataLabels.html) {
|
|
59
|
+
htmlElements.push(...points.map((p) => getHtmlLabel(p, s, xMax)));
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
labels = points.map((p) => getLabelData(p, s, xMax));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
let markers = [];
|
|
66
|
+
if (s.marker.states.normal.enabled || s.marker.states.hover.enabled) {
|
|
67
|
+
markers = points.map((p) => ({
|
|
68
|
+
point: p,
|
|
69
|
+
active: true,
|
|
70
|
+
hovered: false,
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
73
|
+
const result = {
|
|
74
|
+
points,
|
|
75
|
+
markers,
|
|
76
|
+
labels,
|
|
77
|
+
color: s.color,
|
|
78
|
+
width: s.lineWidth,
|
|
79
|
+
series: s,
|
|
80
|
+
hovered: false,
|
|
81
|
+
active: true,
|
|
82
|
+
id: s.id,
|
|
83
|
+
dashStyle: s.dashStyle,
|
|
84
|
+
linecap: s.linecap,
|
|
85
|
+
opacity: s.opacity,
|
|
86
|
+
htmlElements,
|
|
87
|
+
};
|
|
88
|
+
acc.push(result);
|
|
89
|
+
return acc;
|
|
90
|
+
}, []);
|
|
91
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { DashStyle, LineCap } from '../../../constants';
|
|
2
|
+
import type { HtmlItem, LabelData, LineSeriesData } from '../../../types';
|
|
3
|
+
import type { PreparedLineSeries } from '../../useSeries/types';
|
|
4
|
+
export type PointData = {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
data: LineSeriesData;
|
|
8
|
+
series: PreparedLineSeries;
|
|
9
|
+
};
|
|
10
|
+
export type MarkerData = {
|
|
11
|
+
point: PointData;
|
|
12
|
+
active: boolean;
|
|
13
|
+
hovered: boolean;
|
|
14
|
+
};
|
|
15
|
+
export type PreparedLineData = {
|
|
16
|
+
id: string;
|
|
17
|
+
points: PointData[];
|
|
18
|
+
markers: MarkerData[];
|
|
19
|
+
color: string;
|
|
20
|
+
width: number;
|
|
21
|
+
series: PreparedLineSeries;
|
|
22
|
+
hovered: boolean;
|
|
23
|
+
active: boolean;
|
|
24
|
+
labels: LabelData[];
|
|
25
|
+
dashStyle: DashStyle;
|
|
26
|
+
linecap: LineCap;
|
|
27
|
+
opacity: number | null;
|
|
28
|
+
htmlElements: HtmlItem[];
|
|
29
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { BaseType, Selection } from 'd3';
|
|
2
|
+
import { SymbolType } from '../../constants';
|
|
3
|
+
import type { MarkerData as AreaMarkerData } from './area/types';
|
|
4
|
+
import type { MarkerData as LineMarkerData } from './line/types';
|
|
5
|
+
import type { MarkerData as ScatterMarkerData } from './scatter/types';
|
|
6
|
+
type MarkerData = LineMarkerData | AreaMarkerData | ScatterMarkerData;
|
|
7
|
+
export declare function renderMarker<T extends MarkerData>(selection: Selection<BaseType | SVGGElement, T, SVGGElement, unknown>): Selection<BaseType | SVGGElement, T, SVGGElement, unknown>;
|
|
8
|
+
export declare function getMarkerVisibility(d: MarkerData): "" | "hidden";
|
|
9
|
+
export declare function getMarkerHaloVisibility(d: MarkerData): "" | "hidden";
|
|
10
|
+
export declare function setMarker<T extends BaseType, D extends MarkerData>(selection: Selection<T, D, BaseType | null, unknown>, state: 'normal' | 'hover'): void;
|
|
11
|
+
export declare function getMarkerSymbol(type: `${SymbolType}` | undefined, radius: number): string | null;
|
|
12
|
+
export declare function selectMarkerHalo<T>(parentSelection: Selection<BaseType, T, null, undefined>): Selection<BaseType, T, null, undefined>;
|
|
13
|
+
export declare function selectMarkerSymbol<T>(parentSelection: Selection<BaseType, T, null, undefined>): Selection<BaseType, T, null, undefined>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { symbol } from 'd3';
|
|
2
|
+
import get from 'lodash/get';
|
|
3
|
+
import { SymbolType } from '../../constants';
|
|
4
|
+
import { block, getSymbol } from '../../utils';
|
|
5
|
+
const b = block('d3-marker');
|
|
6
|
+
const haloClassName = b('halo');
|
|
7
|
+
const symbolClassName = b('symbol');
|
|
8
|
+
export function renderMarker(selection) {
|
|
9
|
+
const markerSelection = selection
|
|
10
|
+
.attr('class', b('wrapper'))
|
|
11
|
+
.attr('visibility', getMarkerVisibility)
|
|
12
|
+
.attr('transform', (d) => {
|
|
13
|
+
return `translate(${d.point.x},${d.point.y})`;
|
|
14
|
+
});
|
|
15
|
+
markerSelection
|
|
16
|
+
.append('path')
|
|
17
|
+
.attr('class', haloClassName)
|
|
18
|
+
.attr('d', (d) => {
|
|
19
|
+
const series = d.point.series;
|
|
20
|
+
const type = series.marker.states.normal.symbol;
|
|
21
|
+
const radius = get(d.point.data, 'radius', series.marker.states.hover.radius);
|
|
22
|
+
const haloSize = series.marker.states.hover.halo.size;
|
|
23
|
+
return getMarkerSymbol(type, radius + haloSize);
|
|
24
|
+
})
|
|
25
|
+
.attr('fill', (d) => d.point.series.color)
|
|
26
|
+
.attr('opacity', (d) => d.point.series.marker.states.hover.halo.opacity)
|
|
27
|
+
.attr('z-index', -1)
|
|
28
|
+
.attr('visibility', getMarkerHaloVisibility);
|
|
29
|
+
markerSelection
|
|
30
|
+
.append('path')
|
|
31
|
+
.attr('class', symbolClassName)
|
|
32
|
+
.call(setMarker, 'normal')
|
|
33
|
+
.attr('fill', (d) => d.point.series.color);
|
|
34
|
+
return markerSelection;
|
|
35
|
+
}
|
|
36
|
+
export function getMarkerVisibility(d) {
|
|
37
|
+
const markerStates = d.point.series.marker.states;
|
|
38
|
+
let enabled;
|
|
39
|
+
if (d.hovered) {
|
|
40
|
+
enabled = markerStates.hover.enabled && d.hovered;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
enabled =
|
|
44
|
+
markerStates.normal.enabled || get(d.point.data, 'marker.states.normal.enabled', false);
|
|
45
|
+
}
|
|
46
|
+
return enabled ? '' : 'hidden';
|
|
47
|
+
}
|
|
48
|
+
export function getMarkerHaloVisibility(d) {
|
|
49
|
+
const markerStates = d.point.series.marker.states;
|
|
50
|
+
const enabled = markerStates.hover.halo.enabled && d.hovered;
|
|
51
|
+
return enabled ? '' : 'hidden';
|
|
52
|
+
}
|
|
53
|
+
export function setMarker(selection, state) {
|
|
54
|
+
selection
|
|
55
|
+
.attr('d', (d) => {
|
|
56
|
+
const series = d.point.series;
|
|
57
|
+
const type = series.marker.states.normal.symbol;
|
|
58
|
+
const radius = get(d.point.data, 'radius', series.marker.states[state].radius);
|
|
59
|
+
const size = radius + series.marker.states[state].borderWidth;
|
|
60
|
+
return getMarkerSymbol(type, size);
|
|
61
|
+
})
|
|
62
|
+
.attr('stroke-width', (d) => d.point.series.marker.states[state].borderWidth)
|
|
63
|
+
.attr('stroke', (d) => d.point.series.marker.states[state].borderColor);
|
|
64
|
+
}
|
|
65
|
+
export function getMarkerSymbol(type = SymbolType.Circle, radius) {
|
|
66
|
+
const symbolFn = getSymbol(type);
|
|
67
|
+
const size = Math.pow(radius, 2) * Math.PI;
|
|
68
|
+
return symbol(symbolFn, size)();
|
|
69
|
+
}
|
|
70
|
+
export function selectMarkerHalo(parentSelection) {
|
|
71
|
+
return parentSelection.select(`.${haloClassName}`);
|
|
72
|
+
}
|
|
73
|
+
export function selectMarkerSymbol(parentSelection) {
|
|
74
|
+
return parentSelection.select(`.${symbolClassName}`);
|
|
75
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Dispatch, PieArcDatum } from 'd3';
|
|
3
|
+
import type { PreparedSeriesOptions } from '../../useSeries/types';
|
|
4
|
+
import type { PreparedPieData, SegmentData } from './types';
|
|
5
|
+
type PreparePieSeriesArgs = {
|
|
6
|
+
dispatcher: Dispatch<object>;
|
|
7
|
+
preparedData: PreparedPieData[];
|
|
8
|
+
seriesOptions: PreparedSeriesOptions;
|
|
9
|
+
htmlLayout: HTMLElement | null;
|
|
10
|
+
};
|
|
11
|
+
export declare function getHaloVisibility(d: PieArcDatum<SegmentData>): "" | "hidden";
|
|
12
|
+
export declare function PieSeriesShapes(args: PreparePieSeriesArgs): React.JSX.Element;
|
|
13
|
+
export {};
|