@microbiome-informatics/genome-properties-viewer 1.0.0-beta.1 → 1.0.0-beta.3

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.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  A heatmap-styled web viewer for the Genome Properties project.
4
4
 
5
- The x axis is Genome Properties; the y axis is the selected species. Species can be selected from a taxonomy tree on the left of the screen.
5
+ Each column is a species and each row is a Genome Property. Species are selected from a taxonomy tree at the top of the viewer, with property names on the left.
6
6
 
7
7
  Published on npm as [`@microbiome-informatics/genome-properties-viewer`](https://www.npmjs.com/package/@microbiome-informatics/genome-properties-viewer). This is a new scoped package, not a continuation of the unscoped `genome-properties-viewer` name.
8
8
 
package/gp-style.css CHANGED
@@ -42,7 +42,7 @@ text.active,
42
42
  }
43
43
 
44
44
  g.node.loaded {
45
- cursor: ns-resize;
45
+ cursor: ew-resize;
46
46
  opacity: 1;
47
47
  }
48
48
  g.node.loaded:hover .node-type {
@@ -79,7 +79,7 @@ g.node.loaded text.label-species {
79
79
  pointer-events: none;
80
80
  }
81
81
  .height-dragger {
82
- cursor: ew-resize;
82
+ cursor: ns-resize;
83
83
  opacity: 0.7;
84
84
  }
85
85
  .height-dragger:hover {
@@ -90,8 +90,9 @@ g.node.loaded text.label-species {
90
90
  opacity: 0.7;
91
91
  }
92
92
  input[type="file"] {
93
- color: transparent;
94
- width: 150px;
93
+ color: inherit;
94
+ width: auto;
95
+ max-width: 220px;
95
96
  }
96
97
  .selector a {
97
98
  color: #3c67c1;
@@ -114,7 +115,8 @@ input[type="file"] {
114
115
  color: #666;
115
116
  text-align: right;
116
117
  margin-bottom: 2px;
117
- cursor: context-menu;
118
+ cursor: pointer;
119
+ position: relative;
118
120
  }
119
121
  .selector::after {
120
122
  content: " ▾ ";
@@ -130,11 +132,15 @@ input[type="file"] {
130
132
  color: #666;
131
133
  padding: 5px;
132
134
  position: absolute;
133
- z-index: 1;
135
+ left: 0;
136
+ top: 100%;
137
+ z-index: 20;
134
138
  border: 2px #ddd solid;
135
139
  text-align: left;
136
140
  }
137
- .selector:hover div.options {
141
+ .selector:hover div.options,
142
+ .selector.open div.options,
143
+ .selector:focus-within div.options {
138
144
  visibility: visible;
139
145
  }
140
146
  .selector .current_status {
@@ -206,6 +212,7 @@ input[type="file"] {
206
212
  top: 0;
207
213
  left: 0;
208
214
  pointer-events: none;
215
+ z-index: 10000;
209
216
  }
210
217
  div.gp-modal.gp-modal-active {
211
218
  pointer-events: auto;
@@ -220,20 +227,20 @@ div.gp-modal-content.gp-modal-active {
220
227
  position: fixed;
221
228
  left: 50%;
222
229
  top: 50%;
230
+ transform: translate(-50%, -50%);
223
231
  pointer-events: none;
232
+ z-index: 10001;
224
233
  }
225
234
  .gp-modal-content {
226
235
  position: relative;
227
- width: 80vw;
236
+ width: min(90vw, 1200px);
228
237
  min-height: 100px;
229
- height: 100%;
230
238
  max-height: 80vh;
231
239
  background: white;
232
- top: -10vh;
233
- left: -50%;
234
240
  opacity: 0;
235
241
  pointer-events: none;
236
- overflow: scroll;
242
+ overflow: auto;
243
+ box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
237
244
  }
238
245
 
239
246
  .progress-panel {
@@ -408,6 +415,7 @@ div.container .top-block {
408
415
  padding: 4px;
409
416
  background: #fafafa;
410
417
  position: relative;
418
+ z-index: 5;
411
419
  }
412
420
  div.container .top-block .minimise {
413
421
  position: absolute;
@@ -433,6 +441,11 @@ div.container .top-block .minimise.on::after {
433
441
  }
434
442
  .gpv-scrollbar rect.gpv-scrollbar-handle {
435
443
  fill: rgba(100, 100, 100, 0.6);
444
+ }
445
+ .gpv-scrollbar-x rect.gpv-scrollbar-handle {
446
+ cursor: ew-resize;
447
+ }
448
+ .gpv-scrollbar-y rect.gpv-scrollbar-handle {
436
449
  cursor: ns-resize;
437
450
  }
438
451
  .gpv-scrollbar rect.gpv-scrollbar-bg {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microbiome-informatics/genome-properties-viewer",
3
- "version": "1.0.0-beta.1",
3
+ "version": "1.0.0-beta.3",
4
4
  "description": "A heatmap styled viewer for the genome properties",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -10,7 +10,8 @@
10
10
  "bin/d3.custom.min.js"
11
11
  ],
12
12
  "publishConfig": {
13
- "access": "public"
13
+ "access": "public",
14
+ "registry": "https://registry.npmjs.org/"
14
15
  },
15
16
  "scripts": {
16
17
  "build": "rollup -c",
@@ -59,7 +60,7 @@
59
60
  "@babel/cli": "^7.2.0",
60
61
  "@babel/core": "^7.2.0",
61
62
  "@babel/preset-env": "^7.2.0",
62
- "browser-sync": "2.26.14",
63
+ "browser-sync": "^2.29.3",
63
64
  "eslint": "7.21.0",
64
65
  "eslint-config-airbnb-base": "14.2.1",
65
66
  "eslint-config-prettier": "8.1.0",
@@ -69,7 +70,7 @@
69
70
  "mysql": "2.18.1",
70
71
  "prettier": "2.2.1",
71
72
  "regenerator": "0.14.7",
72
- "rollup": "2.40.0",
73
+ "rollup": "^2.80.0",
73
74
  "rollup-plugin-babel": "^4.1.0",
74
75
  "rollup-plugin-node-resolve": "5.2.0"
75
76
  }
@@ -32,25 +32,32 @@ export default class GenomePropertiesController {
32
32
  }
33
33
 
34
34
  if (legends_element_selector) {
35
- this.legends_component = d3.select(legends_element_selector).append("ul");
35
+ const host = d3.select(legends_element_selector);
36
+ host.selectAll("ul").remove();
37
+ this.legends_component = host.append("ul");
36
38
  this.draw_legends();
37
39
  }
38
40
 
39
41
  if (tooltip_selector) {
40
42
  this.tooltip_selector = tooltip_selector;
43
+ d3.select(tooltip_selector).selectAll("ul").remove();
41
44
  this.draw_tooltip(null, null, true);
42
45
  }
43
46
 
44
47
  this.text_filter = "";
45
48
  if (gp_text_filter_selector) {
46
- d3.select(gp_text_filter_selector).on("keyup", (event) => {
49
+ this._textFilterSelector = gp_text_filter_selector;
50
+ const applyTextFilter = (event) => {
47
51
  this.text_filter =
48
52
  event.currentTarget.value.length > 2 ? event.currentTarget.value : "";
49
53
  if (this.text_filter !== this.gp_viewer.filter_text) {
50
54
  this.gp_viewer.filter_text = this.text_filter;
51
55
  this.moveScrollUp();
52
56
  }
53
- });
57
+ };
58
+ d3.select(gp_text_filter_selector)
59
+ .on("input.gpfilter", applyTextFilter)
60
+ .on("keyup.gpfilter", applyTextFilter);
54
61
  }
55
62
  if (gp_label_selector) {
56
63
  d3.select(gp_label_selector).on("change", (event) => {
@@ -182,12 +189,27 @@ export default class GenomePropertiesController {
182
189
  </ul>
183
190
  </div>`);
184
191
 
185
- this.gp_component
186
- .select(".options .all")
187
- .on("click", () => this.update("ALL"));
188
- this.gp_component
189
- .select(".options .none")
190
- .on("click", () => this.update("NONE"));
192
+ this.gp_component.select(".options .all").on("click", (event) => {
193
+ event.preventDefault();
194
+ event.stopPropagation();
195
+ this.update("ALL");
196
+ });
197
+ this.gp_component.select(".options .none").on("click", (event) => {
198
+ event.preventDefault();
199
+ event.stopPropagation();
200
+ this.update("NONE");
201
+ });
202
+ this.gp_component.on("click.gpselector", (event) => {
203
+ if (event.target.closest(".options")) return;
204
+ this.gp_component.classed("open", !this.gp_component.classed("open"));
205
+ });
206
+ this._onDocClick = (event) => {
207
+ const node = this.gp_component.node();
208
+ if (node && !node.contains(event.target)) {
209
+ this.gp_component.classed("open", false);
210
+ }
211
+ };
212
+ document.addEventListener("click", this._onDocClick);
191
213
 
192
214
  const tll = this.gp_component
193
215
  .select(".options ul")
@@ -206,11 +228,19 @@ export default class GenomePropertiesController {
206
228
  (d) => `2px solid ${this.hierarchy_contorller.color(d.id)}`
207
229
  )
208
230
  .style("border-radius", "50%")
209
- .on("click", (event, d) => this.update(d));
231
+ .on("click", (event, d) => {
232
+ event.preventDefault();
233
+ event.stopPropagation();
234
+ this.update(d);
235
+ });
210
236
 
211
237
  li.append("a")
212
238
  .text((d) => this.hierarchy_contorller.nodes[d.id].name)
213
- .on("click", (event, d) => this.update(d));
239
+ .on("click", (event, d) => {
240
+ event.preventDefault();
241
+ event.stopPropagation();
242
+ this.update(d);
243
+ });
214
244
  }
215
245
 
216
246
  update(d) {
@@ -260,9 +290,10 @@ export default class GenomePropertiesController {
260
290
  }
261
291
  this.gp_component
262
292
  .select(".options ul")
263
- .selectAll(".top-level-option div")
293
+ .selectAll(".top-level-option")
294
+ .select("div")
264
295
  .style("background", (item) =>
265
- d.enable ? this.hierarchy_contorller.color(item.id) : "#e3e3e3"
296
+ item.enable ? this.hierarchy_contorller.color(item.id) : "#e3e3e3"
266
297
  );
267
298
  }
268
299
 
@@ -270,4 +301,22 @@ export default class GenomePropertiesController {
270
301
  this.dipatcher.on(typename, callback);
271
302
  return this;
272
303
  }
304
+
305
+ destroy() {
306
+ if (this._onDocClick) {
307
+ document.removeEventListener("click", this._onDocClick);
308
+ this._onDocClick = null;
309
+ }
310
+ if (this._textFilterSelector) {
311
+ d3.select(this._textFilterSelector)
312
+ .on("input.gpfilter", null)
313
+ .on("keyup.gpfilter", null);
314
+ }
315
+ if (this.legends_component) this.legends_component.remove();
316
+ if (this.tooltip_component) this.tooltip_component.remove();
317
+ if (this.gp_component) {
318
+ this.gp_component.on("click.gpselector", null);
319
+ this.gp_component.html("");
320
+ }
321
+ }
273
322
  }
package/src/gp-filters.js CHANGED
@@ -13,28 +13,35 @@ import * as d3 from "./d3";
13
13
  * The current set of filters is in `viewer.legend_filters` and the filtered props will be saved in `viewer.props`.
14
14
  * @param {GernomeProperiesViewer} viewer - The instance of the genome properites viewer
15
15
  */
16
+ const organismKeys = (viewer) =>
17
+ new Set((viewer.organisms || []).map((id) => String(id)));
18
+
19
+ const valuesForLoadedOrganisms = (prop, viewer) => {
20
+ const loaded = organismKeys(viewer);
21
+ return d3
22
+ .entries(prop.values)
23
+ .filter((e) => e.key !== "TOTAL" && loaded.has(String(e.key)));
24
+ };
25
+
16
26
  export const filterByLegend = (viewer) => {
17
27
  if (viewer.legend_filters) {
18
28
  for (const x of Object.keys(viewer.legend_filters)) {
19
29
  if (viewer.legend_filters[x] === "∀") {
20
30
  viewer.props = viewer.props.filter((prop) => {
21
- const values = d3
22
- .entries(prop.values)
23
- .filter((e) => viewer.organisms.indexOf(e.key) !== -1);
24
- return values.filter((e) => e.value === x).length === values.length;
31
+ const values = valuesForLoadedOrganisms(prop, viewer);
32
+ return (
33
+ values.length > 0 &&
34
+ values.filter((e) => e.value === x).length === values.length
35
+ );
25
36
  });
26
37
  } else if (viewer.legend_filters[x] === "∃") {
27
38
  viewer.props = viewer.props.filter((prop) => {
28
- const values = d3
29
- .entries(prop.values)
30
- .filter((e) => viewer.organisms.indexOf(e.key) !== -1);
39
+ const values = valuesForLoadedOrganisms(prop, viewer);
31
40
  return values.filter((e) => e.value === x).length > 0;
32
41
  });
33
42
  } else if (viewer.legend_filters[x] === "∄") {
34
43
  viewer.props = viewer.props.filter((prop) => {
35
- const values = d3
36
- .entries(prop.values)
37
- .filter((e) => viewer.organisms.indexOf(e.key) !== -1);
44
+ const values = valuesForLoadedOrganisms(prop, viewer);
38
45
  return values.filter((e) => e.value === x).length === 0;
39
46
  });
40
47
  }
@@ -49,7 +56,8 @@ export const filterByLegend = (viewer) => {
49
56
  */
50
57
  export const filterByHierarchy = (viewer) => {
51
58
  viewer.props = viewer.props.filter((e) => {
52
- if (e.parent_top_properties === null) return true;
59
+ if (!e.parent_top_properties || e.parent_top_properties.length === 0)
60
+ return true;
53
61
  for (const p of e.parent_top_properties)
54
62
  for (const tp of viewer.gp_hierarchy.hierarchy_switch)
55
63
  if (p === tp.id && tp.enable) return true;
@@ -91,8 +91,10 @@ class GenomePropertiesHierarchy {
91
91
  * @return {Array} Array of ids of the top level properties.
92
92
  */
93
93
  get_top_level_gp_by_id(id) {
94
- if (id in this.nodes)
95
- return [...this.get_top_level_gp(this.nodes[id])].map((d) => d.id);
94
+ if (id in this.nodes) {
95
+ const top = this.get_top_level_gp(this.nodes[id]);
96
+ if (top) return [...top].map((d) => d.id);
97
+ }
96
98
  return [];
97
99
  }
98
100
 
@@ -109,11 +111,11 @@ class GenomePropertiesHierarchy {
109
111
  return node.top_level_gp;
110
112
  }
111
113
  node.top_level_gp = new Set();
112
- for (const parent of node.parents) {
113
- node.top_level_gp = new Set([
114
- ...node.top_level_gp,
115
- ...this.get_top_level_gp(parent),
116
- ]);
114
+ for (const parent of node.parents || []) {
115
+ const parentTop = this.get_top_level_gp(parent);
116
+ if (parentTop) {
117
+ node.top_level_gp = new Set([...node.top_level_gp, ...parentTop]);
118
+ }
117
119
  }
118
120
  return node.top_level_gp;
119
121
  }
@@ -1,6 +1,6 @@
1
1
  import * as d3 from "./d3";
2
2
  /**
3
- * Updates this and othe components as if a scroll event happened.
3
+ * Updates this and other components as if a scroll event happened.
4
4
  * It became the de-facto refresh of the whole viewer, as it groups the minimum necesary changes to trigger a full update.
5
5
  * @param {GernomeProperiesViewer} viewer - The instance of the genome properites viewer
6
6
  */
@@ -13,8 +13,13 @@ export const transformByScroll = (viewer) => {
13
13
  "transform",
14
14
  `translate(${viewer.current_scroll.x}, ${viewer.current_scroll.y})`
15
15
  );
16
+ if (viewer.labelGroup) {
17
+ viewer.labelGroup.attr(
18
+ "transform",
19
+ `translate(0, ${viewer.current_scroll.y})`
20
+ );
21
+ }
16
22
  viewer.options.dimensions.total.short_side = viewer.options.cell_side;
17
- viewer.gp_taxonomy.y = viewer.options.dimensions.total.short_side;
18
23
  viewer.update_viewer();
19
24
  };
20
25
 
@@ -24,30 +29,21 @@ export const transformByScroll = (viewer) => {
24
29
  * @param {GernomeProperiesViewer} viewer - The instance of the genome properites viewer
25
30
  */
26
31
  export const drawScrollXBar = (viewer) => {
27
- const localY = (1 + viewer.organisms.length) * viewer.options.cell_side;
28
32
  const scrollerShortSide = viewer.options.dimensions.scroller.short_side;
29
33
  viewer.scrollbar_x_g = viewer.mainGroup
30
34
  .append("g")
31
- .attr("class", "gpv-scrollbar")
32
- .attr("opacity", 0)
33
- .attr(
34
- "transform",
35
- `translate(${
36
- viewer.options.dimensions.tree.width // at the right of the tree
37
- }, ${localY})`
38
- );
35
+ .attr("class", "gpv-scrollbar gpv-scrollbar-x")
36
+ .attr("opacity", 0);
39
37
 
40
38
  viewer.scrollbar_x_bg = viewer.scrollbar_x_g
41
39
  .append("rect")
42
40
  .attr("class", "gpv-scrollbar-bg")
43
- .attr("width", viewer.options.width - viewer.options.dimensions.tree.width)
44
41
  .attr("height", scrollerShortSide);
45
42
 
46
43
  let selectedXBar = null;
47
44
  viewer.scrollbar_x = viewer.scrollbar_x_g
48
45
  .append("rect")
49
46
  .attr("class", "gpv-scrollbar-handle")
50
- .attr("width", viewer.options.width - viewer.options.dimensions.tree.width)
51
47
  .attr("height", scrollerShortSide - 2)
52
48
  .attr("y", 1)
53
49
  .attr("rx", scrollerShortSide / 2)
@@ -64,11 +60,11 @@ export const drawScrollXBar = (viewer) => {
64
60
  .on("drag", (event) => {
65
61
  viewer.skip_scroll_refreshing = true;
66
62
  event.sourceEvent.stopPropagation();
67
- const propertiesWidth = viewer.x(viewer.props.length);
63
+ const speciesWidth =
64
+ (viewer.organisms?.length || 0) * viewer.options.cell_side;
68
65
  const prevX = Number(selectedXBar.getAttribute("x"));
69
66
  let nextX = prevX + event.dx;
70
- const available_x =
71
- viewer.options.width - viewer.options.dimensions.tree.width;
67
+ const available_x = viewer.heatmapWidth();
72
68
 
73
69
  nextX = Math.max(
74
70
  0,
@@ -76,52 +72,126 @@ export const drawScrollXBar = (viewer) => {
76
72
  );
77
73
 
78
74
  viewer.scrollbar_x.attr("x", nextX);
79
- const dx = (-nextX * propertiesWidth) / available_x;
75
+ const dx = (-nextX * speciesWidth) / available_x;
80
76
  viewer.current_scroll.x = Math.min(0, dx);
81
77
  transformByScroll(viewer);
82
78
  })
83
79
  );
80
+
81
+ viewer.scrollbar_y_g = viewer.mainGroup
82
+ .append("g")
83
+ .attr("class", "gpv-scrollbar gpv-scrollbar-y")
84
+ .attr("opacity", 0);
85
+
86
+ viewer.scrollbar_y_bg = viewer.scrollbar_y_g
87
+ .append("rect")
88
+ .attr("class", "gpv-scrollbar-bg")
89
+ .attr("width", scrollerShortSide);
90
+
91
+ let selectedYBar = null;
92
+ viewer.scrollbar_y = viewer.scrollbar_y_g
93
+ .append("rect")
94
+ .attr("class", "gpv-scrollbar-handle")
95
+ .attr("width", scrollerShortSide - 2)
96
+ .attr("x", 1)
97
+ .attr("rx", scrollerShortSide / 2)
98
+ .attr("ry", scrollerShortSide / 2)
99
+ .style("cursor", "ns-resize")
100
+ .call(
101
+ d3
102
+ .drag()
103
+ .on("start", (event) => (selectedYBar = event.sourceEvent.target))
104
+ .on("end", () => {
105
+ viewer.skip_scroll_refreshing = false;
106
+ selectedYBar = null;
107
+ })
108
+ .on("drag", (event) => {
109
+ viewer.skip_scroll_refreshing = true;
110
+ event.sourceEvent.stopPropagation();
111
+ const propsHeight = viewer.y(viewer.props?.length || 0) || 0;
112
+ const prevY = Number(selectedYBar.getAttribute("y"));
113
+ let nextY = prevY + event.dy;
114
+ const available_y = viewer.heatmapHeight();
115
+
116
+ nextY = Math.max(
117
+ 0,
118
+ Math.min(nextY, available_y - selectedYBar.getAttribute("height"))
119
+ );
120
+
121
+ viewer.scrollbar_y.attr("y", nextY);
122
+ const dy = (-nextY * propsHeight) / available_y;
123
+ viewer.current_scroll.y = Math.min(0, dy);
124
+ transformByScroll(viewer);
125
+ })
126
+ );
84
127
  };
85
128
 
86
- /**
87
- * Updates the size and position of the scrollbar.
88
- * The size of the draggable is proportional to the number of visible columns in the graphic
89
- * @param {GernomeProperiesViewer} viewer - The instance of the genome properites viewer
90
- * @param {Number} visible_cols - Indicates how many columns are visible in the area assgined to the heatmap.
91
- * @param {Number} current_col - Indicates the index of the first visible column out of the total number of GP.
92
- */
93
129
  const updateScrollBarX = (viewer, visible_cols, current_col) => {
94
- const localY = (1 + viewer.organisms.length) * viewer.options.cell_side;
95
- const total_cols = viewer.props.length;
130
+ const total_cols = viewer.organisms.length;
131
+ const available_x = viewer.heatmapWidth();
96
132
  viewer.scrollbar_x_g
97
133
  .attr(
98
134
  "transform",
99
- `translate(${viewer.options.dimensions.tree.width}, ${localY})`
135
+ `translate(${viewer.heatmapLeft}, ${
136
+ viewer.options.height - viewer.options.dimensions.scroller.short_side
137
+ })`
100
138
  )
101
139
  .attr("opacity", total_cols > 0 ? 1 : 0);
102
140
 
103
- const available_x =
104
- viewer.options.width -
105
- viewer.options.dimensions.tree.width -
106
- viewer.options.dimensions.total.short_side;
107
141
  viewer.scrollbar_x
108
142
  .transition()
109
143
  .attr(
110
144
  "width",
111
145
  available_x *
112
- Math.min(1, total_cols !== 0 ? visible_cols / total_cols : 1)
146
+ Math.min(
147
+ 1,
148
+ total_cols !== 0 ? visible_cols / Math.max(total_cols, 1) : 1
149
+ )
113
150
  )
114
151
  .attr("x", total_cols ? (current_col * available_x) / total_cols : 0);
115
152
  viewer.scrollbar_x_bg.attr("width", available_x);
116
153
  };
117
154
 
155
+ const updateScrollBarY = (viewer, visible_rows, current_row) => {
156
+ const total_rows = viewer.props.length;
157
+ const available_y = viewer.heatmapHeight();
158
+ viewer.scrollbar_y_g
159
+ .attr(
160
+ "transform",
161
+ `translate(${
162
+ viewer.options.width - viewer.options.dimensions.scroller.short_side
163
+ }, ${viewer.heatmapTop})`
164
+ )
165
+ .attr("opacity", total_rows > 0 ? 1 : 0);
166
+
167
+ viewer.scrollbar_y
168
+ .transition()
169
+ .attr(
170
+ "height",
171
+ available_y *
172
+ Math.min(
173
+ 1,
174
+ total_rows !== 0 ? visible_rows / Math.max(total_rows, 1) : 1
175
+ )
176
+ )
177
+ .attr("y", total_rows ? (current_row * available_y) / total_rows : 0);
178
+ viewer.scrollbar_y_bg.attr("height", available_y);
179
+ };
180
+
118
181
  /**
119
- * A single method to trigger the update of all the scroll bars of the viewer. We currently only use 1.
182
+ * A single method to trigger the update of all the scroll bars of the viewer.
120
183
  * @param {GernomeProperiesViewer} viewer - The instance of the genome properites viewer
121
- * @param {Number} visible_cols - Indicates how many columns are visible in the area assgined to the heatmap.
122
- * @param {Number} current_col - Indicates the index of the first visible column out of the total number of GP.
184
+ * @param {Number} visible_rows - Visible property rows in the heatmap.
185
+ * @param {Number} current_row - Index of the first visible property.
123
186
  */
124
- export const updateScrollBars = (viewer, visible_cols, current_col) => {
187
+ export const updateScrollBars = (viewer, visible_rows, current_row) => {
188
+ const visible_cols = Math.min(
189
+ viewer.organisms.length,
190
+ Math.ceil(viewer.heatmapWidth() / viewer.options.cell_side)
191
+ );
192
+ const current_col = Math.round(
193
+ Math.abs(viewer.current_scroll.x) / viewer.options.cell_side
194
+ );
125
195
  updateScrollBarX(viewer, visible_cols, current_col);
126
- // updateScrollBarY(viewer);
196
+ updateScrollBarY(viewer, visible_rows, current_row);
127
197
  };
package/src/gp-steps.js CHANGED
@@ -46,9 +46,6 @@ const displayStepsModal = (viewer, gp) => {
46
46
  };
47
47
 
48
48
  const updateStepDetailsButton = (viewer, gp, element, cellSide) => {
49
- const localY =
50
- viewer.organisms.length * cellSide +
51
- viewer.options.dimensions.scroller.short_side;
52
49
  const x0 = cellSide * 0.1;
53
50
  const side = cellSide * 0.8;
54
51
  const top = cellSide * 0.1;
@@ -73,7 +70,7 @@ const updateStepDetailsButton = (viewer, gp, element, cellSide) => {
73
70
 
74
71
  buttonG
75
72
  .merge(button)
76
- .attr("transform", `translate(${cellSide}, ${localY})`)
73
+ .attr("transform", `translate(${-cellSide}, ${cellSide})`)
77
74
  .selectAll("circle")
78
75
  .transition()
79
76
  .attr("cx", x0 + half)
@@ -107,7 +104,7 @@ export const updateSteps = (viewer, gp, element, cellSide, yScale) => {
107
104
  .append("g")
108
105
  .attr("class", "step")
109
106
  .merge(steps)
110
- .attr("transform", (d, i) => `translate(${i * cellSide + p}, 0)`);
107
+ .attr("transform", (d, i) => `translate(0, ${(i + 1) * cellSide + p})`);
111
108
 
112
109
  const onMouseOver = (event, d) => {
113
110
  viewer.controller.draw_tooltip(event, {
@@ -144,7 +141,8 @@ export const updateSteps = (viewer, gp, element, cellSide, yScale) => {
144
141
  .on("mouseover", onMouseOver)
145
142
  .on("mouseout", onMouseOut)
146
143
  .merge(stepPerSpecie)
147
- .attr("y", (d, i) => yScale(i) + p)
144
+ .attr("x", (d, i) => yScale(i) + p)
145
+ .attr("y", 0)
148
146
  .transition()
149
147
  .attr("width", side)
150
148
  .attr("height", side)
@@ -158,10 +156,6 @@ export const updateStepToggler = (viewer, gp, element, cellSide) => {
158
156
  viewer.data[id].isShowingSteps = !viewer.data[id].isShowingSteps;
159
157
  viewer.update_viewer();
160
158
  };
161
- const localY =
162
- viewer.organisms.length * cellSide +
163
- viewer.options.dimensions.scroller.short_side;
164
-
165
159
  const toggler = d3
166
160
  .select(element)
167
161
  .selectAll(".step-toggler")
@@ -203,10 +197,7 @@ export const updateStepToggler = (viewer, gp, element, cellSide) => {
203
197
 
204
198
  newG
205
199
  .merge(toggler)
206
- .attr(
207
- "transform",
208
- `translate(0, ${localY})rotate(90,${cellSide / 2},${cellSide / 2})`
209
- )
200
+ .attr("transform", `translate(${-cellSide}, 0)`)
210
201
  .attr(
211
202
  "class",
212
203
  (id) => `step-toggler ${viewer.data[id].isShowingSteps ? "expanded" : ""}`