Skip to content

Commit 6b28cf8

Browse files
committed
Use zoomed display range when toggling y-axis. Add code comments
1 parent 643549c commit 6b28cf8

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

src/plugins/plot/MctPlot.vue

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -642,11 +642,23 @@ export default {
642642
643643
this.startLoading();
644644
const bounds = this.timeContext.getBounds();
645+
let rangeBounds = {
646+
start: bounds.start,
647+
end: bounds.end
648+
};
649+
// If we have pan/zoom history, load based on the last viewed range instead of time conductor
650+
if (this.plotHistory.length > 0) {
651+
const historyRange = this.plotHistory.slice(-1)[0];
652+
rangeBounds = {
653+
start: historyRange.x.min,
654+
end: historyRange.x.max
655+
};
656+
}
645657
const options = {
646658
size: this.$parent.$refs.plotWrapper.offsetWidth,
647659
domain: this.config.xAxis.get('key'),
648-
start: bounds.start,
649-
end: bounds.end
660+
start: rangeBounds.start,
661+
end: rangeBounds.end
650662
};
651663
652664
series.load(options).then(this.stopLoading.bind(this));

src/plugins/plot/chart/MctChart.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,13 +510,20 @@ export default {
510510
pointSet.reset();
511511
});
512512
},
513+
// This function is designed to establish a relative coordinate system for a data series.
514+
// It defines a specific data point as the new origin (0, 0).
515+
// In the context of plotting large time-series data using relative time,
516+
// this function is a key step in implementing the "Relative Time".
517+
// It shifts the entire series so that one chosen point (offsets) now corresponds to zero on both the X and Y axes.
518+
// Any subsequent data points are then plotted relative to this new origin (x - offsets.x and y - offsets.y)
513519
setOffset(offsetPoint, series) {
514520
const mainYAxisId = this.config.yAxis.get('id');
515521
const yAxisId = series.get('yAxisId') || mainYAxisId;
516522
if (this.offset[yAxisId].x && this.offset[yAxisId].y) {
517523
return;
518524
}
519525
526+
// Set the origin point.
520527
let offsets = {};
521528
offsets.x = series.getXVal(offsetPoint);
522529
offsets.y = series.getYVal(offsetPoint);

0 commit comments

Comments
 (0)