@wonderflow/charts 12.8.0 → 12.10.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 (148) hide show
  1. package/dist/components/bar-chart/bar-chart.d.ts +54 -0
  2. package/dist/components/bar-chart/bar-chart.d.ts.map +1 -0
  3. package/dist/components/bar-chart/bar-chart.js +56 -0
  4. package/dist/components/bar-chart/bar-chart.test.d.ts +2 -0
  5. package/dist/components/bar-chart/bar-chart.test.d.ts.map +1 -0
  6. package/dist/components/bar-chart/bar-chart.test.js +15 -0
  7. package/dist/components/bar-chart/index.d.ts +3 -0
  8. package/dist/components/bar-chart/index.d.ts.map +1 -0
  9. package/dist/components/bar-chart/index.js +16 -0
  10. package/dist/components/cartesian-base/cartesian-base-axis.js +15 -15
  11. package/dist/components/cartesian-base/cartesian-base-brush.d.ts +21 -0
  12. package/dist/components/cartesian-base/cartesian-base-brush.d.ts.map +1 -0
  13. package/dist/components/cartesian-base/cartesian-base-brush.js +59 -0
  14. package/dist/components/cartesian-base/cartesian-base-grid.d.ts +1 -1
  15. package/dist/components/cartesian-base/cartesian-base-grid.d.ts.map +1 -1
  16. package/dist/components/cartesian-base/cartesian-base-legend.d.ts +3 -2
  17. package/dist/components/cartesian-base/cartesian-base-legend.d.ts.map +1 -1
  18. package/dist/components/cartesian-base/cartesian-base-legend.js +9 -8
  19. package/dist/components/cartesian-base/cartesian-base.d.ts +26 -6
  20. package/dist/components/cartesian-base/cartesian-base.d.ts.map +1 -1
  21. package/dist/components/cartesian-base/cartesian-base.js +41 -76
  22. package/dist/components/cartesian-base/cartesian-base.module.css +1 -1
  23. package/dist/components/cartesian-base/cartesian-base.test.d.ts +1 -1
  24. package/dist/components/cartesian-base/cartesian-base.test.d.ts.map +1 -1
  25. package/dist/components/cartesian-base/cartesian-base.test.js +33 -6
  26. package/dist/components/index.d.ts +1 -0
  27. package/dist/components/index.d.ts.map +1 -1
  28. package/dist/components/index.js +1 -0
  29. package/dist/components/line-chart/line-chart.d.ts +59 -2
  30. package/dist/components/line-chart/line-chart.d.ts.map +1 -1
  31. package/dist/components/line-chart/line-chart.js +16 -41
  32. package/dist/components/loader/loader.test.js +3 -1
  33. package/dist/components/shapes/bars/bars.d.ts +3 -0
  34. package/dist/components/shapes/bars/bars.d.ts.map +1 -0
  35. package/dist/components/shapes/bars/bars.js +24 -0
  36. package/dist/components/shapes/bars/bars.module.css +1 -0
  37. package/dist/components/shapes/bars/bars.test.d.ts +2 -0
  38. package/dist/components/shapes/bars/bars.test.d.ts.map +1 -0
  39. package/dist/components/shapes/bars/bars.test.js +71 -0
  40. package/dist/components/shapes/bars/index.d.ts +2 -0
  41. package/dist/components/shapes/bars/index.d.ts.map +1 -0
  42. package/dist/components/shapes/bars/index.js +16 -0
  43. package/dist/components/shapes/index.d.ts +1 -0
  44. package/dist/components/shapes/index.d.ts.map +1 -1
  45. package/dist/components/shapes/index.js +1 -0
  46. package/dist/components/shapes/lines/lines-average.d.ts +3 -0
  47. package/dist/components/shapes/lines/lines-average.d.ts.map +1 -0
  48. package/dist/components/shapes/lines/lines-average.js +69 -0
  49. package/dist/components/shapes/lines/lines-marker-labels.d.ts.map +1 -1
  50. package/dist/components/shapes/lines/lines-marker-labels.js +14 -7
  51. package/dist/components/shapes/lines/lines-overlay.d.ts.map +1 -1
  52. package/dist/components/shapes/lines/lines-overlay.js +8 -5
  53. package/dist/components/shapes/lines/lines-series.d.ts.map +1 -1
  54. package/dist/components/shapes/lines/lines-series.js +10 -7
  55. package/dist/components/shapes/lines/lines-tooltip.d.ts.map +1 -1
  56. package/dist/components/shapes/lines/lines-tooltip.js +16 -20
  57. package/dist/components/shapes/lines/lines.d.ts.map +1 -1
  58. package/dist/components/shapes/lines/lines.js +18 -16
  59. package/dist/components/shapes/lines/lines.module.css +1 -1
  60. package/dist/components/shapes/lines/lines.test.js +13 -7
  61. package/dist/hooks/hooks.test.d.ts +2 -0
  62. package/dist/hooks/hooks.test.d.ts.map +1 -0
  63. package/dist/hooks/hooks.test.js +153 -0
  64. package/dist/hooks/index.d.ts +8 -0
  65. package/dist/hooks/index.d.ts.map +1 -0
  66. package/dist/hooks/index.js +19 -0
  67. package/dist/hooks/useBrush.d.ts +74 -0
  68. package/dist/hooks/useBrush.d.ts.map +1 -0
  69. package/dist/hooks/useBrush.js +175 -0
  70. package/dist/hooks/useCartesian.d.ts +73 -0
  71. package/dist/hooks/useCartesian.d.ts.map +1 -0
  72. package/dist/hooks/useCartesian.js +143 -0
  73. package/dist/hooks/useLineChart.d.ts +39 -0
  74. package/dist/hooks/useLineChart.d.ts.map +1 -0
  75. package/dist/hooks/useLineChart.js +79 -0
  76. package/dist/hooks/useSSR.d.ts +5 -0
  77. package/dist/hooks/useSSR.d.ts.map +1 -0
  78. package/dist/hooks/useSSR.js +24 -0
  79. package/dist/index.d.ts +2 -0
  80. package/dist/index.d.ts.map +1 -1
  81. package/dist/index.js +3 -1
  82. package/dist/providers/cartesian.d.ts +1 -0
  83. package/dist/providers/cartesian.d.ts.map +1 -1
  84. package/dist/providers/cartesian.js +20 -18
  85. package/dist/providers/data.d.ts +3 -1
  86. package/dist/providers/data.d.ts.map +1 -1
  87. package/dist/providers/data.js +19 -17
  88. package/dist/providers/layout.d.ts.map +1 -1
  89. package/dist/providers/layout.js +17 -16
  90. package/dist/providers/style-config.d.ts.map +1 -1
  91. package/dist/providers/style-config.js +17 -16
  92. package/dist/providers/theme.d.ts.map +1 -1
  93. package/dist/providers/theme.js +16 -16
  94. package/dist/style-config/brush.d.ts +3 -0
  95. package/dist/style-config/brush.d.ts.map +1 -0
  96. package/dist/style-config/brush.js +28 -0
  97. package/dist/style-config/cartesian.d.ts.map +1 -1
  98. package/dist/style-config/cartesian.js +5 -3
  99. package/dist/style-config/index.d.ts +1 -0
  100. package/dist/style-config/index.d.ts.map +1 -1
  101. package/dist/style-config/index.js +2 -1
  102. package/dist/style-config/lines.d.ts.map +1 -1
  103. package/dist/style-config/lines.js +13 -1
  104. package/dist/style-config/themes.d.ts.map +1 -1
  105. package/dist/style-config/themes.js +33 -1
  106. package/dist/types/bar-chart.d.ts +49 -0
  107. package/dist/types/bar-chart.d.ts.map +1 -0
  108. package/dist/types/bar-chart.js +54 -0
  109. package/dist/types/brush.d.ts +14 -0
  110. package/dist/types/brush.d.ts.map +1 -0
  111. package/dist/types/brush.js +16 -0
  112. package/dist/types/cartesian.d.ts +4 -2
  113. package/dist/types/cartesian.d.ts.map +1 -1
  114. package/dist/types/cartesian.js +1 -1
  115. package/dist/types/index.d.ts +1 -0
  116. package/dist/types/index.d.ts.map +1 -1
  117. package/dist/types/index.js +1 -0
  118. package/dist/types/line-chart.d.ts +4 -1
  119. package/dist/types/line-chart.d.ts.map +1 -1
  120. package/dist/types/line-chart.js +1 -1
  121. package/dist/types/lines.d.ts +14 -0
  122. package/dist/types/lines.d.ts.map +1 -1
  123. package/dist/types/lines.js +1 -1
  124. package/dist/types/main.d.ts +9 -1
  125. package/dist/types/main.d.ts.map +1 -1
  126. package/dist/types/main.js +1 -1
  127. package/dist/types/themes.d.ts +16 -0
  128. package/dist/types/themes.d.ts.map +1 -1
  129. package/dist/types/themes.js +1 -1
  130. package/dist/types/viewport.d.ts +4 -4
  131. package/dist/types/viewport.d.ts.map +1 -1
  132. package/dist/types/viewport.js +1 -1
  133. package/dist/utils/axis.js +14 -14
  134. package/dist/utils/data.d.ts +10 -7
  135. package/dist/utils/data.d.ts.map +1 -1
  136. package/dist/utils/data.js +26 -1
  137. package/dist/utils/data.test.js +109 -1
  138. package/dist/utils/lines.d.ts +3 -3
  139. package/dist/utils/lines.d.ts.map +1 -1
  140. package/dist/utils/lines.js +3 -3
  141. package/dist/utils/lines.test.js +6 -6
  142. package/dist/utils/metadata.d.ts +7 -4
  143. package/dist/utils/metadata.d.ts.map +1 -1
  144. package/dist/utils/metadata.js +6 -2
  145. package/dist/utils/metadata.test.js +8 -8
  146. package/dist/utils/viewport.d.ts +3 -1
  147. package/dist/utils/viewport.d.ts.map +1 -1
  148. package/package.json +15 -14
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { AxisProps } from './cartesian';
3
- import { Charts } from './main';
3
+ import { AverageType, Charts } from './main';
4
4
  export declare type LineChartIndex = Partial<AxisProps> & {
5
5
  dataKey: string;
6
6
  };
@@ -37,14 +37,17 @@ export declare type LineChartMetadata = {
37
37
  names: string[];
38
38
  colors: Array<string | undefined>;
39
39
  style?: Array<LineStyle | undefined>;
40
+ average: AverageType;
40
41
  };
41
42
  overlay: {
42
43
  dataKey?: string;
43
44
  name: string;
44
45
  color: string;
45
46
  style?: LineStyle;
47
+ average: AverageType;
46
48
  };
47
49
  tooltip?: LineChartTooltip;
50
+ showAverage?: boolean;
48
51
  hideMissingDataConnection?: boolean;
49
52
  showMarker?: boolean;
50
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,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,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,g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C;IACrB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,CAAA;AAED,oBAAY,iBAAiB,GAAG;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,mBAAmB,CAAC;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE;QACN,OAAO,EAAE,MAAM,EAAE,CAAC;QAClB,KAAK,EAAE,MAAM,EAAE,CAAC;QAChB,MAAM,EAAE,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;QAClC,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,SAAS,CAAC,CAAC;QACrC,OAAO,EAAE,WAAW,CAAC;KACtB,CAAC;IACF,OAAO,EAAE;QACP,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,CAAC,EAAE,SAAS,CAAC;QAClB,OAAO,EAAE,WAAW,CAAC;KACtB,CAAC;IACF,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAC3B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,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"}
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright 2023 Wonderflow Design Team
2
+ * Copyright 2023-2024 Wonderflow Design Team
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -1,3 +1,5 @@
1
+ /// <reference types="react" />
2
+ import { TextProps } from '@visx/text';
1
3
  export declare type LinesStyleConfig = {
2
4
  lineIndicator: {
3
5
  strokeWidth: number;
@@ -21,5 +23,17 @@ export declare type LinesStyleConfig = {
21
23
  strokeWidth: number;
22
24
  strokeOpacity: number;
23
25
  };
26
+ average: {
27
+ maxLabelWidth: number;
28
+ opacity: number;
29
+ pointerEvents: string;
30
+ strokeDasharray: string;
31
+ strokeWidth: number;
32
+ titleFontSize: number;
33
+ titleFontWeight: number;
34
+ backgroundPadding: number;
35
+ backgroundProps: React.SVGProps<SVGRectElement> | undefined;
36
+ titleProps: Partial<TextProps> | undefined;
37
+ };
24
38
  };
25
39
  //# sourceMappingURL=lines.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"lines.d.ts","sourceRoot":"","sources":["../../src/types/lines.ts"],"names":[],"mappings":"AAgBA,oBAAY,gBAAgB,GAAG;IAC7B,aAAa,EAAE;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,EAAE,MAAM,CAAC;QAChB,aAAa,EAAE,MAAM,CAAC;QACtB,eAAe,EAAE,MAAM,CAAC;KACzB,CAAC;IACF,SAAS,EAAE;QACT,MAAM,EAAE,MAAM,CAAC;QACf,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;CACH,CAAA"}
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,MAAM,CAAC;QACpB,OAAO,EAAE,MAAM,CAAC;QAChB,aAAa,EAAE,MAAM,CAAC;QACtB,eAAe,EAAE,MAAM,CAAC;KACzB,CAAC;IACF,SAAS,EAAE;QACT,MAAM,EAAE,MAAM,CAAC;QACf,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;CACH,CAAA"}
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright 2023 Wonderflow Design Team
2
+ * Copyright 2023-2024 Wonderflow Design Team
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -2,10 +2,18 @@ export declare type DeepPartial<T> = {
2
2
  [P in keyof T]?: DeepPartial<T[P]>;
3
3
  };
4
4
  export declare type ValidTypeOf = 'undefined' | 'object' | 'boolean' | 'number' | 'string' | 'function' | 'symbol' | 'bigint';
5
- export declare type Data = Array<Record<string, any>>;
5
+ export declare type Data = Array<Record<string, unknown>>;
6
6
  export declare enum Charts {
7
7
  LINE_CHART = "LINE_CHART",
8
8
  BAR_CHART = "BAR_CHART"
9
9
  }
10
10
  export declare type ScaleType = 'linear' | 'label' | 'time';
11
+ export declare type SortingType = 'descending-key' | 'ascending-key' | 'descending-value' | 'ascending-value' | 'as-is';
12
+ export declare type AverageType = {
13
+ average: number;
14
+ dataKey: Array<{
15
+ name: string;
16
+ average: number;
17
+ }>;
18
+ } | undefined;
11
19
  //# 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,GAAG,CAAC,CAAC,CAAC;AAE9C,oBAAY,MAAM;IAChB,UAAU,eAAe;IACzB,SAAS,cAAc;CACxB;AAED,oBAAY,SAAS,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC"}
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,5 +1,5 @@
1
1
  /*
2
- * Copyright 2023 Wonderflow Design Team
2
+ * Copyright 2023-2024 Wonderflow Design Team
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -24,6 +24,22 @@ export declare type Theme = {
24
24
  };
25
25
  lines: {
26
26
  noData: string;
27
+ average: string;
28
+ averageFontColor: string;
29
+ };
30
+ brush: {
31
+ handle: {
32
+ fill: string;
33
+ stroke: string;
34
+ };
35
+ selectedBox: {
36
+ fill: string;
37
+ stroke: string;
38
+ };
39
+ pattern: {
40
+ fill: string;
41
+ stroke: string;
42
+ };
27
43
  };
28
44
  };
29
45
  export declare type ThemeVariants = 'light' | 'dark';
@@ -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,E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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"}
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright 2023 Wonderflow Design Team
2
+ * Copyright 2023-2024 Wonderflow Design Team
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -1,8 +1,8 @@
1
1
  export declare type ViewportSize = 'small' | 'medium' | 'large';
2
- export declare type ViewportSizeConfig = {
3
- maxWidth?: number;
4
- maxHeight?: number;
2
+ export declare type ViewportSizeProperties = {
3
+ maxWidth: number;
4
+ maxHeight: number;
5
5
  numTicks: number;
6
6
  };
7
- export declare type ViewportStyleConfig = Record<ViewportSize, ViewportSizeConfig>;
7
+ export declare type ViewportStyleConfig = Record<'small' | 'medium', ViewportSizeProperties> & Record<'large', Pick<ViewportSizeProperties, 'numTicks'>>;
8
8
  //# sourceMappingURL=viewport.d.ts.map
@@ -1 +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"}
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,sBAAsB,GAAG;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAA;AAED,oBAAY,mBAAmB,GAAG,MAAM,CAAC,OAAO,GAAG,QAAQ,EAAE,sBAAsB,CAAC,GAAG,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,sBAAsB,EAAE,UAAU,CAAC,CAAC,CAAA"}
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright 2023 Wonderflow Design Team
2
+ * Copyright 2023-2024 Wonderflow Design Team
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -1,18 +1,18 @@
1
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
- */
2
+ * Copyright 2023-2024 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
16
  import { scaleBand, scaleLinear, scaleUtc, } from '@visx/scale';
17
17
  import _ from 'lodash';
18
18
  import { axisStyleConfig, } from '../style-config';
@@ -1,14 +1,17 @@
1
1
  import { Except } from 'type-fest';
2
- import { AxisProps, Data, LineChartIndex, LineChartOverlay, LineChartSeries } from '../types';
3
- export declare const getValueFromObjectByPath: (object: Record<string, any>, path: string) => any;
4
- export declare const getPrimitiveFromObjectByPath: (object: Record<string, any>, path: string) => string | number | undefined;
2
+ import { AverageType, AxisProps, Data, LineChartIndex, LineChartOverlay, LineChartSeries, SortingType } from '../types';
3
+ import { BarChartIndex, BarChartOverlay, BarChartSeries } from '../types/bar-chart';
4
+ export declare const getValueFromObjectByPath: (object: Record<string, unknown>, path: string) => unknown;
5
+ export declare const getPrimitiveFromObjectByPath: (object: Record<string, unknown>, path: string) => string | number | undefined;
5
6
  export declare const getLabelFromPath: (path: string) => string;
6
- export declare const getPrimitivesFromObjectArrayByPath: (arr: Array<Record<string, any>>, path: string) => (string | number | undefined)[];
7
- export declare const removeKeysFromObject: (obj: Record<string, any>, keys: string[]) => Record<string, any>;
8
- export declare const handleAxisDomainAndScaleType: (data: Data, axis: LineChartIndex | LineChartSeries | LineChartOverlay) => Except<AxisProps, 'orientation'>;
9
- export declare const handleChartDomainAndScaleType: (data: Data, index: LineChartIndex, series: LineChartSeries, overlay?: LineChartOverlay) => {
7
+ export declare const getPrimitivesFromObjectArrayByPath: (arr: Array<Record<string, unknown>>, path: string) => (string | number | undefined)[];
8
+ export declare const removeKeysFromObject: (obj: Record<string, unknown>, keys: string[]) => Record<string, unknown>;
9
+ export declare const handleAxisDomainAndScaleType: (data: Data, axis: LineChartIndex | LineChartSeries | LineChartOverlay | BarChartIndex | BarChartSeries | BarChartOverlay) => Except<AxisProps, 'orientation'>;
10
+ export declare const handleChartDomainAndScaleType: (data: Data, index: LineChartIndex | BarChartIndex, series: LineChartSeries | BarChartSeries, overlay?: LineChartOverlay | BarChartOverlay) => {
10
11
  index: Except<AxisProps, "orientation">;
11
12
  series: Except<AxisProps, "orientation">;
12
13
  overlay: Except<AxisProps, "orientation"> | undefined;
13
14
  };
15
+ export declare const sortBy: (datum: Record<string, string | number | undefined | null>, dataKey: string[], sorting: SortingType) => string[];
16
+ export declare const computeAverage: (data: Data, dataKeys: string[]) => AverageType;
14
17
  //# sourceMappingURL=data.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../src/utils/data.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC,OAAO,EACL,SAAS,EACT,IAAI,EAAE,cAAc,EAAE,gBAAgB,EAAE,eAAe,EACxD,MAAM,UAAU,CAAC;AAQlB,eAAO,MAAM,wBAAwB,WAAY,OAAO,MAAM,EAAE,GAAG,CAAC,QAAQ,MAAM,QAA0B,CAAC;AAE7G,eAAO,MAAM,4BAA4B,WAAY,OAAO,MAAM,EAAE,GAAG,CAAC,QAAQ,MAAM,gCAGrF,CAAC;AAEF,eAAO,MAAM,gBAAgB,SAAU,MAAM,WAc5C,CAAC;AAEF,eAAO,MAAM,kCAAkC,QACxC,MAAM,OAAO,MAAM,EAAE,GAAG,CAAC,CAAC,QACzB,MAAM,oCAC0C,CAAC;AAEzD,eAAO,MAAM,oBAAoB,QAAS,OAAO,MAAM,EAAE,GAAG,CAAC,QAAQ,MAAM,EAAE,wBAQ5E,CAAC;AAEF,eAAO,MAAM,4BAA4B,qBAEjC,cAAc,GAAG,eAAe,GAAG,gBAAgB,KACxD,OAAO,SAAS,EAAE,aAAa,CAgEjC,CAAC;AAEF,eAAO,MAAM,6BAA6B,sBAEjC,cAAc,UACb,eAAe,YACb,gBAAgB;;;;CAa3B,CAAC"}
1
+ {"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../src/utils/data.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE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
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -114,3 +114,28 @@ export const handleChartDomainAndScaleType = (data, index, series, overlay) => {
114
114
  overlay: o,
115
115
  };
116
116
  };
117
+ export const sortBy = (datum, dataKey, sorting) => {
118
+ if (sorting === 'as-is')
119
+ return dataKey;
120
+ let isAscending = false;
121
+ let order = ['key', 'value'];
122
+ if (sorting === 'ascending-key' || sorting === 'ascending-value') {
123
+ isAscending = true;
124
+ }
125
+ if (sorting === 'descending-value' || sorting === 'ascending-value') {
126
+ order = ['value', 'key'];
127
+ }
128
+ const entries = Object.entries(datum).filter(e => dataKey.includes(e[0])).map(e => ({ key: e[0], value: e[1] }));
129
+ const orderedKeys = _.orderBy(entries, order).map(e => e.key);
130
+ return isAscending ? orderedKeys.reverse() : orderedKeys;
131
+ };
132
+ export const computeAverage = (data, dataKeys) => {
133
+ const dataKey = dataKeys.map((k) => ({
134
+ name: k,
135
+ average: _.mean(data
136
+ .map(d => getPrimitiveFromObjectByPath(d, k))
137
+ .filter((d) => typeof d === 'number')),
138
+ }));
139
+ const all = _.mean(dataKey.map(k => k.average));
140
+ return _.isNaN(all) ? undefined : { average: all, dataKey };
141
+ };
@@ -1,4 +1,4 @@
1
- import { getLabelFromPath, getPrimitiveFromObjectByPath, getPrimitivesFromObjectArrayByPath, getValueFromObjectByPath, handleAxisDomainAndScaleType, handleChartDomainAndScaleType, } from './data';
1
+ import { computeAverage, getLabelFromPath, getPrimitiveFromObjectByPath, getPrimitivesFromObjectArrayByPath, getValueFromObjectByPath, handleAxisDomainAndScaleType, handleChartDomainAndScaleType, sortBy, } from './data';
2
2
  const data = [
3
3
  {
4
4
  user: 'joe',
@@ -369,3 +369,111 @@ describe('handleChartDomainAndScaleType()', () => {
369
369
  expect(res).toStrictEqual(exp);
370
370
  });
371
371
  });
372
+ describe('sortBy()', () => {
373
+ it('should return an unmodified array of datakeys', () => {
374
+ const datum = { a: 2, b: 3, c: 1 };
375
+ const datakey = ['a', 'b', 'c'];
376
+ const res = sortBy(datum, datakey, 'as-is');
377
+ const exp = ['a', 'b', 'c'];
378
+ expect(res).toStrictEqual(exp);
379
+ });
380
+ it('should return alphabetical ordered datakeys', () => {
381
+ const datum = { a: 2, b: 3, c: 1 };
382
+ const datakey = ['c', 'a', 'b'];
383
+ const res = sortBy(datum, datakey, 'descending-key');
384
+ const exp = ['a', 'b', 'c'];
385
+ expect(res).toStrictEqual(exp);
386
+ });
387
+ it('should return reversed alphabetical ordered datakeys', () => {
388
+ const datum = { a: 2, b: 3, c: 1 };
389
+ const datakey = ['c', 'a', 'b'];
390
+ const res = sortBy(datum, datakey, 'ascending-key');
391
+ const exp = ['c', 'b', 'a'];
392
+ expect(res).toStrictEqual(exp);
393
+ });
394
+ it('should return keys sorted by descending numerical dataValue', () => {
395
+ const datum = { a: 2, b: 3, c: 1 };
396
+ const datakey = ['a', 'b', 'c'];
397
+ const res = sortBy(datum, datakey, 'descending-value');
398
+ const exp = ['c', 'a', 'b'];
399
+ expect(res).toStrictEqual(exp);
400
+ });
401
+ it('should return keys sorted by ascending numerical dataValue', () => {
402
+ const datum = { a: 2, b: 3, c: 1 };
403
+ const datakey = ['a', 'b', 'c'];
404
+ const res = sortBy(datum, datakey, 'ascending-value');
405
+ const exp = ['b', 'a', 'c'];
406
+ expect(res).toStrictEqual(exp);
407
+ });
408
+ it('should return keys sorted by descending alphabetical dataValue', () => {
409
+ const datum = { a: 'xyz', b: 'jki', c: 'abc' };
410
+ const datakey = ['b', 'c', 'a'];
411
+ const res = sortBy(datum, datakey, 'descending-value');
412
+ const exp = ['c', 'b', 'a'];
413
+ expect(res).toStrictEqual(exp);
414
+ });
415
+ it('should return keys sorted by ascending alphabetical dataValue', () => {
416
+ const datum = { a: 'xyz', b: 'jki', c: 'abc' };
417
+ const datakey = ['b', 'c', 'a'];
418
+ const res = sortBy(datum, datakey, 'ascending-value');
419
+ const exp = ['a', 'b', 'c'];
420
+ expect(res).toStrictEqual(exp);
421
+ });
422
+ it('should return keys sorted by descending alphabetical dataValue with undefined value', () => {
423
+ const datum = {
424
+ a: 'xyz', b: undefined, c: 'abc', d: undefined,
425
+ };
426
+ const datakey = ['b', 'c', 'a', 'd'];
427
+ const res = sortBy(datum, datakey, 'descending-value');
428
+ const exp = ['c', 'a', 'b', 'd'];
429
+ expect(res).toStrictEqual(exp);
430
+ });
431
+ it('should return keys sorted by descending alphabetical dataValue with undefined value', () => {
432
+ const datum = {
433
+ a: 'xyz', b: undefined, c: 'abc', d: undefined,
434
+ };
435
+ const datakey = ['b', 'c', 'a', 'd'];
436
+ const res = sortBy(datum, datakey, 'descending-value');
437
+ const exp = ['c', 'a', 'b', 'd'];
438
+ expect(res).toStrictEqual(exp);
439
+ });
440
+ it('should return keys sorted by descending alphabetical dataValue with undefined value and less keys', () => {
441
+ const datum = {
442
+ a: 'xyz', b: undefined, c: 'abc', d: undefined,
443
+ };
444
+ const datakey = ['b', 'c'];
445
+ const res = sortBy(datum, datakey, 'descending-value');
446
+ const exp = ['c', 'b'];
447
+ expect(res).toStrictEqual(exp);
448
+ });
449
+ });
450
+ describe('computeAverage()', () => {
451
+ it('should return undefined when average is NaN', () => {
452
+ const data = [];
453
+ const datakeys = [];
454
+ const res = computeAverage(data, datakeys);
455
+ const exp = undefined;
456
+ expect(res).toBe(exp);
457
+ });
458
+ it('should return average for a single dataKey', () => {
459
+ const data = [{ testA: 3, testB: 5 }, { testA: 1, testB: 2 }];
460
+ const datakeys = ['testA'];
461
+ const res = computeAverage(data, datakeys);
462
+ const exp = { average: 2, dataKey: [{ name: 'testA', average: 2 }] };
463
+ expect(res).toStrictEqual(exp);
464
+ });
465
+ it('should return average for multiple dataKeys', () => {
466
+ const data = [{ testA: 3, testB: 5 }, { testA: 1, testB: 3 }];
467
+ const datakeys = ['testA', 'testB'];
468
+ const res = computeAverage(data, datakeys);
469
+ const exp = { average: 3, dataKey: [{ name: 'testA', average: 2 }, { name: 'testB', average: 4 }] };
470
+ expect(res).toStrictEqual(exp);
471
+ });
472
+ it('should return average for multiple dataKeys with undefined value', () => {
473
+ const data = [{ testA: 3, testB: 5 }, { testA: 3, testB: 3 }, { testA: undefined, testB: 4 }];
474
+ const datakeys = ['testA', 'testB'];
475
+ const res = computeAverage(data, datakeys);
476
+ const exp = { average: 3.5, dataKey: [{ name: 'testA', average: 3 }, { name: 'testB', average: 4 }] };
477
+ expect(res).toStrictEqual(exp);
478
+ });
479
+ });
@@ -3,7 +3,7 @@ export declare const accessor: (axis: CartesianAxis, dataKey: string, datum?: Re
3
3
  export declare const accessorInvert: (axis?: CartesianAxis, value?: number) => string | number | Date | undefined;
4
4
  export declare const bisectIndex: (array: ArrayLike<string | number>, x: Date, lo?: number | undefined, hi?: number | undefined) => number;
5
5
  export declare const getCoordinates: ({ datum, indexAxis, indexDataKey, otherAxis, otherDataKey, isHorizontal, }: {
6
- datum: Record<string, any>;
6
+ datum: Record<string, unknown>;
7
7
  indexAxis: CartesianAxis;
8
8
  indexDataKey: string;
9
9
  otherAxis: CartesianAxis;
@@ -47,6 +47,6 @@ export declare const getMarkerLabelProps: (pos: {
47
47
  filter: string;
48
48
  };
49
49
  };
50
- export declare const createSubArrays: (arr: Array<Record<string, any>>, condition: (d: Record<string, any>) => boolean) => Record<string, any>[][];
51
- export declare const createSubPaths: (data: Data, condition: (d: Record<string, any>) => boolean) => Record<string, any>[][];
50
+ export declare const createSubArrays: (arr: Array<Record<string, unknown>>, condition: (d: Record<string, unknown>) => boolean) => Record<string, unknown>[][];
51
+ export declare const createSubPaths: (data: Data, condition: (d: Record<string, unknown>) => boolean) => Record<string, unknown>[][];
52
52
  //# sourceMappingURL=lines.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"lines.d.ts","sourceRoot":"","sources":["../../src/utils/lines.ts"],"names":[],"mappings":"AAuBA,OAAO,EACL,aAAa,EAAE,IAAI,EAAE,mBAAmB,EAAE,KAAK,EAChD,MAAM,UAAU,CAAC;AAGlB,eA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,eAAO,MAAM,cAAc,UAAW,aAAa,UAAU,MAAM,uCA8BlE,CAAC;AAEF,eAAO,MAAM,WAAW,0GAA8D,CAAC;AAEvF,eAAO,MAAM,cAAc;WAShB,OAAO,MAAM,EAAE,OAAO,CAAC;eACnB,aAAa;kBACV,MAAM;eACT,aAAa;kBACV,MAAM;kBACN,OAAO;;;;CASxB,CAAC;AAEF,eAAO,MAAM,gBAAgB,aAAc,mBAAmB,GAAG,SAAS,gBAAgB,OAAO,oCAOhG,CAAC;AAEF,eAAO,MAAM,oBAAoB,UAAW,MAAM,eAAe,MAAM,gCAStE,CAAC;AAEF,eAAO,MAAM,mBAAmB,QACzB;IAAE,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,aAC1C;IAAE,QAAQ,EAAE,MAAM,CAAE;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,gBACrC,OAAO,SACd,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;CA2Eb,CAAC;AAEF,eAAO,MAAM,eAAe,QACrB,MAAM,OAAO,MAAM,EAAE,OAAO,CAAC,CAAC,iBACpB,OAAO,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,gCAgB9C,CAAC;AAEP,eAAO,MAAM,cAAc,8BAEV,OAAO,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,gCA6BnD,CAAC"}
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright 2023 Wonderflow Design Team
2
+ * Copyright 2023-2024 Wonderflow Design Team
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -99,8 +99,8 @@ export const getMarkerLabelProps = (pos, dimension, isHorizontal, theme) => {
99
99
  textAnchor: 'start',
100
100
  },
101
101
  backgroundProps: {
102
- rx: 4,
103
- ry: 4,
102
+ rx: 2,
103
+ ry: 2,
104
104
  x: 0,
105
105
  y: 0,
106
106
  filter: 'opacity(0.7)',
@@ -292,7 +292,7 @@ describe('getMarkerLabelProps()', () => {
292
292
  anchor: 'start',
293
293
  background: 'hsl(220 16% 85%)',
294
294
  backgroundProps: {
295
- filter: 'opacity(0.7)', rx: 4, ry: 4, x: 4, y: 4,
295
+ filter: 'opacity(0.7)', rx: 2, ry: 2, x: 4, y: 4,
296
296
  },
297
297
  fontColor: 'hsl(217 11% 14%)',
298
298
  fontSize: 12,
@@ -311,7 +311,7 @@ describe('getMarkerLabelProps()', () => {
311
311
  anchor: 'end',
312
312
  background: 'hsl(220 16% 85%)',
313
313
  backgroundProps: {
314
- filter: 'opacity(0.7)', rx: 4, ry: 4, x: -4, y: 4,
314
+ filter: 'opacity(0.7)', rx: 2, ry: 2, x: -4, y: 4,
315
315
  },
316
316
  fontColor: 'hsl(217 11% 14%)',
317
317
  fontSize: 12,
@@ -330,7 +330,7 @@ describe('getMarkerLabelProps()', () => {
330
330
  anchor: 'start',
331
331
  background: 'hsl(220 16% 85%)',
332
332
  backgroundProps: {
333
- filter: 'opacity(0.7)', rx: 4, ry: 4, x: 4, y: -4,
333
+ filter: 'opacity(0.7)', rx: 2, ry: 2, x: 4, y: -4,
334
334
  },
335
335
  fontColor: 'hsl(217 11% 14%)',
336
336
  fontSize: 12,
@@ -349,7 +349,7 @@ describe('getMarkerLabelProps()', () => {
349
349
  anchor: 'start',
350
350
  background: 'hsl(220 16% 85%)',
351
351
  backgroundProps: {
352
- filter: 'opacity(0.7)', rx: 4, ry: 4, x: 6, y: 4,
352
+ filter: 'opacity(0.7)', rx: 2, ry: 2, x: 6, y: 4,
353
353
  },
354
354
  fontColor: 'hsl(217 11% 14%)',
355
355
  fontSize: 12,
@@ -368,7 +368,7 @@ describe('getMarkerLabelProps()', () => {
368
368
  anchor: 'start',
369
369
  background: 'hsl(220 16% 85%)',
370
370
  backgroundProps: {
371
- filter: 'opacity(0.7)', rx: 4, ry: 4, x: 6, y: -4,
371
+ filter: 'opacity(0.7)', rx: 2, ry: 2, x: 6, y: -4,
372
372
  },
373
373
  fontColor: 'hsl(217 11% 14%)',
374
374
  fontSize: 12,
@@ -387,7 +387,7 @@ describe('getMarkerLabelProps()', () => {
387
387
  anchor: 'end',
388
388
  background: 'hsl(220 16% 85%)',
389
389
  backgroundProps: {
390
- filter: 'opacity(0.7)', rx: 4, ry: 4, x: 0, y: 4,
390
+ filter: 'opacity(0.7)', rx: 2, ry: 2, x: 0, y: 4,
391
391
  },
392
392
  fontColor: 'hsl(217 11% 14%)',
393
393
  fontSize: 12,
@@ -1,6 +1,9 @@
1
1
  import { LineChartOverlay, LineChartSeries } from '../types';
2
- export declare const handleSeriesNames: (series: LineChartSeries) => string[];
3
- export declare const handleSeriesColors: (series: LineChartSeries, palette: string[]) => (string | undefined)[];
4
- export declare const handleOverlayName: (overlay: LineChartOverlay | undefined) => string;
5
- export declare const handleOverlayColor: (overlay: LineChartOverlay | undefined, palette: string) => string;
2
+ import { BarChartOverlay, BarChartSeries } from '../types/bar-chart';
3
+ export declare const handleSeriesNames: (series: LineChartSeries | BarChartSeries) => string[];
4
+ export declare const handleLineChartSeriesColors: (series: LineChartSeries, palette: string[]) => (string | undefined)[];
5
+ export declare const handleBarChartSeriesColors: (series: BarChartSeries, palette: string[]) => (string | undefined)[];
6
+ export declare const handleOverlayName: (overlay: LineChartOverlay | BarChartOverlay | undefined) => string;
7
+ export declare const handleLineChartOverlayColor: (overlay: LineChartOverlay | undefined, palette: string) => string;
8
+ export declare const handleBarChartOverlayColor: (overlay: BarChartOverlay | undefined, palette: string) => string;
6
9
  //# sourceMappingURL=metadata.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../../src/utils/metadata.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAG7D,eAAO,MAAM,iBAAiB,WAAY,eAAe,aAGvD,CAAC;AAEH,eAAO,MAAM,kBAAkB,WACrB,eAAe,WACd,MAAM,EAAE,2BAKjB,CAAC;AAEH,eAAO,MAAM,iBAAiB,YAAa,gBAAgB,GAAG,SAAS,WAStE,CAAC;AAEF,eAAO,MAAM,kBAAkB,YACpB,gBAAgB,GAAG,SAAS,WAC5B,MAAM,WACqB,CAAC"}
1
+ {"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../../src/utils/metadata.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGrE,eAAO,MAAM,iBAAiB,WACpB,eAAe,GAAG,cAAc,aAIxC,CAAC;AAEH,eAAO,MAAM,2BAA2B,WAC9B,eAAe,WACd,MAAM,EAAE,2BAKjB,CAAC;AAEH,eAAO,MAAM,0BAA0B,WAC7B,cAAc,WACb,MAAM,EAAE,2BAKjB,CAAC;AAEH,eAAO,MAAM,iBAAiB,YAAa,gBAAgB,GAAG,eAAe,GAAE,SAAS,WASvF,CAAC;AAEF,eAAO,MAAM,2BAA2B,YAC7B,gBAAgB,GAAG,SAAS,WAC5B,MAAM,WACqB,CAAC;AAEvC,eAAO,MAAM,0BAA0B,YAC5B,eAAe,GAAG,SAAS,WAC3B,MAAM,WACmB,CAAC"}
@@ -19,9 +19,12 @@ export const handleSeriesNames = (series) => series.dataKey.map((s, i) => {
19
19
  const renamed = series.rename ? series.rename(s, i) : getLabelFromPath(s);
20
20
  return _.startCase(renamed);
21
21
  });
22
- export const handleSeriesColors = (series, palette) => series.dataKey.map((_, i) => (series.style?.[i]
22
+ export const handleLineChartSeriesColors = (series, palette) => series.dataKey.map((_, i) => (series.style?.[i]
23
23
  ? series.style[i]?.stroke
24
24
  : palette[i % palette.length]));
25
+ export const handleBarChartSeriesColors = (series, palette) => series.dataKey.map((_, i) => (series.style?.[i]
26
+ ? series.style[i]?.fill
27
+ : palette[i % palette.length]));
25
28
  export const handleOverlayName = (overlay) => {
26
29
  if (overlay) {
27
30
  const { rename, label, dataKey } = overlay;
@@ -33,4 +36,5 @@ export const handleOverlayName = (overlay) => {
33
36
  }
34
37
  return '';
35
38
  };
36
- export const handleOverlayColor = (overlay, palette) => overlay?.style?.stroke ?? palette;
39
+ export const handleLineChartOverlayColor = (overlay, palette) => overlay?.style?.stroke ?? palette;
40
+ export const handleBarChartOverlayColor = (overlay, palette) => overlay?.style?.fill ?? palette;
@@ -1,5 +1,5 @@
1
1
  import { defaultLineChartPalette } from '../style-config';
2
- import { handleOverlayColor, handleOverlayName, handleSeriesColors, handleSeriesNames, } from './metadata';
2
+ import { handleLineChartOverlayColor, handleLineChartSeriesColors, handleOverlayName, handleSeriesNames, } from './metadata';
3
3
  describe('handleSeriesNames()', () => {
4
4
  it('should return formatted labels', () => {
5
5
  const series = {
@@ -19,14 +19,14 @@ describe('handleSeriesNames()', () => {
19
19
  expect(res).toStrictEqual(exp);
20
20
  });
21
21
  });
22
- describe('handleSeriesColors()', () => {
22
+ describe('handleLineChartSeriesColors()', () => {
23
23
  const colors = defaultLineChartPalette.light.series;
24
24
  it('should return custom styled color', () => {
25
25
  const series = {
26
26
  dataKey: ['test1', 'test2'],
27
27
  style: [{ stroke: 'blue' }, { stroke: 'green' }],
28
28
  };
29
- const res = handleSeriesColors(series, colors);
29
+ const res = handleLineChartSeriesColors(series, colors);
30
30
  const exp = ['blue', 'green'];
31
31
  expect(res).toStrictEqual(exp);
32
32
  });
@@ -34,7 +34,7 @@ describe('handleSeriesColors()', () => {
34
34
  const series = {
35
35
  dataKey: ['test1', 'test2'],
36
36
  };
37
- const res = handleSeriesColors(series, colors);
37
+ const res = handleLineChartSeriesColors(series, colors);
38
38
  const exp = ['hsl(149 83% 35%)', 'hsl(350 66% 49%)'];
39
39
  expect(res).toStrictEqual(exp);
40
40
  });
@@ -42,7 +42,7 @@ describe('handleSeriesColors()', () => {
42
42
  const series = {
43
43
  dataKey: Array(14).fill('test'),
44
44
  };
45
- const res = handleSeriesColors(series, colors)[13];
45
+ const res = handleLineChartSeriesColors(series, colors)[13];
46
46
  const exp = 'hsl(350 66% 49%)';
47
47
  expect(res).toStrictEqual(exp);
48
48
  });
@@ -80,13 +80,13 @@ describe('handleOverlayName()', () => {
80
80
  expect(res).toStrictEqual(exp);
81
81
  });
82
82
  });
83
- describe('handleOverlayColor()', () => {
83
+ describe('handleLineChartOverlayColor()', () => {
84
84
  const colors = defaultLineChartPalette.light.overlay;
85
85
  it('should return the default color', () => {
86
86
  const overlay = {
87
87
  dataKey: 'test',
88
88
  };
89
- const res = handleOverlayColor(overlay, colors);
89
+ const res = handleLineChartOverlayColor(overlay, colors);
90
90
  const exp = 'hsl(14 63% 53%)';
91
91
  expect(res).toStrictEqual(exp);
92
92
  });
@@ -95,7 +95,7 @@ describe('handleOverlayColor()', () => {
95
95
  dataKey: 'test',
96
96
  style: { stroke: 'salmon' },
97
97
  };
98
- const res = handleOverlayColor(overlay, colors);
98
+ const res = handleLineChartOverlayColor(overlay, colors);
99
99
  const exp = 'salmon';
100
100
  expect(res).toStrictEqual(exp);
101
101
  });
@@ -1,3 +1,5 @@
1
1
  import { CartesianAxis, ViewportStyleConfig } from '../types';
2
- export declare const manageViewport: (width: number, height: number, axis: CartesianAxis, config: ViewportStyleConfig) => import("../types").ViewportSizeConfig;
2
+ export declare const manageViewport: (width: number, height: number, axis: CartesianAxis, config: ViewportStyleConfig) => import("../types").ViewportSizeProperties | {
3
+ numTicks: number;
4
+ };
3
5
  //# sourceMappingURL=viewport.d.ts.map