Skip to content

Commit f7d4865

Browse files
committed
Remove unnecessary calculations on scatter rendering
1 parent 301f687 commit f7d4865

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

esm/components/data_layer/scatter.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -240,17 +240,19 @@ class Scatter extends BaseDataLayer {
240240
.selectAll(`g.lz-data_layer-${this.layout.type}-label`)
241241
.data(label_data, (d) => `${d[this.layout.id_field]}_label`);
242242

243+
const style_class = `lz-data_layer-${this.layout.type}-label`;
243244
const groups_enter = this.label_groups.enter()
244245
.append('g')
245-
.attr('class', `lz-data_layer-${this.layout.type}-label`);
246+
.attr('class', style_class);
246247

247248
// Render label texts
248249
if (this.label_texts) {
249250
this.label_texts.remove();
250251
}
252+
251253
this.label_texts = this.label_groups.merge(groups_enter)
252254
.append('text')
253-
.attr('class', `lz-data_layer-${this.layout.type}-label`)
255+
.attr('class', style_class)
254256
.text((d) => parseFields(d, data_layer.layout.label.text || ''))
255257
.attr('x', (d) => {
256258
let x = data_layer.parent[x_scale](d[data_layer.layout.x_axis.field])
@@ -330,8 +332,6 @@ class Scatter extends BaseDataLayer {
330332
.data(track_data, (d) => d[this.layout.id_field]);
331333

332334
// Create elements, apply class, ID, and initial position
333-
const initial_y = isNaN(this.parent.layout.height) ? 0 : this.parent.layout.height;
334-
335335
// Generate new values (or functions for them) for position, color, size, and shape
336336
const transform = (d) => {
337337
let x = this.parent[x_scale](d[this.layout.x_axis.field]);
@@ -349,11 +349,11 @@ class Scatter extends BaseDataLayer {
349349
.size((d, i) => this.resolveScalableParameter(this.layout.point_size, d, i))
350350
.type((d, i) => nameToSymbol(this.resolveScalableParameter(this.layout.point_shape, d, i)));
351351

352+
const style_class = `lz-data_layer-${this.layout.type}`;
352353
selection.enter()
353354
.append('path')
354-
.attr('class', `lz-data_layer-${this.layout.type}`)
355+
.attr('class', style_class)
355356
.attr('id', (d) => this.getElementId(d))
356-
.attr('transform', `translate(0, ${initial_y})`)
357357
.merge(selection)
358358
.attr('transform', transform)
359359
.attr('fill', (d, i) => this.resolveScalableParameter(this.layout.color, d, i))

0 commit comments

Comments
 (0)