Skip to content

Commit 81a0c93

Browse files
Sergei KoshevarovGondragos
andcommitted
fix: BROS-128: Fix large data multichannel displaying (#7800)
Co-authored-by: Gondragos <Gondragos@users.noreply.github.com> (cherry picked from commit 968ab62)
1 parent 863c274 commit 81a0c93

2 files changed

Lines changed: 29 additions & 14 deletions

File tree

web/libs/editor/src/components/TimeSeries/TimeSeriesVisualizer.jsx

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -696,12 +696,16 @@ class TimeSeriesVisualizerD3 extends React.Component {
696696

697697
let { series } = this.props;
698698

699+
if (this.optimizedSeries) {
700+
channel.useOptimizedData = this.useOptimizedData;
701+
series = this.optimizedSeries;
702+
}
703+
699704
series = series.filter((x) => {
700705
return x[column] !== null;
701706
});
702707

703708
if (this.optimizedSeries) {
704-
channel.useOptimizedData = this.useOptimizedData;
705709
channel.optimizedSeries = series;
706710
}
707711

@@ -731,6 +735,7 @@ class TimeSeriesVisualizerD3 extends React.Component {
731735
.domain(d3.extent(values))
732736
.range([height - margin.max, margin.min]);
733737

738+
channel.x = this.x.copy();
734739
channel.plotX = this.x.copy();
735740
channel.y = y;
736741

@@ -743,7 +748,7 @@ class TimeSeriesVisualizerD3 extends React.Component {
743748
.line()
744749
.defined((d) => d[time] >= range[0] && d[time] <= range[1])
745750
.y((d) => channel.y(d[column]))
746-
.x((d) => this.x(d[time]));
751+
.x((d) => channel.x(d[time]));
747752

748753
const marker = this.defs
749754
.append("marker")
@@ -755,7 +760,7 @@ class TimeSeriesVisualizerD3 extends React.Component {
755760

756761
markerSymbol(marker, item.markersymbol, item.markersize, item.markercolor);
757762

758-
channel.path = this.pathContainer.append("path").datum(series).attr("d", this.line);
763+
channel.path = this.pathContainer.append("path").datum(series).attr("d", channel.line);
759764
// to render different zoomed slices of path
760765
channel.path2 = this.pathContainer.append("path");
761766

@@ -776,21 +781,30 @@ class TimeSeriesVisualizerD3 extends React.Component {
776781
}
777782

778783
setRangeWithScaling(range) {
779-
for (const channelItem of this.props.channels) {
780-
this.setChannelRangeWithScaling(channelItem, range);
781-
}
782-
}
783-
setChannelRangeWithScaling(channelItem, range) {
784-
const column = channelItem.columnName;
785-
const channel = this.channels[column];
786784
this.x.domain(range);
787785
const current = this.x.range();
788-
const all = channel.plotX.domain().map(this.x);
786+
const all = this.plotX.domain().map(this.x);
789787
const scale = (all[1] - all[0]) / (current[1] - current[0]);
790788
const left = Math.max(0, Math.floor((this.zoomStep * (current[0] - all[0])) / (all[1] - all[0])));
791789
const right = Math.max(0, Math.floor((this.zoomStep * (current[1] - all[0])) / (all[1] - all[0])));
792790
const translate = all[0] - current[0];
793791

792+
const { item } = this.props;
793+
if (item.timerange) {
794+
const timerange = item.timerange.split(",").map(Number);
795+
796+
this.x.domain(timerange);
797+
}
798+
799+
for (const channelItem of this.props.channels) {
800+
this.setChannelRangeWithScaling(channelItem, range, { left, right, translate, scale });
801+
}
802+
}
803+
setChannelRangeWithScaling(channelItem, range, { left, right, translate, scale }) {
804+
const column = channelItem.columnName;
805+
const channel = this.channels[column];
806+
channel.x.domain(range);
807+
794808
let translateY = 0;
795809
let scaleY = 1;
796810
const originY = channel.y.range()[0];
@@ -806,7 +820,7 @@ class TimeSeriesVisualizerD3 extends React.Component {
806820
if (item.timerange) {
807821
const timerange = item.timerange.split(",").map(Number);
808822

809-
this.x.domain(timerange);
823+
channel.x.domain(timerange);
810824
}
811825

812826
if (!fixedscale) {
@@ -843,13 +857,13 @@ class TimeSeriesVisualizerD3 extends React.Component {
843857

844858
// zoomStep - zoom level when we need to switch between optimized and original data
845859
const strongZoom = scale > this.zoomStep;
846-
const haveToSwitchData = strongZoom === this.useOptimizedData;
860+
const haveToSwitchData = strongZoom === channel.useOptimizedData;
847861

848862
if (channel.optimizedSeries && haveToSwitchData) {
849863
channel.useOptimizedData = !channel.useOptimizedData;
850864
if (channel.useOptimizedData) {
851865
channel.path.datum(channel.optimizedSeries);
852-
channel.path.attr("d", this.line);
866+
channel.path.attr("d", channel.line);
853867
} else {
854868
channel.path.attr("transform", "");
855869
}

web/libs/editor/tests/e2e/tests/toggle-visibility.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ Scenario("Checking regions grouped by label", async ({ I, LabelStudio }) => {
180180
I.click('[data-testid="grouping-manual"]');
181181
I.waitForElement(".lsf-menu", 2);
182182

183+
I.waitForElement(".lsf-dropdown.lsf-visible");
183184
// Click on the "Group by Label" option in the dropdown
184185
I.click('//div[contains(@class, "lsf-view-controls__label") and contains(text(), "Group by Label")]');
185186

0 commit comments

Comments
 (0)