@milaboratories/graph-maker 1.1.136 → 1.1.138

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 (102) hide show
  1. package/README.md +120 -24
  2. package/dist/GraphMaker/components/SettingsTabs/icons/AxesIcon.vue.d.ts.map +1 -0
  3. package/dist/GraphMaker/{icons → components/SettingsTabs/icons}/AxesIcon.vue.js +1 -1
  4. package/dist/GraphMaker/components/SettingsTabs/icons/AxesIcon.vue.js.map +1 -0
  5. package/dist/GraphMaker/components/SettingsTabs/icons/DeleteChartIcon.vue.d.ts.map +1 -0
  6. package/dist/GraphMaker/{icons → components/SettingsTabs/icons}/DeleteChartIcon.vue.js +1 -1
  7. package/dist/GraphMaker/components/SettingsTabs/icons/DeleteChartIcon.vue.js.map +1 -0
  8. package/dist/GraphMaker/components/SettingsTabs/icons/ExportIcon.vue.d.ts.map +1 -0
  9. package/dist/GraphMaker/{icons → components/SettingsTabs/icons}/ExportIcon.vue.js +1 -1
  10. package/dist/GraphMaker/components/SettingsTabs/icons/ExportIcon.vue.js.map +1 -0
  11. package/dist/GraphMaker/components/SettingsTabs/icons/LayersIcon.vue.d.ts.map +1 -0
  12. package/dist/GraphMaker/{icons → components/SettingsTabs/icons}/LayersIcon.vue.js +1 -1
  13. package/dist/GraphMaker/components/SettingsTabs/icons/LayersIcon.vue.js.map +1 -0
  14. package/dist/GraphMaker/components/SettingsTabs/icons/LinkIcon.vue.d.ts.map +1 -0
  15. package/dist/GraphMaker/{icons → components/SettingsTabs/icons}/LinkIcon.vue.js +1 -1
  16. package/dist/GraphMaker/components/SettingsTabs/icons/LinkIcon.vue.js.map +1 -0
  17. package/dist/GraphMaker/components/SettingsTabs/icons/LogIcon.vue.d.ts +3 -0
  18. package/dist/GraphMaker/components/SettingsTabs/icons/LogIcon.vue.d.ts.map +1 -0
  19. package/dist/GraphMaker/components/SettingsTabs/icons/LogIcon.vue.js +12 -0
  20. package/dist/GraphMaker/components/SettingsTabs/icons/LogIcon.vue.js.map +1 -0
  21. package/dist/GraphMaker/components/SettingsTabs/icons/LogIcon.vue2.js +5 -0
  22. package/dist/GraphMaker/components/SettingsTabs/icons/LogIcon.vue2.js.map +1 -0
  23. package/dist/GraphMaker/components/SettingsTabs/icons/SettingsIcon.vue.d.ts.map +1 -0
  24. package/dist/GraphMaker/components/SettingsTabs/index.vue.d.ts +2 -0
  25. package/dist/GraphMaker/components/SettingsTabs/index.vue.d.ts.map +1 -1
  26. package/dist/GraphMaker/components/SettingsTabs/index.vue.js +17 -15
  27. package/dist/GraphMaker/components/SettingsTabs/index.vue.js.map +1 -1
  28. package/dist/GraphMaker/constantsCommon.d.ts +2 -0
  29. package/dist/GraphMaker/constantsCommon.d.ts.map +1 -1
  30. package/dist/GraphMaker/constantsCommon.js +19 -17
  31. package/dist/GraphMaker/constantsCommon.js.map +1 -1
  32. package/dist/GraphMaker/forms/AxesSettingsForm/HeatmapAxesSettingsForm.vue.d.ts.map +1 -1
  33. package/dist/GraphMaker/forms/AxesSettingsForm/HeatmapAxesSettingsForm.vue.js +144 -122
  34. package/dist/GraphMaker/forms/AxesSettingsForm/HeatmapAxesSettingsForm.vue.js.map +1 -1
  35. package/dist/GraphMaker/forms/LogForm.vue.d.ts +19 -0
  36. package/dist/GraphMaker/forms/LogForm.vue.d.ts.map +1 -0
  37. package/dist/GraphMaker/forms/LogForm.vue.js +22 -0
  38. package/dist/GraphMaker/forms/LogForm.vue.js.map +1 -0
  39. package/dist/GraphMaker/forms/index.d.ts +22 -0
  40. package/dist/GraphMaker/forms/index.d.ts.map +1 -1
  41. package/dist/GraphMaker/forms/index.js +35 -28
  42. package/dist/GraphMaker/forms/index.js.map +1 -1
  43. package/dist/GraphMaker/index.vue.d.ts +1 -0
  44. package/dist/GraphMaker/index.vue.d.ts.map +1 -1
  45. package/dist/GraphMaker/index.vue.js +161 -159
  46. package/dist/GraphMaker/index.vue.js.map +1 -1
  47. package/dist/GraphMaker/store.d.ts.map +1 -1
  48. package/dist/GraphMaker/store.js +71 -67
  49. package/dist/GraphMaker/store.js.map +1 -1
  50. package/dist/GraphMaker/utils/createChartSettingsForRender/getAxesDataFromForms.d.ts.map +1 -1
  51. package/dist/GraphMaker/utils/createChartSettingsForRender/getAxesDataFromForms.js +9 -9
  52. package/dist/GraphMaker/utils/createChartSettingsForRender/getAxesDataFromForms.js.map +1 -1
  53. package/dist/lib.js +1 -1
  54. package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/ChartRenderer.js +246 -228
  55. package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/ChartRenderer.js.map +1 -1
  56. package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/components/Captions/GroupCaptions.js +46 -37
  57. package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/components/Captions/GroupCaptions.js.map +1 -1
  58. package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/components/Chart.js +63 -61
  59. package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/components/Chart.js.map +1 -1
  60. package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/components/ChartsGroup.js +4 -4
  61. package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/components/Dendrograms.js +57 -51
  62. package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/components/Dendrograms.js.map +1 -1
  63. package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/getDendrograms.js +33 -33
  64. package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/getDendrograms.js.map +1 -1
  65. package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/index.js +20 -20
  66. package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/utils/calculateCaptionTails.js +89 -54
  67. package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/utils/calculateCaptionTails.js.map +1 -1
  68. package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/utils/calculateChartSideElementSizes.js +19 -19
  69. package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/utils/calculateChartSideElementSizes.js.map +1 -1
  70. package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot/ChartRenderer.js +181 -168
  71. package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot/ChartRenderer.js.map +1 -1
  72. package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot/components/ChartsGroup.js +1 -1
  73. package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot/components/ChartsGroup.js.map +1 -1
  74. package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot/index.js +5 -5
  75. package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot-umap/components/Lasso.js +144 -120
  76. package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot-umap/components/Lasso.js.map +1 -1
  77. package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot-umap/components/LowerSVG.js +35 -35
  78. package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot-umap/components/LowerSVG.js.map +1 -1
  79. package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot-umap/index.js +1 -1
  80. package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot-umap/index.js.map +1 -1
  81. package/package.json +2 -2
  82. package/dist/GraphMaker/icons/AxesIcon.vue.d.ts.map +0 -1
  83. package/dist/GraphMaker/icons/AxesIcon.vue.js.map +0 -1
  84. package/dist/GraphMaker/icons/DeleteChartIcon.vue.d.ts.map +0 -1
  85. package/dist/GraphMaker/icons/DeleteChartIcon.vue.js.map +0 -1
  86. package/dist/GraphMaker/icons/ExportIcon.vue.d.ts.map +0 -1
  87. package/dist/GraphMaker/icons/ExportIcon.vue.js.map +0 -1
  88. package/dist/GraphMaker/icons/LayersIcon.vue.d.ts.map +0 -1
  89. package/dist/GraphMaker/icons/LayersIcon.vue.js.map +0 -1
  90. package/dist/GraphMaker/icons/LinkIcon.vue.d.ts.map +0 -1
  91. package/dist/GraphMaker/icons/LinkIcon.vue.js.map +0 -1
  92. package/dist/GraphMaker/icons/SettingsIcon.vue.d.ts.map +0 -1
  93. /package/dist/GraphMaker/{icons → components/SettingsTabs/icons}/AxesIcon.vue.d.ts +0 -0
  94. /package/dist/GraphMaker/{icons → components/SettingsTabs/icons}/DeleteChartIcon.vue.d.ts +0 -0
  95. /package/dist/GraphMaker/{icons → components/SettingsTabs/icons}/ExportIcon.vue.d.ts +0 -0
  96. /package/dist/GraphMaker/{icons → components/SettingsTabs/icons}/LayersIcon.vue.d.ts +0 -0
  97. /package/dist/GraphMaker/{icons → components/SettingsTabs/icons}/LinkIcon.vue.d.ts +0 -0
  98. /package/dist/GraphMaker/{icons → components/SettingsTabs/icons}/SettingsIcon.vue.d.ts +0 -0
  99. /package/dist/GraphMaker/{icons → components/SettingsTabs/icons}/SettingsIcon.vue.js +0 -0
  100. /package/dist/GraphMaker/{icons → components/SettingsTabs/icons}/SettingsIcon.vue.js.map +0 -0
  101. /package/dist/GraphMaker/{icons → components/SettingsTabs/icons}/SettingsIcon.vue2.js +0 -0
  102. /package/dist/GraphMaker/{icons → components/SettingsTabs/icons}/SettingsIcon.vue2.js.map +0 -0
@@ -1,80 +1,92 @@
1
- import { j as W } from "../node_modules/react/jsx-runtime.js";
2
- import { Error as tt } from "../common/Error.js";
3
- import { MIN_MARGIN as I, LEGEND_OFFSET as et, TITLE_LINE as _, DEFAULT_AES as Y, CHART_SIDE_ELEMENTS as st, MIN_PADDING as it } from "./constants.js";
1
+ import { j as $ } from "../node_modules/react/jsx-runtime.js";
2
+ import { Error as et } from "../common/Error.js";
3
+ import { MIN_MARGIN as M, LEGEND_OFFSET as st, DEFAULT_AES as Y, CHART_SIDE_ELEMENTS as ot, MIN_PADDING as it, TITLE_LINE as U } from "./constants.js";
4
4
  import { calculateChartSideElementSizes as at } from "./utils/calculateChartSideElementSizes.js";
5
- import { calculateSideElementsBBoxes as ot } from "./utils/calculateSideElementsBBoxes.js";
5
+ import { calculateSideElementsBBoxes as rt } from "./utils/calculateSideElementsBBoxes.js";
6
6
  import { createDiscreteColorScale as q, createContinuousColorScale as nt } from "./utils/createColorScales.js";
7
- import { calculateAnnotationTitleSizes as rt } from "./utils/calculateAnnotationTitleSizes.js";
8
- import { calculateCaptionTails as lt } from "./utils/calculateCaptionTails.js";
9
- import { getChartEdgeSides as ht } from "../utils/getChartEdgeSides.js";
7
+ import { calculateAnnotationTitleSizes as lt } from "./utils/calculateAnnotationTitleSizes.js";
8
+ import { calculateCaptionTails as ht } from "./utils/calculateCaptionTails.js";
9
+ import { getChartEdgeSides as ct } from "../utils/getChartEdgeSides.js";
10
10
  import { getContinuousLegendTicks as V } from "../utils/getContinuousLegendTicks.js";
11
- import F from "../node_modules/lodash/lodash.js";
12
- import { TITLE_LINE_HEIGHT as ct, TITLE_MARGIN as ut, DEFAULT_HEIGHT as X, DEFAULT_WIDTH as U } from "../constants.js";
13
- import { createRoot as pt } from "../node_modules/react-dom/client.js";
14
- import { ChartsGroup as dt } from "./components/ChartsGroup.js";
15
- import { TextMeasurer as mt } from "../utils/TextMeasurer.js";
16
- import { arrangeLegendParts as gt } from "../utils/arrangeLegendParts.js";
17
- import B from "../node_modules/d3-scale/src/ordinal.js";
18
- import j from "../node_modules/d3-scale/src/linear.js";
19
- import ft from "../node_modules/d3-array/src/extent.js";
11
+ import ut from "../node_modules/lodash/lodash.js";
12
+ import { TITLE_LINE_HEIGHT as pt, TITLE_MARGIN as dt, DEFAULT_HEIGHT as O, DEFAULT_WIDTH as X } from "../constants.js";
13
+ import { createRoot as mt } from "../node_modules/react-dom/client.js";
14
+ import { ChartsGroup as gt } from "./components/ChartsGroup.js";
15
+ import { TextMeasurer as yt } from "../utils/TextMeasurer.js";
16
+ import { arrangeLegendParts as ft } from "../utils/arrangeLegendParts.js";
17
+ import I from "../node_modules/d3-scale/src/ordinal.js";
18
+ import D from "../node_modules/d3-scale/src/linear.js";
19
+ import xt from "../node_modules/d3-array/src/extent.js";
20
20
  import J from "../node_modules/d3-hierarchy/src/cluster.js";
21
- var yt = Object.defineProperty, Ct = (f, s, t) => s in f ? yt(f, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : f[s] = t, A = (f, s, t) => Ct(f, typeof s != "symbol" ? s + "" : s, t);
22
- function Q(f, s, t) {
23
- function e(r) {
24
- r[t] = s(r.data.height), r.children && r.children.forEach(e);
21
+ var St = Object.defineProperty, Ct = (d, s, t) => s in d ? St(d, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : d[s] = t, A = (d, s, t) => Ct(d, typeof s != "symbol" ? s + "" : s, t);
22
+ const bt = Math.cos(Math.PI / 4), At = 5;
23
+ function Z(d, s, t) {
24
+ function e(l) {
25
+ l[t] = s(l.data.height), l.children && l.children.forEach(e);
25
26
  }
26
- e(f);
27
+ e(d);
27
28
  }
28
- function Z(f, s, t, e = t) {
29
- function r(o) {
30
- o[e] = o[t] + s, o.children && o.children.forEach(r);
29
+ function Q(d, s, t, e = t) {
30
+ function l(i) {
31
+ i[e] = i[t] + s, i.children && i.children.forEach(l);
31
32
  }
32
- r(f);
33
+ l(d);
33
34
  }
34
- const St = (f, s) => {
35
+ const Gt = (d, s) => {
35
36
  const t = Math.min(...s), e = Math.max(...s);
36
37
  if (t === e) {
37
- const a = f % 2 === 0 ? [] : [t];
38
- for (let l = 1; l < f / 2 + 1; l++)
39
- a.push(t + l), a.unshift(t - l);
40
- return a;
38
+ const r = d % 2 === 0 ? [] : [t];
39
+ for (let h = 1; h < d / 2 + 1; h++)
40
+ r.push(t + h), r.unshift(t - h);
41
+ return r;
41
42
  }
42
- if (f < 2)
43
+ if (d < 2)
43
44
  return [t, e];
44
- const r = (e - t) / (f - 1), o = [];
45
- for (let a = 0; a < f - 1; a++)
46
- o.push(t + r * a);
47
- return o.push(e), o;
45
+ const l = (e - t) / (d - 1), i = [];
46
+ for (let r = 0; r < d - 1; r++)
47
+ i.push(t + l * r);
48
+ return i.push(e), i;
48
49
  };
49
- function $(f, s, t) {
50
+ function tt(d, s, t) {
50
51
  let e = t;
51
- return f && (f.colorRange && (e = f.colorRange), f.method === "standardScaling" && (e = [-2, 2]), f.method === "meanNormalization" && (e = [-0.75, 0.75])), St(s, e);
52
+ return d && (d.colorRange && (e = d.colorRange), d.method === "standardScaling" && (e = [-2, 2]), d.method === "meanNormalization" && (e = [-0.75, 0.75])), Gt(s, e);
52
53
  }
53
- class kt {
54
+ function P(d, s, t) {
55
+ let e = 0;
56
+ for (const l of d) {
57
+ const i = t.getTextWidth(s[l]);
58
+ i > e && (e = i);
59
+ }
60
+ return e;
61
+ }
62
+ function F(d, s) {
63
+ return s === 90 ? d : s === 45 ? d * bt + (d > 0 ? 2 * At : 0) : U;
64
+ }
65
+ class Ft {
54
66
  constructor() {
55
- A(this, "reactRoot", null), A(this, "parentNode", null), A(this, "rootNode", null), A(this, "component", /* @__PURE__ */ W.jsx(W.Fragment, {})), A(this, "chartsDimensions", {}), A(this, "chartSizes", {
56
- chartWidth: U,
67
+ A(this, "reactRoot", null), A(this, "parentNode", null), A(this, "rootNode", null), A(this, "component", /* @__PURE__ */ $.jsx($.Fragment, {})), A(this, "chartsDimensions", {}), A(this, "chartSizes", {
68
+ chartWidth: X,
57
69
  // width of single chart
58
- chartHeight: X,
70
+ chartHeight: O,
59
71
  // height of single chart
60
- chartsWidth: U,
72
+ chartsWidth: X,
61
73
  // width of all charts in charts row
62
- chartsHeight: X,
74
+ chartsHeight: O,
63
75
  // width of all charts in charts column, without axes
64
- totalWidth: U,
76
+ totalWidth: X,
65
77
  // width of all charts in charts row, plus left axis, plus legend
66
- totalHeight: X
78
+ totalHeight: O
67
79
  // width of all charts in charts height, plus bottom axis, plus top title
68
80
  }), A(this, "margins", {
69
- top: I,
70
- bottom: I,
71
- left: I,
72
- right: I
81
+ top: M,
82
+ bottom: M,
83
+ left: M,
84
+ right: M
73
85
  }), A(this, "captionsSizes", {
74
86
  xAxisCaptions: 100,
75
87
  yAxisCaptions: 100,
76
- xGroupCaptions: _,
77
- yGroupCaptions: _,
88
+ xGroupCaptions: U,
89
+ yGroupCaptions: U,
78
90
  xCaptionTail: 0,
79
91
  yCaptionTail: 0
80
92
  }), A(this, "labelAngles", {
@@ -84,9 +96,9 @@ class kt {
84
96
  yGroupLabels: 0
85
97
  }), A(this, "columnsCount", 1), A(this, "rowsCount", 1), A(this, "scales", {
86
98
  // scales grouped by facet
87
- x: { null: B().domain(["null"]).range([1]) },
88
- y: { null: B().domain(["null"]).range([1]) }
89
- }), A(this, "step", { x: {}, y: {} }), A(this, "colorScale", j().domain([0, 1]).range(["white", "black"])), A(this, "annotationColorScales", {}), A(this, "dendrogramAesScales", {}), A(this, "legend", {
99
+ x: { null: I().domain(["null"]).range([1]) },
100
+ y: { null: I().domain(["null"]).range([1]) }
101
+ }), A(this, "step", { x: {}, y: {} }), A(this, "colorScale", D().domain([0, 1]).range(["white", "black"])), A(this, "annotationColorScales", {}), A(this, "dendrogramAesScales", {}), A(this, "legend", {
90
102
  width: 0,
91
103
  height: 0,
92
104
  items: []
@@ -100,257 +112,263 @@ class kt {
100
112
  });
101
113
  }
102
114
  init(s) {
103
- this.parentNode === null && (this.parentNode = s, this.rootNode = document.createElement("div"), this.parentNode.appendChild(this.rootNode), this.reactRoot = pt(this.rootNode));
115
+ this.parentNode === null && (this.parentNode = s, this.rootNode = document.createElement("div"), this.parentNode.appendChild(this.rootNode), this.reactRoot = mt(this.rootNode));
104
116
  }
105
117
  updateMargins(s) {
106
118
  this.margins = {
107
- top: s.show ? ct + ut * 2 : I,
108
- bottom: I,
109
- left: I,
110
- right: this.legend.width + I
119
+ top: s.show ? pt + dt * 2 : M,
120
+ bottom: M,
121
+ left: M,
122
+ right: this.legend.width + M
111
123
  }, this.chartSizes.totalWidth = this.margins.left + this.chartSizes.chartsWidth + this.margins.right, this.chartSizes.totalHeight = this.margins.top + Math.max(this.chartSizes.chartsHeight + this.margins.bottom, this.legend.height);
112
124
  }
113
- updateLegendSize(s, t, e, r, o) {
125
+ updateLegendSize(s, t, e, l, i) {
114
126
  if (!t.show) {
115
127
  this.legend = { width: 0, height: 0, items: [] };
116
128
  return;
117
129
  }
118
- const a = this.chartSizes.chartHeight, l = [], c = { width: 0, height: 0, left: 0, top: 0 }, L = (u) => u.reduce((h, i) => (h[i] = String(i), h), {});
130
+ const r = this.chartSizes.chartHeight, h = [], p = { width: 0, height: 0, left: 0, top: 0 }, G = (c) => c.reduce((n, a) => (n[a] = String(a), n), {});
119
131
  if (s === "continuous") {
120
- const u = this.colorScale, h = V(u, o), i = j([h[0], h[h.length - 1]], [a, 0]), n = r.label ?? r.value;
121
- l.push({
122
- ...c,
132
+ const c = this.colorScale, n = V(c, i), a = D([n[0], n[n.length - 1]], [r, 0]), o = l.label ?? l.value;
133
+ h.push({
134
+ ...p,
123
135
  type: "continuous",
124
136
  id: "heatmapValue",
125
- scale: u,
126
- values: h,
127
- title: n,
128
- tickPositionScale: i
137
+ scale: c,
138
+ values: n,
139
+ title: o,
140
+ tickPositionScale: a
129
141
  });
130
142
  } else if (s === "discrete") {
131
- const u = this.colorScale, h = r.label ?? r.value, i = u.domain(), n = L(i);
132
- l.push({ ...c, type: "discreteColor", id: "heatmapValue", title: h, scale: u, values: i, labels: n });
143
+ const c = this.colorScale, n = l.label ?? l.value, a = c.domain(), o = G(a);
144
+ h.push({ ...p, type: "discreteColor", id: "heatmapValue", title: n, scale: c, values: a, labels: o });
133
145
  }
134
- if (e.forEach((u) => {
135
- const h = u.valueColumn.label ?? u.valueColumn.value;
136
- if (u.type === "continuous") {
137
- const i = this.annotationColorScales[u.id].scale, n = V(i, o), C = j([n[0], n[n.length - 1]], [a, 0]);
138
- l.push({ ...c, type: "continuous", id: u.id, tickPositionScale: C, title: h, scale: i, values: n });
146
+ if (e.forEach((c) => {
147
+ const n = c.valueColumn.label ?? c.valueColumn.value;
148
+ if (c.type === "continuous") {
149
+ const a = this.annotationColorScales[c.id].scale, o = V(a, i), y = D([o[0], o[o.length - 1]], [r, 0]);
150
+ h.push({ ...p, type: "continuous", id: c.id, tickPositionScale: y, title: n, scale: a, values: o });
139
151
  }
140
- if (u.type === "discrete") {
141
- const i = this.annotationColorScales[u.id].scale, n = i.domain(), C = L(n);
142
- l.push({ ...c, type: "discreteColor", id: u.id, title: h, scale: i, values: n, labels: C });
152
+ if (c.type === "discrete") {
153
+ const a = this.annotationColorScales[c.id].scale, o = a.domain(), y = G(o);
154
+ h.push({ ...p, type: "discreteColor", id: c.id, title: n, scale: a, values: o, labels: y });
143
155
  }
144
- }), !l.length) {
156
+ }), !h.length) {
145
157
  this.legend = { width: 0, height: 0, items: [] };
146
158
  return;
147
159
  }
148
- const y = gt(l, this.chartSizes.chartHeight), m = y[y.length - 1], S = m.left + m.width + et;
160
+ const S = ft(h, this.chartSizes.chartHeight), m = S[S.length - 1], C = m.left + m.width + st;
149
161
  this.legend = {
150
- width: S,
151
- height: a,
152
- items: y
162
+ width: C,
163
+ height: r,
164
+ items: S
153
165
  };
154
166
  }
155
- updateCaptionsSize(s, t, e, r) {
156
- const o = new mt("bold 14px Arial"), { xGroupKeys: a, yGroupKeys: l, xGroupLabels: c, yGroupLabels: L, xKeysByGroups: y, yKeysByGroups: m, xLabels: S, yLabels: u } = s.meta;
167
+ updateCaptionsSize(s, t, e, l) {
168
+ const i = new yt("bold 16px Manrope"), { xGroupKeys: r, yGroupKeys: h, xGroupLabels: p, yGroupLabels: G, xKeysByGroups: S, yKeysByGroups: m, xLabels: C, yLabels: c } = s.meta;
157
169
  this.labelAngles = {
158
170
  xAxisLabels: t.axisLabelsAngle,
159
171
  yAxisLabels: e.axisLabelsAngle,
160
172
  xGroupLabels: t.groupLabelsAngle,
161
173
  yGroupLabels: e.groupLabelsAngle
162
174
  };
163
- function h(D, K) {
164
- let H = 0;
165
- for (const M of D) {
166
- const G = o.getTextWidth(K[M]);
167
- G > H && (H = G);
168
- }
169
- return H;
170
- }
171
- const i = F.flatten(Object.values(y)), n = F.flatten(Object.values(m)), C = h(i, S), d = h(n, u), p = h(a, c), g = h(l, L), { xCaptionTail: x, yCaptionTail: z } = lt(
175
+ const n = r.reduce((f, x) => Math.max(f, P(S[x], C, i)), 0), a = h.reduce((f, x) => Math.max(f, P(m[x], c, i)), 0), o = P(r, p, i), y = P(h, G, i), { xCaptionTail: u, yCaptionTail: g } = ht(
172
176
  this.labelAngles,
173
- r,
177
+ l,
178
+ this.scales,
174
179
  this.step,
175
180
  s,
176
- o
177
- ), E = this.labelAngles.xGroupLabels / 180 * Math.PI, w = this.labelAngles.yGroupLabels / 180 * Math.PI, v = this.labelAngles.xAxisLabels / 180 * Math.PI, N = this.labelAngles.yAxisLabels / 180 * Math.PI;
181
+ i
182
+ );
178
183
  this.captionsSizes = {
179
- xCaptionTail: x,
180
- yCaptionTail: z,
181
- xGroupCaptions: p * Math.sin(E) || _,
182
- yGroupCaptions: g * Math.sin(w) || _,
183
- xAxisCaptions: C * Math.sin(v) || _,
184
- yAxisCaptions: d * Math.sin(N) || _
184
+ xCaptionTail: u,
185
+ yCaptionTail: g,
186
+ xGroupCaptions: F(o, this.labelAngles.xGroupLabels),
187
+ yGroupCaptions: F(y, this.labelAngles.yGroupLabels),
188
+ xAxisCaptions: F(n, this.labelAngles.xAxisLabels),
189
+ yAxisCaptions: F(a, this.labelAngles.yAxisLabels)
185
190
  };
186
191
  }
187
- updateChartDimensions(s, t, e, r, o, a, l, c, L, y) {
188
- const m = t.length, S = Math.min(o.nRows ?? m, m), u = Math.min(o.nCols ?? m, m);
189
- this.columnsCount = o.nRows ? Math.ceil(m / S) : u, this.rowsCount = Math.ceil(m / this.columnsCount);
190
- const { width: h, height: i } = s, { sharedX: n, sharedY: C } = o;
192
+ updateChartDimensions(s, t, e, l, i, r, h, p, G, S) {
193
+ const m = t.length, C = Math.min(i.nRows ?? m, m), c = Math.min(i.nCols ?? m, m);
194
+ this.columnsCount = i.nRows ? Math.ceil(m / C) : c, this.rowsCount = Math.ceil(m / this.columnsCount);
195
+ const { width: n, height: a } = s, { sharedX: o, sharedY: y } = i;
191
196
  this.chartsDimensions = {};
192
- let d = 0, p = 0;
193
- t.forEach((z, E) => {
194
- const w = E % this.columnsCount + 1, v = ht(E, t.length, this.columnsCount, this.rowsCount), N = this.step.x[z], D = this.step.y[z], K = at(
195
- a,
196
- l,
197
+ let u = 0, g = 0;
198
+ t.forEach((L, z) => {
199
+ const B = z % this.columnsCount + 1, T = ct(z, t.length, this.columnsCount, this.rowsCount), K = this.step.x[L], H = this.step.y[L], _ = at(
200
+ r,
201
+ h,
197
202
  this.captionsSizes,
198
- c,
199
- L,
203
+ p,
204
+ G,
205
+ S,
206
+ T,
207
+ o,
200
208
  y,
201
- v,
202
- n,
203
- C,
204
209
  t,
205
210
  e,
206
- r,
207
- N,
208
- D
209
- ), H = rt(c, v, n, C);
210
- function M(R) {
211
+ l,
212
+ K,
213
+ H
214
+ ), k = lt(p, T, o, y);
215
+ function N(w) {
211
216
  return Math.max(
212
- st[R].reduce((b, T) => b + K[R][T], 0),
213
- H[R],
217
+ ot[w].reduce((b, E) => b + _[w][E], 0),
218
+ k[w],
214
219
  it
215
220
  );
216
221
  }
217
- const G = {
218
- left: M("left"),
219
- right: M("right"),
220
- top: M("top"),
221
- bottom: M("bottom")
222
+ const v = {
223
+ left: N("left"),
224
+ right: N("right"),
225
+ top: N("top"),
226
+ bottom: N("bottom")
222
227
  };
223
- G.left < this.captionsSizes.xCaptionTail && (G.left = this.captionsSizes.xCaptionTail), G.bottom < this.captionsSizes.yCaptionTail && (G.bottom = this.captionsSizes.yCaptionTail);
224
- const k = ot(K, h, i), O = h + G.left + G.right, P = i + G.top + G.bottom;
225
- this.chartsDimensions[z] = {
226
- left: d,
227
- top: p,
228
- inner: { width: h, height: i },
229
- outer: { width: O, height: P },
230
- padding: G,
231
- sideElementBBoxes: k,
232
- chartEdgeSides: v
233
- }, d += O, w === this.columnsCount && (d = 0, p += P);
228
+ v.left < this.captionsSizes.xCaptionTail && (v.left = this.captionsSizes.xCaptionTail), v.bottom < this.captionsSizes.yCaptionTail && (v.bottom = this.captionsSizes.yCaptionTail);
229
+ const R = rt(_, n, a), j = n + v.left + v.right, W = a + v.top + v.bottom;
230
+ this.chartsDimensions[L] = {
231
+ left: u,
232
+ top: g,
233
+ inner: { width: n, height: a },
234
+ outer: { width: j, height: W },
235
+ padding: v,
236
+ sideElementBBoxes: R,
237
+ chartEdgeSides: T
238
+ }, u += j, B === this.columnsCount && (u = 0, g += W);
234
239
  });
235
- const g = t.slice(0, this.columnsCount).reduce((z, E) => z + this.chartsDimensions[E].outer.width, 0), x = t.filter((z, E) => E % this.columnsCount === 0).reduce((z, E) => z + this.chartsDimensions[E].outer.height, 0);
236
- this.chartSizes.chartsWidth = g, this.chartSizes.chartsHeight = x;
240
+ const f = t.slice(0, this.columnsCount).reduce((L, z) => L + this.chartsDimensions[z].outer.width, 0), x = t.filter((L, z) => z % this.columnsCount === 0).reduce((L, z) => L + this.chartsDimensions[z].outer.height, 0);
241
+ this.chartSizes.chartsWidth = f, this.chartSizes.chartsHeight = x;
237
242
  }
238
243
  updateChartsSizes(s) {
239
244
  const { width: t, height: e } = s;
240
245
  this.chartSizes.chartWidth = t, this.chartSizes.chartHeight = e;
241
246
  }
242
247
  // update scales for cell positions, x and y for each facet
243
- updateScales(s, t, e, r, o, a, l, c, L) {
244
- const { width: y, height: m } = o, { meta: S, facets: u } = t, { sharedX: h, sharedY: i } = r, n = (d, p = {}) => d.sort(
245
- (g, x) => a.sorting === "asc" ? (p[g] ?? g).localeCompare(p[x] ?? x, "en", { numeric: !0 }) : (p[x] ?? x).localeCompare(p[g] ?? g, "en", { numeric: !0 })
246
- ), C = (d, p = {}) => d.sort(
247
- (g, x) => l.sorting === "asc" ? (p[g] ?? g).localeCompare(p[x] ?? x, "en", { numeric: !0 }) : (p[x] ?? x).localeCompare(p[g] ?? g, "en", { numeric: !0 })
248
+ updateScales(s, t, e, l, i, r, h, p, G) {
249
+ const { width: S, height: m } = i, { meta: C, facets: c } = t, { sharedX: n, sharedY: a } = l, o = (u, g = {}) => u.sort(
250
+ (f, x) => r.sorting === "asc" ? (g[f] ?? f).localeCompare(g[x] ?? x, "en", { numeric: !0 }) : (g[x] ?? x).localeCompare(g[f] ?? f, "en", { numeric: !0 })
251
+ ), y = (u, g = {}) => u.sort(
252
+ (f, x) => h.sorting === "asc" ? (g[f] ?? f).localeCompare(g[x] ?? x, "en", { numeric: !0 }) : (g[x] ?? x).localeCompare(g[f] ?? f, "en", { numeric: !0 })
248
253
  );
249
- s.forEach((d) => {
250
- const p = u[d], g = n(S.xGroupKeys), x = C(S.yGroupKeys), { xKeysByGroups: z } = h ? S : p, { yKeysByGroups: E } = i ? S : p, w = g.map((b) => z[b].length), v = x.map((b) => E[b].length), N = w.reduce((b, T) => b + T, 0), D = v.reduce((b, T) => b + T, 0), K = (y - (w.filter((b) => b > 0).length - 1) * e) / N, H = (m - (v.filter((b) => b > 0).length - 1) * e) / D, M = [], G = [];
251
- let k = 0;
252
- g.forEach((b) => {
253
- const T = c ? z[b] : n(z[b], S.xLabels);
254
- G.push(...T), T.forEach(() => {
255
- M.push(k), k += K;
256
- }), T.length > 0 && (k += e);
257
- });
258
- const O = [], P = [];
254
+ s.forEach((u) => {
255
+ const g = c[u], f = o(C.xGroupKeys), x = y(C.yGroupKeys), { xKeysByGroups: L } = n ? C : g, { yKeysByGroups: z } = a ? C : g, B = f.map((b) => L[b].length), T = x.map((b) => z[b].length), K = B.reduce((b, E) => b + E, 0), H = T.reduce((b, E) => b + E, 0), _ = (S - (B.filter((b) => b > 0).length - 1) * e) / K, k = (m - (T.filter((b) => b > 0).length - 1) * e) / H, N = [], v = [];
259
256
  let R = 0;
257
+ f.forEach((b) => {
258
+ const E = p ? L[b] : o(L[b], C.xLabels);
259
+ v.push(...E), E.forEach(() => {
260
+ N.push(R), R += _;
261
+ }), E.length > 0 && (R += e);
262
+ });
263
+ const j = [], W = [];
264
+ let w = 0;
260
265
  x.forEach((b) => {
261
- const T = L ? E[b] : C(E[b], S.yLabels);
262
- P.push(...T), T.forEach(() => {
263
- O.push(R), R += H;
264
- }), T.length > 0 && (R += e);
265
- }), this.scales.x[d] = B().domain(G).range(M), this.scales.y[d] = B().domain(P).range(O), this.step.x[d] = K, this.step.y[d] = H;
266
+ const E = G ? z[b] : y(z[b], C.yLabels);
267
+ W.push(...E), E.forEach(() => {
268
+ j.push(w), w += k;
269
+ }), E.length > 0 && (w += e);
270
+ }), this.scales.x[u] = I().domain(v).range(N), this.scales.y[u] = I().domain(W).range(j), this.step.x[u] = _, this.step.y[u] = k;
266
271
  });
267
272
  }
268
- updateAesScale(s, t, e, r, o, a, l) {
273
+ updateAesScale(s, t, e, l, i, r, h) {
269
274
  if (s === "continuous")
270
- e.valueColors ? this.colorScale = j().domain(e.valuesByColors ?? $(l, e.valueColors.length, t)).range(e.valueColors) : e.colorsList && (this.colorScale = j().domain($(l, e.colorsList.length, t)).range(e.colorsList));
275
+ e.valueColors ? this.colorScale = D().domain(e.valuesByColors ?? tt(h, e.valueColors.length, t)).range(e.valueColors) : e.colorsList && (this.colorScale = D().domain(tt(h, e.colorsList.length, t)).range(e.colorsList));
271
276
  else if (e.colorsMap) {
272
- const y = Object.entries(e.colorsMap);
273
- this.colorScale = B().domain(y.map((m) => m[0])).range(y.map((m) => m[1])).unknown("#ccc");
274
- } else e.colorsList && (this.colorScale = q(e.colorsList, a.map(String)));
275
- const { xDataByKeys: c, yDataByKeys: L } = o.meta;
276
- r.forEach((y) => {
277
- const { colors: m, type: S, axis: u, valueColumn: h } = y, i = (u === "x" ? c : L)[h.value];
278
- if (S === "discrete") {
279
- const n = F.uniq(Object.values(i).map(String)).sort();
280
- this.annotationColorScales[y.id] = {
277
+ const S = Object.entries(e.colorsMap);
278
+ this.colorScale = I().domain(S.map((m) => m[0])).range(S.map((m) => m[1])).unknown("#ccc");
279
+ } else e.colorsList && (this.colorScale = q(e.colorsList, r.map(String)));
280
+ const { xDataByKeys: p, yDataByKeys: G } = i.meta;
281
+ l.forEach((S) => {
282
+ const { colors: m, type: C, axis: c, valueColumn: n } = S, a = (c === "x" ? p : G)[n.value];
283
+ if (C === "discrete") {
284
+ const o = ut.uniq(Object.values(a).map(String)).sort();
285
+ this.annotationColorScales[S.id] = {
281
286
  type: "discrete",
282
- scale: q(m, n)
287
+ scale: q(m, o)
283
288
  };
284
289
  } else {
285
- const n = Object.values(i).map(Number);
286
- if (!n.length)
290
+ const o = Object.values(a).map(Number);
291
+ if (!o.length)
287
292
  return;
288
- const [C = n[0], d = n[0]] = ft(n);
289
- this.annotationColorScales[y.id] = {
293
+ const [y = o[0], u = o[0]] = xt(o);
294
+ this.annotationColorScales[S.id] = {
290
295
  type: "continuous",
291
- scale: nt(m, C, d, 0, 0.5, 1)
296
+ scale: nt(m, y, u, 0, 0.5, 1)
292
297
  };
293
298
  }
294
299
  });
295
300
  }
296
- updateDendrogram(s, t, e, r, o, a, l) {
297
- s.forEach((c) => {
298
- this.dendrograms[c] = { x: { trees: [], data: a }, y: { trees: [], data: l } };
299
- const { xKeysByGroups: L, yKeysByGroups: y } = r[c], { hierarchyX: m, hierarchyY: S } = o[c], u = Math.max(...m.map((i) => i.data.height)), h = Math.max(...S.map((i) => i.data.height));
300
- a && (this.dendrograms[c].x.trees = m.map((i, n) => {
301
- const C = t[n], d = L[C];
302
- J().separation(() => 1).size([d.length * this.step.x[c], a.size])(
303
- i
304
- );
305
- const p = i, g = j().domain(a.position === "top" ? [0, u] : [u, 0]).range([a.size, 0]);
306
- return Q(p, g, "y"), Z(p, this.scales.x[c](d[0]), "x"), p;
307
- }), this.dendrograms[c].x.data = a), l && (this.dendrograms[c].y.trees = S.map((i, n) => {
308
- const C = e[n], d = y[C];
309
- J().separation(() => 1).size([d.length * this.step.y[c], l.size])(
310
- i
311
- );
312
- const p = i, g = j().domain(l.position === "left" ? [0, h] : [h, 0]).range([l.size, 0]);
313
- return Z(p, this.scales.y[c](d[0]), "x", "y"), Q(p, g, "x"), p;
314
- }), this.dendrograms[c].y.data = l);
301
+ updateDendrogram(s, t, e, l, i, r, h) {
302
+ s.forEach((p) => {
303
+ this.dendrograms[p] = { x: { treesByGroupKey: {}, data: r }, y: { treesByGroupKey: {}, data: h } };
304
+ const { xKeysByGroups: G, yKeysByGroups: S } = l[p], { hierarchyByGroupX: m, hierarchyByGroupY: C } = i[p];
305
+ if (r) {
306
+ const c = t.reduce((n, a) => {
307
+ var o;
308
+ return Math.max(n, (o = m[a]) == null ? void 0 : o.data.height);
309
+ }, 0);
310
+ this.dendrograms[p].x.treesByGroupKey = t.reduce((n, a) => {
311
+ const o = m[a], y = G[a];
312
+ J().separation(() => 1).size([y.length * this.step.x[p], r.size])(
313
+ o
314
+ );
315
+ const u = o, g = D().domain(r.position === "top" ? [0, c] : [c, 0]).range([r.size, 0]);
316
+ return Z(u, g, "y"), Q(u, this.scales.x[p](y[0]), "x"), n[a] = u, n;
317
+ }, {}), this.dendrograms[p].x.data = r;
318
+ }
319
+ if (h) {
320
+ const c = e.reduce((n, a) => {
321
+ var o;
322
+ return Math.max(n, (o = C[a]) == null ? void 0 : o.data.height);
323
+ }, 0);
324
+ this.dendrograms[p].y.treesByGroupKey = e.reduce((n, a) => {
325
+ const o = C[a], y = S[a];
326
+ J().separation(() => 1).size([y.length * this.step.y[p], h.size])(
327
+ o
328
+ );
329
+ const u = o, g = D().domain(h.position === "left" ? [0, c] : [c, 0]).range([h.size, 0]);
330
+ return Q(u, this.scales.y[p](y[0]), "x", "y"), Z(u, g, "x"), n[a] = u, n;
331
+ }, {}), this.dendrograms[p].y.data = h;
332
+ }
315
333
  });
316
334
  }
317
335
  updateDendrogramAesScales(s) {
318
336
  if (!s)
319
337
  return;
320
338
  const t = Object.keys(s);
321
- this.dendrogramAesScales = t.reduce((e, r) => {
322
- const o = s[r], a = Object.keys(o);
323
- return e[r] = B().domain(a).range(
324
- a.map((l) => ({
339
+ this.dendrogramAesScales = t.reduce((e, l) => {
340
+ const i = s[l], r = Object.keys(i);
341
+ return e[l] = I().domain(r).range(
342
+ r.map((h) => ({
325
343
  ...Y,
326
- ...o[l]
344
+ ...i[h]
327
345
  }))
328
346
  ).unknown(Y), e;
329
347
  }, {});
330
348
  }
331
- render(s, t, e, r, o, a, l, c, L, y, m, S, u, h) {
332
- var i;
333
- const { meta: n, facets: C } = o, { facetKeys: d, xGroupKeys: p, yGroupKeys: g, valueExtent: x } = n, { xAxis: z, yAxis: E, title: w, size: v, valueType: N } = t;
334
- this.updateChartsSizes(v), this.updateAesScale(N, x, r, a, o, S, u), this.updateScales(d, o, r.groupGap, e, v, t.xAxis, t.yAxis, c, L), this.updateCaptionsSize(o, z, E, e), this.updateChartDimensions(
335
- v,
336
- d,
337
- p,
349
+ render(s, t, e, l, i, r, h, p, G, S, m, C, c, n) {
350
+ var a;
351
+ const { meta: o, facets: y } = i, { facetKeys: u, xGroupKeys: g, yGroupKeys: f, valueExtent: x } = o, { xAxis: L, yAxis: z, title: B, size: T, valueType: K } = t;
352
+ this.updateChartsSizes(T), this.updateAesScale(K, x, l, r, i, C, c), this.updateScales(u, i, l.groupGap, e, T, t.xAxis, t.yAxis, p, G), this.updateCaptionsSize(i, L, z, e), this.updateChartDimensions(
353
+ T,
354
+ u,
338
355
  g,
356
+ f,
339
357
  e,
358
+ L,
340
359
  z,
341
- E,
342
- a,
343
- c,
344
- L
345
- ), this.updateLegendSize(N, t.legend, a, l, x), this.updateMargins(w), this.updateDendrogram(d, p, g, C, y, c, L), this.updateDendrogramAesScales(m);
346
- const D = /* @__PURE__ */ W.jsx(
347
- dt,
360
+ r,
361
+ p,
362
+ G
363
+ ), this.updateLegendSize(K, t.legend, r, h, x), this.updateMargins(B), this.updateDendrogram(u, g, f, y, S, p, G), this.updateDendrogramAesScales(m);
364
+ const H = /* @__PURE__ */ $.jsx(
365
+ gt,
348
366
  {
349
- aes: r,
350
- annotations: a,
367
+ aes: l,
368
+ annotations: r,
351
369
  annotationColorScales: this.annotationColorScales,
352
370
  captionsSizes: this.captionsSizes,
353
- cellsMeta: n,
371
+ cellsMeta: o,
354
372
  columnsCount: this.columnsCount,
355
373
  chartsDimensions: this.chartsDimensions,
356
374
  chartSettings: t,
@@ -358,28 +376,28 @@ class kt {
358
376
  colorScale: this.colorScale,
359
377
  dendrogramAesScales: this.dendrogramAesScales,
360
378
  dendrograms: this.dendrograms,
361
- facetKeys: d,
379
+ facetKeys: u,
362
380
  facetSettings: e,
363
- groupedCells: C,
381
+ groupedCells: y,
364
382
  labelAngles: this.labelAngles,
365
383
  legend: this.legend,
366
384
  margins: this.margins,
367
385
  scales: this.scales,
368
386
  settingsId: s,
369
387
  step: this.step,
370
- xGroupKeys: p,
371
- yGroupKeys: g,
372
- onTooltipHintSwitch: h
388
+ xGroupKeys: g,
389
+ yGroupKeys: f,
390
+ onTooltipHintSwitch: n
373
391
  }
374
392
  );
375
- this.component = D, (i = this.reactRoot) == null || i.render(D);
393
+ this.component = H, (a = this.reactRoot) == null || a.render(H);
376
394
  }
377
395
  renderError(s) {
378
396
  var t;
379
- (t = this.reactRoot) == null || t.render(/* @__PURE__ */ W.jsx(tt, { message: s }));
397
+ (t = this.reactRoot) == null || t.render(/* @__PURE__ */ $.jsx(et, { message: s }));
380
398
  }
381
399
  }
382
400
  export {
383
- kt as default
401
+ Ft as default
384
402
  };
385
403
  //# sourceMappingURL=ChartRenderer.js.map