@wonderflow/charts 12.10.0 → 13.0.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.
Files changed (161) hide show
  1. package/dist/components/bar-chart/bar-chart.d.ts +33 -5
  2. package/dist/components/bar-chart/bar-chart.d.ts.map +1 -1
  3. package/dist/components/bar-chart/bar-chart.js +20 -45
  4. package/dist/components/bar-chart/bar-chart.test.js +7 -1
  5. package/dist/components/cartesian-base/cartesian-base-axis.d.ts.map +1 -1
  6. package/dist/components/cartesian-base/cartesian-base-axis.js +10 -11
  7. package/dist/components/cartesian-base/cartesian-base-legend.d.ts.map +1 -1
  8. package/dist/components/cartesian-base/cartesian-base-legend.js +3 -3
  9. package/dist/components/cartesian-base/cartesian-base.d.ts +27 -0
  10. package/dist/components/cartesian-base/cartesian-base.d.ts.map +1 -1
  11. package/dist/components/cartesian-base/cartesian-base.js +7 -3
  12. package/dist/components/cartesian-base/cartesian-base.module.css +1 -1
  13. package/dist/components/headings/headings.d.ts +19 -2
  14. package/dist/components/headings/headings.d.ts.map +1 -1
  15. package/dist/components/headings/headings.js +72 -6
  16. package/dist/components/headings/headings.module.css +1 -0
  17. package/dist/components/headings/headings.test.d.ts +1 -1
  18. package/dist/components/headings/headings.test.d.ts.map +1 -1
  19. package/dist/components/headings/headings.test.js +37 -3
  20. package/dist/components/line-chart/line-chart.d.ts +29 -13
  21. package/dist/components/line-chart/line-chart.d.ts.map +1 -1
  22. package/dist/components/line-chart/line-chart.js +4 -2
  23. package/dist/components/line-chart/line-chart.test.js +2 -2
  24. package/dist/components/loader/bar-chart-loader.d.ts.map +1 -1
  25. package/dist/components/loader/bar-chart-loader.js +1 -1
  26. package/dist/components/loader/loader.js +2 -2
  27. package/dist/components/loader/loader.test.js +4 -2
  28. package/dist/components/shapes/bars/bars-average.d.ts +3 -0
  29. package/dist/components/shapes/bars/bars-average.d.ts.map +1 -0
  30. package/dist/components/shapes/bars/bars-average.js +30 -0
  31. package/dist/components/shapes/bars/bars-overlay.d.ts +6 -0
  32. package/dist/components/shapes/bars/bars-overlay.d.ts.map +1 -0
  33. package/dist/components/shapes/bars/bars-overlay.js +59 -0
  34. package/dist/components/shapes/bars/bars-series.d.ts +6 -0
  35. package/dist/components/shapes/bars/bars-series.d.ts.map +1 -0
  36. package/dist/components/shapes/bars/bars-series.js +56 -0
  37. package/dist/components/shapes/bars/bars-tooltip.d.ts +3 -0
  38. package/dist/components/shapes/bars/bars-tooltip.d.ts.map +1 -0
  39. package/dist/components/shapes/bars/bars-tooltip.js +85 -0
  40. package/dist/components/shapes/bars/bars-trendline.d.ts +3 -0
  41. package/dist/components/shapes/bars/bars-trendline.d.ts.map +1 -0
  42. package/dist/components/shapes/bars/bars-trendline.js +43 -0
  43. package/dist/components/shapes/bars/bars.d.ts.map +1 -1
  44. package/dist/components/shapes/bars/bars.js +25 -18
  45. package/dist/components/shapes/bars/bars.module.css +1 -1
  46. package/dist/components/shapes/bars/bars.test.js +39 -8
  47. package/dist/components/shapes/bars/index.d.ts +5 -0
  48. package/dist/components/shapes/bars/index.d.ts.map +1 -1
  49. package/dist/components/shapes/bars/index.js +6 -1
  50. package/dist/components/shapes/lines/lines-average.d.ts.map +1 -1
  51. package/dist/components/shapes/lines/lines-average.js +8 -46
  52. package/dist/components/shapes/lines/lines-marker-labels.d.ts.map +1 -1
  53. package/dist/components/shapes/lines/lines-marker-labels.js +10 -10
  54. package/dist/components/shapes/lines/lines-overlay.d.ts.map +1 -1
  55. package/dist/components/shapes/lines/lines-overlay.js +21 -26
  56. package/dist/components/shapes/lines/lines-series.d.ts.map +1 -1
  57. package/dist/components/shapes/lines/lines-series.js +6 -19
  58. package/dist/components/shapes/lines/lines-tooltip.d.ts.map +1 -1
  59. package/dist/components/shapes/lines/lines-tooltip.js +20 -27
  60. package/dist/components/shapes/lines/lines-trendline.d.ts +3 -0
  61. package/dist/components/shapes/lines/lines-trendline.d.ts.map +1 -0
  62. package/dist/components/shapes/lines/lines-trendline.js +43 -0
  63. package/dist/components/shapes/lines/lines.d.ts.map +1 -1
  64. package/dist/components/shapes/lines/lines.js +2 -1
  65. package/dist/components/shapes/lines/lines.test.js +29 -8
  66. package/dist/hooks/hooks.test.d.ts.map +1 -1
  67. package/dist/hooks/hooks.test.js +157 -5
  68. package/dist/hooks/index.d.ts +4 -0
  69. package/dist/hooks/index.d.ts.map +1 -1
  70. package/dist/hooks/index.js +4 -0
  71. package/dist/hooks/useAverage.d.ts +82 -0
  72. package/dist/hooks/useAverage.d.ts.map +1 -0
  73. package/dist/hooks/useAverage.js +83 -0
  74. package/dist/hooks/useBarChart.d.ts +16 -0
  75. package/dist/hooks/useBarChart.d.ts.map +1 -0
  76. package/dist/hooks/useBarChart.js +104 -0
  77. package/dist/hooks/useBars.d.ts +52 -0
  78. package/dist/hooks/useBars.d.ts.map +1 -0
  79. package/dist/hooks/useBars.js +82 -0
  80. package/dist/hooks/useCartesian.d.ts +11 -2
  81. package/dist/hooks/useCartesian.d.ts.map +1 -1
  82. package/dist/hooks/useCartesian.js +16 -5
  83. package/dist/hooks/useLineChart.d.ts +3 -27
  84. package/dist/hooks/useLineChart.d.ts.map +1 -1
  85. package/dist/hooks/useLineChart.js +22 -13
  86. package/dist/hooks/useLines.d.ts +48 -0
  87. package/dist/hooks/useLines.d.ts.map +1 -0
  88. package/dist/hooks/useLines.js +70 -0
  89. package/dist/hooks/useTrendline.d.ts +56 -0
  90. package/dist/hooks/useTrendline.d.ts.map +1 -0
  91. package/dist/hooks/useTrendline.js +84 -0
  92. package/dist/providers/cartesian.d.ts +5 -1
  93. package/dist/providers/cartesian.d.ts.map +1 -1
  94. package/dist/providers/cartesian.js +19 -3
  95. package/dist/providers/data.d.ts +6 -7
  96. package/dist/providers/data.d.ts.map +1 -1
  97. package/dist/providers/data.js +4 -3
  98. package/dist/style-config/axis.js +3 -3
  99. package/dist/style-config/bars.d.ts +3 -0
  100. package/dist/style-config/bars.d.ts.map +1 -0
  101. package/dist/style-config/bars.js +33 -0
  102. package/dist/style-config/cartesian.d.ts.map +1 -1
  103. package/dist/style-config/cartesian.js +2 -0
  104. package/dist/style-config/colors.d.ts +1 -4
  105. package/dist/style-config/colors.d.ts.map +1 -1
  106. package/dist/style-config/colors.js +30 -36
  107. package/dist/style-config/headings.d.ts.map +1 -1
  108. package/dist/style-config/headings.js +16 -1
  109. package/dist/style-config/lines.d.ts.map +1 -1
  110. package/dist/style-config/lines.js +6 -0
  111. package/dist/style-config/themes.d.ts.map +1 -1
  112. package/dist/style-config/themes.js +18 -0
  113. package/dist/types/bar-chart.d.ts +20 -15
  114. package/dist/types/bar-chart.d.ts.map +1 -1
  115. package/dist/types/bar-chart.js +1 -39
  116. package/dist/types/bars.d.ts +29 -0
  117. package/dist/types/bars.d.ts.map +1 -0
  118. package/dist/types/bars.js +16 -0
  119. package/dist/types/cartesian.d.ts +3 -0
  120. package/dist/types/cartesian.d.ts.map +1 -1
  121. package/dist/types/headings.d.ts +15 -0
  122. package/dist/types/headings.d.ts.map +1 -1
  123. package/dist/types/headings.js +1 -1
  124. package/dist/types/index.d.ts +3 -0
  125. package/dist/types/index.d.ts.map +1 -1
  126. package/dist/types/index.js +4 -1
  127. package/dist/types/line-chart.d.ts +12 -12
  128. package/dist/types/line-chart.d.ts.map +1 -1
  129. package/dist/types/lines.d.ts +6 -0
  130. package/dist/types/lines.d.ts.map +1 -1
  131. package/dist/types/main.d.ts +14 -1
  132. package/dist/types/main.d.ts.map +1 -1
  133. package/dist/types/themes.d.ts +9 -0
  134. package/dist/types/themes.d.ts.map +1 -1
  135. package/dist/utils/axis.d.ts +12 -2
  136. package/dist/utils/axis.d.ts.map +1 -1
  137. package/dist/utils/axis.js +52 -15
  138. package/dist/utils/axis.test.js +72 -8
  139. package/dist/utils/bars.d.ts +15 -0
  140. package/dist/utils/bars.d.ts.map +1 -0
  141. package/dist/utils/bars.js +71 -0
  142. package/dist/utils/bars.test.d.ts +2 -0
  143. package/dist/utils/bars.test.d.ts.map +1 -0
  144. package/dist/utils/bars.test.js +95 -0
  145. package/dist/utils/data.d.ts +9 -6
  146. package/dist/utils/data.d.ts.map +1 -1
  147. package/dist/utils/data.js +87 -15
  148. package/dist/utils/data.test.js +173 -80
  149. package/dist/utils/format.d.ts +1 -0
  150. package/dist/utils/format.d.ts.map +1 -1
  151. package/dist/utils/format.js +2 -1
  152. package/dist/utils/index.d.ts +1 -0
  153. package/dist/utils/index.d.ts.map +1 -1
  154. package/dist/utils/index.js +2 -1
  155. package/dist/utils/lines.test.js +25 -0
  156. package/dist/utils/metadata.d.ts +7 -8
  157. package/dist/utils/metadata.d.ts.map +1 -1
  158. package/dist/utils/metadata.js +3 -20
  159. package/dist/utils/metadata.test.js +3 -56
  160. package/dist/utils/viewport.test.js +8 -0
  161. package/package.json +4 -2
@@ -1,14 +1,9 @@
1
1
  /// <reference types="react" />
2
2
  import { AxisProps } from './cartesian';
3
- import { AverageType, Charts } from './main';
3
+ import { AverageType, Charts, TrendlineType } from './main';
4
4
  export declare type LineChartIndex = Partial<AxisProps> & {
5
5
  dataKey: string;
6
6
  };
7
- export declare type LineChartOverlay = Partial<AxisProps> & {
8
- dataKey: string;
9
- style?: LineStyle;
10
- rename?: string;
11
- };
12
7
  export declare type LineChartSeries = Partial<AxisProps> & {
13
8
  dataKey: string[];
14
9
  style?: Array<LineStyle | undefined>;
@@ -37,17 +32,22 @@ export declare type LineChartMetadata = {
37
32
  names: string[];
38
33
  colors: Array<string | undefined>;
39
34
  style?: Array<LineStyle | undefined>;
40
- average: AverageType;
35
+ average: AverageType | undefined;
36
+ trendline: TrendlineType[] | undefined;
41
37
  };
42
38
  overlay: {
43
- dataKey?: string;
44
- name: string;
45
- color: string;
46
- style?: LineStyle;
47
- average: AverageType;
39
+ dataKey?: string[];
40
+ names: string[] | undefined;
41
+ colors: Array<string | undefined> | undefined;
42
+ style?: Array<LineStyle | undefined>;
43
+ average: AverageType | undefined;
44
+ trendline: TrendlineType[] | undefined;
48
45
  };
49
46
  tooltip?: LineChartTooltip;
47
+ preventTooltipDisplay?: boolean;
48
+ hideTooltip?: boolean;
50
49
  showAverage?: boolean;
50
+ showTrendline?: boolean;
51
51
  hideMissingDataConnection?: boolean;
52
52
  showMarker?: boolean;
53
53
  showMarkerLabel?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"line-chart.d.ts","sourceRoot":"","sources":["../../src/types/line-chart.ts"],"names":[],"mappings":";AAgBA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE7C,oBAAY,cAAc,GAAG,OAAO,CAAC,SAAS,CAAC,GAAG;IAChD,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,oBAAY,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC,GAAG;IAClD,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,oBAAY,eAAe,GAAG,OAAO,CAAC,SAAS,CAAC,GAAG;IACjD,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,SAAS,CAAC,CAAC;IACrC,MAAM,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,MAAM,CAAC;CACnC,CAAC;AAEF,oBAAY,gBAAgB,GAAG;IAC7B,eAAe,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,MAAM,CAAC;IAC3C,gBAAgB,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,MAAM,CAAC;IAC5C,YAAY,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAChC,CAAC;AAEF,oBAAY,mBAAmB,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;AAE/D,oBAAY,SAAS,GAAG;IACtB,MAAM,CAAC,EAAE,M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,EAAE,WAAW,GAAG,SAAS,CAAC;QACjC,SAAS,EAAE,aAAa,EAAE,GAAG,SAAS,CAAC;KACxC,CAAC;IACF,OAAO,EAAE;QACP,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;QACnB,KAAK,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;QAC5B,MAAM,EAAE,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC,GAAG,SAAS,CAAC;QAC9C,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,SAAS,CAAC,CAAC;QACrC,OAAO,EAAE,WAAW,GAAG,SAAS,CAAC;QACjC,SAAS,EAAE,aAAa,EAAE,GAAG,SAAS,CAAC;KACxC,CAAC;IACF,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAC3B,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAA"}
@@ -35,5 +35,11 @@ export declare type LinesStyleConfig = {
35
35
  backgroundProps: React.SVGProps<SVGRectElement> | undefined;
36
36
  titleProps: Partial<TextProps> | undefined;
37
37
  };
38
+ trendline: {
39
+ opacity: number;
40
+ pointerEvents: string;
41
+ strokeDasharray: string;
42
+ strokeWidth: number;
43
+ };
38
44
  };
39
45
  //# sourceMappingURL=lines.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"lines.d.ts","sourceRoot":"","sources":["../../src/types/lines.ts"],"names":[],"mappings":";AAgBA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,oBAAY,gBAAgB,GAAG;IAC7B,aAAa,EAAE;QACb,WAAW,EAAE,MAA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WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;IACF,IAAI,EAAE;QACJ,WAAW,EAAE,MAAM,CAAC;QACpB,aAAa,EAAE,MAAM,CAAC;KACvB,CAAC;IACF,OAAO,EAAE;QACP,eAAe,EAAE,MAAM,CAAC;KACzB,CAAC;IACF,MAAM,EAAE;QACN,MAAM,EAAE,MAAM,CAAC;QACf,WAAW,EAAE,MAAM,CAAC;QACpB,aAAa,EAAE,MAAM,CAAC;KACvB,CAAC;IACF,OAAO,EAAE;QACP,aAAa,EAAE,MAAM,CAAC;QACtB,OAAO,EAAE,MAAM,CAAC;QAChB,aAAa,EAAE,MAAM,CAAC;QACtB,eAAe,EAAE,MAAM,CAAC;QACxB,WAAW,EAAE,MAAM,CAAC;QACpB,aAAa,EAAE,MAAM,CAAC;QACtB,eAAe,EAAE,MAAM,CAAC;QACxB,iBAAiB,EAAE,MAAM,CAAC;QAC1B,eAAe,EAAE,KAAK,CAAC,QAAQ,CAAC,cAAc,CAAC,GAAG,SAAS,CAAC;QAC5D,UAAU,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,SAAS,CAAC;KAC5C,CAAC;IACF,SAAS,EAAE;QACT,OAAO,EAAE,MAAM,CAAC;QAChB,aAAa,EAAE,MAAM,CAAC;QACtB,eAAe,EAAE,MAAM,CAAC;QACxB,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;CACH,CAAA"}
@@ -1,3 +1,5 @@
1
+ import { BarChartMetadata } from './bar-chart';
2
+ import { LineChartMetadata } from './line-chart';
1
3
  export declare type DeepPartial<T> = {
2
4
  [P in keyof T]?: DeepPartial<T[P]>;
3
5
  };
@@ -7,6 +9,7 @@ export declare enum Charts {
7
9
  LINE_CHART = "LINE_CHART",
8
10
  BAR_CHART = "BAR_CHART"
9
11
  }
12
+ export declare type CartesianChartMetadata = LineChartMetadata | BarChartMetadata;
10
13
  export declare type ScaleType = 'linear' | 'label' | 'time';
11
14
  export declare type SortingType = 'descending-key' | 'ascending-key' | 'descending-value' | 'ascending-value' | 'as-is';
12
15
  export declare type AverageType = {
@@ -15,5 +18,15 @@ export declare type AverageType = {
15
18
  name: string;
16
19
  average: number;
17
20
  }>;
18
- } | undefined;
21
+ };
22
+ export declare type TrendlineType = {
23
+ name: string;
24
+ slope: number;
25
+ intercept: number;
26
+ coefficients: number[];
27
+ score: Record<('r' | 'r2' | 'chi2' | 'rmsd'), number>;
28
+ trendline: number[];
29
+ from: number;
30
+ to: number;
31
+ };
19
32
  //# sourceMappingURL=main.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/types/main.ts"],"names":[],"mappings":"AAgBA,oBAAY,WAAW,CAAC,CAAC,IAAI;KAC1B,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CACnC,CAAC;AAEF,oBAAY,WAAW,GAAG,WAAW,GAAE,QAAQ,GAAE,SAAS,GAAE,QAAQ,GAAE,QAAQ,GAAE,UAAU,GAAE,QAAQ,GAAE,QAAQ,CAAC;AAE/G,oBAAY,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAElD,oBAAY,MAAM;IAChB,UAAU,eAAe;IACzB,SAAS,cAAc;CACxB;AAED,oBAAY,SAAS,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;AAEpD,oBAAY,WAAW,GAAG,gBAAgB,GAAG,eAAe,GAAG,kBAAkB,GAAG,iBAAiB,GAAG,OAAO,CAAC;AAEhH,oBAAY,WAAW,GAAG;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,KAAK,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC,CAAE;CACL,GAAG,SAAS,CAAA"}
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/types/main.ts"],"names":[],"mappings":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IACb,EAAE,EAAE,MAAM,CAAC;CACZ,CAAA"}
@@ -4,6 +4,11 @@ export declare type Theme = {
4
4
  headings: {
5
5
  title: string;
6
6
  subtitle: string;
7
+ button: {
8
+ background: string;
9
+ hover: string;
10
+ foreground: string;
11
+ };
7
12
  };
8
13
  axis: {
9
14
  label: string;
@@ -27,6 +32,10 @@ export declare type Theme = {
27
32
  average: string;
28
33
  averageFontColor: string;
29
34
  };
35
+ bars: {
36
+ backgroundColor: string;
37
+ overlayColor: string;
38
+ };
30
39
  brush: {
31
40
  handle: {
32
41
  fill: string;
@@ -1 +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;QACf,OAAO,EAAE,MAAM,CAAC;QAChB,gBAAgB,EAAE,MAAM,CAAC;KAC1B,CAAC;IACF,KAAK,EAAE;QACL,MAAM,EAAE;YACN,IAAI,EAAE,MAAM,CAAC;YACb,MAAM,EAAE,MAAM,CAAC;SA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AAe,EAAE,MAAM,CAAC;QACxB,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC;IACF,KAAK,EAAE;QACL,MAAM,EAAE;YACN,IAAI,EAAE,MAAM,CAAC;YACb,MAAM,EAAE,MAAM,CAAC;SAChB,CAAC;QACF,WAAW,EAAE;YACX,IAAI,EAAE,MAAM,CAAC;YACb,MAAM,EAAE,MAAM,CAAC;SAChB,CAAC;QACF,OAAO,EAAE;YACP,IAAI,EAAE,MAAM,CAAC;YACb,MAAM,EAAE,MAAM,CAAC;SAChB,CAAC;KACH,CAAC;CACH,CAAA;AAED,oBAAY,aAAa,GAAG,OAAO,GAAG,MAAM,CAAC;AAE7C,oBAAY,MAAM,GAAG,MAAM,CAAC,aAAa,EAAE,KAAK,CAAC,CAAA"}
@@ -32,13 +32,14 @@ export declare const computeAxisSystemOffset: (axis: Record<AxisOrientation, Axi
32
32
  };
33
33
  export declare const computeAxisStyleConfig: (axis: Record<AxisOrientation, AxisProps | undefined>, config?: import("../types").AxisElementsStyleConfig) => AxisConfig;
34
34
  export declare const inferScaleTypeFromDomain: (domain: Array<string | number | undefined>, scaleType?: ScaleType) => ScaleType;
35
+ export declare const clampLinearDomain: (domain: number[]) => [number, number] | undefined;
35
36
  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
37
  export declare const handleTickFormat: (axis: CartesianAxis) => (v: string | Date | NumberValue, i: number) => string | NumberValue | undefined;
37
38
  export declare const handleNumberOfTicks: (width: number, height: number, axis: CartesianAxis, config: ViewportStyleConfig) => number;
38
39
  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 handleVerticalTickLabelTransform: (_: any, isVertical: boolean, axis: CartesianAxis) => {};
40
41
  export declare const handleVerticalTickLabelOffset: (width: number, config: CartesianStyleConfig, axis?: AxisProps) => number;
41
- export declare const computeAxisProperties: ({ axis, maxRangeX, maxRangeY, positionTop, positionRight, positionBottom, positionLeft, }: {
42
+ export declare const computeAxisProperties: ({ axis, maxRangeX, maxRangeY, positionTop, positionRight, positionBottom, positionLeft, config, }: {
42
43
  axis?: AxisProps | undefined;
43
44
  maxRangeX: number;
44
45
  maxRangeY: number;
@@ -46,6 +47,11 @@ export declare const computeAxisProperties: ({ axis, maxRangeX, maxRangeY, posit
46
47
  positionRight: number;
47
48
  positionBottom: number;
48
49
  positionLeft: number;
50
+ config: {
51
+ hasReversedIndex: boolean;
52
+ hasMirroredDomainsHorizontal: boolean;
53
+ hasMirroredDomainsVertical: boolean;
54
+ };
49
55
  }) => CartesianAxis | undefined;
50
56
  export declare const computeAxisSystemProperties: (axis: Record<AxisOrientation, AxisProps | undefined>, dimension: {
51
57
  maxWidth: number;
@@ -55,6 +61,10 @@ export declare const computeAxisSystemProperties: (axis: Record<AxisOrientation,
55
61
  right: number;
56
62
  bottom: number;
57
63
  left: number;
64
+ }, config: {
65
+ hasReversedIndex: boolean;
66
+ hasMirroredDomainsHorizontal: boolean;
67
+ hasMirroredDomainsVertical: boolean;
58
68
  }) => CartesianxAxisSystem;
59
69
  export declare const handleChartAxisLayout: (index: Except<AxisProps, 'orientation'>, series: Except<AxisProps, 'orientation'>, overlay?: Except<AxisProps, 'orientation'>) => Record<CartesianChartLayout, Record<AxisOrientation, AxisProps | undefined>>;
60
70
  //# sourceMappingURL=axis.d.ts.map
@@ -1 +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,EAA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AAM;mBACJ,MAAM;oBACL,MAAM;kBACR,MAAM;YACZ;QACN,gBAAgB,EAAE,OAAO,CAAC;QAC1B,4BAA4B,EAAE,OAAO,CAAC;QACtC,0BAA0B,EAAE,OAAO,CAAC;KACrC;MACC,aAAa,GAAG,SAmEnB,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,UACO;IACN,gBAAgB,EAAE,OAAO,CAAC;IAC1B,4BAA4B,EAAE,OAAO,CAAC;IACtC,0BAA0B,EAAE,OAAO,CAAC;CACrC,yBAwCF,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"}
@@ -16,6 +16,7 @@
16
16
  import { scaleBand, scaleLinear, scaleUtc, } from '@visx/scale';
17
17
  import _ from 'lodash';
18
18
  import { axisStyleConfig, } from '../style-config';
19
+ import { mirrorDomain } from './data';
19
20
  import { truncate } from './format';
20
21
  import { getMaxCharactersNum, getMinMaxDate, getMinMaxNumber, isArrayTypeDate, isArrayTypeNumber, isArrayTypeString, removeNilsFromDomain, } from './math';
21
22
  import { manageViewport } from './viewport';
@@ -186,21 +187,36 @@ export const inferScaleTypeFromDomain = (domain, scaleType) => {
186
187
  }
187
188
  return 'label';
188
189
  };
190
+ export const clampLinearDomain = (domain) => {
191
+ const minMax = getMinMaxNumber(domain.map(v => v));
192
+ const hasOnlyPositiveDomain = Boolean(minMax?.every(e => e > 0));
193
+ const hasOnlyNegativeDomain = Boolean(minMax?.every(e => e < 0));
194
+ let clamped = minMax;
195
+ if (hasOnlyPositiveDomain) {
196
+ clamped = [0, minMax[1]];
197
+ }
198
+ if (hasOnlyNegativeDomain) {
199
+ clamped = [minMax[0], 0];
200
+ }
201
+ return clamped;
202
+ };
189
203
  export const scaleDomainToAxis = (axis) => {
190
- const { domain, range, scaleType, clamp, nice, round = true, paddingInner, paddingOuter, } = axis;
191
- const hasData = domain.length && range?.length && scaleType;
204
+ const { domain, range, scaleType, clamp, nice, round = true, padding = undefined, paddingInner = 1, paddingOuter = 1, } = axis;
205
+ const hasData = Boolean(domain.length && range?.length && scaleType);
192
206
  if (hasData) {
193
207
  if (scaleType === 'label') {
194
208
  return scaleBand({
195
209
  domain: domain.map(v => `${v}`),
196
210
  range,
197
- paddingInner: paddingInner ?? 1,
198
- paddingOuter: paddingOuter ?? 1,
211
+ paddingInner,
212
+ paddingOuter,
213
+ padding,
214
+ round,
199
215
  });
200
216
  }
201
217
  if (scaleType === 'linear') {
202
218
  return scaleLinear({
203
- domain: getMinMaxNumber(domain.map(v => Number(v))),
219
+ domain: clampLinearDomain(domain),
204
220
  range,
205
221
  round,
206
222
  nice,
@@ -266,13 +282,14 @@ export const hasVerticalTickLabel = (width, axis, config) => {
266
282
  }
267
283
  return false;
268
284
  };
269
- export const handleVerticalTickLabelTransform = (t, isVertical, axis) => {
270
- const { orientation, scale } = axis;
285
+ export const handleVerticalTickLabelTransform = (_, isVertical, axis) => {
286
+ const { orientation } = axis;
271
287
  let res = {};
272
288
  if (orientation === 'bottom') {
273
289
  if (isVertical) {
274
290
  res = {
275
- transform: `translate(13, 6) rotate(90, ${scale(t) ?? 0}, 0)`,
291
+ dy: '-6',
292
+ textAnchor: 'start',
276
293
  };
277
294
  }
278
295
  else {
@@ -282,7 +299,7 @@ export const handleVerticalTickLabelTransform = (t, isVertical, axis) => {
282
299
  if (orientation === 'top') {
283
300
  if (isVertical) {
284
301
  res = {
285
- transform: `translate(9, -4) rotate(-90, ${scale(t) ?? 0}, 0)`,
302
+ textAnchor: 'end',
286
303
  };
287
304
  }
288
305
  else {
@@ -310,41 +327,57 @@ export const handleVerticalTickLabelOffset = (width, config, axis) => {
310
327
  }
311
328
  return res * w;
312
329
  };
313
- export const computeAxisProperties = ({ axis, maxRangeX, maxRangeY, positionTop, positionRight, positionBottom, positionLeft, }) => {
330
+ export const computeAxisProperties = ({ axis, maxRangeX, maxRangeY, positionTop, positionRight, positionBottom, positionLeft, config, }) => {
314
331
  if (axis) {
315
332
  const { orientation } = axis;
333
+ const { hasMirroredDomainsHorizontal, hasMirroredDomainsVertical, hasReversedIndex } = config;
316
334
  if (orientation === 'top') {
335
+ const mirrored = mirrorDomain(axis.domain);
336
+ const domain = hasMirroredDomainsVertical ? mirrored : axis.domain;
317
337
  return {
318
338
  ...axis,
319
339
  orientation,
320
- scale: scaleDomainToAxis({ ...axis, range: [0, maxRangeX] }),
340
+ domain,
341
+ scale: scaleDomainToAxis({ ...axis, range: [0, maxRangeX], domain }),
321
342
  top: positionTop,
322
343
  left: positionLeft,
323
344
  };
324
345
  }
325
346
  if (orientation === 'right') {
347
+ const mirrored = mirrorDomain(axis.domain);
348
+ const domain = hasMirroredDomainsHorizontal ? mirrored : axis.domain;
326
349
  return {
327
350
  ...axis,
328
351
  orientation,
329
- scale: scaleDomainToAxis({ ...axis, range: [maxRangeY, 0] }),
352
+ domain,
353
+ scale: scaleDomainToAxis({ ...axis, range: [maxRangeY, 0], domain }),
330
354
  top: positionTop,
331
355
  left: positionRight,
332
356
  };
333
357
  }
334
358
  if (orientation === 'bottom') {
359
+ const mirrored = mirrorDomain(axis.domain);
360
+ const domain = hasMirroredDomainsVertical ? mirrored : axis.domain;
335
361
  return {
336
362
  ...axis,
337
363
  orientation,
338
- scale: scaleDomainToAxis({ ...axis, range: [0, maxRangeX] }),
364
+ domain,
365
+ scale: scaleDomainToAxis({ ...axis, range: [0, maxRangeX], domain }),
339
366
  top: positionBottom,
340
367
  left: positionLeft,
341
368
  };
342
369
  }
343
370
  if (orientation === 'left') {
371
+ const reversed = [0, maxRangeY];
372
+ const regular = [maxRangeY, 0];
373
+ const range = hasReversedIndex ? reversed : regular;
374
+ const mirrored = mirrorDomain(axis.domain);
375
+ const domain = hasMirroredDomainsHorizontal ? mirrored : axis.domain;
344
376
  return {
345
377
  ...axis,
346
378
  orientation,
347
- scale: scaleDomainToAxis({ ...axis, range: [maxRangeY, 0] }),
379
+ domain,
380
+ scale: scaleDomainToAxis({ ...axis, range, domain }),
348
381
  top: positionTop,
349
382
  left: positionLeft,
350
383
  };
@@ -352,7 +385,7 @@ export const computeAxisProperties = ({ axis, maxRangeX, maxRangeY, positionTop,
352
385
  }
353
386
  return undefined;
354
387
  };
355
- export const computeAxisSystemProperties = (axis, dimension, position) => {
388
+ export const computeAxisSystemProperties = (axis, dimension, position, config) => {
356
389
  const shared = {
357
390
  maxRangeX: dimension.maxWidth,
358
391
  maxRangeY: dimension.maxHeight,
@@ -363,18 +396,22 @@ export const computeAxisSystemProperties = (axis, dimension, position) => {
363
396
  };
364
397
  const t = computeAxisProperties({
365
398
  axis: axis.top,
399
+ config,
366
400
  ...shared,
367
401
  });
368
402
  const r = computeAxisProperties({
369
403
  axis: axis.right,
404
+ config,
370
405
  ...shared,
371
406
  });
372
407
  const b = computeAxisProperties({
373
408
  axis: axis.bottom,
409
+ config,
374
410
  ...shared,
375
411
  });
376
412
  const l = computeAxisProperties({
377
413
  axis: axis.left,
414
+ config,
378
415
  ...shared,
379
416
  });
380
417
  const a = {
@@ -1,5 +1,5 @@
1
1
  import { cartesianStyleConfig, viewportStyleConfig } from '../style-config';
2
- import { computeAxisOffset, computeAxisProperties, computeAxisStyleConfig, computeAxisSystemOffset, computeAxisSystemProperties, getAxisOffset, getLabelOffset, getTickLabelSize, handleChartAxisLayout, handleNumberOfTicks, handleTickFormat, handleVerticalTickLabelOffset, handleVerticalTickLabelTransform, hasVerticalTickLabel, inferScaleTypeFromDomain, scaleDomainToAxis, } from './axis';
2
+ import { clampLinearDomain, computeAxisOffset, computeAxisProperties, computeAxisStyleConfig, computeAxisSystemOffset, computeAxisSystemProperties, getAxisOffset, getLabelOffset, getTickLabelSize, handleChartAxisLayout, handleNumberOfTicks, handleTickFormat, handleVerticalTickLabelOffset, handleVerticalTickLabelTransform, hasVerticalTickLabel, inferScaleTypeFromDomain, scaleDomainToAxis, } from './axis';
3
3
  describe('getAxisOffset()', () => {
4
4
  it('should return offset for top axis', () => {
5
5
  const res = getAxisOffset({
@@ -391,7 +391,7 @@ describe('computeAxisStyleConfig()', () => {
391
391
  };
392
392
  const res = computeAxisStyleConfig(system);
393
393
  const exp = {
394
- bottom: { labelOffset: 28, labelProps: { dominantBaseline: 'auto' }, tickLabelProps: { dominantBaseline: 'auto', dy: 4 } },
394
+ bottom: { labelOffset: 28, labelProps: { dominantBaseline: 'auto' }, tickLabelProps: { dominantBaseline: 'middle', dy: 4 } },
395
395
  left: { labelOffset: 28, labelProps: { dominantBaseline: 'auto' }, tickLabelProps: { dominantBaseline: 'middle', dx: -4, textAnchor: 'end' } },
396
396
  offset: {
397
397
  bottomAxisOffset: 63,
@@ -404,7 +404,7 @@ describe('computeAxisStyleConfig()', () => {
404
404
  right: { labelOffset: 28, labelProps: { dominantBaseline: 'auto' }, tickLabelProps: { dominantBaseline: 'middle', dx: 4, textAnchor: 'start' } },
405
405
  style: {
406
406
  axisLineProps: { strokeDasharray: '', strokeWidth: 1 },
407
- bottom: { labelProps: { dominantBaseline: 'auto' }, tickLabelProps: { dominantBaseline: 'auto', dy: 4 } },
407
+ bottom: { labelProps: { dominantBaseline: 'auto' }, tickLabelProps: { dominantBaseline: 'middle', dy: 4 } },
408
408
  formatting: { maxCharactersLength: 20, omission: '...' },
409
409
  labelProps: {
410
410
  fontFamily: 'system-ui, sans-serif', fontSize: 12, fontWeight: 600, textAnchor: 'middle',
@@ -416,9 +416,9 @@ describe('computeAxisStyleConfig()', () => {
416
416
  },
417
417
  tickLabelProps: { fontFamily: 'system-ui, sans-serif', fontSize: 14, fontWeight: 400 },
418
418
  tickLineProps: { length: 4, strokeLinecap: 'round', strokeWidth: 1 },
419
- top: { labelProps: { dominantBaseline: 'auto' }, tickLabelProps: { dominantBaseline: 'auto', dy: -12 } },
419
+ top: { labelProps: { dominantBaseline: 'auto' }, tickLabelProps: { dominantBaseline: 'middle', dy: -12 } },
420
420
  },
421
- top: { labelOffset: 28, labelProps: { dominantBaseline: 'auto' }, tickLabelProps: { dominantBaseline: 'auto', dy: -12 } },
421
+ top: { labelOffset: 28, labelProps: { dominantBaseline: 'auto' }, tickLabelProps: { dominantBaseline: 'middle', dy: -12 } },
422
422
  };
423
423
  expect(res).toStrictEqual(exp);
424
424
  });
@@ -500,6 +500,11 @@ describe('scaleDomainToAxis()', () => {
500
500
  });
501
501
  });
502
502
  describe('handleTickFormat()', () => {
503
+ const config = {
504
+ hasReversedIndex: false,
505
+ hasMirroredDomainsHorizontal: false,
506
+ hasMirroredDomainsVertical: false,
507
+ };
503
508
  it('should return the same value w/o tickFormat', () => {
504
509
  const axis = {
505
510
  domain: [0, 1],
@@ -515,6 +520,7 @@ describe('handleTickFormat()', () => {
515
520
  positionRight: 0,
516
521
  positionBottom: 0,
517
522
  positionLeft: 0,
523
+ config,
518
524
  });
519
525
  const func = handleTickFormat(computed);
520
526
  const res = func(1, 1);
@@ -536,6 +542,7 @@ describe('handleTickFormat()', () => {
536
542
  positionRight: 0,
537
543
  positionBottom: 0,
538
544
  positionLeft: 0,
545
+ config,
539
546
  });
540
547
  const func = handleTickFormat(computed);
541
548
  const res = func(1, 1);
@@ -558,6 +565,7 @@ describe('handleTickFormat()', () => {
558
565
  positionRight: 0,
559
566
  positionBottom: 0,
560
567
  positionLeft: 0,
568
+ config,
561
569
  });
562
570
  const func = handleTickFormat(computed);
563
571
  const res = func(1, 1);
@@ -580,6 +588,7 @@ describe('handleTickFormat()', () => {
580
588
  positionRight: 0,
581
589
  positionBottom: 0,
582
590
  positionLeft: 0,
591
+ config,
583
592
  });
584
593
  const func = handleTickFormat(computed);
585
594
  const res = func('1234567890123456789012345', 1);
@@ -602,6 +611,7 @@ describe('handleTickFormat()', () => {
602
611
  positionRight: 0,
603
612
  positionBottom: 0,
604
613
  positionLeft: 0,
614
+ config,
605
615
  });
606
616
  const func = handleTickFormat(computed);
607
617
  const res = func('1234567890123456789012345', 1);
@@ -624,6 +634,7 @@ describe('handleTickFormat()', () => {
624
634
  positionRight: 0,
625
635
  positionBottom: 0,
626
636
  positionLeft: 0,
637
+ config,
627
638
  });
628
639
  const func = handleTickFormat(computed);
629
640
  const res = func('01-01-2023', 1);
@@ -632,6 +643,11 @@ describe('handleTickFormat()', () => {
632
643
  });
633
644
  });
634
645
  describe('handleNumberOfTicks()', () => {
646
+ const config = {
647
+ hasReversedIndex: false,
648
+ hasMirroredDomainsHorizontal: false,
649
+ hasMirroredDomainsVertical: false,
650
+ };
635
651
  it('should return 10 fro large size', () => {
636
652
  const axis = {
637
653
  domain: [0, 1],
@@ -647,6 +663,7 @@ describe('handleNumberOfTicks()', () => {
647
663
  positionRight: 0,
648
664
  positionBottom: 0,
649
665
  positionLeft: 0,
666
+ config,
650
667
  });
651
668
  const res = handleNumberOfTicks(800, 600, computed, viewportStyleConfig);
652
669
  const exp = 10;
@@ -667,6 +684,7 @@ describe('handleNumberOfTicks()', () => {
667
684
  positionRight: 0,
668
685
  positionBottom: 0,
669
686
  positionLeft: 0,
687
+ config,
670
688
  });
671
689
  const res = handleNumberOfTicks(400, 400, computed, viewportStyleConfig);
672
690
  const exp = 5;
@@ -687,6 +705,7 @@ describe('handleNumberOfTicks()', () => {
687
705
  positionRight: 0,
688
706
  positionBottom: 0,
689
707
  positionLeft: 0,
708
+ config,
690
709
  });
691
710
  const res = handleNumberOfTicks(200, 200, computed, viewportStyleConfig);
692
711
  const exp = 3;
@@ -768,6 +787,11 @@ describe('hasVerticalTickLabel()', () => {
768
787
  });
769
788
  });
770
789
  describe('handleVerticalTickLabelTransform()', () => {
790
+ const config = {
791
+ hasReversedIndex: false,
792
+ hasMirroredDomainsHorizontal: false,
793
+ hasMirroredDomainsVertical: false,
794
+ };
771
795
  it('should return style for top axis', () => {
772
796
  const axis = {
773
797
  domain: [0, 1],
@@ -783,9 +807,10 @@ describe('handleVerticalTickLabelTransform()', () => {
783
807
  positionRight: 0,
784
808
  positionBottom: 0,
785
809
  positionLeft: 0,
810
+ config,
786
811
  });
787
812
  const res = handleVerticalTickLabelTransform(1, true, computed);
788
- const exp = { transform: 'translate(9, -4) rotate(-90, 800, 0)' };
813
+ const exp = { textAnchor: 'end' };
789
814
  expect(res).toStrictEqual(exp);
790
815
  });
791
816
  it('should return style for top axis - horizontal label', () => {
@@ -803,6 +828,7 @@ describe('handleVerticalTickLabelTransform()', () => {
803
828
  positionRight: 0,
804
829
  positionBottom: 0,
805
830
  positionLeft: 0,
831
+ config,
806
832
  });
807
833
  const res = handleVerticalTickLabelTransform(1, false, computed);
808
834
  const exp = { transform: '', textAnchor: 'middle' };
@@ -823,9 +849,13 @@ describe('handleVerticalTickLabelTransform()', () => {
823
849
  positionRight: 0,
824
850
  positionBottom: 0,
825
851
  positionLeft: 0,
852
+ config,
826
853
  });
827
854
  const res = handleVerticalTickLabelTransform(1, true, computed);
828
- const exp = { transform: 'translate(13, 6) rotate(90, 800, 0)' };
855
+ const exp = {
856
+ dy: '-6',
857
+ textAnchor: 'start',
858
+ };
829
859
  expect(res).toStrictEqual(exp);
830
860
  });
831
861
  it('should return style for bottom axis - horizontal label', () => {
@@ -843,6 +873,7 @@ describe('handleVerticalTickLabelTransform()', () => {
843
873
  positionRight: 0,
844
874
  positionBottom: 0,
845
875
  positionLeft: 0,
876
+ config,
846
877
  });
847
878
  const res = handleVerticalTickLabelTransform(1, false, computed);
848
879
  const exp = { transform: '', textAnchor: 'middle' };
@@ -863,6 +894,7 @@ describe('handleVerticalTickLabelTransform()', () => {
863
894
  positionRight: 0,
864
895
  positionBottom: 0,
865
896
  positionLeft: 0,
897
+ config,
866
898
  });
867
899
  const res = handleVerticalTickLabelTransform(1, true, computed);
868
900
  const exp = {};
@@ -908,6 +940,11 @@ describe('handleVerticalTickLabelOffset()', () => {
908
940
  });
909
941
  });
910
942
  describe('computeAxisProperties()', () => {
943
+ const config = {
944
+ hasReversedIndex: false,
945
+ hasMirroredDomainsHorizontal: false,
946
+ hasMirroredDomainsVertical: false,
947
+ };
911
948
  it('should return properties for top axis', () => {
912
949
  const axis = {
913
950
  domain: [0, 1],
@@ -922,6 +959,7 @@ describe('computeAxisProperties()', () => {
922
959
  positionRight: 2,
923
960
  positionBottom: 3,
924
961
  positionLeft: 4,
962
+ config,
925
963
  });
926
964
  expect(res.scale).toBeDefined();
927
965
  });
@@ -939,6 +977,7 @@ describe('computeAxisProperties()', () => {
939
977
  positionRight: 2,
940
978
  positionBottom: 3,
941
979
  positionLeft: 4,
980
+ config,
942
981
  });
943
982
  expect(res.scale).toBeDefined();
944
983
  });
@@ -956,6 +995,7 @@ describe('computeAxisProperties()', () => {
956
995
  positionRight: 2,
957
996
  positionBottom: 3,
958
997
  positionLeft: 4,
998
+ config,
959
999
  });
960
1000
  expect(res.scale).toBeDefined();
961
1001
  });
@@ -973,6 +1013,7 @@ describe('computeAxisProperties()', () => {
973
1013
  positionRight: 2,
974
1014
  positionBottom: 3,
975
1015
  positionLeft: 4,
1016
+ config,
976
1017
  });
977
1018
  expect(res.scale).toBeDefined();
978
1019
  });
@@ -986,11 +1027,17 @@ describe('computeAxisProperties()', () => {
986
1027
  positionRight: 2,
987
1028
  positionBottom: 3,
988
1029
  positionLeft: 4,
1030
+ config,
989
1031
  });
990
1032
  expect(res).toBeUndefined();
991
1033
  });
992
1034
  });
993
1035
  describe('computeAxisSystemProperties()', () => {
1036
+ const config = {
1037
+ hasReversedIndex: false,
1038
+ hasMirroredDomainsHorizontal: false,
1039
+ hasMirroredDomainsVertical: false,
1040
+ };
994
1041
  it('should return', () => {
995
1042
  const axis = {
996
1043
  top: {
@@ -1016,7 +1063,7 @@ describe('computeAxisSystemProperties()', () => {
1016
1063
  };
1017
1064
  const res = computeAxisSystemProperties(axis, { maxWidth: 800, maxHeight: 600 }, {
1018
1065
  top: 1, right: 2, bottom: 3, left: 4,
1019
- });
1066
+ }, config);
1020
1067
  expect(res.top.scale).toBeDefined();
1021
1068
  expect(res.right.scale).toBeDefined();
1022
1069
  expect(res.bottom.scale).toBeDefined();
@@ -1069,3 +1116,20 @@ describe('handleChartAxisLayout()', () => {
1069
1116
  expect(res).toStrictEqual(exp);
1070
1117
  });
1071
1118
  });
1119
+ describe('clampLinearDomain()', () => {
1120
+ it('should return [0,max] for positive only values', () => {
1121
+ const res = clampLinearDomain([10, 100]);
1122
+ const exp = [0, 100];
1123
+ expect(res).toStrictEqual(exp);
1124
+ });
1125
+ it('should return [0,max] for negative only values', () => {
1126
+ const res = clampLinearDomain([-10, -100]);
1127
+ const exp = [-100, 0];
1128
+ expect(res).toStrictEqual(exp);
1129
+ });
1130
+ it('should return domain for both positive and negative values', () => {
1131
+ const res = clampLinearDomain([-10, 100]);
1132
+ const exp = [-10, 100];
1133
+ expect(res).toStrictEqual(exp);
1134
+ });
1135
+ });