@milaboratories/miplots4 1.0.134 → 1.0.135

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 (124) hide show
  1. package/dist/{discrete/components → common}/BandAxis.d.ts +2 -2
  2. package/dist/common/BandAxis.d.ts.map +1 -0
  3. package/dist/{discrete/components → common}/BandAxis.js +3 -3
  4. package/dist/common/BandAxis.js.map +1 -0
  5. package/dist/common/ContinuousGrid.d.ts +3 -3
  6. package/dist/common/ContinuousGrid.d.ts.map +1 -1
  7. package/dist/common/ContinuousGrid.js.map +1 -1
  8. package/dist/discrete/ChartRenderer.d.ts.map +1 -1
  9. package/dist/discrete/ChartRenderer.js +192 -265
  10. package/dist/discrete/ChartRenderer.js.map +1 -1
  11. package/dist/discrete/components/Chart.js +1 -1
  12. package/dist/discrete/components/Chart.js.map +1 -1
  13. package/dist/discrete/components/Grid.d.ts +3 -3
  14. package/dist/discrete/components/Grid.d.ts.map +1 -1
  15. package/dist/discrete/components/Grid.js.map +1 -1
  16. package/dist/discrete/components/types.d.ts +5 -3
  17. package/dist/discrete/components/types.d.ts.map +1 -1
  18. package/dist/discrete/utils/index.d.ts +1 -1
  19. package/dist/discrete/utils/index.d.ts.map +1 -1
  20. package/dist/histogram/ChartRenderer.js +1 -1
  21. package/dist/index.d.ts +2 -2
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/node_modules/d3-scale/src/band.js +45 -35
  24. package/dist/node_modules/d3-scale/src/band.js.map +1 -1
  25. package/dist/scatterplot/ChartRenderer.d.ts +10 -5
  26. package/dist/scatterplot/ChartRenderer.d.ts.map +1 -1
  27. package/dist/scatterplot/ChartRenderer.js +276 -197
  28. package/dist/scatterplot/ChartRenderer.js.map +1 -1
  29. package/dist/scatterplot/ScatterplotSettingsImpl.d.ts +5 -3
  30. package/dist/scatterplot/ScatterplotSettingsImpl.d.ts.map +1 -1
  31. package/dist/scatterplot/ScatterplotSettingsImpl.js +53 -53
  32. package/dist/scatterplot/ScatterplotSettingsImpl.js.map +1 -1
  33. package/dist/scatterplot/components/Chart.d.ts +3 -1
  34. package/dist/scatterplot/components/Chart.d.ts.map +1 -1
  35. package/dist/scatterplot/components/Chart.js +23 -19
  36. package/dist/scatterplot/components/Chart.js.map +1 -1
  37. package/dist/scatterplot/components/ChartAxis.d.ts +3 -1
  38. package/dist/scatterplot/components/ChartAxis.d.ts.map +1 -1
  39. package/dist/scatterplot/components/ChartAxis.js +31 -27
  40. package/dist/scatterplot/components/ChartAxis.js.map +1 -1
  41. package/dist/scatterplot/components/ChartLayersData.d.ts.map +1 -1
  42. package/dist/scatterplot/components/ChartLayersData.js.map +1 -1
  43. package/dist/scatterplot/components/ChartTooltip.js.map +1 -1
  44. package/dist/scatterplot/components/ChartTrendsData.d.ts.map +1 -1
  45. package/dist/scatterplot/components/ChartTrendsData.js +20 -17
  46. package/dist/scatterplot/components/ChartTrendsData.js.map +1 -1
  47. package/dist/scatterplot/components/ChartsGroup.d.ts +5 -1
  48. package/dist/scatterplot/components/ChartsGroup.d.ts.map +1 -1
  49. package/dist/scatterplot/components/ChartsGroup.js +49 -46
  50. package/dist/scatterplot/components/ChartsGroup.js.map +1 -1
  51. package/dist/scatterplot/components/Grid.d.ts +3 -3
  52. package/dist/scatterplot/components/Grid.d.ts.map +1 -1
  53. package/dist/scatterplot/components/Grid.js +31 -27
  54. package/dist/scatterplot/components/Grid.js.map +1 -1
  55. package/dist/scatterplot/components/types.d.ts +15 -5
  56. package/dist/scatterplot/components/types.d.ts.map +1 -1
  57. package/dist/scatterplot/dots.d.ts +2 -2
  58. package/dist/scatterplot/dots.d.ts.map +1 -1
  59. package/dist/scatterplot/dots.js.map +1 -1
  60. package/dist/scatterplot/getLayersData.d.ts +3 -2
  61. package/dist/scatterplot/getLayersData.d.ts.map +1 -1
  62. package/dist/scatterplot/getLayersData.js +29 -18
  63. package/dist/scatterplot/getLayersData.js.map +1 -1
  64. package/dist/scatterplot/index.d.ts +3 -0
  65. package/dist/scatterplot/index.d.ts.map +1 -1
  66. package/dist/scatterplot/index.js +73 -59
  67. package/dist/scatterplot/index.js.map +1 -1
  68. package/dist/scatterplot/linearRegression.d.ts +4 -6
  69. package/dist/scatterplot/linearRegression.d.ts.map +1 -1
  70. package/dist/scatterplot/linearRegression.js.map +1 -1
  71. package/dist/scatterplot/utils/isNumericScale.d.ts +6 -0
  72. package/dist/scatterplot/utils/isNumericScale.d.ts.map +1 -0
  73. package/dist/scatterplot/utils/isNumericScale.js +11 -0
  74. package/dist/scatterplot/utils/isNumericScale.js.map +1 -0
  75. package/dist/scatterplot-umap/ChartRenderer.js +1 -1
  76. package/dist/scatterplot-umap/ChartRenderer.js.map +1 -1
  77. package/dist/scatterplot-umap/SettingsImpl.d.ts +7 -4
  78. package/dist/scatterplot-umap/SettingsImpl.d.ts.map +1 -1
  79. package/dist/scatterplot-umap/SettingsImpl.js.map +1 -1
  80. package/dist/scatterplot-umap/components/LowerSVG.js +7 -7
  81. package/dist/scatterplot-umap/components/LowerSVG.js.map +1 -1
  82. package/dist/types/bubble.d.ts +12 -12
  83. package/dist/types/common.d.ts +186 -21
  84. package/dist/types/common.d.ts.map +1 -1
  85. package/dist/types/common.js +36 -26
  86. package/dist/types/common.js.map +1 -1
  87. package/dist/types/dendro.d.ts +22 -22
  88. package/dist/types/discrete.d.ts +23 -53
  89. package/dist/types/discrete.d.ts.map +1 -1
  90. package/dist/types/discrete.js +35 -35
  91. package/dist/types/discrete.js.map +1 -1
  92. package/dist/types/heatmap.d.ts +12 -12
  93. package/dist/types/histogram.d.ts +4 -4
  94. package/dist/types/scatterplot-umap.d.ts +4 -34
  95. package/dist/types/scatterplot-umap.d.ts.map +1 -1
  96. package/dist/types/scatterplot-umap.js +1 -1
  97. package/dist/types/scatterplot-umap.js.map +1 -1
  98. package/dist/types/scatterplot.d.ts +186 -32
  99. package/dist/types/scatterplot.d.ts.map +1 -1
  100. package/dist/utils/createMultilineDiscreteLabels.d.ts +4 -0
  101. package/dist/utils/createMultilineDiscreteLabels.d.ts.map +1 -0
  102. package/dist/utils/createMultilineDiscreteLabels.js +32 -0
  103. package/dist/utils/createMultilineDiscreteLabels.js.map +1 -0
  104. package/dist/utils/getFacetRowsColumns.d.ts +3 -0
  105. package/dist/utils/getFacetRowsColumns.d.ts.map +1 -0
  106. package/dist/utils/getFacetRowsColumns.js +18 -0
  107. package/dist/utils/getFacetRowsColumns.js.map +1 -0
  108. package/dist/utils/measureMultilineDiscreteLabels.d.ts +9 -0
  109. package/dist/utils/measureMultilineDiscreteLabels.d.ts.map +1 -0
  110. package/dist/utils/measureMultilineDiscreteLabels.js +63 -0
  111. package/dist/utils/measureMultilineDiscreteLabels.js.map +1 -0
  112. package/dist/utils/splitTextByWidth.d.ts.map +1 -0
  113. package/dist/{discrete/utils → utils}/splitTextByWidth.js +1 -1
  114. package/dist/utils/splitTextByWidth.js.map +1 -0
  115. package/package.json +1 -1
  116. package/dist/discrete/components/BandAxis.d.ts.map +0 -1
  117. package/dist/discrete/components/BandAxis.js.map +0 -1
  118. package/dist/discrete/utils/splitTextByWidth.d.ts.map +0 -1
  119. package/dist/discrete/utils/splitTextByWidth.js.map +0 -1
  120. package/dist/scatterplot/components/Axis.d.ts +0 -13
  121. package/dist/scatterplot/components/Axis.d.ts.map +0 -1
  122. package/dist/scatterplot/components/Axis.js +0 -59
  123. package/dist/scatterplot/components/Axis.js.map +0 -1
  124. /package/dist/{discrete/utils → utils}/splitTextByWidth.d.ts +0 -0
@@ -1,104 +1,96 @@
1
- var Y = Object.defineProperty;
2
- var k = (x, i, t) => i in x ? Y(x, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : x[i] = t;
3
- var C = (x, i, t) => k(x, typeof i != "symbol" ? i + "" : i, t);
4
- import { j as w } from "../node_modules/react/jsx-runtime.js";
5
- import V from "../node_modules/lodash/lodash.js";
6
- import { createRoot as Z } from "../node_modules/react-dom/client.js";
7
- import { Error as $ } from "../common/Error.js";
8
- import { DataFrameProvider as q } from "../common/useDataFrame.js";
9
- import { DEFAULT_HEIGHT as P, DEFAULT_WIDTH as I, TITLE_LINE_HEIGHT as J, TITLE_MARGIN as Q } from "../constants.js";
10
- import { DEFAULT_COMMON_AES as R, DEFAULT_TICKS_SIZE as v } from "../scatterplot/constants.js";
11
- import { arrangeLegendParts as y } from "../utils/arrangeLegendParts.js";
12
- import { TextMeasurer as G } from "../utils/TextMeasurer/TextMeasurer.js";
13
- import { ChartsGroup as K } from "./components/ChartsGroup.js";
14
- import { DEFAULT_AES as O, CAPTION_LINE_HEIGHT as W, LEGEND_OFFSET as tt, TICK_OFFSET as B, TITLE_LINE as z, MIN_PADDING as H, FACET_TITLE_OFFSET as it, FACET_TITLE_LINE as st } from "./constants.js";
15
- import { getChartStatsPadding as X } from "./utils/getChartStatsPadding.js";
16
- import { splitTextByWidth as D } from "./utils/splitTextByWidth.js";
17
- import S from "../node_modules/d3-scale/src/ordinal.js";
18
- import j from "../node_modules/d3-scale/src/linear.js";
19
- import _ from "../node_modules/d3-scale/src/band.js";
20
- import et from "../node_modules/d3-scale/src/log.js";
21
- function ot(x, i, t, s) {
22
- const e = [];
23
- return x % t === t - 1 && e.push("right"), x % t === 0 && e.push("left"), x < t && e.push("top"), (Math.ceil((x + 1) / t) === s || Math.ceil((x + 1) / t) === s - 1 && x % t > (i - 1) % t) && e.push("bottom"), e;
1
+ var S = Object.defineProperty;
2
+ var U = (c, i, t) => i in c ? S(c, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : c[i] = t;
3
+ var f = (c, i, t) => U(c, typeof i != "symbol" ? i + "" : i, t);
4
+ import { j as E } from "../node_modules/react/jsx-runtime.js";
5
+ import X from "../node_modules/lodash/lodash.js";
6
+ import { createRoot as k } from "../node_modules/react-dom/client.js";
7
+ import { Error as V } from "../common/Error.js";
8
+ import { DataFrameProvider as y } from "../common/useDataFrame.js";
9
+ import { DEFAULT_HEIGHT as z, DEFAULT_WIDTH as W, TITLE_LINE_HEIGHT as Z, TITLE_MARGIN as $ } from "../constants.js";
10
+ import { DEFAULT_COMMON_AES as R, DEFAULT_TICKS_SIZE as D } from "../scatterplot/constants.js";
11
+ import { arrangeLegendParts as q } from "../utils/arrangeLegendParts.js";
12
+ import { TextMeasurer as J } from "../utils/TextMeasurer/TextMeasurer.js";
13
+ import { ChartsGroup as Q } from "./components/ChartsGroup.js";
14
+ import { DEFAULT_AES as P, LEGEND_OFFSET as G, TICK_OFFSET as v, TITLE_LINE as _, MIN_PADDING as H, FACET_TITLE_OFFSET as K, FACET_TITLE_LINE as tt } from "./constants.js";
15
+ import { getChartStatsPadding as B } from "./utils/getChartStatsPadding.js";
16
+ import { splitTextByWidth as O } from "../utils/splitTextByWidth.js";
17
+ import { createMultilineDiscreteLabels as it } from "../utils/createMultilineDiscreteLabels.js";
18
+ import { measureMultilineDiscreteLabels as st } from "../utils/measureMultilineDiscreteLabels.js";
19
+ import { getFacetRows as et } from "../utils/getFacetRowsColumns.js";
20
+ import j from "../node_modules/d3-scale/src/ordinal.js";
21
+ import Y from "../node_modules/d3-scale/src/linear.js";
22
+ import F from "../node_modules/d3-scale/src/band.js";
23
+ import ot from "../node_modules/d3-scale/src/log.js";
24
+ function ht(c, i, t, s) {
25
+ const o = [];
26
+ return c % t === t - 1 && o.push("right"), c % t === 0 && o.push("left"), c < t && o.push("top"), (Math.ceil((c + 1) / t) === s || Math.ceil((c + 1) / t) === s - 1 && c % t > (i - 1) % t) && o.push("bottom"), o;
24
27
  }
25
- function nt(x, i, t, s, e, r, p, o, c, d, u) {
26
- const T = x === "vertical", m = p.includes("left") || T && !(o != null && o.sharedY) || !T && !(o != null && o.sharedX), M = p.includes("left") && t.title !== "", f = p.includes("bottom") || T && !(o != null && o.sharedX) || !T && !(o != null && o.sharedY), l = p.includes("bottom") && i.title !== "", h = s.yAxisCaptionsWidth, n = (t.showTicks ? v : 0) + (t.hiddenLabels ? 0 : B), a = M ? z : 0, g = s.xAxisCaptionsWidthByRows[T ? c : d], A = (i.showTicks ? v : 0) + (i.hiddenLabels ? 0 : B), L = l ? z : 0, N = T ? h + n + a : g + A + L, F = T ? A + g + L : n + 2 * z, b = Math.max(...e.map((E) => r[E].length));
28
+ function nt(c, i, t, s, o, h, r, e, l, p, u) {
29
+ const d = c === "vertical", T = r.includes("left") || d && !(e != null && e.sharedY) || !d && !(e != null && e.sharedX), a = r.includes("left") && t.title !== "", x = r.includes("bottom") || d && !(e != null && e.sharedX) || !d && !(e != null && e.sharedY), n = r.includes("bottom") && i.title !== "", A = s.leftAxisCaptionsWidth, C = (t.showTicks ? D : 0) + (t.hiddenLabels ? 0 : v), m = a ? _ : 0, g = d ? s.bottomAxisCaptionsWidthByRows[l] : s.leftAxisCaptionsWidthByColumns[p], b = (i.showTicks ? D : 0) + (i.hiddenLabels ? 0 : v), M = d && n || !d && a ? _ : 0, N = d ? A + C + m : g + b + M, I = d ? b + g + M : C + 2 * _, L = Math.max(...o.map((w) => h[w].length));
27
30
  return {
28
- left: m ? N : H,
29
- top: b === 0 ? 0 : it * 2 + b * st,
30
- bottom: f ? F : H,
31
+ left: T ? N : H,
32
+ top: L === 0 ? 0 : K * 2 + L * tt,
33
+ bottom: x ? I : H,
31
34
  right: u ? 0 : H
32
35
  };
33
36
  }
34
- function at(x, i, t) {
35
- const s = new Array(t).fill(null).map(() => []);
36
- for (let e = 0; e < t; e++)
37
- for (let r = 0; r < i; r++)
38
- r * t + e < x.length && s[e].push(x[r * t + e]);
39
- return s;
40
- }
41
- function U(x, i, t) {
42
- const s = [];
43
- for (let e = 0; e < i; e++)
44
- s.push(x.slice(e * t, e * t + t));
45
- return s;
46
- }
47
- function ht(x, i) {
48
- const t = Math.floor(x / i), s = x - t * i;
37
+ function at(c, i) {
38
+ const t = Math.floor(c / i), s = c - t * i;
49
39
  return [t, s];
50
40
  }
51
- function rt(x) {
52
- return typeof x == "object" && "type" in x;
41
+ function rt(c) {
42
+ return typeof c == "object" && "type" in c;
53
43
  }
54
- class Nt {
44
+ class It {
55
45
  constructor() {
56
- C(this, "reactRoot", null);
57
- C(this, "parentNode", null);
58
- C(this, "rootNode", null);
59
- C(this, "component", /* @__PURE__ */ w.jsx(w.Fragment, {}));
60
- C(this, "chartsDimensions", {});
61
- C(this, "chartSizes", {
62
- chartWidth: I,
46
+ f(this, "reactRoot", null);
47
+ f(this, "parentNode", null);
48
+ f(this, "rootNode", null);
49
+ f(this, "component", /* @__PURE__ */ E.jsx(E.Fragment, {}));
50
+ f(this, "chartsDimensions", {});
51
+ f(this, "chartSizes", {
52
+ chartWidth: W,
63
53
  // width of single chart
64
- chartHeight: P,
54
+ chartHeight: z,
65
55
  // height of single chart
66
- chartsWidth: I,
56
+ chartsWidth: W,
67
57
  // width of all charts in charts row
68
- chartsHeight: P,
58
+ chartsHeight: z,
69
59
  // width of all charts in charts column, without axes
70
- totalWidth: I,
60
+ totalWidth: W,
71
61
  // width of all charts in charts row, plus left axis, plus legend
72
- totalHeight: P
62
+ totalHeight: z
73
63
  // width of all charts in charts height, plus bottom axis, plus top title
74
64
  });
75
- C(this, "columnsCount", 1);
76
- C(this, "rowsCount", 1);
77
- C(this, "scales", {
65
+ f(this, "columnsCount", 1);
66
+ f(this, "rowsCount", 1);
67
+ f(this, "scales", {
78
68
  // Scale from primary grouping categories to every category x coordinate
79
- xPrimary: { null: _().range([0, I]).domain(["1"]) },
69
+ xPrimary: { null: F().range([0, W]).domain(["1"]) },
80
70
  // Scale from secondary grouping categories to x shift inside corresponding primary group
81
- xSecondary: { null: _().range([0, I]).domain(["1"]) },
71
+ xSecondary: { null: F().range([0, W]).domain(["1"]) },
82
72
  // Scale from y value to y coordinate, by facet
83
- y: { null: j().domain([0, 10]).range([P, 0]).nice() },
73
+ y: { null: Y().domain([0, 10]).range([z, 0]).nice() },
84
74
  // Scale for link primary grouping category and aesthetics
85
- xPrimaryAes: S().unknown(O),
75
+ xPrimaryAes: j().unknown(P),
86
76
  // Scale for link secondary grouping category and aesthetics
87
- xSecondaryAes: S().unknown(O)
77
+ xSecondaryAes: j().unknown(P)
88
78
  });
89
- C(this, "facetTitles", {});
79
+ f(this, "facetTitles", {});
90
80
  // can be multiline
91
- C(this, "mainTitle", []);
81
+ f(this, "mainTitle", []);
92
82
  // can be multiline
93
- C(this, "axisLabelsX", {});
83
+ f(this, "axisLabelsX", {});
94
84
  // can be multiline
95
- C(this, "captionsSizes", {
96
- xAxisCaptionsWidthByRows: [],
97
- xCaptionsTail: 0,
98
- yAxisCaptionsWidth: 100
85
+ f(this, "captionsSizes", {
86
+ bottomAxisCaptionsWidthByRows: [],
87
+ leftAxisCaptionsWidthByColumns: [],
88
+ bottomCaptionsTail: 0,
89
+ leftCaptionsTail: 0,
90
+ leftAxisCaptionsWidth: 100
99
91
  });
100
- C(this, "legend", { width: 0, height: 0, items: [] });
101
- C(this, "margins", { left: 0, right: 0, top: 0, bottom: 0 });
92
+ f(this, "legend", { width: 0, height: 0, items: [] });
93
+ f(this, "margins", { left: 0, right: 0, top: 0, bottom: 0 });
102
94
  }
103
95
  clear() {
104
96
  var i;
@@ -108,210 +100,145 @@ class Nt {
108
100
  });
109
101
  }
110
102
  init(i) {
111
- this.parentNode === null && (this.parentNode = i, this.rootNode = document.createElement("div"), this.parentNode.appendChild(this.rootNode), this.reactRoot = Z(this.rootNode));
103
+ this.parentNode === null && (this.parentNode = i, this.rootNode = document.createElement("div"), this.parentNode.appendChild(this.rootNode), this.reactRoot = k(this.rootNode));
112
104
  }
113
- updateChartSize(i, t, s, e, r, p) {
114
- const o = i.innerOffset, c = i.innerOffset, d = X(p, e, i.innerOffset), u = t.length, T = Math.min((s == null ? void 0 : s.nRows) ?? u, u), m = Math.min((s == null ? void 0 : s.nCols) ?? u, u);
115
- this.columnsCount = s != null && s.nRows ? Math.ceil(u / T) : m, this.rowsCount = Math.ceil(u / this.columnsCount);
116
- let { width: M, height: f } = i;
117
- r === "vertical" && d > o && (f += d), r === "horizontal" && d > c && (M += d), this.chartSizes.chartWidth = M, this.chartSizes.chartHeight = f;
105
+ updateChartSize(i, t, s, o, h, r) {
106
+ const e = i.innerOffset, l = i.innerOffset, p = B(r, o, i.innerOffset), u = t.length, d = Math.min((s == null ? void 0 : s.nRows) ?? u, u), T = Math.min((s == null ? void 0 : s.nCols) ?? u, u);
107
+ this.columnsCount = s != null && s.nRows ? Math.ceil(u / d) : T, this.rowsCount = Math.ceil(u / this.columnsCount);
108
+ let { width: a, height: x } = i;
109
+ h === "vertical" && p > e && (x += p), h === "horizontal" && p > l && (a += p), this.chartSizes.chartWidth = a, this.chartSizes.chartHeight = x;
118
110
  }
119
- updateChartDimensions(i, t, s, e, r) {
120
- const { chartWidth: p, chartHeight: o } = this.chartSizes;
121
- let c = 0, d = 0;
122
- this.chartsDimensions = i.reduce((m, M, f) => {
123
- const [l, h] = ht(f, this.columnsCount), n = ot(f, i.length, this.columnsCount, this.rowsCount), a = nt(
111
+ updateChartDimensions(i, t, s, o, h) {
112
+ const { chartWidth: r, chartHeight: e } = this.chartSizes;
113
+ let l = 0, p = 0;
114
+ const u = et(i, this.rowsCount, this.columnsCount);
115
+ this.chartsDimensions = i.reduce((a, x, n) => {
116
+ const [A, C] = at(n, this.columnsCount), m = ht(n, i.length, this.columnsCount, this.rowsCount), g = nt(
124
117
  s,
125
- e,
126
- r,
118
+ o,
119
+ h,
127
120
  this.captionsSizes,
128
- U(i, this.rowsCount, this.columnsCount)[l],
121
+ u[A],
129
122
  this.facetTitles,
130
- n,
123
+ m,
131
124
  t,
132
- l,
133
- h,
134
- h === this.columnsCount - 1
135
- ), g = p + a.left + a.right, A = o + a.top + a.bottom;
136
- return m[M] = {
137
- left: c,
138
- top: d,
139
- chartEdgeSides: n,
140
- padding: a,
141
- inner: { width: p, height: o },
142
- outer: { width: g, height: A }
143
- }, c += g, h === this.columnsCount - 1 && (c = 0, d += A), m;
125
+ A,
126
+ C,
127
+ C === this.columnsCount - 1
128
+ ), b = r + g.left + g.right, M = e + g.top + g.bottom;
129
+ return a[x] = {
130
+ left: l,
131
+ top: p,
132
+ chartEdgeSides: m,
133
+ padding: g,
134
+ inner: { width: r, height: e },
135
+ outer: { width: b, height: M }
136
+ }, l += b, C === this.columnsCount - 1 && (l = 0, p += M), a;
144
137
  }, {});
145
- const u = Math.max(
146
- ...i.map((m) => this.chartsDimensions[m].outer.width + this.chartsDimensions[m].left)
138
+ const d = Math.max(
139
+ ...i.map((a) => this.chartsDimensions[a].outer.width + this.chartsDimensions[a].left)
147
140
  ), T = Math.max(
148
- ...i.map((m) => this.chartsDimensions[m].outer.height + this.chartsDimensions[m].top)
141
+ ...i.map((a) => this.chartsDimensions[a].outer.height + this.chartsDimensions[a].top)
149
142
  );
150
- this.chartSizes.chartsWidth = u, this.chartSizes.chartsHeight = T;
143
+ this.chartSizes.chartsWidth = d, this.chartSizes.chartsHeight = T;
151
144
  }
152
- updateViewport(i, t, s, e, r, p, o, c, d, u) {
153
- const T = d.innerOffset, m = i === "vertical", M = X(c, t, d.innerOffset), f = r === null || r.sharedX, l = r === null || r.sharedY, { chartHeight: h, chartWidth: n } = this.chartSizes;
154
- e.forEach((a) => {
155
- const g = p.scale === "log" ? et() : j(), A = Math.min(...l ? o.map(({ meta: b }) => b.minY) : o.map(({ geoms: b }) => Math.min(...b[a].map(({ boundsY: E }) => E.min)))), L = Math.max(...l ? o.map(({ meta: b }) => b.maxY) : o.map(({ geoms: b }) => Math.max(...b[a].map(({ boundsY: E }) => E.max)))), N = g.copy().domain([A, L]).range(
156
- m ? [h - T, M] : [T, n - M]
145
+ updateViewport(i, t, s, o, h, r, e, l, p, u) {
146
+ const d = p.innerOffset, T = i === "vertical", a = B(l, t, p.innerOffset), x = h === null || h.sharedX, n = h === null || h.sharedY, { chartHeight: A, chartWidth: C } = this.chartSizes;
147
+ o.forEach((m) => {
148
+ const g = r.scale === "log" ? ot() : Y(), b = Math.min(...n ? e.map(({ meta: L }) => L.minY) : e.map(({ geoms: L }) => Math.min(...L[m].map(({ boundsY: w }) => w.min)))), M = Math.max(...n ? e.map(({ meta: L }) => L.maxY) : e.map(({ geoms: L }) => Math.max(...L[m].map(({ boundsY: w }) => w.max)))), N = g.copy().domain([b, M]).range(
149
+ T ? [A - d, a] : [d, C - a]
157
150
  );
158
- g.domain([N.invert(m ? h : 0), N.invert(m ? 0 : n)]).range(m ? [h, 0] : [0, n]), this.scales.y[a] = g;
159
- const F = f ? t : u[a];
160
- this.scales.xPrimary[a] = _().domain(F).range(m ? [0, n] : [h, 0]), this.scales.xSecondary[a] = _().domain(s).range([0, this.scales.xPrimary[a].bandwidth()]);
151
+ g.domain([N.invert(T ? A : 0), N.invert(T ? 0 : C)]).range(T ? [A, 0] : [0, C]), this.scales.y[m] = g;
152
+ const I = x ? t : u[m];
153
+ this.scales.xPrimary[m] = F().domain(I).range(T ? [0, C] : [A, 0]), this.scales.xSecondary[m] = F().domain(s).range([0, this.scales.xPrimary[m].bandwidth()]);
161
154
  });
162
155
  }
163
156
  createFacetTitles(i, t) {
164
- this.facetTitles = i.reduce((s, e, r) => (t[r].length === 1 && t[r][0] === "null" ? s[e] = [] : s[e] = D(t[r].join(", "), this.chartSizes.chartWidth, 14), s), {});
157
+ this.facetTitles = i.reduce((s, o, h) => (t[h].length === 1 && t[h][0] === "null" ? s[o] = [] : s[o] = O(t[h].join(", "), this.chartSizes.chartWidth, 14), s), {});
165
158
  }
166
159
  createMainTitle(i, t) {
167
- const s = this.chartsDimensions[i[0]], e = this.chartsDimensions[i[i.length - 1]];
168
- this.mainTitle = D(
160
+ const s = this.chartsDimensions[i[0]], o = this.chartsDimensions[i[i.length - 1]];
161
+ this.mainTitle = O(
169
162
  t.name,
170
- this.chartSizes.chartsWidth - s.padding.left - e.padding.right,
163
+ this.chartSizes.chartsWidth - s.padding.left - o.padding.right,
171
164
  20
172
165
  );
173
166
  }
174
- createAxisLabels(i, t, s, e) {
175
- const r = {
176
- center: 120,
177
- "45deg": 256,
178
- "90deg": 320
179
- }, p = e === "vertical";
180
- function o(c, d) {
181
- return c === "center" ? 1 / 0 : Math.floor(c === "45deg" ? d * Math.sin(Math.PI / 4) / W : d / W);
182
- }
183
- this.axisLabelsX = i.reduce((c, d) => {
184
- const u = this.scales.xPrimary[d], T = u.bandwidth(), m = r[t.labelsPosition], M = t.labelsPosition === "center" ? Math.min(m, T) : m, f = s.valueLabels;
185
- return c[d] = u.domain().reduce((l, h) => {
186
- if (t.hiddenLabels)
187
- return l[h] = [], l;
188
- const n = f[h];
189
- if (!p)
190
- l[h] = [n];
191
- else {
192
- const a = o(t.labelsPosition, T), g = D(n, M, 14);
193
- l[h] = g.length > a ? [n] : g;
194
- }
195
- return l;
196
- }, {}), c;
197
- }, {});
167
+ createAxisLabels(i, t, s, o) {
168
+ this.axisLabelsX = it(
169
+ i,
170
+ t.labelsPosition,
171
+ s.valueLabels,
172
+ t.hiddenLabels,
173
+ o,
174
+ this.scales.xPrimary
175
+ );
198
176
  }
199
177
  updateAesScales(i, t) {
200
178
  if (i.inheritedAes) {
201
- const { inheritedAes: s, keys: e } = i;
202
- this.scales.xPrimaryAes.domain(e).range(e.map((r) => s[r] ?? R));
179
+ const { inheritedAes: s, keys: o } = i;
180
+ this.scales.xPrimaryAes.domain(o).range(o.map((h) => s[h] ?? R));
203
181
  } else
204
182
  this.scales.xPrimaryAes.domain([]).range([]);
205
183
  if (t.inheritedAes) {
206
- const { inheritedAes: s, keys: e } = t;
207
- this.scales.xSecondaryAes.domain(e).range(e.map((r) => s[r] ?? R));
184
+ const { inheritedAes: s, keys: o } = t;
185
+ this.scales.xSecondaryAes.domain(o).range(o.map((h) => s[h] ?? R));
208
186
  } else
209
187
  this.scales.xSecondaryAes.domain([]).range([]);
210
188
  }
211
- updateCaptionsSize(i, t, s, e) {
212
- const p = new G("600 14px Manrope"), o = i === "vertical";
213
- function c(h) {
214
- return h.length ? Math.max(...h.map((n) => p.getTextWidth(n))) : 0;
189
+ updateCaptionsSize(i, t, s, o) {
190
+ const r = new J("600 14px Manrope");
191
+ function e(a) {
192
+ return a.length ? Math.max(...a.map((x) => r.getTextWidth(x))) : 0;
215
193
  }
216
- function d(h) {
217
- return h.length ? Math.max(...h.map(c)) : 0;
218
- }
219
- let u = [], T = 0;
220
- const m = U(t, this.rowsCount, this.columnsCount), M = at(t, this.rowsCount, this.columnsCount);
221
- if (!o)
222
- u = M.map(
223
- (h) => Math.max(
224
- ...h.map(
225
- (n) => d(
226
- this.scales.xPrimary[n].domain().map((a) => this.axisLabelsX[n][a])
227
- )
228
- )
229
- )
230
- );
231
- else {
232
- if (s.labelsPosition === "center" && (u = m.map(
233
- (h) => Math.max(
234
- ...h.map(
235
- (n) => Math.max(
236
- ...this.scales.xPrimary[n].domain().map(
237
- (a) => a ? this.axisLabelsX[n][a].length * W : 0
238
- )
239
- )
240
- )
241
- )
242
- )), s.labelsPosition === "45deg") {
243
- const h = Math.sin(Math.PI / 4);
244
- u = m.map((n) => Math.max(
245
- ...n.map((a) => {
246
- const g = this.scales.xPrimary[a].domain().map((L) => this.axisLabelsX[a][L]), A = d(g);
247
- return A > 0 ? A * h + 14 : 0;
248
- })
249
- )), T = Math.max(
250
- ...M[0].map((n) => {
251
- const a = this.scales.xPrimary[n].domain(), g = this.axisLabelsX[n][a[0]];
252
- return Math.max(
253
- c(g) * h - this.scales.xPrimary[n].bandwidth() / 2 + 14,
254
- 0
255
- );
256
- })
257
- );
258
- }
259
- s.labelsPosition === "90deg" && (u = m.map(
260
- (h) => Math.max(
261
- ...h.map(
262
- (n) => d(
263
- this.scales.xPrimary[n].domain().map((a) => this.axisLabelsX[n][a])
264
- )
265
- )
266
- )
267
- ));
268
- }
269
- const f = V.flatten(
270
- t.map((h) => {
271
- if (e.hiddenLabels)
194
+ const { xTail: l, yTail: p, axisCaptionsWidthByRows: u, axisCaptionsWidthByColumns: d } = st(t, this.rowsCount, this.columnsCount, s.labelsPosition, this.axisLabelsX, i, this.scales.xPrimary), T = X.flatten(
195
+ t.map((a) => {
196
+ if (o.hiddenLabels)
272
197
  return [];
273
- const n = this.scales.y[h], a = n.ticks(), g = a.some((L) => Math.abs(L) < 1e-4 && L !== 0 || L > 1e4) ? ",e" : ",f", A = n.tickFormat(10, g);
274
- return a.map(A);
198
+ const x = this.scales.y[a], n = x.ticks(), A = n.some((m) => Math.abs(m) < 1e-4 && m !== 0 || m > 1e4) ? ",e" : ",f", C = x.tickFormat(10, A);
199
+ return n.map(C);
275
200
  })
276
- ), l = c(f);
201
+ );
277
202
  this.captionsSizes = {
278
- xCaptionsTail: T,
279
- xAxisCaptionsWidthByRows: u,
280
- yAxisCaptionsWidth: l
203
+ bottomCaptionsTail: l,
204
+ leftCaptionsTail: p,
205
+ bottomAxisCaptionsWidthByRows: u,
206
+ leftAxisCaptionsWidthByColumns: d,
207
+ leftAxisCaptionsWidth: e(T)
281
208
  };
282
209
  }
283
210
  updateMargins(i, t, s) {
284
- const e = this.chartsDimensions[t[0]], r = this.chartsDimensions[t[t.length - 1]], p = i === "vertical", o = this.mainTitle.length ? J * this.mainTitle.length + Q * 2 : 0, c = s.outerOffset;
211
+ const o = this.chartsDimensions[t[0]], h = this.chartsDimensions[t[t.length - 1]], r = i === "vertical", e = this.mainTitle.length ? Z * this.mainTitle.length + $ * 2 : 0, l = s.outerOffset;
285
212
  this.margins = {
286
- left: Math.max(c, p ? this.captionsSizes.xCaptionsTail - e.padding.left : 0),
287
- right: this.legend.width + c,
288
- top: Math.max(o, c),
289
- bottom: Math.max(c, p ? 0 : this.captionsSizes.xCaptionsTail - r.padding.bottom)
213
+ left: Math.max(l, r ? this.captionsSizes.bottomCaptionsTail - o.padding.left : 0),
214
+ right: this.legend.width + l,
215
+ top: Math.max(e, l),
216
+ bottom: Math.max(l, r ? 0 : this.captionsSizes.leftCaptionsTail - h.padding.bottom)
290
217
  }, this.chartSizes.totalWidth = this.margins.left + this.chartSizes.chartsWidth + this.margins.right, this.chartSizes.totalHeight = this.margins.top + Math.max(this.chartSizes.chartsHeight, this.legend.height) + this.margins.bottom;
291
218
  }
292
- updateLegendSize(i, t, s, e) {
219
+ updateLegendSize(i, t, s, o) {
293
220
  if (!i.show) {
294
221
  this.legend = { width: 0, height: 0, items: [] };
295
222
  return;
296
223
  }
297
- const r = this.chartSizes.chartHeight, p = { width: 0, height: 0, left: 0, top: 0 }, o = [];
298
- function c(l, h) {
299
- return e.some((n) => {
300
- const a = n.aes[h];
301
- return a && rt(a) && a.type === l;
224
+ const h = this.chartSizes.chartHeight, r = { width: 0, height: 0, left: 0, top: 0 }, e = [];
225
+ function l(n, A) {
226
+ return o.some((C) => {
227
+ const m = C.aes[A];
228
+ return m && rt(m) && m.type === n;
302
229
  });
303
230
  }
304
- function d(l) {
231
+ function p(n) {
305
232
  return {
306
- dotFill: c(l, "dotFill"),
307
- fillColor: c(l, "fillColor"),
308
- lineColor: c(l, "lineColor"),
309
- dotShape: c(l, "dotShape"),
310
- lineShape: c(l, "lineShape")
233
+ dotFill: l(n, "dotFill"),
234
+ fillColor: l(n, "fillColor"),
235
+ lineColor: l(n, "lineColor"),
236
+ dotShape: l(n, "dotShape"),
237
+ lineShape: l(n, "lineShape")
311
238
  };
312
239
  }
313
- const u = d("primaryGrouping"), T = d("secondaryGrouping");
314
- if (Object.values(u).some((l) => l) && t.inheritedAes && o.push({
240
+ const u = p("primaryGrouping"), d = p("secondaryGrouping");
241
+ if (Object.values(u).some((n) => n) && t.inheritedAes && e.push({
315
242
  type: "discreteMulti",
316
243
  id: "primary",
317
244
  title: t.label,
@@ -319,74 +246,74 @@ class Nt {
319
246
  values: t.keys,
320
247
  labels: t.valueLabels,
321
248
  usedAes: u,
322
- ...p
323
- }), Object.values(T).some((l) => l) && s.inheritedAes && o.push({
249
+ ...r
250
+ }), Object.values(d).some((n) => n) && s.inheritedAes && e.push({
324
251
  type: "discreteMulti",
325
252
  id: "secondary",
326
253
  title: s.label,
327
254
  scale: this.scales.xSecondaryAes,
328
255
  values: s.keys,
329
256
  labels: s.valueLabels,
330
- usedAes: T,
331
- ...p
332
- }), !o.length) {
257
+ usedAes: d,
258
+ ...r
259
+ }), !e.length) {
333
260
  this.legend = { width: 0, height: 0, items: [] };
334
261
  return;
335
262
  }
336
- const m = y(o, this.chartSizes.chartHeight), M = m[m.length - 1], f = M.left + M.width + tt;
263
+ const T = q(e, this.chartSizes.chartHeight), a = T[T.length - 1], x = a.left + a.width + G;
337
264
  this.legend = {
338
- width: f,
339
- height: r,
340
- items: m
265
+ width: x,
266
+ height: h,
267
+ items: T
341
268
  };
342
269
  }
343
- render(i, t, s, e, r, p, o, c, d, u, T, m, M, f) {
344
- var A;
345
- const { orientation: l, xAxis: h, yAxis: n, size: a } = s;
346
- this.updateChartSize(a, o, p, e.keys, l, u), this.updateViewport(
347
- l,
348
- e.keys,
349
- r.keys,
350
- o,
351
- p,
270
+ render(i, t, s, o, h, r, e, l, p, u, d, T, a, x) {
271
+ var b;
272
+ const { orientation: n, xAxis: A, yAxis: C, size: m } = s;
273
+ this.updateChartSize(m, e, r, o.keys, n, u), this.updateViewport(
352
274
  n,
353
- d,
275
+ o.keys,
276
+ h.keys,
277
+ e,
278
+ r,
279
+ C,
280
+ p,
354
281
  u,
355
- a,
356
- m
357
- ), this.createAxisLabels(o, h, e, l), this.createFacetTitles(o, c), this.updateCaptionsSize(l, o, h, n), this.updateChartDimensions(o, p, l, h, n), this.updateLegendSize(s.legend, e, r, d), this.createMainTitle(o, s.title), this.updateMargins(l, o, a), this.updateAesScales(e, r);
358
- const g = /* @__PURE__ */ w.jsx(q, { dataFrame: i, children: /* @__PURE__ */ w.jsx(
359
- K,
282
+ m,
283
+ T
284
+ ), this.createAxisLabels(e, A, o, n), this.createFacetTitles(e, l), this.updateCaptionsSize(n, e, A, C), this.updateChartDimensions(e, r, n, A, C), this.updateLegendSize(s.legend, o, h, p), this.createMainTitle(e, s.title), this.updateMargins(n, e, m), this.updateAesScales(o, h);
285
+ const g = /* @__PURE__ */ E.jsx(y, { dataFrame: i, children: /* @__PURE__ */ E.jsx(
286
+ Q,
360
287
  {
361
288
  settingsId: t,
362
289
  chartSettings: s,
363
- facetKeys: o,
364
- facetSettings: p,
290
+ facetKeys: e,
291
+ facetSettings: r,
365
292
  facetTitles: this.facetTitles,
366
293
  chartSizes: this.chartSizes,
367
294
  chartsDimensions: this.chartsDimensions,
368
295
  scales: this.scales,
369
- layersData: d,
296
+ layersData: p,
370
297
  statsData: u,
371
298
  legendData: this.legend,
372
299
  margins: this.margins,
373
300
  columnsCount: this.columnsCount,
374
- keyColumn: T,
301
+ keyColumn: d,
375
302
  xLabels: this.axisLabelsX,
376
303
  chartTitle: this.mainTitle,
377
- onlyPositive: M,
378
- secondaryGrouping: r,
379
- onTooltipHintSwitch: f
304
+ onlyPositive: a,
305
+ secondaryGrouping: h,
306
+ onTooltipHintSwitch: x
380
307
  }
381
308
  ) });
382
- this.component = g, (A = this.reactRoot) == null || A.render(g);
309
+ this.component = g, (b = this.reactRoot) == null || b.render(g);
383
310
  }
384
311
  renderError(i) {
385
312
  var t;
386
- (t = this.reactRoot) == null || t.render(/* @__PURE__ */ w.jsx($, { message: i }));
313
+ (t = this.reactRoot) == null || t.render(/* @__PURE__ */ E.jsx(V, { message: i }));
387
314
  }
388
315
  }
389
316
  export {
390
- Nt as default
317
+ It as default
391
318
  };
392
319
  //# sourceMappingURL=ChartRenderer.js.map