@milaboratories/miplots4 1.0.174 → 1.0.175

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 (98) hide show
  1. package/dist/DataFrame.d.ts +1 -1
  2. package/dist/DataFrame.d.ts.map +1 -1
  3. package/dist/DataFrame.js +52 -51
  4. package/dist/DataFrame.js.map +1 -1
  5. package/dist/bubble/BubbleSettingsImpl.d.ts +3 -0
  6. package/dist/bubble/BubbleSettingsImpl.d.ts.map +1 -1
  7. package/dist/bubble/BubbleSettingsImpl.js +16 -16
  8. package/dist/bubble/BubbleSettingsImpl.js.map +1 -1
  9. package/dist/bubble/getGroupedCellsData.d.ts +1 -1
  10. package/dist/bubble/getGroupedCellsData.d.ts.map +1 -1
  11. package/dist/bubble/getGroupedCellsData.js +12 -11
  12. package/dist/bubble/getGroupedCellsData.js.map +1 -1
  13. package/dist/bubble/index.d.ts.map +1 -1
  14. package/dist/bubble/index.js +61 -69
  15. package/dist/bubble/index.js.map +1 -1
  16. package/dist/constants.js +9 -11
  17. package/dist/constants.js.map +1 -1
  18. package/dist/discrete/DiscreteSettingsImpl.d.ts +2 -1
  19. package/dist/discrete/DiscreteSettingsImpl.d.ts.map +1 -1
  20. package/dist/discrete/DiscreteSettingsImpl.js.map +1 -1
  21. package/dist/discrete/index.d.ts.map +1 -1
  22. package/dist/discrete/index.js +137 -157
  23. package/dist/discrete/index.js.map +1 -1
  24. package/dist/heatmap/HeatmapSettingsImpl.d.ts +1 -0
  25. package/dist/heatmap/HeatmapSettingsImpl.d.ts.map +1 -1
  26. package/dist/heatmap/HeatmapSettingsImpl.js +29 -28
  27. package/dist/heatmap/HeatmapSettingsImpl.js.map +1 -1
  28. package/dist/heatmap/fillCellsData.d.ts +1 -1
  29. package/dist/heatmap/fillCellsData.d.ts.map +1 -1
  30. package/dist/heatmap/fillCellsData.js +172 -160
  31. package/dist/heatmap/fillCellsData.js.map +1 -1
  32. package/dist/heatmap/getCells.d.ts +1 -1
  33. package/dist/heatmap/getCells.d.ts.map +1 -1
  34. package/dist/heatmap/getCells.js +10 -9
  35. package/dist/heatmap/getCells.js.map +1 -1
  36. package/dist/heatmap/index.d.ts.map +1 -1
  37. package/dist/heatmap/index.js +95 -102
  38. package/dist/heatmap/index.js.map +1 -1
  39. package/dist/histogram/HistogramSettingsImpl.d.ts +1 -0
  40. package/dist/histogram/HistogramSettingsImpl.d.ts.map +1 -1
  41. package/dist/histogram/HistogramSettingsImpl.js +43 -43
  42. package/dist/histogram/HistogramSettingsImpl.js.map +1 -1
  43. package/dist/histogram/getHistogramData.d.ts +2 -2
  44. package/dist/histogram/getHistogramData.d.ts.map +1 -1
  45. package/dist/histogram/getHistogramData.js +47 -46
  46. package/dist/histogram/getHistogramData.js.map +1 -1
  47. package/dist/histogram/index.d.ts +0 -1
  48. package/dist/histogram/index.d.ts.map +1 -1
  49. package/dist/histogram/index.js +88 -89
  50. package/dist/histogram/index.js.map +1 -1
  51. package/dist/index.d.ts +3 -1
  52. package/dist/index.d.ts.map +1 -1
  53. package/dist/index.js +8 -4
  54. package/dist/index.js.map +1 -1
  55. package/dist/scatterplot/ScatterplotSettingsImpl.d.ts +2 -0
  56. package/dist/scatterplot/ScatterplotSettingsImpl.d.ts.map +1 -1
  57. package/dist/scatterplot/ScatterplotSettingsImpl.js.map +1 -1
  58. package/dist/scatterplot/dots.d.ts +2 -2
  59. package/dist/scatterplot/dots.d.ts.map +1 -1
  60. package/dist/scatterplot/dots.js +17 -16
  61. package/dist/scatterplot/dots.js.map +1 -1
  62. package/dist/scatterplot/index.d.ts +0 -1
  63. package/dist/scatterplot/index.d.ts.map +1 -1
  64. package/dist/scatterplot/index.js +92 -101
  65. package/dist/scatterplot/index.js.map +1 -1
  66. package/dist/scatterplot/utils/createLegendInfo.d.ts.map +1 -1
  67. package/dist/scatterplot/utils/createLegendInfo.js +1 -1
  68. package/dist/scatterplot/utils/createLegendInfo.js.map +1 -1
  69. package/dist/types/bubble.d.ts +5 -0
  70. package/dist/types/bubble.d.ts.map +1 -1
  71. package/dist/types/bubble.js +19 -18
  72. package/dist/types/bubble.js.map +1 -1
  73. package/dist/types/dendro.d.ts +5 -0
  74. package/dist/types/dendro.d.ts.map +1 -1
  75. package/dist/types/dendro.js +10 -9
  76. package/dist/types/dendro.js.map +1 -1
  77. package/dist/types/discrete.d.ts +8 -5
  78. package/dist/types/discrete.d.ts.map +1 -1
  79. package/dist/types/discrete.js +12 -11
  80. package/dist/types/discrete.js.map +1 -1
  81. package/dist/types/heatmap.d.ts +5 -0
  82. package/dist/types/heatmap.d.ts.map +1 -1
  83. package/dist/types/heatmap.js +2 -1
  84. package/dist/types/heatmap.js.map +1 -1
  85. package/dist/types/histogram.d.ts +5 -0
  86. package/dist/types/histogram.d.ts.map +1 -1
  87. package/dist/types/histogram.js +43 -42
  88. package/dist/types/histogram.js.map +1 -1
  89. package/dist/types/scatterplot.d.ts +6 -0
  90. package/dist/types/scatterplot.d.ts.map +1 -1
  91. package/dist/types/scatterplot.js +21 -19
  92. package/dist/types/scatterplot.js.map +1 -1
  93. package/dist/utils/getFacetKeysFromValueLists.d.ts +6 -0
  94. package/dist/utils/getFacetKeysFromValueLists.d.ts.map +1 -0
  95. package/dist/utils/getFacetKeysFromValueLists.js +9 -0
  96. package/dist/utils/getFacetKeysFromValueLists.js.map +1 -0
  97. package/dist/utils/getPointShape.d.ts +1 -1
  98. package/package.json +1 -1
@@ -1,39 +1,45 @@
1
- var j = Object.defineProperty;
2
- var F = (i, c, t) => c in i ? j(i, c, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[c] = t;
3
- var C = (i, c, t) => F(i, typeof c != "symbol" ? c + "" : c, t);
4
- import { s as V } from "../_virtual/server.browser.js";
5
- import { AbstractChart as v } from "../AbstractChart.js";
6
- import { getUnknownErrorInfo as L, isErrorInfo as w } from "../types/common.js";
1
+ var z = Object.defineProperty;
2
+ var H = (l, i, t) => i in l ? z(l, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[i] = t;
3
+ var C = (l, i, t) => H(l, typeof i != "symbol" ? i + "" : i, t);
4
+ import { s as X } from "../_virtual/server.browser.js";
5
+ import { AbstractChart as Y } from "../AbstractChart.js";
6
+ import { NO_GROUPED as q } from "../DataFrame.js";
7
+ import { getUnknownErrorInfo as B, isErrorInfo as I } from "../types/common.js";
7
8
  import "../types/discrete.js";
8
9
  import "../types/scatterplot.js";
9
10
  import "../types/heatmap.js";
10
11
  import "../types/dendro.js";
11
12
  import "../types/histogram.js";
12
13
  import "../types/bubble.js";
13
- import { arraysAreDifferent as A } from "../utils/arraysAreDifferent.js";
14
- import { getKeysCombinations as I } from "../utils/getKeysCombination.js";
15
- import P from "./ChartRenderer.js";
16
- import { getDots as X } from "./dots.js";
17
- import { getLayersData as z } from "./getLayersData.js";
18
- import { getRegressionData as H } from "./linearRegression.js";
14
+ import { l as G } from "../_virtual/lodash.js";
15
+ import { arraysAreDifferent as f } from "../utils/arraysAreDifferent.js";
16
+ import { getKeysCombinations as N } from "../utils/getKeysCombination.js";
17
+ import J from "./ChartRenderer.js";
18
+ import { getDots as Q } from "./dots.js";
19
+ import { getLayersData as W } from "./getLayersData.js";
20
+ import { getRegressionData as Z } from "./linearRegression.js";
19
21
  import { ScatterplotSettingsImpl as M } from "./ScatterplotSettingsImpl.js";
20
- import { createLegendInfo as Y, addPalettesToAesMapping as q } from "./utils/createLegendInfo.js";
21
- import { MAX_FACETS_COUNT as R, MAX_GROUPS_COUNT as S } from "../constants.js";
22
- import { getFacetLabels as J } from "../discrete/utils/getFacetLabels.js";
23
- function Q(i) {
24
- return typeof i == "object" && "type" in i && i.type === "grouping";
22
+ import { createLegendInfo as $, addPalettesToAesMapping as tt } from "./utils/createLegendInfo.js";
23
+ import { getFacetLabels as et } from "../discrete/utils/getFacetLabels.js";
24
+ import { getFacetStringKey as E } from "../discrete/utils/getFacetStringKey.js";
25
+ function at(l) {
26
+ return typeof l == "object" && "type" in l && l.type === "grouping";
25
27
  }
26
- function B(i, c, t) {
27
- if (c.scale === "discrete") {
28
- const e = c.keys ? c.keys : i.getColumnCategories(t.value, !1);
28
+ function O(l, i, t) {
29
+ if (i.scale === "discrete") {
30
+ const e = i.keys ? i.keys : l.getColumnCategories(t.value, !1);
29
31
  return { keys: e, labels: e.reduce((a, s) => {
30
- const u = (c.labels ?? {})[s] ?? (t.valueLabels ? i.getColumnValue(t.valueLabels, i.getColumnCategoryRowIndex(t.value, s)) : s);
32
+ const u = (i.labels ?? {})[s] ?? (t.valueLabels ? l.getColumnValue(t.valueLabels, l.getColumnCategoryRowIndex(t.value, s)) : s);
31
33
  return a[s] = String(u), s === "null" && (a[s] = t.nullValueLabel ?? "NA"), a;
32
34
  }, {}) };
33
35
  }
34
36
  return { keys: [], labels: {} };
35
37
  }
36
- class yt extends v {
38
+ function rt(l, i, t = null) {
39
+ const e = i.value, a = l.getColumnCategories(e);
40
+ return G.intersection(t ?? a, a).map(String);
41
+ }
42
+ class Lt extends Y {
37
43
  constructor(t, e, a) {
38
44
  super(t, e);
39
45
  C(this, "settings");
@@ -41,13 +47,13 @@ class yt extends v {
41
47
  C(this, "onTooltipHintSwitch", () => {
42
48
  });
43
49
  C(this, "calculatedData", null);
44
- this.chartRenderer = new P(), this.settings = new M(e), a && (this.onTooltipHintSwitch = a.onTooltipHintSwitch);
50
+ this.chartRenderer = new J(), this.settings = new M(e), a && (this.onTooltipHintSwitch = a.onTooltipHintSwitch);
45
51
  }
46
52
  mount(t) {
47
53
  try {
48
54
  this.chartRenderer.init(t), this._updateData(), this._updateChart(), this.hasError = !1, this.errorInfo = null;
49
55
  } catch (e) {
50
- this.hasError = !0, e instanceof Error && (this.errorInfo = w(e.cause) ? e.cause : L(e), this.chartRenderer.renderError(e.message), console.error(e));
56
+ this.hasError = !0, e instanceof Error && (this.errorInfo = I(e.cause) ? e.cause : B(e), this.chartRenderer.renderError(e.message), console.error(e));
51
57
  }
52
58
  }
53
59
  unmount() {
@@ -58,30 +64,30 @@ class yt extends v {
58
64
  const a = this.settings, s = this.data;
59
65
  this.settings = new M(e), this.data = t, this._needUpdateCalculatedDataBySettings(a, this.settings) || this._needUpdateCalculatedDataByData(s, this.data) ? this._updateData() : this._updateAesInData(), this._updateChart(), this.hasError = !1, this.errorInfo = null;
60
66
  } catch (a) {
61
- this.hasError = !0, console.error(a), a instanceof Error && (this.errorInfo = w(a.cause) ? a.cause : L(a), this.chartRenderer.renderError(a.message), console.error(a));
67
+ this.hasError = !0, console.error(a), a instanceof Error && (this.errorInfo = I(a.cause) ? a.cause : B(a), this.chartRenderer.renderError(a.message), console.error(a));
62
68
  }
63
69
  }
64
70
  updateChartState(t, e) {
65
71
  console.warn("no chart state for scatterplot");
66
72
  }
67
73
  export() {
68
- return this._updateChart(), V.renderToString(this.chartRenderer.component);
74
+ return this._updateChart(), X.renderToString(this.chartRenderer.component);
69
75
  }
70
76
  _needUpdateCalculatedDataBySettings(t, e) {
71
- var a, s, h, u;
72
- return t.facetBy.some((n, l) => {
73
- var p;
74
- return n.value !== ((p = e.facetBy[l]) == null ? void 0 : p.value);
75
- }) || t.grouping.length !== e.grouping.length || A(
76
- t.grouping.map((n) => n.columnName.value),
77
- e.grouping.map((n) => n.columnName.value)
78
- ) || A(
79
- t.grouping.map((n) => n.columnName.nullValueLabel),
80
- e.grouping.map((n) => n.columnName.nullValueLabel)
81
- ) || t.grouping.some((n, l) => {
82
- var p;
83
- return A(n.order, (p = e.grouping) == null ? void 0 : p[l].order);
84
- }) || A(t.chartSettings.xAxis.keys, e.chartSettings.xAxis.keys) || A(t.chartSettings.yAxis.keys, e.chartSettings.yAxis.keys) || (((a = t.label) == null ? void 0 : a.value) || ((s = e.label) == null ? void 0 : s.value)) && ((h = t.label) == null ? void 0 : h.value) !== ((u = e.label) == null ? void 0 : u.value) || t.layers.length !== e.layers.length || t.layers.some((n, l) => n.type !== e.layers[l].type) || !!t.trend != !!e.trend;
77
+ var a, s, h, u, g, p, m, c;
78
+ return f(((a = t.facetSettings) == null ? void 0 : a.order) ?? [], ((s = e.facetSettings) == null ? void 0 : s.order) ?? []) || t.facetBy.some((r, d) => {
79
+ var n;
80
+ return r.value !== ((n = e.facetBy[d]) == null ? void 0 : n.value);
81
+ }) || t.grouping.length !== e.grouping.length || f(
82
+ t.grouping.map((r) => r.columnName.value),
83
+ e.grouping.map((r) => r.columnName.value)
84
+ ) || f(
85
+ t.grouping.map((r) => r.columnName.nullValueLabel),
86
+ e.grouping.map((r) => r.columnName.nullValueLabel)
87
+ ) || t.grouping.some((r, d) => {
88
+ var n;
89
+ return f(r.order, (n = e.grouping) == null ? void 0 : n[d].order);
90
+ }) || f(((h = t.facetSettings) == null ? void 0 : h.order) ?? [], ((u = e.facetSettings) == null ? void 0 : u.order) ?? []) || f(t.chartSettings.xAxis.keys, e.chartSettings.xAxis.keys) || f(t.chartSettings.yAxis.keys, e.chartSettings.yAxis.keys) || (((g = t.label) == null ? void 0 : g.value) || ((p = e.label) == null ? void 0 : p.value)) && ((m = t.label) == null ? void 0 : m.value) !== ((c = e.label) == null ? void 0 : c.value) || t.layers.length !== e.layers.length || t.layers.some((r, d) => r.type !== e.layers[d].type) || !!t.trend != !!e.trend;
85
91
  }
86
92
  _needUpdateCalculatedDataByData(t, e) {
87
93
  const a = Object.keys(t.data), s = Object.keys(e.data);
@@ -91,94 +97,79 @@ class yt extends v {
91
97
  });
92
98
  }
93
99
  _updateData() {
94
- const { x: t, y: e, facetBy: a, grouping: s, dotSize: h, dotShape: u, trend: n, layers: l, label: p, highlight: d, chartSettings: o } = this.settings, y = a.map((r) => this.data.getColumnCategories(r.value)).filter((r) => r.length > 0), D = s.map(({ columnName: r }) => this.data.getColumnCategories(r.value, !1)).filter((r) => r.length > 0), g = y.length ? I(y) : [["null"]], b = D.length ? I(D) : [["null"]], m = a.map((r) => r.value) ?? null;
95
- this.data.setGrouping([...m]);
96
- const N = {
97
- x: this.data.getColumn(t.value).every((r) => r === null || !(Number(r) < 0)),
98
- y: this.data.getColumn(e.value).every((r) => r === null || !(Number(r) < 0))
99
- }, k = s.map((r) => r.columnName), x = X(this.data, g, t, e, p, d, s, o.xAxis, o.yAxis, l.find((r) => r.type === "dots")), f = Object.keys(x);
100
- if (f.length > R) {
101
- const r = {
102
- type: "tooManyFacets",
103
- info: { count: f.length, maxCount: R }
104
- };
105
- throw Error(r.type, { cause: r });
106
- }
107
- const K = H(this.data, x, f, b, k, n), E = B(this.data, o.xAxis, t), _ = B(this.data, o.yAxis, e);
108
- if (E.keys.length > S) {
109
- const r = {
110
- type: "tooManyScatterplotGroupsX",
111
- info: { count: E.keys.length, maxCount: S }
112
- };
113
- throw Error(r.type, { cause: r });
114
- }
115
- if (_.keys.length > S) {
116
- const r = {
117
- type: "tooManyScatterplotGroupsY",
118
- info: { count: _.keys.length, maxCount: S }
119
- };
120
- throw Error(r.type, { cause: r });
100
+ var K;
101
+ const { x: t, y: e, facetBy: a, grouping: s, dotSize: h, dotShape: u, trend: g, layers: p, label: m, highlight: c, chartSettings: r, facetSettings: d } = this.settings;
102
+ let n = N(
103
+ a.map((o) => rt(this.data, o))
104
+ );
105
+ if (n.length === 0 && (n = [[q]]), (K = d == null ? void 0 : d.order) != null && K.length) {
106
+ const o = n.map(E);
107
+ n = G.intersection(d.order, o).map((b) => n.find((P) => E(P) === b)).filter((b) => b != null);
121
108
  }
122
- const T = [...s, ...h, ...u], O = Y(this.data, T, l), U = z(this.data, l, f, x, b, k, o.xAxis, E), G = J(this.data, a, f, g);
109
+ const D = a.length ? a.map((o) => o.value) : [null], A = a.length ? D.map((o, R) => [...new Set(n.map((b) => b[R]))]) : [void 0];
110
+ this.data.setGrouping(D, A);
111
+ const y = {
112
+ x: this.data.getColumn(t.value).every((o) => o === null || !(Number(o) < 0)),
113
+ y: this.data.getColumn(e.value).every((o) => o === null || !(Number(o) < 0))
114
+ }, _ = s.map((o) => o.columnName), S = Q(this.data, n, t, e, m, c, s, r.xAxis, r.yAxis, p.find((o) => o.type === "dots")), x = n.map(E), L = s.map(({ columnName: o }) => this.data.getColumnCategories(o.value, !1)).filter((o) => o.length > 0), k = L.length ? N(L) : [["null"]], F = Z(this.data, S, x, k, _, g), w = O(this.data, r.xAxis, t), T = O(this.data, r.yAxis, e), U = [...s, ...h, ...u], V = $(this.data, U, p), j = W(this.data, p, x, S, k, _, r.xAxis, w), v = et(this.data, a, x, n);
123
115
  this.calculatedData = {
124
- onlyPositive: N,
125
- dotsByFacets: x,
126
- facetKeys: f,
127
- facetKeysCombinations: g,
128
- facetLabels: G,
129
- trendsData: K,
130
- legendLabels: O,
131
- layersData: U,
132
- discreteAxisDataX: E,
133
- discreteAxisDataY: _
116
+ onlyPositive: y,
117
+ dotsByFacets: S,
118
+ facetKeys: x,
119
+ facetLabels: v,
120
+ trendsData: F,
121
+ legendLabels: V,
122
+ layersData: j,
123
+ discreteAxisDataX: w,
124
+ discreteAxisDataY: T
134
125
  };
135
126
  }
136
127
  _updateAesInData() {
137
128
  const t = this.calculatedData;
138
129
  if (!t)
139
130
  return;
140
- const { grouping: e, trend: a, layers: s, dotSize: h, dotShape: u } = this.settings, { facetKeys: n, trendsData: l } = t;
141
- n.forEach((d) => {
142
- for (let o = 0; o < s.length; o++)
143
- t.layersData[d][o].info = s[o];
144
- }), [...e, ...h, ...u].forEach(({ columnName: d, inheritedAes: o }) => {
145
- const y = /* @__PURE__ */ new Set(), D = {};
146
- s.forEach((g) => {
147
- g.aes && Object.entries(g.aes).forEach(([b, m]) => {
148
- Q(m) && m.value === d.value && (y.add(b), m.palette && (D[b] = m.palette));
131
+ const { grouping: e, trend: a, layers: s, dotSize: h, dotShape: u } = this.settings, { facetKeys: g, trendsData: p } = t;
132
+ g.forEach((c) => {
133
+ for (let r = 0; r < s.length; r++)
134
+ t.layersData[c][r].info = s[r];
135
+ }), [...e, ...h, ...u].forEach(({ columnName: c, inheritedAes: r }) => {
136
+ const d = /* @__PURE__ */ new Set(), n = {};
137
+ s.forEach((D) => {
138
+ D.aes && Object.entries(D.aes).forEach(([A, y]) => {
139
+ at(y) && y.value === c.value && (d.add(A), y.palette && (n[A] = y.palette));
149
140
  });
150
- }), t.legendLabels[d.value].usedAes = [...y], t.legendLabels[d.value].aesMap = q(
151
- d,
152
- D,
153
- o
141
+ }), t.legendLabels[c.value].usedAes = [...d], t.legendLabels[c.value].aesMap = tt(
142
+ c,
143
+ n,
144
+ r
154
145
  );
155
- }), l && a && Object.keys(l).forEach((d) => {
156
- l[d].forEach((o) => {
157
- o.color = a.color, o.bounded = a.bounded;
146
+ }), p && a && Object.keys(p).forEach((c) => {
147
+ p[c].forEach((r) => {
148
+ r.color = a.color, r.bounded = a.bounded;
158
149
  });
159
150
  });
160
151
  }
161
152
  _updateChart() {
162
153
  if (!this.calculatedData)
163
154
  return;
164
- const { facetLabels: t } = this.calculatedData, { id: e, chartSettings: a, facetSettings: s, grouping: h, dotSize: u, dotShape: n, keyColumn: l, layers: p, trend: d } = this.settings;
155
+ const { facetLabels: t } = this.calculatedData, { id: e, chartSettings: a, facetSettings: s, grouping: h, dotSize: u, dotShape: g, keyColumn: p, layers: m, trend: c } = this.settings;
165
156
  this.chartRenderer.render(
166
157
  this.data,
167
158
  e,
168
159
  a,
169
160
  s,
170
161
  this.calculatedData.facetKeys,
171
- this.calculatedData.facetKeys.map((o) => t[o]),
162
+ this.calculatedData.facetKeys.map((r) => t[r]),
172
163
  //for titles, if facet by more than 1 column
173
164
  this.calculatedData.dotsByFacets,
174
165
  this.calculatedData.trendsData,
175
- l,
166
+ p,
176
167
  this.calculatedData.onlyPositive,
177
168
  this.calculatedData.legendLabels,
178
169
  this.calculatedData.layersData,
179
- [...h.map((o) => o.columnName), ...u.map((o) => o.columnName), ...n.map((o) => o.columnName)],
180
- p,
181
- d,
170
+ [...h.map((r) => r.columnName), ...u.map((r) => r.columnName), ...g.map((r) => r.columnName)],
171
+ m,
172
+ c,
182
173
  this.calculatedData.discreteAxisDataX,
183
174
  this.calculatedData.discreteAxisDataY,
184
175
  this.onTooltipHintSwitch
@@ -186,6 +177,6 @@ class yt extends v {
186
177
  }
187
178
  }
188
179
  export {
189
- yt as ChartScatterplot
180
+ Lt as ChartScatterplot
190
181
  };
191
182
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/scatterplot/index.ts"],"sourcesContent":["import { renderToString } from 'react-dom/server.browser';\nimport { AbstractChart } from '../AbstractChart';\nimport type { DataFrame } from '../DataFrame';\nimport type {\n ErrorInfoScatterplotGroupsX,\n ErrorInfoScatterplotGroupsY} from '../types';\nimport {\n type AesItem,\n type AxisSettings,\n type AxisSettingsDiscrete,\n type Category,\n type ColumnName,\n type ContinuousAesFromColumn,\n type ErrorInfoFacets,\n getUnknownErrorInfo,\n type InheritAesScatterplot,\n isErrorInfo,\n type ScatterplotEventHandlers,\n type ScatterplotLegendInfo,\n type ScatterplotSettings,\n} from '../types';\nimport { arraysAreDifferent } from '../utils/arraysAreDifferent';\nimport { getKeysCombinations } from '../utils/getKeysCombination';\nimport ChartRenderer from './ChartRenderer';\nimport type { GroupedDots } from './dots';\nimport { getDots } from './dots';\nimport type { ScatterplotLayerData } from './getLayersData';\nimport { getLayersData } from './getLayersData';\nimport type { TrendsData } from './linearRegression';\nimport { getRegressionData } from './linearRegression';\nimport { ScatterplotSettingsImpl } from './ScatterplotSettingsImpl';\nimport { addPalettesToAesMapping, createLegendInfo } from './utils/createLegendInfo';\nimport type { DiscreteAxisData } from './components/types';\nimport { MAX_FACETS_COUNT, MAX_GROUPS_COUNT } from '../constants';\nimport { getFacetLabels } from '../discrete/utils/getFacetLabels';\n\nfunction isInheritMapping<T extends (string | number)>(value:T | InheritAesScatterplot | ContinuousAesFromColumn<T>):value is InheritAesScatterplot {\n return typeof value === 'object' && 'type' in value && value.type === 'grouping';\n}\n\nfunction getDiscreteAxisData(data: DataFrame, axis: AxisSettings, column: ColumnName): DiscreteAxisData {\n if (axis.scale === 'discrete') {\n const keys = axis.keys ? axis.keys : data.getColumnCategories(column.value, false);\n return {keys, labels: keys.reduce((res, v) => {\n const labelsMap = axis.labels ?? {};\n const labelValue = labelsMap[v] ?? (column.valueLabels ? data.getColumnValue(column.valueLabels, data.getColumnCategoryRowIndex(column.value, v as Category)) : v);\n res[v] = String(labelValue);\n if (v === 'null') {\n res[v] = column.nullValueLabel ?? 'NA';\n }\n return res;\n }, {} as Record<string, string>)};\n }\n return {keys: [], labels: {}};\n}\n\nexport class ChartScatterplot extends AbstractChart {\n settings: ScatterplotSettingsImpl;\n chartRenderer: ChartRenderer;\n\n onTooltipHintSwitch: (v:boolean) => void = () => undefined;\n calculatedData: {\n onlyPositive: {x: boolean; y: boolean};\n dotsByFacets: GroupedDots;\n facetKeys: string[];\n facetKeysCombinations: string[][];\n facetLabels: Record<string, string[]>;\n trendsData: TrendsData | null;\n legendLabels: ScatterplotLegendInfo;\n layersData: Record<string, ScatterplotLayerData[]>;\n discreteAxisDataX: DiscreteAxisData;\n discreteAxisDataY: DiscreteAxisData;\n } | null = null;\n\n constructor(data: DataFrame, settings: ScatterplotSettings, eventHandlers?:ScatterplotEventHandlers) {\n super(data, settings);\n\n this.chartRenderer = new ChartRenderer();\n this.settings = new ScatterplotSettingsImpl(settings);\n if (eventHandlers) {\n this.onTooltipHintSwitch = eventHandlers.onTooltipHintSwitch;\n }\n }\n\n mount(node: HTMLElement) {\n try {\n this.chartRenderer.init(node);\n this._updateData();\n this._updateChart();\n this.hasError = false;\n this.errorInfo = null;\n } catch (err) {\n this.hasError = true;\n if (err instanceof Error) {\n this.errorInfo = isErrorInfo(err.cause) ? err.cause : getUnknownErrorInfo(err);\n this.chartRenderer.renderError(err.message as string);\n console.error(err);\n }\n }\n }\n\n unmount() {\n this.chartRenderer.clear();\n }\n\n updateSettingsAndData(data: DataFrame, settings: ScatterplotSettings) {\n try {\n const previousSettings = this.settings;\n const previousData = this.data;\n this.settings = new ScatterplotSettingsImpl(settings);\n this.data = data;\n if (\n this._needUpdateCalculatedDataBySettings(previousSettings, this.settings) ||\n this._needUpdateCalculatedDataByData(previousData, this.data)\n ) {\n this._updateData();\n } else {\n this._updateAesInData();\n }\n this._updateChart();\n this.hasError = false;\n this.errorInfo = null;\n } catch (err) {\n this.hasError = true;\n console.error(err);\n if (err instanceof Error) {\n this.errorInfo = isErrorInfo(err.cause) ? err.cause : getUnknownErrorInfo(err);\n this.chartRenderer.renderError(err.message as string);\n console.error(err);\n }\n }\n }\n\n updateChartState(_field: string, _value: unknown) {\n console.warn('no chart state for scatterplot');\n }\n\n export(): string {\n this._updateChart();\n return renderToString(this.chartRenderer.component);\n }\n\n _needUpdateCalculatedDataBySettings(prevSettings: ScatterplotSettingsImpl, settings: ScatterplotSettingsImpl) {\n return (\n prevSettings.facetBy.some((el, idx) => el.value !== settings.facetBy[idx]?.value) ||\n prevSettings.grouping.length !== settings.grouping.length ||\n arraysAreDifferent(\n prevSettings.grouping.map(v => v.columnName.value),\n settings.grouping.map(v => v.columnName.value),\n ) ||\n arraysAreDifferent(\n prevSettings.grouping.map(v => v.columnName.nullValueLabel),\n settings.grouping.map(v => v.columnName.nullValueLabel),\n ) ||\n prevSettings.grouping.some((v, idx) => arraysAreDifferent(v.order, settings.grouping?.[idx].order)) ||\n arraysAreDifferent((prevSettings.chartSettings.xAxis as AxisSettingsDiscrete).keys, (settings.chartSettings.xAxis as AxisSettingsDiscrete).keys) ||\n arraysAreDifferent((prevSettings.chartSettings.yAxis as AxisSettingsDiscrete).keys, (settings.chartSettings.yAxis as AxisSettingsDiscrete).keys) ||\n (prevSettings.label?.value || settings.label?.value) && prevSettings.label?.value !== settings.label?.value ||\n prevSettings.layers.length !== settings.layers.length ||\n prevSettings.layers.some((l, idx) => l.type !== settings.layers[idx].type) ||\n Boolean(prevSettings.trend) !== Boolean(settings.trend)\n );\n }\n\n _needUpdateCalculatedDataByData(prevData: DataFrame, data: DataFrame) {\n const prevKeys = Object.keys(prevData.data);\n const keys = Object.keys(data.data);\n return (\n prevData.id !== data.id ||\n prevKeys.length !== keys.length ||\n prevKeys.some(key => prevData.data[key].length !== data.data[key]?.length)\n );\n }\n\n _updateData() {\n const {x, y, facetBy, grouping, dotSize, dotShape, trend, layers, label, highlight, chartSettings} = this.settings;\n const facetKeysLists = facetBy.map(column => this.data.getColumnCategories(column.value)).filter(v => v.length > 0);\n const categoryGroupingKeysLists = grouping.map(({columnName}) => this.data.getColumnCategories(columnName.value, false)).filter(v => v.length > 0);\n\n const facetKeysCombinations = facetKeysLists.length\n ? getKeysCombinations(facetKeysLists)\n : [['null']];\n const categoryGroupingCombinations = categoryGroupingKeysLists.length\n ? getKeysCombinations(categoryGroupingKeysLists)\n : [['null']];\n\n const facetGroupingValues = facetBy.map(column => column.value) ?? null;\n\n this.data.setGrouping([...facetGroupingValues]);\n const onlyPositive = {\n x: this.data.getColumn(x.value).every(v => {\n return v === null || !(Number(v) < 0);\n }),\n y: this.data.getColumn(y.value).every(v => {\n return v === null || !(Number(v) < 0);\n }),\n };\n\n const groupingColumns = grouping.map(v => v.columnName);\n\n const dotsByFacets = getDots(this.data, facetKeysCombinations, x, y, label, highlight, grouping, chartSettings.xAxis, chartSettings.yAxis, layers.find(l => l.type === 'dots'));\n const facetKeys = Object.keys(dotsByFacets);\n\n if (facetKeys.length > MAX_FACETS_COUNT) {\n const errorInfo: ErrorInfoFacets = {\n type: 'tooManyFacets',\n info: {count: facetKeys.length, maxCount: MAX_FACETS_COUNT}\n };\n throw Error(errorInfo.type, {cause: errorInfo});\n }\n\n const trendsData = getRegressionData(this.data, dotsByFacets, facetKeys, categoryGroupingCombinations, groupingColumns, trend);\n\n const discreteAxisDataX = getDiscreteAxisData(this.data, chartSettings.xAxis, x);\n const discreteAxisDataY = getDiscreteAxisData(this.data, chartSettings.yAxis, y);\n\n if (discreteAxisDataX.keys.length > MAX_GROUPS_COUNT) {\n const errorInfo: ErrorInfoScatterplotGroupsX = {\n type: 'tooManyScatterplotGroupsX',\n info: {count: discreteAxisDataX.keys.length, maxCount: MAX_GROUPS_COUNT}\n };\n throw Error(errorInfo.type, {cause: errorInfo});\n }\n if (discreteAxisDataY.keys.length > MAX_GROUPS_COUNT) {\n const errorInfo: ErrorInfoScatterplotGroupsY = {\n type: 'tooManyScatterplotGroupsY',\n info: {count: discreteAxisDataY.keys.length, maxCount: MAX_GROUPS_COUNT}\n };\n throw Error(errorInfo.type, {cause: errorInfo});\n }\n const allAesMappings = [...grouping, ...dotSize, ...dotShape];\n const legendLabels = createLegendInfo(this.data, allAesMappings, layers);\n const layersData = getLayersData(this.data, layers, facetKeys, dotsByFacets, categoryGroupingCombinations, groupingColumns, chartSettings.xAxis, discreteAxisDataX);\n const facetLabels = getFacetLabels(this.data, facetBy, facetKeys, facetKeysCombinations);\n\n this.calculatedData = {\n onlyPositive,\n dotsByFacets,\n facetKeys,\n facetKeysCombinations,\n facetLabels,\n trendsData,\n legendLabels,\n layersData,\n discreteAxisDataX,\n discreteAxisDataY\n };\n }\n\n _updateAesInData() {\n const calculated = this.calculatedData;\n if (!calculated) {\n return;\n }\n const {grouping, trend, layers, dotSize, dotShape} = this.settings;\n const {facetKeys, trendsData} = calculated;\n\n facetKeys.forEach(facetKey => {\n for (let i = 0; i < layers.length; i++) {\n calculated.layersData[facetKey][i].info = layers[i];\n }\n });\n\n const allAesMappings = [...grouping, ...dotSize, ...dotShape];\n\n allAesMappings.forEach(({columnName, inheritedAes}) => {\n const usedAes = new Set<keyof AesItem>();\n const usedAesFromPalettes: Partial<Record<keyof AesItem, string[]>> = {}; // if there is palette in mapping then\n layers.forEach(layer => {\n if (layer.aes) {\n Object.entries(layer.aes).forEach(([key, value]) => {\n if (isInheritMapping(value) && value.value === columnName.value) {\n usedAes.add(key as keyof AesItem);\n if (value.palette) {\n usedAesFromPalettes[key as keyof AesItem] = value.palette;\n }\n }\n });\n }\n });\n calculated.legendLabels[columnName.value].usedAes = [...usedAes];\n calculated.legendLabels[columnName.value].aesMap = addPalettesToAesMapping(\n columnName,\n usedAesFromPalettes,\n inheritedAes\n );\n });\n if (trendsData && trend) {\n Object.keys(trendsData).forEach((key) => {\n trendsData[key].forEach(trendInfo => {\n trendInfo.color = trend.color;\n trendInfo.bounded = trend.bounded;\n });\n });\n }\n }\n\n _updateChart() {\n if (!this.calculatedData) {\n return;\n }\n const {facetLabels} = this.calculatedData;\n const {id, chartSettings, facetSettings, grouping, dotSize, dotShape, keyColumn, layers, trend} = this.settings;\n\n this.chartRenderer.render(\n this.data,\n id,\n chartSettings,\n facetSettings,\n this.calculatedData.facetKeys,\n this.calculatedData.facetKeys.map(v => facetLabels[v]), //for titles, if facet by more than 1 column\n this.calculatedData.dotsByFacets,\n this.calculatedData.trendsData,\n keyColumn,\n this.calculatedData.onlyPositive,\n this.calculatedData.legendLabels,\n this.calculatedData.layersData,\n [...grouping.map(v => v.columnName), ...dotSize.map(v => v.columnName), ...dotShape.map(v => v.columnName)],\n layers,\n trend,\n this.calculatedData.discreteAxisDataX,\n this.calculatedData.discreteAxisDataY,\n this.onTooltipHintSwitch\n );\n }\n}\n"],"names":["isInheritMapping","value","getDiscreteAxisData","data","axis","column","keys","res","v","labelValue","ChartScatterplot","AbstractChart","settings","eventHandlers","__publicField","ChartRenderer","ScatterplotSettingsImpl","node","err","isErrorInfo","getUnknownErrorInfo","previousSettings","previousData","_field","_value","renderToString","prevSettings","el","idx","_a","arraysAreDifferent","_b","_c","_d","l","prevData","prevKeys","key","x","y","facetBy","grouping","dotSize","dotShape","trend","layers","label","highlight","chartSettings","facetKeysLists","categoryGroupingKeysLists","columnName","facetKeysCombinations","getKeysCombinations","categoryGroupingCombinations","facetGroupingValues","onlyPositive","groupingColumns","dotsByFacets","getDots","facetKeys","MAX_FACETS_COUNT","errorInfo","trendsData","getRegressionData","discreteAxisDataX","discreteAxisDataY","MAX_GROUPS_COUNT","allAesMappings","legendLabels","createLegendInfo","layersData","getLayersData","facetLabels","getFacetLabels","calculated","facetKey","i","inheritedAes","usedAes","usedAesFromPalettes","layer","addPalettesToAesMapping","trendInfo","id","facetSettings","keyColumn"],"mappings":";;;;;;;;;;;;;;;;;;;;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rC,MAAA0B,EAAW1B,CAAG,EAAE,QAAQ,CAAA8C,MAAa;AACjC,QAAAA,EAAU,QAAQvC,EAAM,OACxBuC,EAAU,UAAUvC,EAAM;AAAA,MAC9B,CAAC;AAAA,IACL,CAAC;AAAA,EAET;AAAA,EAEA,eAAe;AACX,QAAI,CAAC,KAAK;AACN;AAEJ,UAAM,EAAC,aAAA6B,MAAe,KAAK,gBACrB,EAAC,IAAAW,GAAI,eAAApC,GAAe,eAAAqC,GAAe,UAAA5C,GAAU,SAAAC,GAAS,UAAAC,GAAU,WAAA2C,GAAW,QAAAzC,GAAQ,OAAAD,EAAA,IAAS,KAAK;AAEvG,SAAK,cAAc;AAAA,MACf,KAAK;AAAA,MACLwC;AAAA,MACApC;AAAA,MACAqC;AAAA,MACA,KAAK,eAAe;AAAA,MACpB,KAAK,eAAe,UAAU,IAAI,CAAA7E,MAAKiE,EAAYjE,CAAC,CAAC;AAAA;AAAA,MACrD,KAAK,eAAe;AAAA,MACpB,KAAK,eAAe;AAAA,MACpB8E;AAAA,MACA,KAAK,eAAe;AAAA,MACpB,KAAK,eAAe;AAAA,MACpB,KAAK,eAAe;AAAA,MACpB,CAAC,GAAG7C,EAAS,IAAI,OAAKjC,EAAE,UAAU,GAAG,GAAGkC,EAAQ,IAAI,CAAAlC,MAAKA,EAAE,UAAU,GAAG,GAAGmC,EAAS,IAAI,CAAAnC,MAAKA,EAAE,UAAU,CAAC;AAAA,MAC1GqC;AAAA,MACAD;AAAA,MACA,KAAK,eAAe;AAAA,MACpB,KAAK,eAAe;AAAA,MACpB,KAAK;AAAA,IAAA;AAAA,EAEb;AACJ;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/scatterplot/index.ts"],"sourcesContent":["import { renderToString } from 'react-dom/server.browser';\nimport { AbstractChart } from '../AbstractChart';\nimport { type DataFrame, type GroupKey, NO_GROUPED } from '../DataFrame';\nimport type { DataValue} from '../types';\nimport {\n type AesItem,\n type AxisSettings,\n type AxisSettingsDiscrete,\n type Category,\n type ColumnName,\n type ContinuousAesFromColumn,\n getUnknownErrorInfo,\n type InheritAesScatterplot,\n isErrorInfo,\n type ScatterplotEventHandlers,\n type ScatterplotLegendInfo,\n type ScatterplotSettings,\n} from '../types';\nimport { intersection } from 'lodash';\nimport { arraysAreDifferent } from '../utils/arraysAreDifferent';\nimport { getKeysCombinations } from '../utils/getKeysCombination';\nimport ChartRenderer from './ChartRenderer';\nimport type { GroupedDots } from './dots';\nimport { getDots } from './dots';\nimport type { ScatterplotLayerData } from './getLayersData';\nimport { getLayersData } from './getLayersData';\nimport type { TrendsData } from './linearRegression';\nimport { getRegressionData } from './linearRegression';\nimport { ScatterplotSettingsImpl } from './ScatterplotSettingsImpl';\nimport { addPalettesToAesMapping, createLegendInfo } from './utils/createLegendInfo';\nimport type { DiscreteAxisData } from './components/types';\nimport { getFacetLabels } from '../discrete/utils/getFacetLabels';\nimport { getFacetStringKey } from '../discrete/utils/getFacetStringKey';\n\nfunction isInheritMapping<T extends (string | number)>(value:T | InheritAesScatterplot | ContinuousAesFromColumn<T>):value is InheritAesScatterplot {\n return typeof value === 'object' && 'type' in value && value.type === 'grouping';\n}\n\nfunction getDiscreteAxisData(data: DataFrame, axis: AxisSettings, column: ColumnName): DiscreteAxisData {\n if (axis.scale === 'discrete') {\n const keys = axis.keys ? axis.keys : data.getColumnCategories(column.value, false);\n return {keys, labels: keys.reduce((res, v) => {\n const labelsMap = axis.labels ?? {};\n const labelValue = labelsMap[v] ?? (column.valueLabels ? data.getColumnValue(column.valueLabels, data.getColumnCategoryRowIndex(column.value, v as Category)) : v);\n res[v] = String(labelValue);\n if (v === 'null') {\n res[v] = column.nullValueLabel ?? 'NA';\n }\n return res;\n }, {} as Record<string, string>)};\n }\n return {keys: [], labels: {}};\n}\n\nfunction getGroupingKeys(data: DataFrame, column: ColumnName, order: DataValue[] | null = null) {\n const groupingColumn = column.value;\n const availableKeys = data.getColumnCategories(groupingColumn);\n return intersection(order ?? availableKeys, availableKeys).map(String);\n}\nexport class ChartScatterplot extends AbstractChart {\n settings: ScatterplotSettingsImpl;\n chartRenderer: ChartRenderer;\n\n onTooltipHintSwitch: (v:boolean) => void = () => undefined;\n calculatedData: {\n onlyPositive: {x: boolean; y: boolean};\n dotsByFacets: GroupedDots;\n facetKeys: string[];\n facetLabels: Record<string, string[]>;\n trendsData: TrendsData | null;\n legendLabels: ScatterplotLegendInfo;\n layersData: Record<string, ScatterplotLayerData[]>;\n discreteAxisDataX: DiscreteAxisData;\n discreteAxisDataY: DiscreteAxisData;\n } | null = null;\n\n constructor(data: DataFrame, settings: ScatterplotSettings, eventHandlers?:ScatterplotEventHandlers) {\n super(data, settings);\n\n this.chartRenderer = new ChartRenderer();\n this.settings = new ScatterplotSettingsImpl(settings);\n if (eventHandlers) {\n this.onTooltipHintSwitch = eventHandlers.onTooltipHintSwitch;\n }\n }\n\n mount(node: HTMLElement) {\n try {\n this.chartRenderer.init(node);\n this._updateData();\n this._updateChart();\n this.hasError = false;\n this.errorInfo = null;\n } catch (err) {\n this.hasError = true;\n if (err instanceof Error) {\n this.errorInfo = isErrorInfo(err.cause) ? err.cause : getUnknownErrorInfo(err);\n this.chartRenderer.renderError(err.message as string);\n console.error(err);\n }\n }\n }\n\n unmount() {\n this.chartRenderer.clear();\n }\n\n updateSettingsAndData(data: DataFrame, settings: ScatterplotSettings) {\n try {\n const previousSettings = this.settings;\n const previousData = this.data;\n this.settings = new ScatterplotSettingsImpl(settings);\n this.data = data;\n if (\n this._needUpdateCalculatedDataBySettings(previousSettings, this.settings) ||\n this._needUpdateCalculatedDataByData(previousData, this.data)\n ) {\n this._updateData();\n } else {\n this._updateAesInData();\n }\n this._updateChart();\n this.hasError = false;\n this.errorInfo = null;\n } catch (err) {\n this.hasError = true;\n console.error(err);\n if (err instanceof Error) {\n this.errorInfo = isErrorInfo(err.cause) ? err.cause : getUnknownErrorInfo(err);\n this.chartRenderer.renderError(err.message as string);\n console.error(err);\n }\n }\n }\n\n updateChartState(_field: string, _value: unknown) {\n console.warn('no chart state for scatterplot');\n }\n\n export(): string {\n this._updateChart();\n return renderToString(this.chartRenderer.component);\n }\n\n _needUpdateCalculatedDataBySettings(prevSettings: ScatterplotSettingsImpl, settings: ScatterplotSettingsImpl) {\n return (\n arraysAreDifferent(prevSettings.facetSettings?.order ?? [], settings.facetSettings?.order ?? []) ||\n prevSettings.facetBy.some((el, idx) => el.value !== settings.facetBy[idx]?.value) ||\n prevSettings.grouping.length !== settings.grouping.length ||\n arraysAreDifferent(\n prevSettings.grouping.map(v => v.columnName.value),\n settings.grouping.map(v => v.columnName.value),\n ) ||\n arraysAreDifferent(\n prevSettings.grouping.map(v => v.columnName.nullValueLabel),\n settings.grouping.map(v => v.columnName.nullValueLabel),\n ) ||\n prevSettings.grouping.some((v, idx) => arraysAreDifferent(v.order, settings.grouping?.[idx].order)) ||\n arraysAreDifferent(prevSettings.facetSettings?.order ?? [], settings.facetSettings?.order ?? []) ||\n arraysAreDifferent((prevSettings.chartSettings.xAxis as AxisSettingsDiscrete).keys, (settings.chartSettings.xAxis as AxisSettingsDiscrete).keys) ||\n arraysAreDifferent((prevSettings.chartSettings.yAxis as AxisSettingsDiscrete).keys, (settings.chartSettings.yAxis as AxisSettingsDiscrete).keys) ||\n (prevSettings.label?.value || settings.label?.value) && prevSettings.label?.value !== settings.label?.value ||\n prevSettings.layers.length !== settings.layers.length ||\n prevSettings.layers.some((l, idx) => l.type !== settings.layers[idx].type) ||\n Boolean(prevSettings.trend) !== Boolean(settings.trend)\n );\n }\n\n _needUpdateCalculatedDataByData(prevData: DataFrame, data: DataFrame) {\n const prevKeys = Object.keys(prevData.data);\n const keys = Object.keys(data.data);\n return (\n prevData.id !== data.id ||\n prevKeys.length !== keys.length ||\n prevKeys.some(key => prevData.data[key].length !== data.data[key]?.length)\n );\n }\n\n _updateData() {\n const {x, y, facetBy, grouping, dotSize, dotShape, trend, layers, label, highlight, chartSettings, facetSettings} = this.settings;\n let facetKeyLists: (GroupKey)[][] = getKeysCombinations(\n facetBy.map(column => getGroupingKeys(this.data, column))\n );\n if (facetKeyLists.length === 0) {\n facetKeyLists = [[NO_GROUPED]];\n }\n if (facetSettings?.order?.length) {\n const allFacetKeys = facetKeyLists.map(getFacetStringKey);\n const keyOrder = intersection(facetSettings.order, allFacetKeys);\n facetKeyLists = keyOrder\n .map((keyStr) => facetKeyLists.find((fkl) => getFacetStringKey(fkl) === keyStr))\n .filter((x): x is GroupKey[] => x != null);\n }\n const facetGroupingValues = facetBy.length ? facetBy.map(column => column.value) : [null];\n const facetGroupingKeys = facetBy.length\n ? facetGroupingValues.map((_, idx) => [...new Set(facetKeyLists.map(fkl => fkl[idx]))])\n : [undefined];\n this.data.setGrouping(facetGroupingValues, facetGroupingKeys);\n const onlyPositive = {\n x: this.data.getColumn(x.value).every(v => {\n return v === null || !(Number(v) < 0);\n }),\n y: this.data.getColumn(y.value).every(v => {\n return v === null || !(Number(v) < 0);\n }),\n };\n\n const groupingColumns = grouping.map(v => v.columnName);\n\n const dotsByFacets = getDots(this.data, facetKeyLists, x, y, label, highlight, grouping, chartSettings.xAxis, chartSettings.yAxis, layers.find(l => l.type === 'dots'));\n const facetKeys = facetKeyLists.map(getFacetStringKey);\n\n // not for data groupig, for curves, trends, colors\n const categoryGroupingKeysLists = grouping.map(({columnName}) => this.data.getColumnCategories(columnName.value, false)).filter(v => v.length > 0);\n const categoryGroupingCombinations = categoryGroupingKeysLists.length\n ? getKeysCombinations(categoryGroupingKeysLists)\n : [['null']];\n const trendsData = getRegressionData(this.data, dotsByFacets, facetKeys, categoryGroupingCombinations, groupingColumns, trend);\n\n const discreteAxisDataX = getDiscreteAxisData(this.data, chartSettings.xAxis, x);\n const discreteAxisDataY = getDiscreteAxisData(this.data, chartSettings.yAxis, y);\n\n const allAesMappings = [...grouping, ...dotSize, ...dotShape];\n const legendLabels = createLegendInfo(this.data, allAesMappings, layers);\n const layersData = getLayersData(this.data, layers, facetKeys, dotsByFacets, categoryGroupingCombinations, groupingColumns, chartSettings.xAxis, discreteAxisDataX);\n const facetLabels = getFacetLabels(this.data, facetBy, facetKeys, facetKeyLists);\n\n this.calculatedData = {\n onlyPositive,\n dotsByFacets,\n facetKeys,\n facetLabels,\n trendsData,\n legendLabels,\n layersData,\n discreteAxisDataX,\n discreteAxisDataY\n };\n }\n\n _updateAesInData() {\n const calculated = this.calculatedData;\n if (!calculated) {\n return;\n }\n const {grouping, trend, layers, dotSize, dotShape} = this.settings;\n const {facetKeys, trendsData} = calculated;\n\n facetKeys.forEach(facetKey => {\n for (let i = 0; i < layers.length; i++) {\n calculated.layersData[facetKey][i].info = layers[i];\n }\n });\n\n const allAesMappings = [...grouping, ...dotSize, ...dotShape];\n\n allAesMappings.forEach(({columnName, inheritedAes}) => {\n const usedAes = new Set<keyof AesItem>();\n const usedAesFromPalettes: Partial<Record<keyof AesItem, string[]>> = {}; // if there is palette in mapping then\n layers.forEach(layer => {\n if (layer.aes) {\n Object.entries(layer.aes).forEach(([key, value]) => {\n if (isInheritMapping(value) && value.value === columnName.value) {\n usedAes.add(key as keyof AesItem);\n if (value.palette) {\n usedAesFromPalettes[key as keyof AesItem] = value.palette;\n }\n }\n });\n }\n });\n calculated.legendLabels[columnName.value].usedAes = [...usedAes];\n calculated.legendLabels[columnName.value].aesMap = addPalettesToAesMapping(\n columnName,\n usedAesFromPalettes,\n inheritedAes\n );\n });\n if (trendsData && trend) {\n Object.keys(trendsData).forEach((key) => {\n trendsData[key].forEach(trendInfo => {\n trendInfo.color = trend.color;\n trendInfo.bounded = trend.bounded;\n });\n });\n }\n }\n\n _updateChart() {\n if (!this.calculatedData) {\n return;\n }\n const {facetLabels} = this.calculatedData;\n const {id, chartSettings, facetSettings, grouping, dotSize, dotShape, keyColumn, layers, trend} = this.settings;\n\n this.chartRenderer.render(\n this.data,\n id,\n chartSettings,\n facetSettings,\n this.calculatedData.facetKeys,\n this.calculatedData.facetKeys.map(v => facetLabels[v]), //for titles, if facet by more than 1 column\n this.calculatedData.dotsByFacets,\n this.calculatedData.trendsData,\n keyColumn,\n this.calculatedData.onlyPositive,\n this.calculatedData.legendLabels,\n this.calculatedData.layersData,\n [...grouping.map(v => v.columnName), ...dotSize.map(v => v.columnName), ...dotShape.map(v => v.columnName)],\n layers,\n trend,\n this.calculatedData.discreteAxisDataX,\n this.calculatedData.discreteAxisDataY,\n this.onTooltipHintSwitch\n );\n }\n}\n"],"names":["isInheritMapping","value","getDiscreteAxisData","data","axis","column","keys","res","v","labelValue","getGroupingKeys","order","groupingColumn","availableKeys","intersection","ChartScatterplot","AbstractChart","settings","eventHandlers","__publicField","ChartRenderer","ScatterplotSettingsImpl","node","err","isErrorInfo","getUnknownErrorInfo","previousSettings","previousData","_field","_value","renderToString","prevSettings","arraysAreDifferent","_a","_b","el","idx","_c","_d","_e","_f","_g","_h","l","prevData","prevKeys","key","x","y","facetBy","grouping","dotSize","dotShape","trend","layers","label","highlight","chartSettings","facetSettings","facetKeyLists","getKeysCombinations","NO_GROUPED","allFacetKeys","getFacetStringKey","keyStr","fkl","facetGroupingValues","facetGroupingKeys","_","onlyPositive","groupingColumns","dotsByFacets","getDots","facetKeys","categoryGroupingKeysLists","columnName","categoryGroupingCombinations","trendsData","getRegressionData","discreteAxisDataX","discreteAxisDataY","allAesMappings","legendLabels","createLegendInfo","layersData","getLayersData","facetLabels","getFacetLabels","calculated","facetKey","i","inheritedAes","usedAes","usedAesFromPalettes","layer","addPalettesToAesMapping","trendInfo","id","keyColumn"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAkCA,SAASA,GAA8CC,GAA6F;AAChJ,SAAO,OAAOA,KAAU,YAAY,UAAUA,KAASA,EAAM,SAAS;AAC1E;AAEA,SAASC,EAAoBC,GAAiBC,GAAoBC,GAAsC;AACpG,MAAID,EAAK,UAAU,YAAY;AAC3B,UAAME,IAAOF,EAAK,OAAOA,EAAK,OAAOD,EAAK,oBAAoBE,EAAO,OAAO,EAAK;AACjF,WAAO,EAAC,MAAAC,GAAM,QAAQA,EAAK,OAAO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,EAChB,qBAAqB,EACxB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAyB1E,wBAAgB,uBAAuB,CACnC,UAAU,EAAE,UAAU,EACtB,mBAAmB,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC,EAC7D,YAAY,CAAC,EAAE,SAAS,cAQO,QAAQ,SAAS,MAAM,OAAO,iCAchE;AAKD,wBAAgB,gBAAgB,CAC5B,IAAI,EAAE,SAAS,EACf,QAAQ,EAAE,uBAAuB,CAAC,UAAU,CAAC,EAC7C,MAAM,EAAE,gBAAgB,EAAE,GAC3B,qBAAqB,CA2DvB"}
1
+ {"version":3,"file":"createLegendInfo.d.ts","sourceRoot":"","sources":["../../../src/scatterplot/utils/createLegendInfo.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,EACR,OAAO,EACP,QAAQ,EACR,UAAU,EAGV,gBAAgB,EAChB,qBAAqB,EACxB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAyB1E,wBAAgB,uBAAuB,CACnC,UAAU,EAAE,UAAU,EACtB,mBAAmB,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC,EAC7D,YAAY,CAAC,EAAE,SAAS,cAQO,QAAQ,SAAS,MAAM,OAAO,iCAahE;AAKD,wBAAgB,gBAAgB,CAC5B,IAAI,EAAE,SAAS,EACf,QAAQ,EAAE,uBAAuB,CAAC,UAAU,CAAC,EAC7C,MAAM,EAAE,gBAAgB,EAAE,GAC3B,qBAAqB,CA2DvB"}
@@ -17,7 +17,7 @@ function v(n, h, d) {
17
17
  return (i, g) => {
18
18
  var f;
19
19
  const u = a ? (f = d[i]) == null ? void 0 : f[g] : void 0;
20
- return g === "dotFill" && e ? o[I.getIndex(n, i) % o.length] ?? u : g === "lineColor" && p ? r[I.getIndex(n, i) % r.length] ?? u : u;
20
+ return g === "dotFill" && e ? u ?? o[I.getIndex(n, i) % o.length] : g === "lineColor" && p ? u ?? r[I.getIndex(n, i) % r.length] : u;
21
21
  };
22
22
  }
23
23
  function A(n) {
@@ -1 +1 @@
1
- {"version":3,"file":"createLegendInfo.js","sources":["../../../src/scatterplot/utils/createLegendInfo.ts"],"sourcesContent":["import { MAX_SHOWN_UNIQUE_VALUES_IN_LABELS } from '../../constants';\nimport type { DataFrame } from '../../DataFrame';\nimport type {AesRecord} from '../../types';\nimport type {\n AesItem,\n Category,\n ColumnName,\n ContinuousAesFromColumn,\n InheritAesScatterplot,\n ScatterplotLayer,\n ScatterplotLegendInfo\n} from '../../types';\nimport type { ScatterplotSettingsImpl } from '../ScatterplotSettingsImpl';\n\nconst categoryIndexer = (() => {\n const map = new Map<string, Map<Category, number>>();\n const clear = () => map.clear();\n const getIndex = (columnName: ColumnName, category: Category): number => {\n let categoryMap = map.get(columnName.value);\n if (categoryMap === undefined) {\n categoryMap = new Map();\n map.set(columnName.value, categoryMap);\n }\n let index = categoryMap.get(category);\n if (index === undefined) {\n index = categoryMap.size;\n categoryMap.set(category, index);\n }\n return index;\n };\n\n return {\n clear,\n getIndex,\n };\n})();\n\nexport function addPalettesToAesMapping(\n columnName: ColumnName,\n usedAesFromPalettes: Partial<Record<keyof AesItem, string[]>>,\n inheritedAes?: AesRecord\n) {\n categoryIndexer.clear();\n const hasInheritedAes = inheritedAes && Object.keys(inheritedAes).length > 0;\n const dotFill = usedAesFromPalettes['dotFill'];\n const hasDotFill = dotFill && dotFill.length > 0;\n const lineColor = usedAesFromPalettes['lineColor'];\n const hasLineColor = lineColor && lineColor.length > 0;\n const getAesField = (category: Category, field: keyof AesItem) => {\n const inheritedResult = hasInheritedAes ? inheritedAes[category]?.[field] : undefined;\n \n if (field === 'dotFill' && hasDotFill) {\n return dotFill[categoryIndexer.getIndex(columnName, category) % dotFill.length] ?? inheritedResult;\n }\n if (field === 'lineColor' && hasLineColor) {\n return lineColor[categoryIndexer.getIndex(columnName, category) % lineColor.length] ?? inheritedResult;\n }\n \n return inheritedResult;\n };\n\n return getAesField;\n}\n\nfunction isInheritMapping<T extends (string | number)>(value:T | InheritAesScatterplot | ContinuousAesFromColumn<T>):value is InheritAesScatterplot {\n return typeof value === 'object' && 'type' in value && value.type === 'grouping';\n}\nexport function createLegendInfo(\n data: DataFrame,\n grouping: ScatterplotSettingsImpl['grouping'],\n layers: ScatterplotLayer[],\n): ScatterplotLegendInfo {\n return grouping.reduce((res: ScatterplotLegendInfo, groupingElement) => {\n // TODO: remove String conversion\n const column = groupingElement.columnName;\n const nullValueLabel = column.nullValueLabel ?? 'NA';\n const order = groupingElement.order;\n const getValueLabel = (index: number) => {\n return column.valueLabels\n ? data.getColumnValueCategory(column.valueLabels, index)\n : undefined;\n };\n\n const usedAes = new Set<keyof AesItem>();\n const usedAesFromPalettes:Partial<Record<keyof AesItem, string[]>> = {}; // if there is palette in mapping then\n layers.forEach(layer => {\n if (!layer.aes) return;\n \n Object.entries(layer.aes).forEach(([key, value]) => {\n if (!(isInheritMapping(value) && value.value === column.value)) return;\n \n usedAes.add(key as keyof AesItem);\n usedAesFromPalettes[key as keyof AesItem] = value.palette;\n });\n });\n let labels: Record<Category, string> = {};\n let values: Category[] = [];\n if (usedAes.has('dotFill') || usedAes.has('dotShape') || usedAes.has('lineColor')) {\n const categories = data.getColumnCategories(column.value, false);\n if (categories.length < MAX_SHOWN_UNIQUE_VALUES_IN_LABELS) {\n labels = categories.reduce((res, category) => {\n const index = data.getColumnCategoryRowIndex(column.value, category);\n res[category] = getValueLabel(index) ?? category;\n if (res[category] === 'null') {\n res[category] = nullValueLabel;\n }\n return res;\n }, labels);\n const sortWeights = categories.reduce((res, v) => {\n res[v] = order?.indexOf(v) ?? -1;\n return res;\n }, {} as Record<string, number>);\n values = categories.sort((a, b) => {\n if (sortWeights[a] !== sortWeights[b]) {\n return sortWeights[a] - sortWeights[b];\n }\n return labels[a]?.localeCompare(labels[b] ?? '', 'en', {numeric: true}) ?? 0;\n });\n } else {\n values = categories;\n }\n }\n res[column.value] = {\n values,\n usedAes: [...usedAes],\n aesMap: addPalettesToAesMapping(column, usedAesFromPalettes, groupingElement.inheritedAes),\n labels,\n };\n return res;\n }, {});\n}"],"names":["categoryIndexer","map","columnName","category","categoryMap","index","addPalettesToAesMapping","usedAesFromPalettes","inheritedAes","hasInheritedAes","dotFill","hasDotFill","lineColor","hasLineColor","field","inheritedResult","_a","isInheritMapping","value","createLegendInfo","data","grouping","layers","res","groupingElement","column","nullValueLabel","order","getValueLabel","usedAes","layer","key","labels","values","categories","MAX_SHOWN_UNIQUE_VALUES_IN_LABELS","sortWeights","v","a","b"],"mappings":";AAcA,MAAMA,IAAmB,uBAAM;AAC3B,QAAMC,wBAAU,IAAA;AAgBhB,SAAO;AAAA,IACH,OAhBU,MAAMA,EAAI,MAAA;AAAA,IAiBpB,UAhBa,CAACC,GAAwBC,MAA+B;AACrE,UAAIC,IAAcH,EAAI,IAAIC,EAAW,KAAK;AAC1C,MAAIE,MAAgB,WAChBA,wBAAkB,IAAA,GAClBH,EAAI,IAAIC,EAAW,OAAOE,CAAW;AAEzC,UAAIC,IAAQD,EAAY,IAAID,CAAQ;AACpC,aAAIE,MAAU,WACVA,IAAQD,EAAY,MACpBA,EAAY,IAAID,GAAUE,CAAK,IAE5BA;AAAA,IACX;AAAA,EAII;AAER,GAAA;AAEO,SAASC,EACZJ,GACAK,GACAC,GACF;AACE,EAAAR,EAAgB,MAAA;AAChB,QAAMS,IAAkBD,KAAgB,OAAO,KAAKA,CAAY,EAAE,SAAS,GACrEE,IAAUH,EAAoB,SAC9BI,IAAaD,KAAWA,EAAQ,SAAS,GACzCE,IAAYL,EAAoB,WAChCM,IAAeD,KAAaA,E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C,GAAmC;AACvD,QAAAH,IAASE,EAAW,OAAO,CAACX,GAAKpB,MAAa;AAC1C,gBAAME,IAAQe,EAAK,0BAA0BK,EAAO,OAAOtB,CAAQ;AACnEoB,iBAAAA,EAAIpB,CAAQ,IAAIyB,EAAcvB,CAAK,KAAKF,GACpCoB,EAAIpB,CAAQ,MAAM,WAClBoB,EAAIpB,CAAQ,IAAIuB,IAEbH;AAAAA,QACX,GAAGS,CAAM;AACT,cAAMI,IAAcF,EAAW,OAAO,CAACX,GAAKc,OACxCd,EAAIc,CAAC,KAAIV,KAAA,gBAAAA,EAAO,QAAQU,OAAM,IACvBd,IACR,CAAA,CAA4B;AAC/B,QAAAU,IAASC,EAAW,KAAK,CAACI,GAAGC,MAAM;;AAC/B,iBAAIH,EAAYE,CAAC,MAAMF,EAAYG,CAAC,IACzBH,EAAYE,CAAC,IAAIF,EAAYG,CAAC,MAElCvB,IAAAgB,EAAOM,CAAC,MAAR,gBAAAtB,EAAW,cAAcgB,EAAOO,CAAC,KAAK,IAAI,MAAM,EAAC,SAAS,GAAA,OAAU;AAAA,QAC/E,CAAC;AAAA,MACL;AACI,QAAAN,IAASC;AAAA,IAEjB;AACA,WAAAX,EAAIE,EAAO,KAAK,IAAI;AAAA,MAChB,QAAAQ;AAAA,MACA,SAAS,CAAC,GAAGJ,CAAO;AAAA,MACpB,QAAQvB,EAAwBmB,GAAQlB,GAAqBiB,EAAgB,YAAY;AAAA,MACzF,QAAAQ;AAAA,IAAA,GAEGT;AAAA,EACX,GAAG,CAAA,CAAE;AACT;"}
1
+ {"version":3,"file":"createLegendInfo.js","sources":["../../../src/scatterplot/utils/createLegendInfo.ts"],"sourcesContent":["import { MAX_SHOWN_UNIQUE_VALUES_IN_LABELS } from '../../constants';\nimport type { DataFrame } from '../../DataFrame';\nimport type {AesRecord} from '../../types';\nimport type {\n AesItem,\n Category,\n ColumnName,\n ContinuousAesFromColumn,\n InheritAesScatterplot,\n ScatterplotLayer,\n ScatterplotLegendInfo\n} from '../../types';\nimport type { ScatterplotSettingsImpl } from '../ScatterplotSettingsImpl';\n\nconst categoryIndexer = (() => {\n const map = new Map<string, Map<Category, number>>();\n const clear = () => map.clear();\n const getIndex = (columnName: ColumnName, category: Category): number => {\n let categoryMap = map.get(columnName.value);\n if (categoryMap === undefined) {\n categoryMap = new Map();\n map.set(columnName.value, categoryMap);\n }\n let index = categoryMap.get(category);\n if (index === undefined) {\n index = categoryMap.size;\n categoryMap.set(category, index);\n }\n return index;\n };\n\n return {\n clear,\n getIndex,\n };\n})();\n\nexport function addPalettesToAesMapping(\n columnName: ColumnName,\n usedAesFromPalettes: Partial<Record<keyof AesItem, string[]>>,\n inheritedAes?: AesRecord\n) {\n categoryIndexer.clear();\n const hasInheritedAes = inheritedAes && Object.keys(inheritedAes).length > 0;\n const dotFill = usedAesFromPalettes['dotFill'];\n const hasDotFill = dotFill && dotFill.length > 0;\n const lineColor = usedAesFromPalettes['lineColor'];\n const hasLineColor = lineColor && lineColor.length > 0;\n const getAesField = (category: Category, field: keyof AesItem) => {\n const inheritedResult = hasInheritedAes ? inheritedAes[category]?.[field] : undefined;\n // Use inherited when defined; otherwise generate from palette so overflow categories get a color\n if (field === 'dotFill' && hasDotFill) {\n return inheritedResult ?? dotFill[categoryIndexer.getIndex(columnName, category) % dotFill.length];\n }\n if (field === 'lineColor' && hasLineColor) {\n return inheritedResult ?? lineColor[categoryIndexer.getIndex(columnName, category) % lineColor.length];\n }\n return inheritedResult;\n };\n\n return getAesField;\n}\n\nfunction isInheritMapping<T extends (string | number)>(value:T | InheritAesScatterplot | ContinuousAesFromColumn<T>):value is InheritAesScatterplot {\n return typeof value === 'object' && 'type' in value && value.type === 'grouping';\n}\nexport function createLegendInfo(\n data: DataFrame,\n grouping: ScatterplotSettingsImpl['grouping'],\n layers: ScatterplotLayer[],\n): ScatterplotLegendInfo {\n return grouping.reduce((res: ScatterplotLegendInfo, groupingElement) => {\n // TODO: remove String conversion\n const column = groupingElement.columnName;\n const nullValueLabel = column.nullValueLabel ?? 'NA';\n const order = groupingElement.order;\n const getValueLabel = (index: number) => {\n return column.valueLabels\n ? data.getColumnValueCategory(column.valueLabels, index)\n : undefined;\n };\n\n const usedAes = new Set<keyof AesItem>();\n const usedAesFromPalettes:Partial<Record<keyof AesItem, string[]>> = {}; // if there is palette in mapping then\n layers.forEach(layer => {\n if (!layer.aes) return;\n \n Object.entries(layer.aes).forEach(([key, value]) => {\n if (!(isInheritMapping(value) && value.value === column.value)) return;\n \n usedAes.add(key as keyof AesItem);\n usedAesFromPalettes[key as keyof AesItem] = value.palette;\n });\n });\n let labels: Record<Category, string> = {};\n let values: Category[] = [];\n if (usedAes.has('dotFill') || usedAes.has('dotShape') || usedAes.has('lineColor')) {\n const categories = data.getColumnCategories(column.value, false);\n if (categories.length < MAX_SHOWN_UNIQUE_VALUES_IN_LABELS) {\n labels = categories.reduce((res, category) => {\n const index = data.getColumnCategoryRowIndex(column.value, category);\n res[category] = getValueLabel(index) ?? category;\n if (res[category] === 'null') {\n res[category] = nullValueLabel;\n }\n return res;\n }, labels);\n const sortWeights = categories.reduce((res, v) => {\n res[v] = order?.indexOf(v) ?? -1;\n return res;\n }, {} as Record<string, number>);\n values = categories.sort((a, b) => {\n if (sortWeights[a] !== sortWeights[b]) {\n return sortWeights[a] - sortWeights[b];\n }\n return labels[a]?.localeCompare(labels[b] ?? '', 'en', {numeric: true}) ?? 0;\n });\n } else {\n values = categories;\n }\n }\n res[column.value] = {\n values,\n usedAes: [...usedAes],\n aesMap: addPalettesToAesMapping(column, usedAesFromPalettes, groupingElement.inheritedAes),\n labels,\n };\n return res;\n }, {});\n}"],"names":["categoryIndexer","map","columnName","category","categoryMap","index","addPalettesToAesMapping","usedAesFromPalettes","inheritedAes","hasInheritedAes","dotFill","hasDotFill","lineColor","hasLineColor","field","inheritedResult","_a","isInheritMapping","value","createLegendInfo","data","grouping","layers","res","groupingElement","column","nullValueLabel","order","getValueLabel","usedAes","layer","key","labels","values","categories","MAX_SHOWN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AAC,IAAIF,EAAYG,CAAC,MAElCvB,IAAAgB,EAAOM,CAAC,MAAR,gBAAAtB,EAAW,cAAcgB,EAAOO,CAAC,KAAK,IAAI,MAAM,EAAC,SAAS,GAAA,OAAU;AAAA,QAC/E,CAAC;AAAA,MACL;AACI,QAAAN,IAASC;AAAA,IAEjB;AACA,WAAAX,EAAIE,EAAO,KAAK,IAAI;AAAA,MAChB,QAAAQ;AAAA,MACA,SAAS,CAAC,GAAGJ,CAAO;AAAA,MACpB,QAAQvB,EAAwBmB,GAAQlB,GAAqBiB,EAAgB,YAAY;AAAA,MACzF,QAAAQ;AAAA,IAAA,GAEGT;AAAA,EACX,GAAG,CAAA,CAAE;AACT;"}
@@ -47,10 +47,13 @@ export declare const BubblesSettingsSchema: z.ZodObject<{
47
47
  facetSettings: z.ZodOptional<z.ZodObject<{
48
48
  nRows: z.ZodOptional<z.ZodNumber>;
49
49
  nCols: z.ZodOptional<z.ZodNumber>;
50
+ order: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
50
51
  }, "strip", z.ZodTypeAny, {
52
+ order?: string[] | undefined;
51
53
  nRows?: number | undefined;
52
54
  nCols?: number | undefined;
53
55
  }, {
56
+ order?: string[] | undefined;
54
57
  nRows?: number | undefined;
55
58
  nCols?: number | undefined;
56
59
  }>>;
@@ -423,6 +426,7 @@ export declare const BubblesSettingsSchema: z.ZodObject<{
423
426
  type?: "left" | "bottom" | "left-bottom" | "full" | "empty" | undefined;
424
427
  } | undefined;
425
428
  facetSettings?: {
429
+ order?: string[] | undefined;
426
430
  nRows?: number | undefined;
427
431
  nCols?: number | undefined;
428
432
  } | undefined;
@@ -551,6 +555,7 @@ export declare const BubblesSettingsSchema: z.ZodObject<{
551
555
  type?: "left" | "bottom" | "left-bottom" | "full" | "empty" | undefined;
552
556
  } | undefined;
553
557
  facetSettings?: {
558
+ order?: string[] | undefined;
554
559
  nRows?: number | undefined;
555
560
  nCols?: number | undefined;
556
561
  } | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"bubble.d.ts","sourceRoot":"","sources":["../../src/types/bubble.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAYxB,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmEhC,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC"}
1
+ {"version":3,"file":"bubble.d.ts","sourceRoot":"","sources":["../../src/types/bubble.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAYxB,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoEhC,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC"}
@@ -1,7 +1,7 @@
1
- import { ColumnNameSchema as i, TooltipSettingsSchema as c, AggregationMethodSchema as y, FrameTypeSchema as g, LegendPositionSchema as u, TitlePositionSchema as h } from "./common.js";
2
- import { optional as e, union as p, literal as r, boolean as n, string as s, object as o, number as a, null as d, array as t, enum as l, record as T } from "../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.js";
1
+ import { ColumnNameSchema as s, TooltipSettingsSchema as c, AggregationMethodSchema as y, FrameTypeSchema as g, LegendPositionSchema as u, TitlePositionSchema as h } from "./common.js";
2
+ import { optional as e, union as p, literal as r, boolean as n, string as t, object as o, number as a, null as d, array as i, enum as l, record as T } from "../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.js";
3
3
  const m = {
4
- title: e(s()),
4
+ title: e(t()),
5
5
  showTicks: e(n()),
6
6
  showTitle: e(n()),
7
7
  showAxisLabels: e(n()),
@@ -9,7 +9,7 @@ const m = {
9
9
  }, x = o({
10
10
  type: r("bubble"),
11
11
  title: o({
12
- name: s(),
12
+ name: t(),
13
13
  show: e(n()),
14
14
  position: e(h)
15
15
  }),
@@ -30,24 +30,25 @@ const m = {
30
30
  facetSettings: e(
31
31
  o({
32
32
  nRows: e(a()),
33
- nCols: e(a())
33
+ nCols: e(a()),
34
+ order: e(i(t()))
34
35
  })
35
36
  ),
36
- valueSize: i,
37
- valueColor: i,
38
- xColumn: i,
39
- yColumn: i,
40
- xGroupBy: e(t(i)),
41
- yGroupBy: e(t(i)),
37
+ valueSize: s,
38
+ valueColor: s,
39
+ xColumn: s,
40
+ yColumn: s,
41
+ xGroupBy: e(i(s)),
42
+ yGroupBy: e(i(s)),
42
43
  keysOrder: e(
43
44
  // x, y, grouping, facet keys in user's order
44
- T(s(), t(s()))
45
+ T(t(), i(t()))
45
46
  ),
46
47
  normalization: e(o({
47
48
  direction: l(["row", "column"]),
48
49
  method: l(["standardScaling", "meanNormalization"]),
49
- colorRange: e(t(a())),
50
- sizeRange: e(t(a()))
50
+ colorRange: e(i(a())),
51
+ sizeRange: e(i(a()))
51
52
  })),
52
53
  aggregation: e(o({
53
54
  x: e(n()),
@@ -64,13 +65,13 @@ const m = {
64
65
  sorting: e(l(["asc", "desc"])),
65
66
  position: e(l(["left", "right"]))
66
67
  })),
67
- facetBy: e(t(i)),
68
+ facetBy: e(i(s)),
68
69
  aes: e(o({
69
- colorsList: e(t(s())),
70
+ colorsList: e(i(t())),
70
71
  minRadius: e(a()),
71
72
  maxRadius: e(a()),
72
- cellStrokeColor: e(s()),
73
- emptyCellColor: e(s())
73
+ cellStrokeColor: e(t()),
74
+ emptyCellColor: e(t())
74
75
  })),
75
76
  tooltips: e(c),
76
77
  NAValueAs: e(p([a(), d()]))
@@ -1 +1 @@
1
- {"version":3,"file":"bubble.js","sources":["../../src/types/bubble.ts"],"sourcesContent":["import {\n AggregationMethodSchema,\n ColumnNameSchema,\n FrameTypeSchema,\n LegendPositionSchema,\n TitlePositionSchema,\n TooltipSettingsSchema,\n} from './common';\nimport { z } from 'zod';\n\nconst axisCommonSchema = {\n title: z.optional(z.string()),\n showTicks: z.optional(z.boolean()),\n showTitle: z.optional(z.boolean()),\n showAxisLabels: z.optional(z.boolean()),\n axisLabelsAngle: z.optional(z.union([z.literal(0), z.literal(45), z.literal(90)])),\n};\n\n//const InheritAesSchema = z.object({type: z.literal('grouping'), value: z.string()}); // link to aes mapped to column\n\nexport const BubblesSettingsSchema = z.object({\n type: z.literal('bubble'),\n title: z.object({\n name: z.string(),\n show: z.optional(z.boolean()),\n position: z.optional(TitlePositionSchema),\n }),\n size: z.optional(\n z.object({\n width: z.optional(z.number()),\n height: z.optional(z.number()),\n cellSize: z.optional(z.number())\n })\n ),\n legend: z.optional(\n z.object({\n show: z.optional(z.boolean()),\n position: z.optional(LegendPositionSchema),\n })\n ),\n frame: z.optional(z.object({ type: z.optional(FrameTypeSchema) })),\n facetSettings: z.optional(\n z.object({\n nRows: z.optional(z.number()),\n nCols: z.optional(z.number()),\n })\n ),\n valueSize: ColumnNameSchema,\n valueColor: ColumnNameSchema,\n xColumn: ColumnNameSchema,\n yColumn: ColumnNameSchema,\n xGroupBy: z.optional(z.array(ColumnNameSchema)),\n yGroupBy: z.optional(z.array(ColumnNameSchema)),\n keysOrder: z.optional( // x, y, grouping, facet keys in user's order\n z.record(z.string(), z.array(z.string()))\n ),\n normalization: z.optional(z.object({\n direction: z.enum(['row', 'column']),\n method: z.enum(['standardScaling', 'meanNormalization']),\n colorRange: z.optional(z.array(z.number())),\n sizeRange: z.optional(z.array(z.number())),\n })),\n aggregation: z.optional(z.object({\n x: z.optional(z.boolean()),\n y: z.optional(z.boolean()),\n method: z.optional(AggregationMethodSchema),\n })),\n xAxis: z.optional(z.object({\n ...axisCommonSchema,\n sorting: z.optional(z.enum(['asc', 'desc'])),\n position: z.optional(z.enum(['top', 'bottom'])),\n })),\n yAxis: z.optional(z.object({\n ...axisCommonSchema,\n sorting: z.optional(z.enum(['asc', 'desc'])),\n position: z.optional(z.enum(['left', 'right'])),\n })),\n facetBy: z.optional(z.array(ColumnNameSchema)),\n aes: z.optional(z.object({\n colorsList: z.optional(z.array(z.string())),\n minRadius: z.optional(z.number()),\n maxRadius: z.optional(z.number()),\n cellStrokeColor: z.optional(z.string()),\n emptyCellColor: z.optional(z.string()),\n })),\n tooltips: z.optional(TooltipSettingsSchema),\n NAValueAs: z.optional(z.union([z.number(), z.null()])),\n});\n\nexport type BubbleSettings = z.infer<typeof BubblesSettingsSchema>;\n"],"names":["axisCommonSchema","z.optional","z.string","z.boolean","z.union","z.literal","BubblesSettingsSchema","z.object","TitlePositionSchema","z.number","LegendPositionSchema","FrameTypeSchema","ColumnNameSchema","z.array","z.record","z.enum","AggregationMethodSchema","TooltipSettingsSchema","z.null"],"mappings":";;AAUA,MAAMA,IAAmB;AAAA,EACrB,OAAOC,EAAWC,GAAU;AAAA,EAC5B,WAAWD,EAAWE,GAAW;AAAA,EACjC,WAAWF,EAAWE,GAAW;AAAA,EACjC,gBAAgBF,EAAWE,GAAW;AAAA,EACtC,iBAAiBF,EAAWG,EAAQ,CAACC,EAAU,CAAC,GAAGA,EAAU,EAAE,GAAGA,EAAU,EAAE,CAAC,CAAC,CAAC;AACrF,GAIaC,IAAwBC,EAAS;AAAA,EAC1C,MAAMF,EAAU,QAAQ;AAAA,EACxB,OAAOE,EAAS;AAAA,IACZ,MAAML,EAAE;AAAA,IACR,MAAMD,EAAWE,GAAW;AAAA,IAC5B,UAAUF,EAAWO,CAAmB;AAAA,EAAA,CAC3C;AAAA,EACD,MAAMP;AAAAA,IACFM,EAAS;AAAA,MACL,OAAON,EAAWQ,GAAU;AAAA,MAC5B,QAAQR,EAAWQ,GAAU;AAAA,MAC7B,UAAUR,EAAWQ,GAAU;AAAA,IAAA,CAClC;AAAA,EAAA;AAAA,EAEL,QAAQ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,OAAOd,EAAWM,EAAS;AAAA,IACvB,GAAGP;AAAA,IACH,SAASC,EAAWc,EAAO,CAAC,OAAO,MAAM,CAAC,CAAC;AAAA,IAC3C,UAAUd,EAAWc,EAAO,CAAC,QAAQ,OAAO,CAAC,CAAC;AAAA,EAAA,CACjD,CAAC;AAAA,EACF,SAASd,EAAWY,EAAQD,CAAgB,CAAC;AAAA,EAC7C,KAAKX,EAAWM,EAAS;AAAA,IACrB,YAAYN,EAAWY,EAAQX,EAAE,CAAQ,CAAC;AAAA,IAC1C,WAAWD,EAAWQ,GAAU;AAAA,IAChC,WAAWR,EAAWQ,GAAU;AAAA,IAChC,iBAAiBR,EAAWC,GAAU;AAAA,IACtC,gBAAgBD,EAAWC,GAAU;AAAA,EAAA,CACxC,CAAC;AAAA,EACF,UAAUD,EAAWgB,CAAqB;AAAA,EAC1C,WAAWhB,EAAWG,EAAQ,CAACK,EAAE,GAAUS,EAAE,CAAM,CAAC,CAAC;AACzD,CAAC;"}
1
+ {"version":3,"file":"bubble.js","sources":["../../src/types/bubble.ts"],"sourcesContent":["import {\n AggregationMethodSchema,\n ColumnNameSchema,\n FrameTypeSchema,\n LegendPositionSchema,\n TitlePositionSchema,\n TooltipSettingsSchema,\n} from './common';\nimport { z } from 'zod';\n\nconst axisCommonSchema = {\n title: z.optional(z.string()),\n showTicks: z.optional(z.boolean()),\n showTitle: z.optional(z.boolean()),\n showAxisLabels: z.optional(z.boolean()),\n axisLabelsAngle: z.optional(z.union([z.literal(0), z.literal(45), z.literal(90)])),\n};\n\n//const InheritAesSchema = z.object({type: z.literal('grouping'), value: z.string()}); // link to aes mapped to column\n\nexport const BubblesSettingsSchema = z.object({\n type: z.literal('bubble'),\n title: z.object({\n name: z.string(),\n show: z.optional(z.boolean()),\n position: z.optional(TitlePositionSchema),\n }),\n size: z.optional(\n z.object({\n width: z.optional(z.number()),\n height: z.optional(z.number()),\n cellSize: z.optional(z.number())\n })\n ),\n legend: z.optional(\n z.object({\n show: z.optional(z.boolean()),\n position: z.optional(LegendPositionSchema),\n })\n ),\n frame: z.optional(z.object({ type: z.optional(FrameTypeSchema) })),\n facetSettings: z.optional(\n z.object({\n nRows: z.optional(z.number()),\n nCols: z.optional(z.number()),\n order: z.optional(z.array(z.string())),\n })\n ),\n valueSize: ColumnNameSchema,\n valueColor: ColumnNameSchema,\n xColumn: ColumnNameSchema,\n yColumn: ColumnNameSchema,\n xGroupBy: z.optional(z.array(ColumnNameSchema)),\n yGroupBy: z.optional(z.array(ColumnNameSchema)),\n keysOrder: z.optional( // x, y, grouping, facet keys in user's order\n z.record(z.string(), z.array(z.string()))\n ),\n normalization: z.optional(z.object({\n direction: z.enum(['row', 'column']),\n method: z.enum(['standardScaling', 'meanNormalization']),\n colorRange: z.optional(z.array(z.number())),\n sizeRange: z.optional(z.array(z.number())),\n })),\n aggregation: z.optional(z.object({\n x: z.optional(z.boolean()),\n y: z.optional(z.boolean()),\n method: z.optional(AggregationMethodSchema),\n })),\n xAxis: z.optional(z.object({\n ...axisCommonSchema,\n sorting: z.optional(z.enum(['asc', 'desc'])),\n position: z.optional(z.enum(['top', 'bottom'])),\n })),\n yAxis: z.optional(z.object({\n ...axisCommonSchema,\n sorting: z.optional(z.enum(['asc', 'desc'])),\n position: z.optional(z.enum(['left', 'right'])),\n })),\n facetBy: z.optional(z.array(ColumnNameSchema)),\n aes: z.optional(z.object({\n colorsList: z.optional(z.array(z.string())),\n minRadius: z.optional(z.number()),\n maxRadius: z.optional(z.number()),\n cellStrokeColor: z.optional(z.string()),\n emptyCellColor: z.optional(z.string()),\n })),\n tooltips: z.optional(TooltipSettingsSchema),\n NAValueAs: z.optional(z.union([z.number(), z.null()])),\n});\n\nexport type BubbleSettings = z.infer<typeof BubblesSettingsSchema>;\n"],"names":["axisCommonSchema","z.optional","z.string","z.boolean","z.union","z.literal","BubblesSettingsSchema","z.object","TitlePositionSchema","z.number","LegendPositionSchema","FrameTypeSchema","z.array","ColumnNameSchema","z.record","z.enum","AggregationMethodS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