@wonderflow/charts 12.8.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/dist/components/cartesian-base/cartesian-base-axis.d.ts +15 -0
- package/dist/components/cartesian-base/cartesian-base-axis.d.ts.map +1 -0
- package/dist/components/cartesian-base/cartesian-base-axis.js +53 -0
- package/dist/components/cartesian-base/cartesian-base-grid.d.ts +23 -0
- package/dist/components/cartesian-base/cartesian-base-grid.d.ts.map +1 -0
- package/dist/components/cartesian-base/cartesian-base-grid.js +35 -0
- package/dist/components/cartesian-base/cartesian-base-legend.d.ts +7 -0
- package/dist/components/cartesian-base/cartesian-base-legend.d.ts.map +1 -0
- package/dist/components/cartesian-base/cartesian-base-legend.js +35 -0
- package/dist/components/cartesian-base/cartesian-base.d.ts +78 -0
- package/dist/components/cartesian-base/cartesian-base.d.ts.map +1 -0
- package/dist/components/cartesian-base/cartesian-base.js +98 -0
- package/dist/components/cartesian-base/cartesian-base.module.css +1 -0
- package/dist/components/cartesian-base/cartesian-base.test.d.ts +2 -0
- package/dist/components/cartesian-base/cartesian-base.test.d.ts.map +1 -0
- package/dist/components/cartesian-base/cartesian-base.test.js +51 -0
- package/dist/components/cartesian-base/index.d.ts +3 -0
- package/dist/components/cartesian-base/index.d.ts.map +1 -0
- package/dist/components/cartesian-base/index.js +16 -0
- package/dist/components/empty-state/empty-state.d.ts +16 -0
- package/dist/components/empty-state/empty-state.d.ts.map +1 -0
- package/dist/components/empty-state/empty-state.js +31 -0
- package/dist/components/empty-state/empty-state.test.d.ts +2 -0
- package/dist/components/empty-state/empty-state.test.d.ts.map +1 -0
- package/dist/components/empty-state/empty-state.test.js +67 -0
- package/dist/components/empty-state/index.d.ts +2 -0
- package/dist/components/empty-state/index.d.ts.map +1 -0
- package/dist/components/empty-state/index.js +16 -0
- package/dist/components/headings/headings.d.ts +27 -0
- package/dist/components/headings/headings.d.ts.map +1 -0
- package/dist/components/headings/headings.js +31 -0
- package/dist/components/headings/headings.test.d.ts +2 -0
- package/dist/components/headings/headings.test.d.ts.map +1 -0
- package/dist/components/headings/headings.test.js +14 -0
- package/dist/components/headings/index.d.ts +3 -0
- package/dist/components/headings/index.d.ts.map +1 -0
- package/dist/components/headings/index.js +16 -0
- package/dist/components/index.d.ts +7 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +21 -0
- package/dist/components/line-chart/index.d.ts +3 -0
- package/dist/components/line-chart/index.d.ts.map +1 -0
- package/dist/components/line-chart/index.js +16 -0
- package/dist/components/line-chart/line-chart.d.ts +57 -0
- package/dist/components/line-chart/line-chart.d.ts.map +1 -0
- package/dist/components/line-chart/line-chart.js +68 -0
- package/dist/components/line-chart/line-chart.test.d.ts +2 -0
- package/dist/components/line-chart/line-chart.test.d.ts.map +1 -0
- package/dist/components/line-chart/line-chart.test.js +20 -0
- package/dist/components/loader/bar-chart-loader.d.ts +11 -0
- package/dist/components/loader/bar-chart-loader.d.ts.map +1 -0
- package/dist/components/loader/bar-chart-loader.js +3 -0
- package/dist/components/loader/index.d.ts +2 -0
- package/dist/components/loader/index.d.ts.map +1 -0
- package/dist/components/loader/index.js +16 -0
- package/dist/components/loader/line-chart-loader.d.ts +11 -0
- package/dist/components/loader/line-chart-loader.d.ts.map +1 -0
- package/dist/components/loader/line-chart-loader.js +3 -0
- package/dist/components/loader/loader.d.ts +10 -0
- package/dist/components/loader/loader.d.ts.map +1 -0
- package/dist/components/loader/loader.js +35 -0
- package/dist/components/loader/loader.test.d.ts +2 -0
- package/dist/components/loader/loader.test.d.ts.map +1 -0
- package/dist/components/loader/loader.test.js +50 -0
- package/dist/components/placeholder/index.d.ts +3 -0
- package/dist/components/placeholder/index.d.ts.map +1 -0
- package/dist/components/placeholder/index.js +16 -0
- package/dist/components/placeholder/placeholder.d.ts +9 -0
- package/dist/components/placeholder/placeholder.d.ts.map +1 -0
- package/dist/components/placeholder/placeholder.js +19 -0
- package/dist/components/placeholder/placeholder.test.d.ts +2 -0
- package/dist/components/placeholder/placeholder.test.d.ts.map +1 -0
- package/dist/components/placeholder/placeholder.test.js +15 -0
- package/dist/components/shapes/index.d.ts +2 -0
- package/dist/components/shapes/index.d.ts.map +1 -0
- package/dist/components/shapes/index.js +16 -0
- package/dist/components/shapes/lines/index.d.ts +2 -0
- package/dist/components/shapes/lines/index.d.ts.map +1 -0
- package/dist/components/shapes/lines/index.js +16 -0
- package/dist/components/shapes/lines/lines-marker-labels.d.ts +3 -0
- package/dist/components/shapes/lines/lines-marker-labels.d.ts.map +1 -0
- package/dist/components/shapes/lines/lines-marker-labels.js +72 -0
- package/dist/components/shapes/lines/lines-overlay.d.ts +3 -0
- package/dist/components/shapes/lines/lines-overlay.d.ts.map +1 -0
- package/dist/components/shapes/lines/lines-overlay.js +52 -0
- package/dist/components/shapes/lines/lines-series.d.ts +3 -0
- package/dist/components/shapes/lines/lines-series.d.ts.map +1 -0
- package/dist/components/shapes/lines/lines-series.js +58 -0
- package/dist/components/shapes/lines/lines-tooltip.d.ts +3 -0
- package/dist/components/shapes/lines/lines-tooltip.d.ts.map +1 -0
- package/dist/components/shapes/lines/lines-tooltip.js +107 -0
- package/dist/components/shapes/lines/lines.d.ts +3 -0
- package/dist/components/shapes/lines/lines.d.ts.map +1 -0
- package/dist/components/shapes/lines/lines.js +28 -0
- package/dist/components/shapes/lines/lines.module.css +1 -0
- package/dist/components/shapes/lines/lines.test.d.ts +2 -0
- package/dist/components/shapes/lines/lines.test.d.ts.map +1 -0
- package/dist/components/shapes/lines/lines.test.js +142 -0
- package/dist/components/tooltip/index.d.ts +3 -0
- package/dist/components/tooltip/index.d.ts.map +1 -0
- package/dist/components/tooltip/index.js +16 -0
- package/dist/components/tooltip/tooltip.d.ts +35 -0
- package/dist/components/tooltip/tooltip.d.ts.map +1 -0
- package/dist/components/tooltip/tooltip.js +37 -0
- package/dist/components/tooltip/tooltip.module.css +1 -0
- package/dist/components/tooltip/tooltip.test.d.ts +2 -0
- package/dist/components/tooltip/tooltip.test.d.ts.map +1 -0
- package/dist/components/tooltip/tooltip.test.js +20 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/providers/cartesian.d.ts +20 -0
- package/dist/providers/cartesian.d.ts.map +1 -0
- package/dist/providers/cartesian.js +43 -0
- package/dist/providers/data.d.ts +11 -0
- package/dist/providers/data.d.ts.map +1 -0
- package/dist/providers/data.js +32 -0
- package/dist/providers/index.d.ts +6 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/index.js +20 -0
- package/dist/providers/layout.d.ts +14 -0
- package/dist/providers/layout.d.ts.map +1 -0
- package/dist/providers/layout.js +34 -0
- package/dist/providers/style-config.d.ts +11 -0
- package/dist/providers/style-config.d.ts.map +1 -0
- package/dist/providers/style-config.js +29 -0
- package/dist/providers/theme.d.ts +10 -0
- package/dist/providers/theme.d.ts.map +1 -0
- package/dist/providers/theme.js +29 -0
- package/dist/style-config/axis.d.ts +3 -0
- package/dist/style-config/axis.d.ts.map +1 -0
- package/dist/style-config/axis.js +86 -0
- package/dist/style-config/cartesian.d.ts +3 -0
- package/dist/style-config/cartesian.d.ts.map +1 -0
- package/dist/style-config/cartesian.js +31 -0
- package/dist/style-config/colors.d.ts +9 -0
- package/dist/style-config/colors.d.ts.map +1 -0
- package/dist/style-config/colors.js +271 -0
- package/dist/style-config/grid.d.ts +7 -0
- package/dist/style-config/grid.d.ts.map +1 -0
- package/dist/style-config/grid.js +24 -0
- package/dist/style-config/headings.d.ts +3 -0
- package/dist/style-config/headings.d.ts.map +1 -0
- package/dist/style-config/headings.js +39 -0
- package/dist/style-config/index.d.ts +10 -0
- package/dist/style-config/index.d.ts.map +1 -0
- package/dist/style-config/index.js +24 -0
- package/dist/style-config/legend.d.ts +3 -0
- package/dist/style-config/legend.d.ts.map +1 -0
- package/dist/style-config/legend.js +18 -0
- package/dist/style-config/linear-gradient.d.ts +3 -0
- package/dist/style-config/linear-gradient.d.ts.map +1 -0
- package/dist/style-config/linear-gradient.js +20 -0
- package/dist/style-config/lines.d.ts +3 -0
- package/dist/style-config/lines.d.ts.map +1 -0
- package/dist/style-config/lines.js +39 -0
- package/dist/style-config/themes.d.ts +5 -0
- package/dist/style-config/themes.d.ts.map +1 -0
- package/dist/style-config/themes.js +86 -0
- package/dist/style-config/tooltip.d.ts +8 -0
- package/dist/style-config/tooltip.d.ts.map +1 -0
- package/dist/style-config/tooltip.js +56 -0
- package/dist/style-config/viewport.d.ts +3 -0
- package/dist/style-config/viewport.d.ts.map +1 -0
- package/dist/style-config/viewport.js +30 -0
- package/dist/types/axis.d.ts +108 -0
- package/dist/types/axis.d.ts.map +1 -0
- package/dist/types/axis.js +16 -0
- package/dist/types/cartesian.d.ts +58 -0
- package/dist/types/cartesian.d.ts.map +1 -0
- package/dist/types/cartesian.js +20 -0
- package/dist/types/colors.d.ts +9 -0
- package/dist/types/colors.d.ts.map +1 -0
- package/dist/types/colors.js +16 -0
- package/dist/types/grid.d.ts +14 -0
- package/dist/types/grid.d.ts.map +1 -0
- package/dist/types/grid.js +1 -0
- package/dist/types/headings.d.ts +26 -0
- package/dist/types/headings.d.ts.map +1 -0
- package/dist/types/headings.js +16 -0
- package/dist/types/index.d.ts +13 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +27 -0
- package/dist/types/legend.d.ts +4 -0
- package/dist/types/legend.d.ts.map +1 -0
- package/dist/types/legend.js +16 -0
- package/dist/types/line-chart.d.ts +53 -0
- package/dist/types/line-chart.d.ts.map +1 -0
- package/dist/types/line-chart.js +16 -0
- package/dist/types/linear-gradient.d.ts +5 -0
- package/dist/types/linear-gradient.d.ts.map +1 -0
- package/dist/types/linear-gradient.js +16 -0
- package/dist/types/lines.d.ts +25 -0
- package/dist/types/lines.d.ts.map +1 -0
- package/dist/types/lines.js +16 -0
- package/dist/types/main.d.ts +11 -0
- package/dist/types/main.d.ts.map +1 -0
- package/dist/types/main.js +20 -0
- package/dist/types/themes.d.ts +31 -0
- package/dist/types/themes.d.ts.map +1 -0
- package/dist/types/themes.js +16 -0
- package/dist/types/tooltip.d.ts +23 -0
- package/dist/types/tooltip.d.ts.map +1 -0
- package/dist/types/tooltip.js +16 -0
- package/dist/types/viewport.d.ts +8 -0
- package/dist/types/viewport.d.ts.map +1 -0
- package/dist/types/viewport.js +16 -0
- package/dist/utils/axis.d.ts +60 -0
- package/dist/utils/axis.d.ts.map +1 -0
- package/dist/utils/axis.js +401 -0
- package/dist/utils/axis.test.d.ts +2 -0
- package/dist/utils/axis.test.d.ts.map +1 -0
- package/dist/utils/axis.test.js +1071 -0
- package/dist/utils/colors.d.ts +8 -0
- package/dist/utils/colors.d.ts.map +1 -0
- package/dist/utils/colors.js +33 -0
- package/dist/utils/colors.test.d.ts +2 -0
- package/dist/utils/colors.test.d.ts.map +1 -0
- package/dist/utils/colors.test.js +31 -0
- package/dist/utils/data.d.ts +14 -0
- package/dist/utils/data.d.ts.map +1 -0
- package/dist/utils/data.js +116 -0
- package/dist/utils/data.test.d.ts +2 -0
- package/dist/utils/data.test.d.ts.map +1 -0
- package/dist/utils/data.test.js +371 -0
- package/dist/utils/format.d.ts +15 -0
- package/dist/utils/format.d.ts.map +1 -0
- package/dist/utils/format.js +41 -0
- package/dist/utils/format.test.d.ts +2 -0
- package/dist/utils/format.test.d.ts.map +1 -0
- package/dist/utils/format.test.js +101 -0
- package/dist/utils/index.d.ts +8 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +22 -0
- package/dist/utils/lines.d.ts +52 -0
- package/dist/utils/lines.d.ts.map +1 -0
- package/dist/utils/lines.js +190 -0
- package/dist/utils/lines.test.d.ts +2 -0
- package/dist/utils/lines.test.d.ts.map +1 -0
- package/dist/utils/lines.test.js +498 -0
- package/dist/utils/math.d.ts +13 -0
- package/dist/utils/math.d.ts.map +1 -0
- package/dist/utils/math.js +89 -0
- package/dist/utils/math.test.d.ts +2 -0
- package/dist/utils/math.test.d.ts.map +1 -0
- package/dist/utils/math.test.js +142 -0
- package/dist/utils/metadata.d.ts +6 -0
- package/dist/utils/metadata.d.ts.map +1 -0
- package/dist/utils/metadata.js +36 -0
- package/dist/utils/metadata.test.d.ts +2 -0
- package/dist/utils/metadata.test.d.ts.map +1 -0
- package/dist/utils/metadata.test.js +102 -0
- package/dist/utils/viewport.d.ts +3 -0
- package/dist/utils/viewport.d.ts.map +1 -0
- package/dist/utils/viewport.js +29 -0
- package/dist/utils/viewport.test.d.ts +2 -0
- package/dist/utils/viewport.test.d.ts.map +1 -0
- package/dist/utils/viewport.test.js +63 -0
- package/package.json +106 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Background } from './linear-gradient';
|
|
2
|
+
export declare type Theme = {
|
|
3
|
+
background: Background;
|
|
4
|
+
headings: {
|
|
5
|
+
title: string;
|
|
6
|
+
subtitle: string;
|
|
7
|
+
};
|
|
8
|
+
axis: {
|
|
9
|
+
label: string;
|
|
10
|
+
tickLabel: string;
|
|
11
|
+
tick: string;
|
|
12
|
+
line: string;
|
|
13
|
+
};
|
|
14
|
+
grid: {
|
|
15
|
+
line: string;
|
|
16
|
+
background: Background;
|
|
17
|
+
};
|
|
18
|
+
markerLabel: {
|
|
19
|
+
fontColor: string;
|
|
20
|
+
background: string;
|
|
21
|
+
};
|
|
22
|
+
marker: {
|
|
23
|
+
fill: string;
|
|
24
|
+
};
|
|
25
|
+
lines: {
|
|
26
|
+
noData: string;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
export declare type ThemeVariants = 'light' | 'dark';
|
|
30
|
+
export declare type Themes = Record<ThemeVariants, Theme>;
|
|
31
|
+
//# sourceMappingURL=themes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"themes.d.ts","sourceRoot":"","sources":["../../src/types/themes.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,oBAAY,KAAK,GAAG;IAClB,UAAU,EAAE,UAAU,CAAC;IACvB,QAAQ,EAAE;QACR,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,IAAI,EAAE;QACJ,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,EAAE,MAAM,CAAC;QAClB,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IACF,IAAI,EAAE;QACJ,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,EAAE,UAAU,CAAC;KACxB,CAAC;IACF,WAAW,EAAE;QACX,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,MAAM,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IACF,KAAK,EAAE;QACL,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH,CAAA;AAED,oBAAY,aAAa,GAAG,OAAO,GAAG,MAAM,CAAC;AAE7C,oBAAY,MAAM,GAAG,MAAM,CAAC,aAAa,EAAE,KAAK,CAAC,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 Wonderflow Design Team
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ThemeVariants } from './themes';
|
|
2
|
+
export declare type TooltipStyleMain = {
|
|
3
|
+
color: string;
|
|
4
|
+
minWidth: string | number;
|
|
5
|
+
minHeight: string | number;
|
|
6
|
+
maxWidth: string | number;
|
|
7
|
+
maxHeight: string | number;
|
|
8
|
+
overflow: string;
|
|
9
|
+
padding: string;
|
|
10
|
+
borderRadius: string;
|
|
11
|
+
zIndex: string;
|
|
12
|
+
};
|
|
13
|
+
export declare type TooltipStyleColors = {
|
|
14
|
+
backdropFilter: string;
|
|
15
|
+
background: string;
|
|
16
|
+
border: string;
|
|
17
|
+
boxShadow: string;
|
|
18
|
+
separatorStroke: string;
|
|
19
|
+
lineIndicatorStroke: string;
|
|
20
|
+
};
|
|
21
|
+
export declare type TooltipStyleConfig = TooltipStyleColors & TooltipStyleMain;
|
|
22
|
+
export declare type TooltipStyleTheme = Record<ThemeVariants, TooltipStyleConfig>;
|
|
23
|
+
//# sourceMappingURL=tooltip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tooltip.d.ts","sourceRoot":"","sources":["../../src/types/tooltip.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,oBAAY,gBAAgB,GAAG;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;IAC1B,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3B,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;IAC1B,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAA;AAED,oBAAY,kBAAkB,GAAG;IAC/B,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,mBAAmB,EAAE,MAAM,CAAC;CAC7B,CAAA;AAED,oBAAY,kBAAkB,GAAG,kBAAkB,GAAG,gBAAgB,CAAC;AAEvE,oBAAY,iBAAiB,GAAG,MAAM,CAAC,aAAa,EAAE,kBAAkB,CAAC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 Wonderflow Design Team
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare type ViewportSize = 'small' | 'medium' | 'large';
|
|
2
|
+
export declare type ViewportSizeConfig = {
|
|
3
|
+
maxWidth?: number;
|
|
4
|
+
maxHeight?: number;
|
|
5
|
+
numTicks: number;
|
|
6
|
+
};
|
|
7
|
+
export declare type ViewportStyleConfig = Record<ViewportSize, ViewportSizeConfig>;
|
|
8
|
+
//# sourceMappingURL=viewport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viewport.d.ts","sourceRoot":"","sources":["../../src/types/viewport.ts"],"names":[],"mappings":"AAgBA,oBAAY,YAAY,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;AAExD,oBAAY,kBAAkB,GAAG;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAA;AAED,oBAAY,mBAAmB,GAAG,MAAM,CAAC,YAAY,EAAE,kBAAkB,CAAC,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 Wonderflow Design Team
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { NumberValue, ScaleTime } from '@visx/vendor/d3-scale';
|
|
2
|
+
import { Except } from 'type-fest';
|
|
3
|
+
import { AxisProps, CartesianChartLayout, CartesianStyleConfig, ScaleType, ViewportStyleConfig } from '../types';
|
|
4
|
+
import { AxisConfig, AxisElements, AxisOffsetConfig, AxisOffsetProps, AxisOrientation, AxisSystemElements, CartesianAxis, CartesianxAxisSystem } from '../types/axis';
|
|
5
|
+
export declare const getAxisOffset: ({ orientation, tick, tickOffset, tickLabelHeight, maxLength, axisLabel, axisLine, }: {
|
|
6
|
+
orientation: AxisOrientation;
|
|
7
|
+
tick: number;
|
|
8
|
+
tickOffset: number;
|
|
9
|
+
tickLabelHeight: number;
|
|
10
|
+
maxLength: number;
|
|
11
|
+
axisLabel: number;
|
|
12
|
+
axisLine: number;
|
|
13
|
+
}) => number;
|
|
14
|
+
export declare const getTickLabelSize: ({ isVertical, hideTickLabel, maxLength, tickOffset, tickLabelHeight, }: {
|
|
15
|
+
isVertical: boolean;
|
|
16
|
+
hideTickLabel: boolean | undefined;
|
|
17
|
+
maxLength: number;
|
|
18
|
+
tickOffset: number;
|
|
19
|
+
tickLabelHeight: number;
|
|
20
|
+
}) => number;
|
|
21
|
+
export declare const getLabelOffset: ({ orientation, labelOffset, tickOffset, tickLabelSize, maxLength, }: {
|
|
22
|
+
orientation: AxisOrientation;
|
|
23
|
+
labelOffset: number;
|
|
24
|
+
tickOffset: number;
|
|
25
|
+
tickLabelSize: number;
|
|
26
|
+
maxLength: number;
|
|
27
|
+
}) => number;
|
|
28
|
+
export declare const computeAxisOffset: (axis: AxisOffsetProps, config?: import("../types").AxisElementsStyleConfig) => AxisElements;
|
|
29
|
+
export declare const computeAxisSystemOffset: (axis: Record<AxisOrientation, AxisOffsetProps | undefined>, config?: import("../types").AxisElementsStyleConfig) => {
|
|
30
|
+
offset: AxisOffsetConfig;
|
|
31
|
+
axis: AxisSystemElements;
|
|
32
|
+
};
|
|
33
|
+
export declare const computeAxisStyleConfig: (axis: Record<AxisOrientation, AxisProps | undefined>, config?: import("../types").AxisElementsStyleConfig) => AxisConfig;
|
|
34
|
+
export declare const inferScaleTypeFromDomain: (domain: Array<string | number | undefined>, scaleType?: ScaleType) => ScaleType;
|
|
35
|
+
export declare const scaleDomainToAxis: (axis: Except<AxisProps, 'orientation'>) => import("d3-scale").ScaleBand<string> | import("d3-scale").ScaleLinear<number, number, never> | ScaleTime<number, number, never> | undefined;
|
|
36
|
+
export declare const handleTickFormat: (axis: CartesianAxis) => (v: string | Date | NumberValue, i: number) => string | NumberValue | undefined;
|
|
37
|
+
export declare const handleNumberOfTicks: (width: number, height: number, axis: CartesianAxis, config: ViewportStyleConfig) => number;
|
|
38
|
+
export declare const hasVerticalTickLabel: (width: number, axis: AxisProps, config: ViewportStyleConfig) => boolean;
|
|
39
|
+
export declare const handleVerticalTickLabelTransform: (t: any, isVertical: boolean, axis: CartesianAxis) => {};
|
|
40
|
+
export declare const handleVerticalTickLabelOffset: (width: number, config: CartesianStyleConfig, axis?: AxisProps) => number;
|
|
41
|
+
export declare const computeAxisProperties: ({ axis, maxRangeX, maxRangeY, positionTop, positionRight, positionBottom, positionLeft, }: {
|
|
42
|
+
axis?: AxisProps | undefined;
|
|
43
|
+
maxRangeX: number;
|
|
44
|
+
maxRangeY: number;
|
|
45
|
+
positionTop: number;
|
|
46
|
+
positionRight: number;
|
|
47
|
+
positionBottom: number;
|
|
48
|
+
positionLeft: number;
|
|
49
|
+
}) => CartesianAxis | undefined;
|
|
50
|
+
export declare const computeAxisSystemProperties: (axis: Record<AxisOrientation, AxisProps | undefined>, dimension: {
|
|
51
|
+
maxWidth: number;
|
|
52
|
+
maxHeight: number;
|
|
53
|
+
}, position: {
|
|
54
|
+
top: number;
|
|
55
|
+
right: number;
|
|
56
|
+
bottom: number;
|
|
57
|
+
left: number;
|
|
58
|
+
}) => CartesianxAxisSystem;
|
|
59
|
+
export declare const handleChartAxisLayout: (index: Except<AxisProps, 'orientation'>, series: Except<AxisProps, 'orientation'>, overlay?: Except<AxisProps, 'orientation'>) => Record<CartesianChartLayout, Record<AxisOrientation, AxisProps | undefined>>;
|
|
60
|
+
//# sourceMappingURL=axis.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"axis.d.ts","sourceRoot":"","sources":["../../src/utils/axis.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAE/D,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAKnC,OAAO,EACL,SAAS,EAAE,oBAAoB,EAAE,oBAAoB,EACrD,SAAS,EAAE,mBAAmB,EAC/B,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,UAAU,EACV,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,aAAa,EACb,oBAAoB,EAGrB,MAAM,eAAe,CAAC;AAavB,eAAO,MAAM,aAAa;iBASX,eAAe;UACtB,MAAM;gBACA,MAAM;qBACD,MAAM;eACZ,MAAM;eACN,MAAM;cACP,MAAM;YAajB,CAAC;AAEF,eAAO,MAAM,gBAAgB;gBAOf,OAAO;mBACJ,OAAO,GAAG,SAAS;eACvB,MAAM;gBACL,MAAM;qBACD,MAAM;YASxB,CAAC;AAEF,eAAO,MAAM,cAAc;iBAOZ,eAAe;iBACf,MAAM;gBACP,MAAM;mBACH,MAAM;eACV,MAAM;YAUlB,CAAC;AAEF,eAAO,MAAM,iBAAiB,SACtB,eAAe,sEAgGtB,CAAC;AAEF,eAAO,MAAM,uBAAuB,SAC5B,OAAO,eAAe,EAAE,eAAe,GAAG,SAAS,CAAC;;;CAqC3D,CAAC;AAEF,eAAO,MAAM,sBAAsB,SAC3B,OAAO,eAAe,EAAE,SAAS,GAAG,SAAS,CAAC,oEAsCrD,CAAC;AAEF,eAAO,MAAM,wBAAwB,WAC3B,MAAM,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC,cAC9B,SAAS,KACpB,SAaF,CAAC;AAEF,eAAO,MAAM,iBAAiB,SAAU,OAAO,SAAS,EAAE,aAAa,CAAC,gJAiDvE,CAAC;AAEF,eAAO,MAAM,gBAAgB,SAAU,aAAa,SAcvC,MAAM,GAAG,IAAI,GAAG,WAAW,KAAK,MAAM,qCAelD,CAAC;AAEF,eAAO,MAAM,mBAAmB,UACvB,MAAM,UACL,MAAM,QACR,aAAa,UACX,mBAAmB,WAC4B,CAAC;AAE1D,eAAO,MAAM,oBAAoB,UACxB,MAAM,QACP,SAAS,UACP,mBAAmB,YA0B5B,CAAC;AAEF,eAAO,MAAM,gCAAgC,MACxC,GAAG,cACM,OAAO,QACb,aAAa,OA2BpB,CAAC;AAEF,eAAO,MAAM,6BAA6B,UACjC,MAAM,UACL,oBAAoB,SACrB,SAAS,WAqBjB,CAAC;AAEF,eAAO,MAAM,qBAAqB;;eAUrB,MAAM;eACN,MAAM;iBACJ,MAAM;mBACJ,MAAM;oBACL,MAAM;kBACR,MAAM;MAClB,aAAa,GAAG,SA8CnB,CAAC;AAEF,eAAO,MAAM,2BAA2B,SAChC,OAAO,eAAe,EAAE,SAAS,GAAG,SAAS,CAAC,aACzC;IACT,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB,YACS;IACR,KAAK,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd,yBAoCF,CAAC;AAEF,eAAO,MAAM,qBAAqB,UACzB,OAAO,SAAS,EAAE,aAAa,CAAC,UAC/B,OAAO,SAAS,EAAE,aAAa,CAAC,YAC9B,OAAO,SAAS,EAAE,aAAa,CAAC,KACzC,OAAO,oBAAoB,EAAE,OAAO,eAAe,EAAE,SAAS,GAAG,SAAS,CAAC,CAa5E,CAAC"}
|
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 Wonderflow Design Team
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { scaleBand, scaleLinear, scaleUtc, } from '@visx/scale';
|
|
17
|
+
import _ from 'lodash';
|
|
18
|
+
import { axisStyleConfig, } from '../style-config';
|
|
19
|
+
import { truncate } from './format';
|
|
20
|
+
import { getMaxCharactersNum, getMinMaxDate, getMinMaxNumber, isArrayTypeDate, isArrayTypeNumber, isArrayTypeString, removeNilsFromDomain, } from './math';
|
|
21
|
+
import { manageViewport } from './viewport';
|
|
22
|
+
export const getAxisOffset = ({ orientation, tick, tickOffset, tickLabelHeight, maxLength, axisLabel, axisLine, }) => {
|
|
23
|
+
const v = tick + Math.abs(tickOffset) + maxLength + axisLabel + axisLine;
|
|
24
|
+
const h = tick + tickLabelHeight + axisLabel + axisLine;
|
|
25
|
+
const offset = {
|
|
26
|
+
top: h,
|
|
27
|
+
right: v,
|
|
28
|
+
bottom: h,
|
|
29
|
+
left: v,
|
|
30
|
+
};
|
|
31
|
+
return offset[orientation];
|
|
32
|
+
};
|
|
33
|
+
export const getTickLabelSize = ({ isVertical, hideTickLabel, maxLength, tickOffset, tickLabelHeight, }) => {
|
|
34
|
+
if (hideTickLabel) {
|
|
35
|
+
return isVertical
|
|
36
|
+
? maxLength + Math.abs(tickOffset)
|
|
37
|
+
: tickLabelHeight + Math.abs(tickOffset);
|
|
38
|
+
}
|
|
39
|
+
return 0;
|
|
40
|
+
};
|
|
41
|
+
export const getLabelOffset = ({ orientation, labelOffset, tickOffset, tickLabelSize, maxLength, }) => {
|
|
42
|
+
const off = {
|
|
43
|
+
top: labelOffset + (-tickOffset) - tickLabelSize,
|
|
44
|
+
right: labelOffset + maxLength + tickOffset - tickLabelSize,
|
|
45
|
+
bottom: labelOffset + tickOffset - tickLabelSize,
|
|
46
|
+
left: labelOffset + maxLength + (-tickOffset) - tickLabelSize,
|
|
47
|
+
};
|
|
48
|
+
return off[orientation];
|
|
49
|
+
};
|
|
50
|
+
export const computeAxisOffset = (axis, config = axisStyleConfig) => {
|
|
51
|
+
const { domain, orientation, label, hideAxisLine, hideTickLabel, hideTicks, tickFormat, } = axis;
|
|
52
|
+
const hasValues = !!domain?.length;
|
|
53
|
+
let res = {
|
|
54
|
+
orientation: 'left',
|
|
55
|
+
offset: 0,
|
|
56
|
+
tickLabelMaxChar: 0,
|
|
57
|
+
tickLabelMaxLength: 0,
|
|
58
|
+
tickLength: 0,
|
|
59
|
+
tickLabelOffset: 0,
|
|
60
|
+
tickLabelHeight: 0,
|
|
61
|
+
tickLabelSize: 0,
|
|
62
|
+
labelOffset: 0,
|
|
63
|
+
axisLabel: 0,
|
|
64
|
+
axisLine: 0,
|
|
65
|
+
};
|
|
66
|
+
if (hasValues) {
|
|
67
|
+
const isVertical = orientation === 'left' || orientation === 'right';
|
|
68
|
+
const tickLabelMaxChar = (isVertical) ? getMaxCharactersNum(domain, tickFormat) : 0;
|
|
69
|
+
const { labelCharExtimatedWidth: char, labelHeight, labelOffset, tickLabelHeight, tickLength, } = config.spacing;
|
|
70
|
+
const tickOffset = isVertical
|
|
71
|
+
? config[orientation].tickLabelProps.dx
|
|
72
|
+
: config[orientation].tickLabelProps.dy;
|
|
73
|
+
const extraChar = orientation === 'right' ? 1 : 0;
|
|
74
|
+
const tick = hideTicks ? 0 : tickLength;
|
|
75
|
+
const tlh = hideTickLabel ? 0 : tickLabelHeight + Math.abs(tickOffset);
|
|
76
|
+
const axisLabel = label ? (labelHeight + labelOffset) : 0;
|
|
77
|
+
const maxLength = hideTickLabel ? 0 : char * (tickLabelMaxChar + extraChar);
|
|
78
|
+
const axisLine = hideAxisLine ? 0 : config.axisLineProps.strokeWidth;
|
|
79
|
+
const offset = getAxisOffset({
|
|
80
|
+
orientation,
|
|
81
|
+
axisLabel,
|
|
82
|
+
axisLine,
|
|
83
|
+
maxLength,
|
|
84
|
+
tick,
|
|
85
|
+
tickOffset,
|
|
86
|
+
tickLabelHeight: tlh,
|
|
87
|
+
});
|
|
88
|
+
const tickLabelSize = getTickLabelSize({
|
|
89
|
+
isVertical,
|
|
90
|
+
hideTickLabel,
|
|
91
|
+
maxLength,
|
|
92
|
+
tickLabelHeight,
|
|
93
|
+
tickOffset,
|
|
94
|
+
});
|
|
95
|
+
const lo = getLabelOffset({
|
|
96
|
+
orientation,
|
|
97
|
+
labelOffset,
|
|
98
|
+
maxLength,
|
|
99
|
+
tickLabelSize,
|
|
100
|
+
tickOffset,
|
|
101
|
+
});
|
|
102
|
+
res = {
|
|
103
|
+
orientation,
|
|
104
|
+
offset,
|
|
105
|
+
tickLabelMaxChar,
|
|
106
|
+
tickLabelMaxLength: maxLength,
|
|
107
|
+
tickLength,
|
|
108
|
+
tickLabelOffset: tickOffset,
|
|
109
|
+
tickLabelHeight: tlh,
|
|
110
|
+
tickLabelSize,
|
|
111
|
+
axisLabel,
|
|
112
|
+
labelOffset: lo,
|
|
113
|
+
axisLine,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
return res;
|
|
117
|
+
};
|
|
118
|
+
export const computeAxisSystemOffset = (axis, config = axisStyleConfig) => {
|
|
119
|
+
const { top, right, bottom, left, } = axis;
|
|
120
|
+
const t = top && computeAxisOffset(top, config);
|
|
121
|
+
const r = right && computeAxisOffset(right, config);
|
|
122
|
+
const b = bottom && computeAxisOffset(bottom, config);
|
|
123
|
+
const l = left && computeAxisOffset(left, config);
|
|
124
|
+
const to = t ? t.offset : 0;
|
|
125
|
+
const ro = r ? r.offset : 0;
|
|
126
|
+
const bo = b ? b.offset : 0;
|
|
127
|
+
const lo = l ? l.offset : 0;
|
|
128
|
+
const offset = {
|
|
129
|
+
leftAxisOffset: lo,
|
|
130
|
+
rightAxisOffset: ro,
|
|
131
|
+
topAxisOffset: to,
|
|
132
|
+
bottomAxisOffset: bo,
|
|
133
|
+
verticalAxisOffset: lo + ro,
|
|
134
|
+
horizontalAxisOffset: to + bo,
|
|
135
|
+
};
|
|
136
|
+
const a = {
|
|
137
|
+
top: t,
|
|
138
|
+
right: r,
|
|
139
|
+
bottom: b,
|
|
140
|
+
left: l,
|
|
141
|
+
};
|
|
142
|
+
return ({
|
|
143
|
+
offset,
|
|
144
|
+
axis: a,
|
|
145
|
+
});
|
|
146
|
+
};
|
|
147
|
+
export const computeAxisStyleConfig = (axis, config = axisStyleConfig) => {
|
|
148
|
+
const { offset, axis: ao } = computeAxisSystemOffset(axis, config);
|
|
149
|
+
const { top: t, right: r, bottom: b, left: l, } = ao;
|
|
150
|
+
const top = {
|
|
151
|
+
...config.top,
|
|
152
|
+
labelOffset: t ? t.labelOffset : 0,
|
|
153
|
+
};
|
|
154
|
+
const right = {
|
|
155
|
+
...config.right,
|
|
156
|
+
labelOffset: r ? r.labelOffset : 0,
|
|
157
|
+
};
|
|
158
|
+
const bottom = {
|
|
159
|
+
...config.bottom,
|
|
160
|
+
labelOffset: b ? b.labelOffset : 0,
|
|
161
|
+
};
|
|
162
|
+
const left = {
|
|
163
|
+
...config.left,
|
|
164
|
+
labelOffset: l ? l.labelOffset : 0,
|
|
165
|
+
};
|
|
166
|
+
const c = {
|
|
167
|
+
offset,
|
|
168
|
+
style: config,
|
|
169
|
+
top,
|
|
170
|
+
right,
|
|
171
|
+
bottom,
|
|
172
|
+
left,
|
|
173
|
+
};
|
|
174
|
+
return c;
|
|
175
|
+
};
|
|
176
|
+
export const inferScaleTypeFromDomain = (domain, scaleType) => {
|
|
177
|
+
const d = removeNilsFromDomain(domain);
|
|
178
|
+
if (scaleType)
|
|
179
|
+
return scaleType;
|
|
180
|
+
if (isArrayTypeNumber(d))
|
|
181
|
+
return 'linear';
|
|
182
|
+
if (isArrayTypeString(d)) {
|
|
183
|
+
const toDate = d.map(el => new Date(el));
|
|
184
|
+
if (isArrayTypeDate(toDate))
|
|
185
|
+
return 'time';
|
|
186
|
+
}
|
|
187
|
+
return 'label';
|
|
188
|
+
};
|
|
189
|
+
export const scaleDomainToAxis = (axis) => {
|
|
190
|
+
const { domain, range, scaleType, clamp, nice, round = true, paddingInner, paddingOuter, } = axis;
|
|
191
|
+
const hasData = domain.length && range?.length && scaleType;
|
|
192
|
+
if (hasData) {
|
|
193
|
+
if (scaleType === 'label') {
|
|
194
|
+
return scaleBand({
|
|
195
|
+
domain: domain.map(v => `${v}`),
|
|
196
|
+
range,
|
|
197
|
+
paddingInner: paddingInner ?? 1,
|
|
198
|
+
paddingOuter: paddingOuter ?? 1,
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
if (scaleType === 'linear') {
|
|
202
|
+
return scaleLinear({
|
|
203
|
+
domain: getMinMaxNumber(domain.map(v => Number(v))),
|
|
204
|
+
range,
|
|
205
|
+
round,
|
|
206
|
+
nice,
|
|
207
|
+
clamp,
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
if (scaleType === 'time') {
|
|
211
|
+
const d = domain.map(v => new Date(v));
|
|
212
|
+
const isDates = isArrayTypeDate(d);
|
|
213
|
+
return scaleUtc({
|
|
214
|
+
domain: isDates ? getMinMaxDate(d) : [],
|
|
215
|
+
range,
|
|
216
|
+
round,
|
|
217
|
+
nice,
|
|
218
|
+
clamp,
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return undefined;
|
|
223
|
+
};
|
|
224
|
+
export const handleTickFormat = (axis) => {
|
|
225
|
+
const { tickFormat, hideTickLabel, scaleType, scale, } = axis;
|
|
226
|
+
if (hideTickLabel) {
|
|
227
|
+
return () => ('');
|
|
228
|
+
}
|
|
229
|
+
const isLabel = scaleType === 'label';
|
|
230
|
+
const isTime = scaleType === 'time';
|
|
231
|
+
const doTruncate = (value) => (isLabel ? truncate(value) : value);
|
|
232
|
+
return (v, i) => {
|
|
233
|
+
if (tickFormat) {
|
|
234
|
+
return doTruncate(tickFormat(v, i, [{ value: v, index: i }]));
|
|
235
|
+
}
|
|
236
|
+
if (isLabel)
|
|
237
|
+
return doTruncate(v);
|
|
238
|
+
if (isTime && typeof v !== 'string') {
|
|
239
|
+
const s = scale;
|
|
240
|
+
const f = s.tickFormat();
|
|
241
|
+
return (f(v));
|
|
242
|
+
}
|
|
243
|
+
return v;
|
|
244
|
+
};
|
|
245
|
+
};
|
|
246
|
+
export const handleNumberOfTicks = (width, height, axis, config) => manageViewport(width, height, axis, config).numTicks;
|
|
247
|
+
export const hasVerticalTickLabel = (width, axis, config) => {
|
|
248
|
+
const { domain, scaleType, numTicks, orientation, } = axis;
|
|
249
|
+
const isLabel = scaleType === 'label';
|
|
250
|
+
const isHorizontal = orientation === 'bottom' || orientation === 'top';
|
|
251
|
+
const isSmall = _.inRange(width, 0, config.small.maxWidth);
|
|
252
|
+
const isMedium = _.inRange(width, config.small.maxWidth, config.medium.maxWidth);
|
|
253
|
+
if (isHorizontal) {
|
|
254
|
+
if (isLabel) {
|
|
255
|
+
const len = domain.join().length * 8;
|
|
256
|
+
return width / len < 2;
|
|
257
|
+
}
|
|
258
|
+
if (isSmall)
|
|
259
|
+
return false;
|
|
260
|
+
if (isMedium)
|
|
261
|
+
return true;
|
|
262
|
+
if (numTicks && numTicks > 10)
|
|
263
|
+
return true;
|
|
264
|
+
if (!isSmall && !isMedium)
|
|
265
|
+
return false;
|
|
266
|
+
}
|
|
267
|
+
return false;
|
|
268
|
+
};
|
|
269
|
+
export const handleVerticalTickLabelTransform = (t, isVertical, axis) => {
|
|
270
|
+
const { orientation, scale } = axis;
|
|
271
|
+
let res = {};
|
|
272
|
+
if (orientation === 'bottom') {
|
|
273
|
+
if (isVertical) {
|
|
274
|
+
res = {
|
|
275
|
+
transform: `translate(13, 6) rotate(90, ${scale(t) ?? 0}, 0)`,
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
else {
|
|
279
|
+
res = { transform: '', textAnchor: 'middle' };
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
if (orientation === 'top') {
|
|
283
|
+
if (isVertical) {
|
|
284
|
+
res = {
|
|
285
|
+
transform: `translate(9, -4) rotate(-90, ${scale(t) ?? 0}, 0)`,
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
else {
|
|
289
|
+
res = { transform: '', textAnchor: 'middle' };
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
return res;
|
|
293
|
+
};
|
|
294
|
+
export const handleVerticalTickLabelOffset = (width, config, axis) => {
|
|
295
|
+
let res = 0;
|
|
296
|
+
if (!axis)
|
|
297
|
+
return res;
|
|
298
|
+
const { viewport, axis: aConfig } = config;
|
|
299
|
+
const { domain, tickFormat, scaleType, } = axis;
|
|
300
|
+
const { maxCharactersLength: l, omission: o } = aConfig.formatting;
|
|
301
|
+
const { labelCharExtimatedWidth: w } = aConfig.spacing;
|
|
302
|
+
if (hasVerticalTickLabel(width, axis, viewport)) {
|
|
303
|
+
const num = getMaxCharactersNum(domain, tickFormat);
|
|
304
|
+
if (scaleType === 'label')
|
|
305
|
+
res = _.clamp(num, 0, l - o.length);
|
|
306
|
+
else if (scaleType === 'linear')
|
|
307
|
+
res = num;
|
|
308
|
+
else
|
|
309
|
+
res = _.clamp(num, 0, 8);
|
|
310
|
+
}
|
|
311
|
+
return res * w;
|
|
312
|
+
};
|
|
313
|
+
export const computeAxisProperties = ({ axis, maxRangeX, maxRangeY, positionTop, positionRight, positionBottom, positionLeft, }) => {
|
|
314
|
+
if (axis) {
|
|
315
|
+
const { orientation } = axis;
|
|
316
|
+
if (orientation === 'top') {
|
|
317
|
+
return {
|
|
318
|
+
...axis,
|
|
319
|
+
orientation,
|
|
320
|
+
scale: scaleDomainToAxis({ ...axis, range: [0, maxRangeX] }),
|
|
321
|
+
top: positionTop,
|
|
322
|
+
left: positionLeft,
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
if (orientation === 'right') {
|
|
326
|
+
return {
|
|
327
|
+
...axis,
|
|
328
|
+
orientation,
|
|
329
|
+
scale: scaleDomainToAxis({ ...axis, range: [maxRangeY, 0] }),
|
|
330
|
+
top: positionTop,
|
|
331
|
+
left: positionRight,
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
if (orientation === 'bottom') {
|
|
335
|
+
return {
|
|
336
|
+
...axis,
|
|
337
|
+
orientation,
|
|
338
|
+
scale: scaleDomainToAxis({ ...axis, range: [0, maxRangeX] }),
|
|
339
|
+
top: positionBottom,
|
|
340
|
+
left: positionLeft,
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
if (orientation === 'left') {
|
|
344
|
+
return {
|
|
345
|
+
...axis,
|
|
346
|
+
orientation,
|
|
347
|
+
scale: scaleDomainToAxis({ ...axis, range: [maxRangeY, 0] }),
|
|
348
|
+
top: positionTop,
|
|
349
|
+
left: positionLeft,
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
return undefined;
|
|
354
|
+
};
|
|
355
|
+
export const computeAxisSystemProperties = (axis, dimension, position) => {
|
|
356
|
+
const shared = {
|
|
357
|
+
maxRangeX: dimension.maxWidth,
|
|
358
|
+
maxRangeY: dimension.maxHeight,
|
|
359
|
+
positionTop: position.top,
|
|
360
|
+
positionRight: position.right,
|
|
361
|
+
positionBottom: position.bottom,
|
|
362
|
+
positionLeft: position.left,
|
|
363
|
+
};
|
|
364
|
+
const t = computeAxisProperties({
|
|
365
|
+
axis: axis.top,
|
|
366
|
+
...shared,
|
|
367
|
+
});
|
|
368
|
+
const r = computeAxisProperties({
|
|
369
|
+
axis: axis.right,
|
|
370
|
+
...shared,
|
|
371
|
+
});
|
|
372
|
+
const b = computeAxisProperties({
|
|
373
|
+
axis: axis.bottom,
|
|
374
|
+
...shared,
|
|
375
|
+
});
|
|
376
|
+
const l = computeAxisProperties({
|
|
377
|
+
axis: axis.left,
|
|
378
|
+
...shared,
|
|
379
|
+
});
|
|
380
|
+
const a = {
|
|
381
|
+
top: t,
|
|
382
|
+
right: r,
|
|
383
|
+
bottom: b,
|
|
384
|
+
left: l,
|
|
385
|
+
};
|
|
386
|
+
return a;
|
|
387
|
+
};
|
|
388
|
+
export const handleChartAxisLayout = (index, series, overlay) => ({
|
|
389
|
+
vertical: {
|
|
390
|
+
left: { ...index, orientation: 'left' },
|
|
391
|
+
bottom: { ...series, orientation: 'bottom' },
|
|
392
|
+
top: overlay ? { ...overlay, orientation: 'top' } : undefined,
|
|
393
|
+
right: undefined,
|
|
394
|
+
},
|
|
395
|
+
horizontal: {
|
|
396
|
+
bottom: { ...index, orientation: 'bottom' },
|
|
397
|
+
left: { ...series, orientation: 'left' },
|
|
398
|
+
right: overlay ? { ...overlay, orientation: 'right' } : undefined,
|
|
399
|
+
top: undefined,
|
|
400
|
+
},
|
|
401
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"axis.test.d.ts","sourceRoot":"","sources":["../../src/utils/axis.test.ts"],"names":[],"mappings":""}
|