Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix plot duplication and purging logic #7939

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/plugins/plot/MctPlot.vue
Original file line number Diff line number Diff line change
@@ -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) {
12 changes: 9 additions & 3 deletions src/plugins/plot/configuration/PlotSeries.js
Original file line number Diff line number Diff line change
@@ -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 {
2 changes: 1 addition & 1 deletion src/plugins/telemetryTable/TelemetryTableConfiguration.js
Original file line number Diff line number Diff line change
@@ -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,
{}
);