cherry pick ##7939

fix plot duplication and purge logic
This commit is contained in:
David Tsay 2024-12-16 12:42:10 -08:00
parent 5cc3cd4310
commit b25076e202
3 changed files with 12 additions and 4 deletions

View File

@ -1113,6 +1113,7 @@ export default {
}
this.listenTo(window, 'mouseup', this.onMouseUp, this);
// TODO: Why do we need this mousemove listener when we have a mousemove listener on the canvas above?
this.listenTo(window, 'mousemove', this.trackMousePosition, this);
// track frozen state on mouseDown to be read on mouseUp
@ -1133,6 +1134,7 @@ export default {
onMouseUp(event) {
this.stopListening(window, 'mouseup', this.onMouseUp, this);
// TODO: Why do we need this when we have a mousemove listener on the canvas above?
this.stopListening(window, 'mousemove', this.trackMousePosition, this);
if (this.isMouseClick() && event.shiftKey) {

View File

@ -230,7 +230,9 @@ export default class PlotSeries extends Model {
const newPoints = _(data)
.concat(points)
.sortBy(this.getXVal)
.uniq(true, (point) => [this.getXVal(point), this.getYVal(point)].join())
.sortedUniqBy((point) => {
return [this.getXVal(point), this.getYVal(point)].join();
})
.value();
this.reset(newPoints);
} catch (error) {
@ -429,7 +431,7 @@ export default class PlotSeries extends Model {
let data = this.getSeriesData();
let insertIndex = data.length;
const currentYVal = this.getYVal(newData);
const lastYVal = this.getYVal(data[insertIndex - 1]);
const lastYVal = insertIndex > 0 ? this.getYVal(data[insertIndex - 1]) : undefined;
if (this.isValueInvalid(currentYVal) && this.isValueInvalid(lastYVal)) {
console.warn(`[Plot] Invalid Y Values detected: ${currentYVal} ${lastYVal}`);
@ -505,8 +507,12 @@ export default class PlotSeries extends Model {
const pointsToRemove = startIndex + (data.length - endIndex + 1);
if (pointsToRemove > 0) {
if (pointsToRemove < 1000) {
// Remove all points up to the start index
data.slice(0, startIndex).forEach(this.remove, this);
data.slice(endIndex, data.length).forEach(this.remove, this);
// Re-calculate the endIndex since the data array has changed,
// then remove items from endIndex to the end of the array
const newEndIndex = endIndex - startIndex + 1;
data.slice(newEndIndex, data.length).forEach(this.remove, this);
this.updateSeriesData(data);
this.resetStats();
} else {

View File

@ -142,7 +142,7 @@ export default class TelemetryTableConfiguration extends EventEmitter {
getAllHeaders() {
let flattenedColumns = _.flatten(Object.values(this.columns));
/* eslint-disable you-dont-need-lodash-underscore/uniq */
let headers = _.uniq(flattenedColumns, false, (column) => column.getKey()).reduce(
let headers = _.uniqBy(flattenedColumns, (column) => column.getKey()).reduce(
fromColumnsToHeadersMap,
{}
);