@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,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { getPreparedChart } from './chart';
|
|
3
|
+
import { getPreparedTitle } from './title';
|
|
4
|
+
import { getPreparedTooltip } from './tooltip';
|
|
5
|
+
export const useChartOptions = (args) => {
|
|
6
|
+
const { data: { chart, title, tooltip }, } = args;
|
|
7
|
+
const options = React.useMemo(() => {
|
|
8
|
+
const preparedTitle = getPreparedTitle({ title });
|
|
9
|
+
const preparedTooltip = getPreparedTooltip({ tooltip });
|
|
10
|
+
const preparedChart = getPreparedChart({
|
|
11
|
+
chart,
|
|
12
|
+
preparedTitle,
|
|
13
|
+
});
|
|
14
|
+
return {
|
|
15
|
+
chart: preparedChart,
|
|
16
|
+
title: preparedTitle,
|
|
17
|
+
tooltip: preparedTooltip,
|
|
18
|
+
};
|
|
19
|
+
}, [chart, title, tooltip]);
|
|
20
|
+
return options;
|
|
21
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import get from 'lodash/get';
|
|
2
|
+
import { getHorisontalSvgTextHeight } from '../../utils';
|
|
3
|
+
const DEFAULT_TITLE_FONT_SIZE = '15px';
|
|
4
|
+
const TITLE_PADDINGS = 8 * 2;
|
|
5
|
+
export const getPreparedTitle = ({ title, }) => {
|
|
6
|
+
const titleText = get(title, 'text');
|
|
7
|
+
const titleStyle = {
|
|
8
|
+
fontSize: get(title, 'style.fontSize', DEFAULT_TITLE_FONT_SIZE),
|
|
9
|
+
fontWeight: get(title, 'style.fontWeight'),
|
|
10
|
+
};
|
|
11
|
+
const titleHeight = titleText
|
|
12
|
+
? getHorisontalSvgTextHeight({ text: titleText, style: titleStyle }) + TITLE_PADDINGS
|
|
13
|
+
: 0;
|
|
14
|
+
const preparedTitle = titleText
|
|
15
|
+
? { text: titleText, style: titleStyle, height: titleHeight }
|
|
16
|
+
: undefined;
|
|
17
|
+
return preparedTitle;
|
|
18
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { BaseTextStyle, ChartAxis, ChartAxisLabels, ChartAxisTitleAlignment, ChartAxisType, ChartData, ChartMargin } from '../../types';
|
|
2
|
+
type PreparedAxisLabels = Omit<ChartAxisLabels, 'enabled' | 'padding' | 'style' | 'autoRotation'> & Required<Pick<ChartAxisLabels, 'enabled' | 'padding' | 'margin' | 'rotation'>> & {
|
|
3
|
+
style: BaseTextStyle;
|
|
4
|
+
rotation: number;
|
|
5
|
+
height: number;
|
|
6
|
+
width: number;
|
|
7
|
+
lineHeight: number;
|
|
8
|
+
maxWidth: number;
|
|
9
|
+
};
|
|
10
|
+
export type PreparedChart = {
|
|
11
|
+
margin: ChartMargin;
|
|
12
|
+
};
|
|
13
|
+
export type PreparedAxis = Omit<ChartAxis, 'type' | 'labels'> & {
|
|
14
|
+
type: ChartAxisType;
|
|
15
|
+
labels: PreparedAxisLabels;
|
|
16
|
+
title: {
|
|
17
|
+
height: number;
|
|
18
|
+
width: number;
|
|
19
|
+
text: string;
|
|
20
|
+
margin: number;
|
|
21
|
+
style: BaseTextStyle;
|
|
22
|
+
align: ChartAxisTitleAlignment;
|
|
23
|
+
maxRowCount: number;
|
|
24
|
+
};
|
|
25
|
+
min?: number;
|
|
26
|
+
grid: {
|
|
27
|
+
enabled: boolean;
|
|
28
|
+
};
|
|
29
|
+
maxPadding: number;
|
|
30
|
+
ticks: {
|
|
31
|
+
pixelInterval?: number;
|
|
32
|
+
};
|
|
33
|
+
position: 'left' | 'right' | 'top' | 'bottom';
|
|
34
|
+
plotIndex: number;
|
|
35
|
+
};
|
|
36
|
+
export type PreparedTitle = ChartData['title'] & {
|
|
37
|
+
height: number;
|
|
38
|
+
};
|
|
39
|
+
export type PreparedTooltip = ChartData['tooltip'] & {
|
|
40
|
+
enabled: boolean;
|
|
41
|
+
};
|
|
42
|
+
export type ChartOptions = {
|
|
43
|
+
chart: PreparedChart;
|
|
44
|
+
tooltip: PreparedTooltip;
|
|
45
|
+
title?: PreparedTitle;
|
|
46
|
+
};
|
|
47
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import get from 'lodash/get';
|
|
2
|
+
import { DEFAULT_AXIS_LABEL_FONT_SIZE, axisLabelsDefaults, xAxisTitleDefaults, } from '../../constants';
|
|
3
|
+
import { CHART_SERIES_WITH_VOLUME_ON_X_AXIS, calculateCos, formatAxisTickLabel, getClosestPointsRange, getHorisontalSvgTextHeight, getLabelsSize, getMaxTickCount, getTicksCount, getXAxisItems, hasOverlappingLabels, wrapText, } from '../../utils';
|
|
4
|
+
import { createXScale } from '../useAxisScales';
|
|
5
|
+
function getLabelSettings({ axis, series, width, autoRotation = true, }) {
|
|
6
|
+
const scale = createXScale(axis, series, width);
|
|
7
|
+
const tickCount = getTicksCount({ axis, range: width });
|
|
8
|
+
const ticks = getXAxisItems({
|
|
9
|
+
scale: scale,
|
|
10
|
+
count: tickCount,
|
|
11
|
+
maxCount: getMaxTickCount({ width, axis }),
|
|
12
|
+
});
|
|
13
|
+
const step = getClosestPointsRange(axis, ticks);
|
|
14
|
+
const labels = ticks.map((value) => {
|
|
15
|
+
return formatAxisTickLabel({
|
|
16
|
+
axis,
|
|
17
|
+
value,
|
|
18
|
+
step,
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
const overlapping = hasOverlappingLabels({
|
|
22
|
+
width,
|
|
23
|
+
labels,
|
|
24
|
+
padding: axis.labels.padding,
|
|
25
|
+
style: axis.labels.style,
|
|
26
|
+
});
|
|
27
|
+
const defaultRotation = overlapping && autoRotation ? -45 : 0;
|
|
28
|
+
const rotation = axis.labels.rotation || defaultRotation;
|
|
29
|
+
const labelsHeight = rotation
|
|
30
|
+
? getLabelsSize({
|
|
31
|
+
labels,
|
|
32
|
+
style: axis.labels.style,
|
|
33
|
+
rotation,
|
|
34
|
+
}).maxHeight
|
|
35
|
+
: axis.labels.lineHeight;
|
|
36
|
+
const maxHeight = rotation ? calculateCos(rotation) * axis.labels.maxWidth : labelsHeight;
|
|
37
|
+
return { height: Math.min(maxHeight, labelsHeight), rotation };
|
|
38
|
+
}
|
|
39
|
+
function getAxisMin(axis, series) {
|
|
40
|
+
const min = axis === null || axis === void 0 ? void 0 : axis.min;
|
|
41
|
+
if (typeof min === 'undefined' &&
|
|
42
|
+
(series === null || series === void 0 ? void 0 : series.some((s) => CHART_SERIES_WITH_VOLUME_ON_X_AXIS.includes(s.type)))) {
|
|
43
|
+
return series.reduce((minValue, s) => {
|
|
44
|
+
// @ts-expect-error
|
|
45
|
+
const minYValue = s.data.reduce((res, d) => Math.min(res, get(d, 'x', 0)), 0);
|
|
46
|
+
return Math.min(minValue, minYValue);
|
|
47
|
+
}, 0);
|
|
48
|
+
}
|
|
49
|
+
return min;
|
|
50
|
+
}
|
|
51
|
+
export const getPreparedXAxis = ({ xAxis, series, width, }) => {
|
|
52
|
+
var _a;
|
|
53
|
+
const titleText = get(xAxis, 'title.text', '');
|
|
54
|
+
const titleStyle = Object.assign(Object.assign({}, xAxisTitleDefaults.style), get(xAxis, 'title.style'));
|
|
55
|
+
const titleMaxRowsCount = get(xAxis, 'title.maxRowCount', xAxisTitleDefaults.maxRowCount);
|
|
56
|
+
const estimatedTitleRows = wrapText({
|
|
57
|
+
text: titleText,
|
|
58
|
+
style: titleStyle,
|
|
59
|
+
width,
|
|
60
|
+
}).slice(0, titleMaxRowsCount);
|
|
61
|
+
const titleSize = getLabelsSize({
|
|
62
|
+
labels: [titleText],
|
|
63
|
+
style: titleStyle,
|
|
64
|
+
});
|
|
65
|
+
const labelsStyle = {
|
|
66
|
+
fontSize: get(xAxis, 'labels.style.fontSize', DEFAULT_AXIS_LABEL_FONT_SIZE),
|
|
67
|
+
};
|
|
68
|
+
const preparedXAxis = {
|
|
69
|
+
type: get(xAxis, 'type', 'linear'),
|
|
70
|
+
labels: {
|
|
71
|
+
enabled: get(xAxis, 'labels.enabled', true),
|
|
72
|
+
margin: get(xAxis, 'labels.margin', axisLabelsDefaults.margin),
|
|
73
|
+
padding: get(xAxis, 'labels.padding', axisLabelsDefaults.padding),
|
|
74
|
+
dateFormat: get(xAxis, 'labels.dateFormat'),
|
|
75
|
+
numberFormat: get(xAxis, 'labels.numberFormat'),
|
|
76
|
+
rotation: get(xAxis, 'labels.rotation', 0),
|
|
77
|
+
style: labelsStyle,
|
|
78
|
+
width: 0,
|
|
79
|
+
height: 0,
|
|
80
|
+
lineHeight: getHorisontalSvgTextHeight({ text: 'Tmp', style: labelsStyle }),
|
|
81
|
+
maxWidth: get(xAxis, 'labels.maxWidth', axisLabelsDefaults.maxWidth),
|
|
82
|
+
},
|
|
83
|
+
lineColor: get(xAxis, 'lineColor'),
|
|
84
|
+
categories: get(xAxis, 'categories'),
|
|
85
|
+
timestamps: get(xAxis, 'timestamps'),
|
|
86
|
+
title: {
|
|
87
|
+
text: titleText,
|
|
88
|
+
style: titleStyle,
|
|
89
|
+
margin: get(xAxis, 'title.margin', xAxisTitleDefaults.margin),
|
|
90
|
+
height: titleSize.maxHeight * estimatedTitleRows.length,
|
|
91
|
+
width: titleSize.maxWidth,
|
|
92
|
+
align: get(xAxis, 'title.align', xAxisTitleDefaults.align),
|
|
93
|
+
maxRowCount: get(xAxis, 'title.maxRowCount', xAxisTitleDefaults.maxRowCount),
|
|
94
|
+
},
|
|
95
|
+
min: getAxisMin(xAxis, series),
|
|
96
|
+
maxPadding: get(xAxis, 'maxPadding', 0.01),
|
|
97
|
+
grid: {
|
|
98
|
+
enabled: get(xAxis, 'grid.enabled', true),
|
|
99
|
+
},
|
|
100
|
+
ticks: {
|
|
101
|
+
pixelInterval: get(xAxis, 'ticks.pixelInterval'),
|
|
102
|
+
},
|
|
103
|
+
position: 'bottom',
|
|
104
|
+
plotIndex: 0,
|
|
105
|
+
};
|
|
106
|
+
const { height, rotation } = getLabelSettings({
|
|
107
|
+
axis: preparedXAxis,
|
|
108
|
+
series,
|
|
109
|
+
width,
|
|
110
|
+
autoRotation: (_a = xAxis === null || xAxis === void 0 ? void 0 : xAxis.labels) === null || _a === void 0 ? void 0 : _a.autoRotation,
|
|
111
|
+
});
|
|
112
|
+
preparedXAxis.labels.height = height;
|
|
113
|
+
preparedXAxis.labels.rotation = rotation;
|
|
114
|
+
return preparedXAxis;
|
|
115
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ChartSeries, ChartYAxis } from '../../types';
|
|
2
|
+
import type { PreparedAxis } from './types';
|
|
3
|
+
export declare const getPreparedYAxis: ({ series, yAxis, height, }: {
|
|
4
|
+
series: ChartSeries[];
|
|
5
|
+
yAxis: ChartYAxis[] | undefined;
|
|
6
|
+
height: number;
|
|
7
|
+
}) => PreparedAxis[];
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import get from 'lodash/get';
|
|
2
|
+
import { DEFAULT_AXIS_LABEL_FONT_SIZE, DEFAULT_AXIS_TYPE, axisLabelsDefaults, yAxisTitleDefaults, } from '../../constants';
|
|
3
|
+
import { CHART_SERIES_WITH_VOLUME_ON_Y_AXIS, formatAxisTickLabel, getClosestPointsRange, getHorisontalSvgTextHeight, getLabelsSize, getScaleTicks, getWaterfallPointSubtotal, wrapText, } from '../../utils';
|
|
4
|
+
import { createYScale } from '../useAxisScales';
|
|
5
|
+
const getAxisLabelMaxWidth = (args) => {
|
|
6
|
+
const { axis, series } = args;
|
|
7
|
+
if (!axis.labels.enabled) {
|
|
8
|
+
return 0;
|
|
9
|
+
}
|
|
10
|
+
const scale = createYScale(axis, series, 1);
|
|
11
|
+
const ticks = getScaleTicks(scale);
|
|
12
|
+
// FIXME: it is necessary to filter data, since we do not draw overlapping ticks
|
|
13
|
+
const step = getClosestPointsRange(axis, ticks);
|
|
14
|
+
const labels = ticks.map((tick) => formatAxisTickLabel({
|
|
15
|
+
axis,
|
|
16
|
+
value: tick,
|
|
17
|
+
step,
|
|
18
|
+
}));
|
|
19
|
+
return getLabelsSize({
|
|
20
|
+
labels,
|
|
21
|
+
style: axis.labels.style,
|
|
22
|
+
rotation: axis.labels.rotation,
|
|
23
|
+
}).maxWidth;
|
|
24
|
+
};
|
|
25
|
+
function getAxisMin(axis, series) {
|
|
26
|
+
const min = axis === null || axis === void 0 ? void 0 : axis.min;
|
|
27
|
+
if (typeof min === 'undefined' &&
|
|
28
|
+
(series === null || series === void 0 ? void 0 : series.some((s) => CHART_SERIES_WITH_VOLUME_ON_Y_AXIS.includes(s.type)))) {
|
|
29
|
+
return series.reduce((minValue, s) => {
|
|
30
|
+
switch (s.type) {
|
|
31
|
+
case 'waterfall': {
|
|
32
|
+
const minSubTotal = s.data.reduce((res, d) => Math.min(res, getWaterfallPointSubtotal(d, s) || 0), 0);
|
|
33
|
+
return Math.min(minValue, minSubTotal);
|
|
34
|
+
}
|
|
35
|
+
default: {
|
|
36
|
+
// @ts-expect-error
|
|
37
|
+
const minYValue = s.data.reduce((res, d) => Math.min(res, get(d, 'y', 0)), 0);
|
|
38
|
+
return Math.min(minValue, minYValue);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}, 0);
|
|
42
|
+
}
|
|
43
|
+
return min;
|
|
44
|
+
}
|
|
45
|
+
export const getPreparedYAxis = ({ series, yAxis, height, }) => {
|
|
46
|
+
const axisByPlot = [];
|
|
47
|
+
const axisItems = yAxis || [{}];
|
|
48
|
+
return axisItems.map((axisItem) => {
|
|
49
|
+
const plotIndex = get(axisItem, 'plotIndex', 0);
|
|
50
|
+
const firstPlotAxis = !axisByPlot[plotIndex];
|
|
51
|
+
if (firstPlotAxis) {
|
|
52
|
+
axisByPlot[plotIndex] = [];
|
|
53
|
+
}
|
|
54
|
+
axisByPlot[plotIndex].push(axisItem);
|
|
55
|
+
const defaultAxisPosition = firstPlotAxis ? 'left' : 'right';
|
|
56
|
+
const labelsEnabled = get(axisItem, 'labels.enabled', true);
|
|
57
|
+
const labelsStyle = {
|
|
58
|
+
fontSize: get(axisItem, 'labels.style.fontSize', DEFAULT_AXIS_LABEL_FONT_SIZE),
|
|
59
|
+
};
|
|
60
|
+
const titleText = get(axisItem, 'title.text', '');
|
|
61
|
+
const titleStyle = Object.assign(Object.assign({}, yAxisTitleDefaults.style), get(axisItem, 'title.style'));
|
|
62
|
+
const titleMaxRowsCount = get(axisItem, 'title.maxRowCount', yAxisTitleDefaults.maxRowCount);
|
|
63
|
+
const estimatedTitleRows = wrapText({
|
|
64
|
+
text: titleText,
|
|
65
|
+
style: titleStyle,
|
|
66
|
+
width: height,
|
|
67
|
+
}).slice(0, titleMaxRowsCount);
|
|
68
|
+
const titleSize = getLabelsSize({ labels: [titleText], style: titleStyle });
|
|
69
|
+
const axisType = get(axisItem, 'type', DEFAULT_AXIS_TYPE);
|
|
70
|
+
const preparedAxis = {
|
|
71
|
+
type: axisType,
|
|
72
|
+
labels: {
|
|
73
|
+
enabled: labelsEnabled,
|
|
74
|
+
margin: labelsEnabled
|
|
75
|
+
? get(axisItem, 'labels.margin', axisLabelsDefaults.margin)
|
|
76
|
+
: 0,
|
|
77
|
+
padding: labelsEnabled
|
|
78
|
+
? get(axisItem, 'labels.padding', axisLabelsDefaults.padding)
|
|
79
|
+
: 0,
|
|
80
|
+
dateFormat: get(axisItem, 'labels.dateFormat'),
|
|
81
|
+
numberFormat: get(axisItem, 'labels.numberFormat'),
|
|
82
|
+
style: labelsStyle,
|
|
83
|
+
rotation: get(axisItem, 'labels.rotation', 0),
|
|
84
|
+
width: 0,
|
|
85
|
+
height: 0,
|
|
86
|
+
lineHeight: getHorisontalSvgTextHeight({ text: 'TmpLabel', style: labelsStyle }),
|
|
87
|
+
maxWidth: get(axisItem, 'labels.maxWidth', axisLabelsDefaults.maxWidth),
|
|
88
|
+
},
|
|
89
|
+
lineColor: get(axisItem, 'lineColor'),
|
|
90
|
+
categories: get(axisItem, 'categories'),
|
|
91
|
+
timestamps: get(axisItem, 'timestamps'),
|
|
92
|
+
title: {
|
|
93
|
+
text: titleText,
|
|
94
|
+
margin: get(axisItem, 'title.margin', yAxisTitleDefaults.margin),
|
|
95
|
+
style: titleStyle,
|
|
96
|
+
width: titleSize.maxWidth,
|
|
97
|
+
height: titleSize.maxHeight * estimatedTitleRows.length,
|
|
98
|
+
align: get(axisItem, 'title.align', yAxisTitleDefaults.align),
|
|
99
|
+
maxRowCount: titleMaxRowsCount,
|
|
100
|
+
},
|
|
101
|
+
min: getAxisMin(axisItem, series),
|
|
102
|
+
maxPadding: get(axisItem, 'maxPadding', 0.05),
|
|
103
|
+
grid: {
|
|
104
|
+
enabled: get(axisItem, 'grid.enabled', firstPlotAxis),
|
|
105
|
+
},
|
|
106
|
+
ticks: {
|
|
107
|
+
pixelInterval: get(axisItem, 'ticks.pixelInterval'),
|
|
108
|
+
},
|
|
109
|
+
position: get(axisItem, 'position', defaultAxisPosition),
|
|
110
|
+
plotIndex: get(axisItem, 'plotIndex', 0),
|
|
111
|
+
};
|
|
112
|
+
if (labelsEnabled) {
|
|
113
|
+
preparedAxis.labels.width = getAxisLabelMaxWidth({ axis: preparedAxis, series });
|
|
114
|
+
}
|
|
115
|
+
return preparedAxis;
|
|
116
|
+
});
|
|
117
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { BaseTextStyle, Halo } from '../../types';
|
|
2
|
+
import type { PointMarkerOptions } from '../../types/chart/marker';
|
|
3
|
+
export declare const DEFAULT_LEGEND_SYMBOL_SIZE = 8;
|
|
4
|
+
export declare const DEFAULT_LEGEND_SYMBOL_PADDING = 5;
|
|
5
|
+
export declare const DEFAULT_DATALABELS_PADDING = 5;
|
|
6
|
+
export declare const DEFAULT_DATALABELS_STYLE: BaseTextStyle;
|
|
7
|
+
export declare const DEFAULT_HALO_OPTIONS: Required<Halo>;
|
|
8
|
+
export declare const DEFAULT_POINT_MARKER_OPTIONS: Omit<Required<PointMarkerOptions>, 'enabled'>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export const DEFAULT_LEGEND_SYMBOL_SIZE = 8;
|
|
2
|
+
export const DEFAULT_LEGEND_SYMBOL_PADDING = 5;
|
|
3
|
+
export const DEFAULT_DATALABELS_PADDING = 5;
|
|
4
|
+
export const DEFAULT_DATALABELS_STYLE = {
|
|
5
|
+
fontSize: '11px',
|
|
6
|
+
fontWeight: 'bold',
|
|
7
|
+
fontColor: 'var(--d3-data-labels)',
|
|
8
|
+
};
|
|
9
|
+
export const DEFAULT_HALO_OPTIONS = {
|
|
10
|
+
enabled: true,
|
|
11
|
+
opacity: 0.25,
|
|
12
|
+
size: 6,
|
|
13
|
+
};
|
|
14
|
+
export const DEFAULT_POINT_MARKER_OPTIONS = {
|
|
15
|
+
radius: 4,
|
|
16
|
+
borderColor: '',
|
|
17
|
+
borderWidth: 0,
|
|
18
|
+
symbol: 'circle',
|
|
19
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ChartData } from '../../types';
|
|
2
|
+
import type { PreparedAxis, PreparedChart } from '../useChartOptions/types';
|
|
3
|
+
import type { OnLegendItemClick, PreparedSeries } from './types';
|
|
4
|
+
type Args = {
|
|
5
|
+
chartWidth: number;
|
|
6
|
+
chartHeight: number;
|
|
7
|
+
chartMargin: PreparedChart['margin'];
|
|
8
|
+
legend: ChartData['legend'];
|
|
9
|
+
series: ChartData['series'];
|
|
10
|
+
preparedYAxis: PreparedAxis[];
|
|
11
|
+
};
|
|
12
|
+
export declare const useSeries: (args: Args) => {
|
|
13
|
+
legendItems: import("./types").LegendItem[][];
|
|
14
|
+
legendConfig: {
|
|
15
|
+
offset: {
|
|
16
|
+
left: number;
|
|
17
|
+
top: number;
|
|
18
|
+
};
|
|
19
|
+
pagination: {
|
|
20
|
+
limit: number;
|
|
21
|
+
maxPage: number;
|
|
22
|
+
} | undefined;
|
|
23
|
+
};
|
|
24
|
+
preparedLegend: import("./types").PreparedLegend;
|
|
25
|
+
preparedSeries: PreparedSeries[];
|
|
26
|
+
preparedSeriesOptions: import("../../constants").SeriesOptionsDefaults;
|
|
27
|
+
handleLegendItemClick: OnLegendItemClick;
|
|
28
|
+
};
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { group, scaleOrdinal } from 'd3';
|
|
3
|
+
import { DEFAULT_PALETTE } from '../../constants';
|
|
4
|
+
import { getSeriesNames } from '../../utils';
|
|
5
|
+
import { getLegendComponents, getPreparedLegend } from './prepare-legend';
|
|
6
|
+
import { getPreparedOptions } from './prepare-options';
|
|
7
|
+
import { prepareSeries } from './prepareSeries';
|
|
8
|
+
import { getActiveLegendItems, getAllLegendItems } from './utils';
|
|
9
|
+
export const useSeries = (args) => {
|
|
10
|
+
const { chartWidth, chartHeight, chartMargin, legend, preparedYAxis, series: { data: series, options: seriesOptions }, } = args;
|
|
11
|
+
const preparedLegend = React.useMemo(() => getPreparedLegend({ legend, series }), [legend, series]);
|
|
12
|
+
const preparedSeries = React.useMemo(() => {
|
|
13
|
+
const seriesNames = getSeriesNames(series);
|
|
14
|
+
const colorScale = scaleOrdinal(seriesNames, DEFAULT_PALETTE);
|
|
15
|
+
const groupedSeries = group(series, (item) => item.type);
|
|
16
|
+
return Array.from(groupedSeries).reduce((acc, [seriesType, seriesList]) => {
|
|
17
|
+
acc.push(...prepareSeries({
|
|
18
|
+
type: seriesType,
|
|
19
|
+
series: seriesList,
|
|
20
|
+
seriesOptions,
|
|
21
|
+
legend: preparedLegend,
|
|
22
|
+
colorScale,
|
|
23
|
+
}));
|
|
24
|
+
return acc;
|
|
25
|
+
}, []);
|
|
26
|
+
}, [series, seriesOptions, preparedLegend]);
|
|
27
|
+
const preparedSeriesOptions = React.useMemo(() => {
|
|
28
|
+
return getPreparedOptions(seriesOptions);
|
|
29
|
+
}, [seriesOptions]);
|
|
30
|
+
const [activeLegendItems, setActiveLegendItems] = React.useState(getActiveLegendItems(preparedSeries));
|
|
31
|
+
const chartSeries = React.useMemo(() => {
|
|
32
|
+
return preparedSeries.map((singleSeries) => {
|
|
33
|
+
if (singleSeries.legend.enabled) {
|
|
34
|
+
return Object.assign(Object.assign({}, singleSeries), { visible: activeLegendItems.includes(singleSeries.name) });
|
|
35
|
+
}
|
|
36
|
+
return singleSeries;
|
|
37
|
+
});
|
|
38
|
+
}, [preparedSeries, activeLegendItems]);
|
|
39
|
+
const { legendConfig, legendItems } = React.useMemo(() => {
|
|
40
|
+
return getLegendComponents({
|
|
41
|
+
chartHeight,
|
|
42
|
+
chartMargin,
|
|
43
|
+
chartWidth,
|
|
44
|
+
series: chartSeries,
|
|
45
|
+
preparedLegend,
|
|
46
|
+
preparedYAxis,
|
|
47
|
+
});
|
|
48
|
+
}, [chartWidth, chartHeight, chartMargin, chartSeries, preparedLegend, preparedYAxis]);
|
|
49
|
+
const handleLegendItemClick = React.useCallback(({ name, metaKey }) => {
|
|
50
|
+
const allItems = getAllLegendItems(preparedSeries);
|
|
51
|
+
const onlyItemSelected = activeLegendItems.length === 1 && activeLegendItems.includes(name);
|
|
52
|
+
let nextActiveLegendItems;
|
|
53
|
+
if (metaKey && activeLegendItems.includes(name)) {
|
|
54
|
+
nextActiveLegendItems = activeLegendItems.filter((item) => item !== name);
|
|
55
|
+
}
|
|
56
|
+
else if (metaKey && !activeLegendItems.includes(name)) {
|
|
57
|
+
nextActiveLegendItems = activeLegendItems.concat(name);
|
|
58
|
+
}
|
|
59
|
+
else if (onlyItemSelected && allItems.length === 1) {
|
|
60
|
+
nextActiveLegendItems = [];
|
|
61
|
+
}
|
|
62
|
+
else if (onlyItemSelected) {
|
|
63
|
+
nextActiveLegendItems = allItems;
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
nextActiveLegendItems = [name];
|
|
67
|
+
}
|
|
68
|
+
setActiveLegendItems(nextActiveLegendItems);
|
|
69
|
+
}, [preparedSeries, activeLegendItems]);
|
|
70
|
+
// FIXME: remove effect. It initiates extra rerender
|
|
71
|
+
React.useEffect(() => {
|
|
72
|
+
setActiveLegendItems(getActiveLegendItems(preparedSeries));
|
|
73
|
+
}, [preparedSeries]);
|
|
74
|
+
return {
|
|
75
|
+
legendItems,
|
|
76
|
+
legendConfig,
|
|
77
|
+
preparedLegend,
|
|
78
|
+
preparedSeries: chartSeries,
|
|
79
|
+
preparedSeriesOptions,
|
|
80
|
+
handleLegendItemClick,
|
|
81
|
+
};
|
|
82
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ScaleOrdinal } from 'd3';
|
|
2
|
+
import type { AreaSeries, ChartSeriesOptions } from '../../types';
|
|
3
|
+
import type { PreparedAreaSeries, PreparedLegend } from './types';
|
|
4
|
+
export declare const DEFAULT_LINE_WIDTH = 1;
|
|
5
|
+
export declare const DEFAULT_MARKER: {
|
|
6
|
+
enabled: boolean;
|
|
7
|
+
symbol: `${import("../../constants").SymbolType}`;
|
|
8
|
+
borderColor: string;
|
|
9
|
+
borderWidth: number;
|
|
10
|
+
radius: number;
|
|
11
|
+
};
|
|
12
|
+
type PrepareAreaSeriesArgs = {
|
|
13
|
+
colorScale: ScaleOrdinal<string, string>;
|
|
14
|
+
series: AreaSeries[];
|
|
15
|
+
seriesOptions?: ChartSeriesOptions;
|
|
16
|
+
legend: PreparedLegend;
|
|
17
|
+
};
|
|
18
|
+
export declare function prepareArea(args: PrepareAreaSeriesArgs): PreparedAreaSeries[];
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import get from 'lodash/get';
|
|
2
|
+
import merge from 'lodash/merge';
|
|
3
|
+
import { getUniqId } from '../../utils';
|
|
4
|
+
import { DEFAULT_DATALABELS_PADDING, DEFAULT_DATALABELS_STYLE, DEFAULT_HALO_OPTIONS, DEFAULT_POINT_MARKER_OPTIONS, } from './constants';
|
|
5
|
+
import { getSeriesStackId, prepareLegendSymbol } from './utils';
|
|
6
|
+
export const DEFAULT_LINE_WIDTH = 1;
|
|
7
|
+
export const DEFAULT_MARKER = Object.assign(Object.assign({}, DEFAULT_POINT_MARKER_OPTIONS), { enabled: false });
|
|
8
|
+
function prepareMarker(series, seriesOptions) {
|
|
9
|
+
var _a;
|
|
10
|
+
const seriesHoverState = get(seriesOptions, 'area.states.hover');
|
|
11
|
+
const markerNormalState = Object.assign({}, DEFAULT_MARKER, (_a = seriesOptions === null || seriesOptions === void 0 ? void 0 : seriesOptions.area) === null || _a === void 0 ? void 0 : _a.marker, series.marker);
|
|
12
|
+
const hoveredMarkerDefaultOptions = {
|
|
13
|
+
enabled: true,
|
|
14
|
+
radius: markerNormalState.radius,
|
|
15
|
+
borderWidth: 1,
|
|
16
|
+
borderColor: '#ffffff',
|
|
17
|
+
halo: DEFAULT_HALO_OPTIONS,
|
|
18
|
+
};
|
|
19
|
+
return {
|
|
20
|
+
states: {
|
|
21
|
+
normal: markerNormalState,
|
|
22
|
+
hover: merge(hoveredMarkerDefaultOptions, seriesHoverState === null || seriesHoverState === void 0 ? void 0 : seriesHoverState.marker),
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export function prepareArea(args) {
|
|
27
|
+
const { colorScale, series: seriesList, seriesOptions, legend } = args;
|
|
28
|
+
const defaultAreaWidth = get(seriesOptions, 'area.lineWidth', DEFAULT_LINE_WIDTH);
|
|
29
|
+
const defaultOpacity = get(seriesOptions, 'area.opacity', 0.75);
|
|
30
|
+
return seriesList.map((series) => {
|
|
31
|
+
var _a, _b;
|
|
32
|
+
const id = getUniqId();
|
|
33
|
+
const name = series.name || '';
|
|
34
|
+
const color = series.color || colorScale(name);
|
|
35
|
+
const prepared = {
|
|
36
|
+
type: series.type,
|
|
37
|
+
color,
|
|
38
|
+
opacity: get(series, 'opacity', defaultOpacity),
|
|
39
|
+
lineWidth: get(series, 'lineWidth', defaultAreaWidth),
|
|
40
|
+
name,
|
|
41
|
+
id,
|
|
42
|
+
visible: get(series, 'visible', true),
|
|
43
|
+
legend: {
|
|
44
|
+
enabled: get(series, 'legend.enabled', legend.enabled),
|
|
45
|
+
symbol: prepareLegendSymbol(series),
|
|
46
|
+
},
|
|
47
|
+
data: series.data,
|
|
48
|
+
stacking: series.stacking,
|
|
49
|
+
stackId: getSeriesStackId(series),
|
|
50
|
+
dataLabels: {
|
|
51
|
+
enabled: ((_a = series.dataLabels) === null || _a === void 0 ? void 0 : _a.enabled) || false,
|
|
52
|
+
style: Object.assign({}, DEFAULT_DATALABELS_STYLE, (_b = series.dataLabels) === null || _b === void 0 ? void 0 : _b.style),
|
|
53
|
+
padding: get(series, 'dataLabels.padding', DEFAULT_DATALABELS_PADDING),
|
|
54
|
+
allowOverlap: get(series, 'dataLabels.allowOverlap', false),
|
|
55
|
+
html: get(series, 'dataLabels.html', false),
|
|
56
|
+
},
|
|
57
|
+
marker: prepareMarker(series, seriesOptions),
|
|
58
|
+
cursor: get(series, 'cursor', null),
|
|
59
|
+
yAxis: get(series, 'yAxis', 0),
|
|
60
|
+
};
|
|
61
|
+
return prepared;
|
|
62
|
+
}, []);
|
|
63
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ScaleOrdinal } from 'd3';
|
|
2
|
+
import type { BarXSeries } from '../../types';
|
|
3
|
+
import type { PreparedLegend, PreparedSeries } from './types';
|
|
4
|
+
type PrepareBarXSeriesArgs = {
|
|
5
|
+
colorScale: ScaleOrdinal<string, string>;
|
|
6
|
+
series: BarXSeries[];
|
|
7
|
+
legend: PreparedLegend;
|
|
8
|
+
};
|
|
9
|
+
export declare function prepareBarXSeries(args: PrepareBarXSeriesArgs): PreparedSeries[];
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import get from 'lodash/get';
|
|
2
|
+
import { getUniqId } from '../../utils';
|
|
3
|
+
import { DEFAULT_DATALABELS_PADDING, DEFAULT_DATALABELS_STYLE } from './constants';
|
|
4
|
+
import { getSeriesStackId, prepareLegendSymbol } from './utils';
|
|
5
|
+
export function prepareBarXSeries(args) {
|
|
6
|
+
const { colorScale, series: seriesList, legend } = args;
|
|
7
|
+
return seriesList.map((series) => {
|
|
8
|
+
var _a, _b, _c, _d, _e;
|
|
9
|
+
const name = series.name || '';
|
|
10
|
+
const color = series.color || colorScale(name);
|
|
11
|
+
return {
|
|
12
|
+
type: series.type,
|
|
13
|
+
color,
|
|
14
|
+
name,
|
|
15
|
+
id: getUniqId(),
|
|
16
|
+
visible: get(series, 'visible', true),
|
|
17
|
+
legend: {
|
|
18
|
+
enabled: get(series, 'legend.enabled', legend.enabled),
|
|
19
|
+
symbol: prepareLegendSymbol(series),
|
|
20
|
+
},
|
|
21
|
+
data: series.data,
|
|
22
|
+
stacking: series.stacking,
|
|
23
|
+
stackId: getSeriesStackId(series),
|
|
24
|
+
dataLabels: {
|
|
25
|
+
enabled: ((_a = series.dataLabels) === null || _a === void 0 ? void 0 : _a.enabled) || false,
|
|
26
|
+
inside: typeof ((_b = series.dataLabels) === null || _b === void 0 ? void 0 : _b.inside) === 'boolean'
|
|
27
|
+
? (_c = series.dataLabels) === null || _c === void 0 ? void 0 : _c.inside
|
|
28
|
+
: false,
|
|
29
|
+
style: Object.assign({}, DEFAULT_DATALABELS_STYLE, (_d = series.dataLabels) === null || _d === void 0 ? void 0 : _d.style),
|
|
30
|
+
allowOverlap: ((_e = series.dataLabels) === null || _e === void 0 ? void 0 : _e.allowOverlap) || false,
|
|
31
|
+
padding: get(series, 'dataLabels.padding', DEFAULT_DATALABELS_PADDING),
|
|
32
|
+
html: get(series, 'dataLabels.html', false),
|
|
33
|
+
},
|
|
34
|
+
cursor: get(series, 'cursor', null),
|
|
35
|
+
yAxis: get(series, 'yAxis', 0),
|
|
36
|
+
};
|
|
37
|
+
}, []);
|
|
38
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ScaleOrdinal } from 'd3';
|
|
2
|
+
import type { BarYSeries } from '../../types';
|
|
3
|
+
import type { PreparedLegend, PreparedSeries } from './types';
|
|
4
|
+
type PrepareBarYSeriesArgs = {
|
|
5
|
+
colorScale: ScaleOrdinal<string, string>;
|
|
6
|
+
series: BarYSeries[];
|
|
7
|
+
legend: PreparedLegend;
|
|
8
|
+
};
|
|
9
|
+
export declare function prepareBarYSeries(args: PrepareBarYSeriesArgs): PreparedSeries[];
|
|
10
|
+
export {};
|