@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,109 +1,133 @@
1
- var $ = Object.defineProperty;
2
- var J = (r, t, i) => t in r ? $(r, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : r[t] = i;
3
- var C = (r, t, i) => J(r, typeof t != "symbol" ? t + "" : t, i);
4
- import { j as F } from "../node_modules/react/jsx-runtime.js";
5
- import { createRoot as k } from "../node_modules/react-dom/client.js";
6
- import { Error as K } from "../common/Error.js";
7
- import { DataFrameProvider as y } from "../common/useDataFrame.js";
8
- import { DEFAULT_HEIGHT as X, DEFAULT_WIDTH as G, TITLE_LINE_HEIGHT as tt, MAX_SHOWN_UNIQUE_VALUES_IN_LABELS as it, BLACK as Z, TITLE_MARGIN as et } from "../constants.js";
9
- import { FACET_TITLE_LINE as st } from "../discrete/constants.js";
10
- import { splitTextByWidth as U } from "../discrete/utils/splitTextByWidth.js";
11
- import { isContinuousAes as j } from "../types/common.js";
1
+ var st = Object.defineProperty;
2
+ var ot = (a, t, i) => t in a ? st(a, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : a[t] = i;
3
+ var b = (a, t, i) => ot(a, typeof t != "symbol" ? t + "" : t, i);
4
+ import { j as v } from "../node_modules/react/jsx-runtime.js";
5
+ import { createRoot as nt } from "../node_modules/react-dom/client.js";
6
+ import { Error as at } from "../common/Error.js";
7
+ import { DataFrameProvider as ht } from "../common/useDataFrame.js";
8
+ import { DEFAULT_HEIGHT as X, DEFAULT_WIDTH as P, TITLE_LINE_HEIGHT as rt, MAX_SHOWN_UNIQUE_VALUES_IN_LABELS as lt, BLACK as et, TITLE_MARGIN as ct } from "../constants.js";
9
+ import { FACET_TITLE_LINE as mt } from "../discrete/constants.js";
10
+ import { splitTextByWidth as V } from "../utils/splitTextByWidth.js";
11
+ import { isContinuousAes as q } from "../types/common.js";
12
12
  import "../types/discrete.js";
13
13
  import "../types/scatterplot.js";
14
14
  import "../types/heatmap.js";
15
15
  import "../types/dendro.js";
16
16
  import "../types/histogram.js";
17
17
  import "../types/bubble.js";
18
- import { arrangeLegendParts as ot } from "../utils/arrangeLegendParts.js";
19
- import { getContinuousColorScale as nt } from "../utils/getContinuousColorScale.js";
20
- import { getContinuousLegendTicks as at } from "../utils/getContinuousLegendTicks.js";
21
- import { TextMeasurer as ht } from "../utils/TextMeasurer/TextMeasurer.js";
22
- import { ChartsGroup as rt } from "./components/ChartsGroup.js";
23
- import { MIN_MARGIN as v, PADDINGS as B, DEFAULT_DOT_AES as D, LEGEND_OFFSET as lt, TICK_OFFSET as O, DEFAULT_TICKS_SIZE as P, MIN_PADDING as b, FACET_TITLE_OFFSET as ct, FACET_AXIS_OFFSET as V, TITLE_LINE as q } from "./constants.js";
24
- import { createAesGetter as _ } from "./utils/createAesGetter.js";
25
- import { getTicksAndFormat as mt } from "./utils/getTicksAndFormat.js";
26
- import L from "../node_modules/d3-scale/src/linear.js";
27
- import Q from "../node_modules/d3-scale/src/log.js";
28
- import dt from "../node_modules/d3-scale/src/ordinal.js";
29
- import pt from "../node_modules/d3-scale/src/symlog.js";
30
- import { sqrt as ut } from "../node_modules/d3-scale/src/pow.js";
31
- function gt(r, t, i, s) {
18
+ import { arrangeLegendParts as dt } from "../utils/arrangeLegendParts.js";
19
+ import { getContinuousColorScale as pt } from "../utils/getContinuousColorScale.js";
20
+ import { getContinuousLegendTicks as ut } from "../utils/getContinuousLegendTicks.js";
21
+ import { TextMeasurer as gt } from "../utils/TextMeasurer/TextMeasurer.js";
22
+ import { ChartsGroup as ft } from "./components/ChartsGroup.js";
23
+ import { MIN_MARGIN as H, PADDINGS as G, DEFAULT_DOT_AES as _, LEGEND_OFFSET as Ct, TICK_OFFSET as O, DEFAULT_TICKS_SIZE as Q, MIN_PADDING as F, FACET_TITLE_OFFSET as Tt, TITLE_LINE as U, FACET_AXIS_OFFSET as Z } from "./constants.js";
24
+ import { createAesGetter as D } from "./utils/createAesGetter.js";
25
+ import { getTicksAndFormat as St } from "./utils/getTicksAndFormat.js";
26
+ import { isContinuousAxis as $ } from "./utils/isNumericScale.js";
27
+ import { createMultilineDiscreteLabels as J } from "../utils/createMultilineDiscreteLabels.js";
28
+ import { measureMultilineDiscreteLabels as k } from "../utils/measureMultilineDiscreteLabels.js";
29
+ import B from "../node_modules/d3-scale/src/linear.js";
30
+ import { point as y } from "../node_modules/d3-scale/src/band.js";
31
+ import K from "../node_modules/d3-scale/src/log.js";
32
+ import xt from "../node_modules/d3-scale/src/ordinal.js";
33
+ import Mt from "../node_modules/d3-scale/src/symlog.js";
34
+ import { sqrt as zt } from "../node_modules/d3-scale/src/pow.js";
35
+ function tt(a, t) {
36
+ if (a === void 0)
37
+ return !0;
38
+ {
39
+ const i = a.domain(), s = a.range(), e = t.domain(), o = t.range();
40
+ if (i.length !== e.length || i.some((g, T) => g !== e[T]) || s[0] !== o[0] || s[1] !== o[1])
41
+ return !0;
42
+ }
43
+ return !1;
44
+ }
45
+ function bt(a, t, i, s) {
32
46
  const e = [];
33
- return r % i === i - 1 && e.push("right"), r % i === 0 && e.push("left"), r < i && e.push("top"), (Math.ceil((r + 1) / i) === s || Math.ceil((r + 1) / i) === s - 1 && r % i > (t - 1) % i) && e.push("bottom"), e;
47
+ return a % i === i - 1 && e.push("right"), a % i === 0 && e.push("left"), a < i && e.push("top"), (Math.ceil((a + 1) / i) === s || Math.ceil((a + 1) / i) === s - 1 && a % i > (t - 1) % i) && e.push("bottom"), e;
34
48
  }
35
- function ft(r, t, i, s, e, o, c) {
36
- const g = o.includes("left") || !(c != null && c.sharedY), N = o.includes("left") && t.title !== "", W = o.includes("bottom") || !(c != null && c.sharedX), w = o.includes("bottom") && r.title !== "", a = i.yAxisCaptionsWidth + 2 * O, n = (t.showTicks ? P : 0) + O, d = N ? q + b : 0, S = i.xAxisCaptionsWidth + 2 * O, E = r.showTicks ? P : 0, m = w ? q + b : 0, l = a + n + d + V, f = S + E + m + V, z = Math.max(...s.map((p) => e[p].length));
49
+ function Et(a, t, i, s, e, o, g, T, M, u) {
50
+ const W = a.scale === "discrete", m = t.scale === "discrete", n = o.includes("left") || !(u != null && u.sharedY), h = o.includes("left") && t.title !== "", c = o.includes("bottom") || !(u != null && u.sharedX), f = o.includes("bottom") && a.title !== "", r = m ? i.leftAxisCaptionsWidthByColumns[T] : i.yAxisCaptionsWidth + 2 * O, d = (t.showTicks ? Q : 0) + O, S = h ? U + F : 0, x = W ? i.bottomAxisCaptionsWidthByRows[g] : i.xAxisCaptionsWidth + 2 * O, z = a.showTicks ? Q : 0, L = f ? U + F : 0, C = r + d + S + Z, l = x + z + L + Z, I = Math.max(...s.map((p) => e[p].length));
37
51
  return {
38
- left: g ? l : b,
39
- top: z === 0 ? 0 : ct * 2 + z * st,
40
- bottom: W ? f + 8 : b,
41
- right: b
52
+ left: n ? C : F,
53
+ top: I === 0 ? 0 : Tt * 2 + I * mt,
54
+ bottom: c ? l + 8 : F,
55
+ right: M ? 0 : F
42
56
  };
43
57
  }
44
- function Tt(r, t, i) {
58
+ function wt(a, t, i) {
45
59
  const s = [];
46
60
  for (let e = 0; e < t; e++)
47
- s.push(r.slice(e * i, e * i + i));
61
+ s.push(a.slice(e * i, e * i + i));
48
62
  return s;
49
63
  }
50
- function St(r, t) {
51
- const i = Math.floor(r / t), s = r - i * t;
64
+ function Nt(a, t) {
65
+ const i = Math.floor(a / t), s = a - i * t;
52
66
  return [i, s];
53
67
  }
54
- function xt(r, t, i, s) {
55
- const e = i.find((c) => c.type === "dots"), o = i.find((c) => c.type === "curve");
68
+ function Wt(a, t, i, s) {
69
+ const e = i.find((g) => g.type === "dots"), o = i.find((g) => g.type === "curve");
56
70
  return {
57
- dotShape: _(r, t, (e == null ? void 0 : e.aes.dotShape) ?? D.shape, "dotShape"),
58
- dotColor: _(r, t, (e == null ? void 0 : e.aes.dotFill) ?? D.color, "dotFill"),
59
- dotSize: _(r, t, (e == null ? void 0 : e.aes.dotSize) ?? D.size, "dotSize"),
60
- lineShape: _(r, t, (o == null ? void 0 : o.aes.lineShape) ?? "solid", "lineShape"),
61
- lineColor: _(r, t, (o == null ? void 0 : o.aes.lineColor) ?? Z, "lineColor"),
62
- trendColor: _(r, t, (s == null ? void 0 : s.color) ?? D.color, "fillColor")
71
+ dotShape: D(a, t, (e == null ? void 0 : e.aes.dotShape) ?? _.shape, "dotShape"),
72
+ dotColor: D(a, t, (e == null ? void 0 : e.aes.dotFill) ?? _.color, "dotFill"),
73
+ dotSize: D(a, t, (e == null ? void 0 : e.aes.dotSize) ?? _.size, "dotSize"),
74
+ lineShape: D(a, t, (o == null ? void 0 : o.aes.lineShape) ?? "solid", "lineShape"),
75
+ lineColor: D(a, t, (o == null ? void 0 : o.aes.lineColor) ?? et, "lineColor"),
76
+ trendColor: D(a, t, (s == null ? void 0 : s.color) ?? _.color, "fillColor")
63
77
  };
64
78
  }
65
- class Zt {
79
+ const It = Math.cos(Math.PI / 4), At = 5;
80
+ function it(a, t) {
81
+ return t.scale === "discrete" ? t.labelsPosition === "90deg" ? a : t.labelsPosition === "45deg" ? a * It + (a > 0 ? 2 * At : 0) : U : a;
82
+ }
83
+ class ri {
66
84
  constructor() {
67
- C(this, "reactRoot", null);
68
- C(this, "parentNode", null);
69
- C(this, "rootNode", null);
70
- C(this, "component", /* @__PURE__ */ F.jsx(F.Fragment, {}));
71
- C(this, "margins", {
72
- top: v,
73
- bottom: v,
74
- left: v,
75
- right: v
85
+ b(this, "reactRoot", null);
86
+ b(this, "parentNode", null);
87
+ b(this, "rootNode", null);
88
+ b(this, "component", /* @__PURE__ */ v.jsx(v.Fragment, {}));
89
+ b(this, "margins", {
90
+ top: H,
91
+ bottom: H,
92
+ left: H,
93
+ right: H
76
94
  });
77
- C(this, "chartsDimensions", {});
78
- C(this, "chartSizes", {
79
- chartWidth: G,
95
+ b(this, "chartsDimensions", {});
96
+ b(this, "chartSizes", {
97
+ chartWidth: P,
80
98
  // width of single chart
81
99
  chartHeight: X,
82
100
  // height of single chart
83
- chartsWidth: G,
101
+ chartsWidth: P,
84
102
  // width of all charts in charts row
85
103
  chartsHeight: X,
86
104
  // width of all charts in charts column, without axes
87
- totalWidth: G,
105
+ totalWidth: P,
88
106
  // width of all charts in charts row, plus left axis, plus legend
89
107
  totalHeight: X
90
108
  // width of all charts in charts height, plus bottom axis, plus top title
91
109
  });
92
- C(this, "columnsCount", 1);
93
- C(this, "rowsCount", 1);
94
- C(this, "scales", {
95
- x: { null: L().domain([0, 10]).range([0, G]) },
96
- y: { null: L().domain([0, 10]).range([X, 0]) }
110
+ b(this, "columnsCount", 1);
111
+ b(this, "rowsCount", 1);
112
+ b(this, "scales", {
113
+ x: { null: B().domain([0, 1]).range([0, P]) },
114
+ y: { null: B().domain([0, 1]).range([X, 0]) }
97
115
  });
98
- C(this, "captionsSizes", {
116
+ b(this, "captionsSizes", {
99
117
  xAxisCaptionsWidth: 30,
100
- yAxisCaptionsWidth: 100
118
+ yAxisCaptionsWidth: 100,
119
+ bottomAxisCaptionsWidthByRows: [],
120
+ leftAxisCaptionsWidthByColumns: [],
121
+ bottomCaptionsTail: 0,
122
+ leftCaptionsTail: 0
101
123
  });
102
- C(this, "facetTitles", {});
124
+ b(this, "facetTitles", {});
103
125
  // can be multiline
104
- C(this, "mainTitle", []);
126
+ b(this, "mainTitle", []);
105
127
  // can be multiline
106
- C(this, "legend", { width: 0, height: 0, items: [] });
128
+ b(this, "discreteAxesLabels", { x: {}, y: {} });
129
+ // only for discrete axes, by facets, can be multiline
130
+ b(this, "legend", { width: 0, height: 0, items: [] });
107
131
  }
108
132
  clear() {
109
133
  var t;
@@ -113,134 +137,188 @@ class Zt {
113
137
  });
114
138
  }
115
139
  init(t) {
116
- this.parentNode === null && (this.parentNode = t, this.rootNode = document.createElement("div"), this.parentNode.appendChild(this.rootNode), this.reactRoot = k(this.rootNode));
140
+ this.parentNode === null && (this.parentNode = t, this.rootNode = document.createElement("div"), this.parentNode.appendChild(this.rootNode), this.reactRoot = nt(this.rootNode));
117
141
  }
118
142
  updateChartSizes(t) {
119
143
  this.chartSizes.chartWidth = t.width, this.chartSizes.chartHeight = t.height;
120
144
  }
121
145
  updateChartDimensions(t, i, s, e) {
122
- const { chartWidth: o, chartHeight: c } = this.chartSizes;
123
- let g = 0, N = 0;
124
- this.chartsDimensions = t.reduce((a, n, d) => {
125
- const [S, E] = St(d, this.columnsCount), m = gt(d, t.length, this.columnsCount, this.rowsCount), l = ft(
146
+ const { chartWidth: o, chartHeight: g } = this.chartSizes;
147
+ let T = 0, M = 0;
148
+ const u = wt(t, this.rowsCount, this.columnsCount);
149
+ this.chartsDimensions = t.reduce((n, h, c) => {
150
+ const [f, r] = Nt(c, this.columnsCount), d = bt(c, t.length, this.columnsCount, this.rowsCount), S = Et(
126
151
  s,
127
152
  e,
128
153
  this.captionsSizes,
129
- Tt(t, this.rowsCount, this.columnsCount)[S],
154
+ u[f],
130
155
  this.facetTitles,
131
- m,
156
+ d,
157
+ f,
158
+ r,
159
+ r === this.columnsCount - 1,
132
160
  i
133
- ), f = o + l.left + l.right, z = c + l.top + l.bottom;
134
- return a[n] = {
135
- left: g,
136
- top: N,
137
- chartEdgeSides: m,
138
- padding: l,
139
- inner: { width: o, height: c },
140
- outer: { width: f, height: z }
141
- }, g += f, E === this.columnsCount - 1 && (g = 0, N += z), a;
161
+ ), x = o + S.left + S.right, z = g + S.top + S.bottom;
162
+ return n[h] = {
163
+ left: T,
164
+ top: M,
165
+ chartEdgeSides: d,
166
+ padding: S,
167
+ inner: { width: o, height: g },
168
+ outer: { width: x, height: z }
169
+ }, T += x, r === this.columnsCount - 1 && (T = 0, M += z), n;
142
170
  }, {});
143
171
  const W = Math.max(
144
- ...t.map((a) => this.chartsDimensions[a].outer.width + this.chartsDimensions[a].left)
145
- ), w = Math.max(
146
- ...t.map((a) => this.chartsDimensions[a].outer.height + this.chartsDimensions[a].top)
172
+ ...t.map((n) => this.chartsDimensions[n].outer.width + this.chartsDimensions[n].left)
173
+ ), m = Math.max(
174
+ ...t.map((n) => this.chartsDimensions[n].outer.height + this.chartsDimensions[n].top)
147
175
  );
148
- this.chartSizes.chartsWidth = W, this.chartSizes.chartsHeight = w;
176
+ this.chartSizes.chartsWidth = W, this.chartSizes.chartsHeight = m;
149
177
  }
150
- updateViewport(t, i, s, e, o, c) {
151
- const g = t.length, N = Math.min(i.nRows ?? g, g), W = Math.min(i.nCols ?? g, g);
152
- this.columnsCount = i.nRows ? Math.ceil(g / N) : W, this.rowsCount = Math.ceil(g / this.columnsCount);
153
- let [w, a] = [1 / 0, -1 / 0], [n, d] = [1 / 0, -1 / 0];
154
- const S = t.reduce((p, h) => {
155
- const Y = o[h], { minX: u, minY: T, maxX: A, maxY: I } = Y;
156
- return w = Math.min(w, u), n = Math.min(n, T), a = Math.max(a, A), d = Math.max(d, I), p[h] = { minX: u, maxX: A, minY: T, maxY: I }, p;
157
- }, {}), E = {}, m = {};
158
- let l = !1, f = !1;
159
- t.forEach((p) => {
160
- const h = s.scale === "log" ? Q() : L(), Y = S[p];
161
- let u = s.lowerValue ? Number(s.lowerValue) : i.sharedX ? w : Y.minX, T = s.upperValue ? Number(s.upperValue) : i.sharedX ? a : Y.maxX;
162
- if (typeof s.symmetricRange < "u") {
163
- const M = s.symmetricRange;
164
- if (M >= u && M <= T) {
165
- const x = Math.max(M - u, T - M);
166
- u = M - x, T = M + x;
178
+ updateViewport(t, i, s, e, o, g, T, M) {
179
+ const u = t.length, W = Math.min(i.nRows ?? u, u), m = Math.min(i.nCols ?? u, u);
180
+ this.columnsCount = i.nRows ? Math.ceil(u / W) : m, this.rowsCount = Math.ceil(u / this.columnsCount);
181
+ let [n, h] = [1 / 0, -1 / 0], [c, f] = [1 / 0, -1 / 0];
182
+ const r = t.reduce((C, l) => {
183
+ const I = T[l], { minX: p, minY: E, maxX: w, maxY: N } = I;
184
+ return n = Math.min(n, p), c = Math.min(c, E), h = Math.max(h, w), f = Math.max(f, N), C[l] = { minX: p, maxX: w, minY: E, maxY: N }, C;
185
+ }, {}), d = {}, S = {};
186
+ let x = !1, z = !1;
187
+ t.forEach((C) => {
188
+ let l;
189
+ if (!$(s))
190
+ l = y().range([0, this.chartSizes.chartWidth]).domain(o.keys ?? []).padding(0.5);
191
+ else {
192
+ l = s.scale === "log" ? K() : B();
193
+ const p = r[C];
194
+ let E = s.lowerValue ? Number(s.lowerValue) : i.sharedX ? n : p.minX, w = s.upperValue ? Number(s.upperValue) : i.sharedX ? h : p.maxX;
195
+ if (typeof s.symmetricRange < "u") {
196
+ const R = s.symmetricRange;
197
+ if (R >= E && R <= w) {
198
+ const Y = Math.max(R - E, w - R);
199
+ E = R - Y, w = R + Y;
200
+ }
167
201
  }
202
+ const N = [0, this.chartSizes.chartWidth], A = l.copy().domain([E, w]).range([G.LEFT, this.chartSizes.chartWidth - G.RIGHT]);
203
+ l.domain([A.invert(0), A.invert(this.chartSizes.chartWidth)]).range(N).nice();
168
204
  }
169
- const A = [0, this.chartSizes.chartWidth], I = h.copy().domain([u, T]).range([B.LEFT, this.chartSizes.chartWidth - B.RIGHT]);
170
- h.domain([I.invert(0), I.invert(this.chartSizes.chartWidth)]).range(A).nice();
171
- const H = this.scales.x[p];
172
- if (H === void 0)
173
- l = !0;
174
- else if (!l) {
175
- const M = H.domain(), x = H.range();
176
- (M[0] !== h.domain()[0] || M[1] !== h.domain()[1] || x[0] !== h.range()[0] || x[1] !== h.range()[1]) && (l = !0);
177
- }
178
- E[p] = h;
205
+ const I = this.scales.x[C];
206
+ d[C] = l, x = x || tt(I, l);
179
207
  });
180
- const z = t.reduce((p, h) => {
181
- const Y = c ? c[h] : [];
182
- return p[h] = Y.reduce(
183
- (u, T) => {
184
- const A = T.bounded ? T.xBounds : this.scales.x[h].domain(), I = T.getInterval(A[0]), H = T.getInterval(A[1]);
185
- return u.minY = Math.min(u.minY, isNaN(I.left) ? u.minY : I.left, isNaN(H.left) ? u.minY : H.left), u.maxY = Math.max(u.maxY, isNaN(I.right) ? u.maxY : I.right, isNaN(H.right) ? u.maxY : H.right), u;
208
+ const L = t.reduce((C, l) => {
209
+ const I = M ? M[l] : [];
210
+ return C[l] = I.reduce(
211
+ (p, E) => {
212
+ const w = E.bounded ? E.xBounds : this.scales.x[l].domain(), N = E.getInterval(w[0]), A = E.getInterval(w[1]);
213
+ return p.minY = Math.min(p.minY, isNaN(N.left) ? p.minY : N.left, isNaN(A.left) ? p.minY : A.left), p.maxY = Math.max(p.maxY, isNaN(N.right) ? p.maxY : N.right, isNaN(A.right) ? p.maxY : A.right), p;
186
214
  },
187
215
  { minY: 1 / 0, maxY: -1 / 0 }
188
- ), n = Math.min(n, p[h].minY), d = Math.max(d, p[h].maxY), p;
216
+ ), c = Math.min(c, C[l].minY), f = Math.max(f, C[l].maxY), C;
189
217
  }, {});
190
- t.forEach((p) => {
191
- const h = e.scale === "log" ? Q() : L(), Y = S[p], u = z[p];
192
- let T = e.lowerValue ? Number(e.lowerValue) : i.sharedY ? n : Math.min(Y.minY, u.minY), A = e.upperValue ? Number(e.upperValue) : i.sharedY ? d : Math.max(Y.maxY, u.maxY);
193
- if (typeof e.symmetricRange < "u") {
194
- const x = e.symmetricRange;
195
- if (x >= T && x <= A) {
196
- const R = Math.max(x - T, A - x);
197
- T = x - R, A = x + R;
218
+ t.forEach((C) => {
219
+ let l;
220
+ if (!$(e))
221
+ l = y().range([this.chartSizes.chartHeight, 0]).domain(g.keys ?? []).padding(0.5);
222
+ else {
223
+ l = e.scale === "log" ? K() : B();
224
+ const p = r[C], E = L[C];
225
+ let w = e.lowerValue ? Number(e.lowerValue) : i.sharedY ? c : Math.min(p.minY, E.minY), N = e.upperValue ? Number(e.upperValue) : i.sharedY ? f : Math.max(p.maxY, E.maxY);
226
+ if (typeof e.symmetricRange < "u") {
227
+ const Y = e.symmetricRange;
228
+ if (Y >= w && Y <= N) {
229
+ const j = Math.max(Y - w, N - Y);
230
+ w = Y - j, N = Y + j;
231
+ }
198
232
  }
233
+ const A = [this.chartSizes.chartHeight, 0], R = l.copy().domain([w, N]).range([this.chartSizes.chartHeight - G.BOTTOM, G.TOP]);
234
+ l.domain([R.invert(this.chartSizes.chartHeight), R.invert(0)]).range(A).nice();
199
235
  }
200
- const I = [this.chartSizes.chartHeight, 0], H = h.copy().domain([T, A]).range([this.chartSizes.chartHeight - B.BOTTOM, B.TOP]);
201
- h.domain([H.invert(this.chartSizes.chartHeight), H.invert(0)]).range(I).nice();
202
- const M = this.scales.y[p];
203
- if (M === void 0)
204
- f = !0;
205
- else if (!f) {
206
- const x = M.domain(), R = M.range();
207
- (x[0] !== h.domain()[0] || x[1] !== h.domain()[1] || R[0] !== h.range()[0] || R[1] !== h.range()[1]) && (f = !0);
208
- }
209
- m[p] = h;
210
- }), l && (this.scales.x = E), f && (this.scales.y = m);
236
+ const I = this.scales.y[C];
237
+ S[C] = l, z = z || tt(I, l);
238
+ }), x && (this.scales.x = d), z && (this.scales.y = S);
211
239
  }
212
- updateCaptionsSize(t) {
213
- const i = new ht("600 14px Arial");
214
- let s = 0;
215
- function e(o) {
216
- return Math.max(...o.map((c) => i.getTextWidth(c)));
240
+ updateCaptionsSize(t, i, s, e) {
241
+ const o = new gt("600 14px Manrope");
242
+ function g(h) {
243
+ return Math.max(...h.map((c) => o.getTextWidth(c)));
217
244
  }
218
- Object.values(this.scales.y).forEach((o) => {
219
- const { ticks: c, format: g } = mt(o, t);
220
- s = Math.max(s, e(c.map(g)));
221
- }), this.captionsSizes = {
222
- xAxisCaptionsWidth: 20,
223
- yAxisCaptionsWidth: s
245
+ let T = 0, M = 0, u = [], W = [], m = 0, n = 0;
246
+ if (i.scale === "discrete") {
247
+ const h = k(
248
+ t,
249
+ this.rowsCount,
250
+ this.columnsCount,
251
+ i.labelsPosition ?? "center",
252
+ this.discreteAxesLabels.x,
253
+ "vertical",
254
+ this.scales.x
255
+ );
256
+ T = h.xTail, u = h.axisCaptionsWidthByRows;
257
+ } else
258
+ m = 20;
259
+ if (s.scale === "discrete") {
260
+ const h = k(
261
+ t,
262
+ this.rowsCount,
263
+ this.columnsCount,
264
+ s.labelsPosition ?? "center",
265
+ this.discreteAxesLabels.y,
266
+ "horizontal",
267
+ this.scales.y
268
+ );
269
+ M = h.yTail, W = h.axisCaptionsWidthByColumns;
270
+ } else
271
+ Object.values(this.scales.y).forEach((h) => {
272
+ const { ticks: c, format: f } = St(h, e);
273
+ n = Math.max(n, g(c.map(f)));
274
+ });
275
+ this.captionsSizes = {
276
+ xAxisCaptionsWidth: it(m, i),
277
+ yAxisCaptionsWidth: it(n, s),
278
+ bottomAxisCaptionsWidthByRows: u,
279
+ leftAxisCaptionsWidthByColumns: W,
280
+ bottomCaptionsTail: T,
281
+ leftCaptionsTail: M
224
282
  };
225
283
  }
226
284
  createMainTitle(t, i) {
227
285
  const s = this.chartsDimensions[t[0]], e = this.chartsDimensions[t[t.length - 1]];
228
- this.mainTitle = U(
286
+ this.mainTitle = V(
229
287
  i.name,
230
288
  this.chartSizes.chartsWidth - s.padding.left - e.padding.right,
231
289
  20
232
290
  );
233
291
  }
234
292
  createFacetTitles(t, i) {
235
- this.facetTitles = t.reduce((s, e, o) => (i[o].length === 1 && i[o][0] === "null" ? s[e] = [] : s[e] = U(i[o].join(", "), this.chartSizes.chartWidth, 14), s), {});
293
+ this.facetTitles = t.reduce((s, e, o) => (i[o].length === 1 && i[o][0] === "null" ? s[e] = [] : s[e] = V(i[o].join(", "), this.chartSizes.chartWidth, 14), s), {});
294
+ }
295
+ createAxisLabels(t, i, s, e, o) {
296
+ this.discreteAxesLabels = {
297
+ x: i.scale !== "discrete" ? {} : J(
298
+ t,
299
+ (i == null ? void 0 : i.labelsPosition) ?? "center",
300
+ e.labels,
301
+ !1,
302
+ "vertical",
303
+ this.scales.x
304
+ ),
305
+ y: s.scale !== "discrete" ? {} : J(
306
+ t,
307
+ s.labelsPosition ?? "center",
308
+ o.labels,
309
+ !1,
310
+ "horizontal",
311
+ this.scales.y
312
+ )
313
+ };
236
314
  }
237
- updateMargins() {
238
- const t = tt * this.mainTitle.length, i = t > 0 ? t + et * 2 : 0;
315
+ updateMargins(t) {
316
+ const i = rt * this.mainTitle.length, s = i > 0 ? i + ct * 2 : 0, e = this.chartsDimensions[t[0]], o = this.chartsDimensions[t[t.length - 1]];
239
317
  this.margins = {
240
- top: Math.max(i, v),
241
- bottom: v,
242
- left: v,
243
- right: this.legend.width + v
318
+ top: Math.max(s, H),
319
+ bottom: Math.max(H, this.captionsSizes.leftCaptionsTail - o.padding.bottom),
320
+ left: Math.max(H, this.captionsSizes.bottomCaptionsTail - e.padding.left),
321
+ right: this.legend.width + H
244
322
  }, 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;
245
323
  }
246
324
  updateLegendSize(t, i, s, e) {
@@ -248,49 +326,49 @@ class Zt {
248
326
  this.legend = { width: 0, height: 0, items: [] };
249
327
  return;
250
328
  }
251
- const o = [], c = { width: 0, height: 0, left: 0, top: 0 };
252
- if (s.forEach((a) => {
253
- const n = i[a.value];
329
+ const o = [], g = { width: 0, height: 0, left: 0, top: 0 };
330
+ if (s.forEach((m) => {
331
+ const n = i[m.value];
254
332
  if (n.usedAes.length === 0 || !n.aesMap)
255
333
  return;
256
- if (n.values.length > it) {
334
+ if (n.values.length > lt) {
257
335
  console.warn(`Too many values for discrete legend (${n.values.length})`);
258
336
  return;
259
337
  }
260
- const d = {};
261
- n.values.forEach((m) => {
262
- d[m] || (d[m] = { ...D }), n.usedAes.forEach((l) => {
263
- (l === "dotFill" || l === "lineColor") && (d[m].color = n.aesMap(m, l) ?? Z), l === "dotShape" && (d[m].shape = n.aesMap(m, l) ?? "21"), l === "dotSize" && (d[m].size = n.aesMap(m, l) ?? 3);
338
+ const h = {};
339
+ n.values.forEach((r) => {
340
+ h[r] || (h[r] = { ..._ }), n.usedAes.forEach((d) => {
341
+ (d === "dotFill" || d === "lineColor") && (h[r].color = n.aesMap(r, d) ?? et), d === "dotShape" && (h[r].shape = n.aesMap(r, d) ?? "21"), d === "dotSize" && (h[r].size = n.aesMap(r, d) ?? 3);
264
342
  });
265
343
  });
266
- const S = a.label ?? a.value, E = dt().domain(n.values).range(n.values.map((m) => d[m])).unknown(D);
267
- o.push({ ...c, id: a.value, type: "dots", title: S, scale: E, values: n.values, labels: n.labels });
268
- }), e.forEach((a) => {
269
- if (a.type === "dots" && j(a.aes.dotFill)) {
270
- const { domain: n, range: d, columnName: S, type: E = "linear" } = a.aes.dotFill, m = S.label ?? S.value, l = nt(d, n, "linear"), f = (E === "log" ? pt() : L()).domain(n).range([this.chartSizes.chartHeight, 0]), z = at(f, n);
271
- o.push({ ...c, id: "dotFill", type: "continuous", title: m, scale: l, tickPositionScale: f, values: z });
344
+ const c = m.label ?? m.value, f = xt().domain(n.values).range(n.values.map((r) => h[r])).unknown(_);
345
+ o.push({ ...g, id: m.value, type: "dots", title: c, scale: f, values: n.values, labels: n.labels });
346
+ }), e.forEach((m) => {
347
+ if (m.type === "dots" && q(m.aes.dotFill)) {
348
+ const { domain: n, range: h, columnName: c, type: f = "linear" } = m.aes.dotFill, r = c.label ?? c.value, d = pt(h, n, "linear"), S = (f === "log" ? Mt() : B()).domain(n).range([this.chartSizes.chartHeight, 0]), x = ut(S, n);
349
+ o.push({ ...g, id: "dotFill", type: "continuous", title: r, scale: d, tickPositionScale: S, values: x });
272
350
  }
273
- if (a.type === "dots" && j(a.aes.dotSize)) {
274
- const { columnName: n, domain: d, range: S } = a.aes.dotSize, E = n.label ?? n.value, m = ut(d, S), l = m.ticks(3), f = m.tickFormat(3), z = l.reduce((p, h) => (p[String(h)] = f(h), p), {});
275
- o.push({ ...c, id: n.value, type: "size", title: E, scale: m, values: l, labels: z });
351
+ if (m.type === "dots" && q(m.aes.dotSize)) {
352
+ const { columnName: n, domain: h, range: c } = m.aes.dotSize, f = n.label ?? n.value, r = zt(h, c), d = r.ticks(3), S = r.tickFormat(3), x = d.reduce((z, L) => (z[String(L)] = S(L), z), {});
353
+ o.push({ ...g, id: n.value, type: "size", title: f, scale: r, values: d, labels: x });
276
354
  }
277
355
  }), !o.length) {
278
356
  this.legend = { width: 0, height: 0, items: [] };
279
357
  return;
280
358
  }
281
- const g = ot(o, this.chartSizes.chartHeight), N = g[g.length - 1], W = N.left + N.width + lt, w = this.chartSizes.chartHeight;
359
+ const T = dt(o, this.chartSizes.chartHeight), M = T[T.length - 1], u = M.left + M.width + Ct, W = this.chartSizes.chartHeight;
282
360
  this.legend = {
283
- width: W,
284
- height: w,
285
- items: g
361
+ width: u,
362
+ height: W,
363
+ items: T
286
364
  };
287
365
  }
288
- render(t, i, s, e, o, c, g, N, W, w, a, n, d, S, E, m) {
289
- var u;
290
- const { xAxis: l, yAxis: f, size: z, title: p, legend: h } = s;
291
- this.updateChartSizes(z), this.updateViewport(o, e, l, f, g, N), this.updateCaptionsSize(w.y), this.createFacetTitles(o, c), this.updateChartDimensions(o, e, l, f), this.updateLegendSize(h, a, d, S), this.createMainTitle(o, p), this.updateMargins();
292
- const Y = /* @__PURE__ */ F.jsx(y, { dataFrame: t, children: /* @__PURE__ */ F.jsx(
293
- rt,
366
+ render(t, i, s, e, o, g, T, M, u, W, m, n, h, c, f, r, d, S) {
367
+ var p;
368
+ const { xAxis: x, yAxis: z, size: L, title: C, legend: l } = s;
369
+ this.updateChartSizes(L), this.updateViewport(o, e, x, z, r, d, T, M), this.createAxisLabels(o, x, z, r, d), this.updateCaptionsSize(o, x, z, W.y), this.createFacetTitles(o, g), this.updateChartDimensions(o, e, x, z), this.updateLegendSize(l, m, h, c), this.createMainTitle(o, C), this.updateMargins(o);
370
+ const I = /* @__PURE__ */ v.jsx(ht, { dataFrame: t, children: /* @__PURE__ */ v.jsx(
371
+ ft,
294
372
  {
295
373
  settingsId: i,
296
374
  chartSettings: s,
@@ -299,29 +377,30 @@ class Zt {
299
377
  chartSizes: this.chartSizes,
300
378
  chartsDimensions: this.chartsDimensions,
301
379
  scales: this.scales,
302
- groupedDots: g,
303
- trendsData: N,
380
+ groupedDots: T,
381
+ trendsData: M,
304
382
  legendData: this.legend,
305
383
  columnsCount: this.columnsCount,
306
384
  margins: this.margins,
307
- keyColumn: W,
385
+ keyColumn: u,
308
386
  mainTitle: this.mainTitle,
309
387
  facetTitles: this.facetTitles,
310
388
  captionsSizes: this.captionsSizes,
311
- onlyPositive: w,
389
+ onlyPositive: W,
312
390
  layersData: n,
313
- aesGetters: xt(t, a, S, E),
314
- onTooltipHintSwitch: m
391
+ aesGetters: Wt(t, m, c, f),
392
+ onTooltipHintSwitch: S,
393
+ discreteAxesLabels: this.discreteAxesLabels
315
394
  }
316
395
  ) });
317
- this.component = Y, (u = this.reactRoot) == null || u.render(Y);
396
+ this.component = I, (p = this.reactRoot) == null || p.render(I);
318
397
  }
319
398
  renderError(t) {
320
399
  var i;
321
- (i = this.reactRoot) == null || i.render(/* @__PURE__ */ F.jsx(K, { message: t }));
400
+ (i = this.reactRoot) == null || i.render(/* @__PURE__ */ v.jsx(at, { message: t }));
322
401
  }
323
402
  }
324
403
  export {
325
- Zt as default
404
+ ri as default
326
405
  };
327
406
  //# sourceMappingURL=ChartRenderer.js.map