Skip to content

Commit ab741f3

Browse files
authored
Merge pull request #631 from OpenC3/pause_graph
Pause graph when clicking
2 parents df12993 + aa00ad3 commit ab741f3

File tree

3 files changed

+35
-7
lines changed

3 files changed

+35
-7
lines changed

openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-tlmgrapher/src/tools/TlmGrapher/TlmGrapher.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@
128128
@close-graph="() => closeGraph(graph)"
129129
@min-max-graph="() => minMaxGraph(graph)"
130130
@resize="() => resize()"
131+
@pause="() => (state = 'pause')"
132+
@start="() => (state = 'start')"
131133
@click="() => graphSelected(graph)"
132134
@started="graphStarted"
133135
/>

openc3-cosmos-init/plugins/packages/openc3-tool-common/src/components/Graph.vue

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -725,11 +725,23 @@ export default {
725725
// setSeries links graphs so clicking an item to hide it also hides the other graph item
726726
// setSeries: true,
727727
},
728+
bind: {
729+
mouseup: (self, targ, handler) => {
730+
return (e) => {
731+
// Single click while paused will resume the graph
732+
// This makes it possible to resume in TlmViewer widgets
733+
if (this.state === 'pause' && self.select.width === 0) {
734+
this.$emit('start')
735+
}
736+
handler(e)
737+
}
738+
},
739+
},
728740
},
729741
hooks: {
730742
setScale: [
731743
(chart, key) => {
732-
if (key == 'x' && !this.zoomOverview && this.overview) {
744+
if (key === 'x' && !this.zoomOverview && this.overview) {
733745
this.zoomChart = true
734746
let left = Math.round(
735747
this.overview.valToPos(chart.scales.x.min, 'x')
@@ -742,6 +754,14 @@ export default {
742754
}
743755
},
744756
],
757+
setSelect: [
758+
(chart) => {
759+
// Pause the graph while selecting a range to zoom
760+
if (this.state === 'start' && chart.select.width > 0) {
761+
this.$emit('pause')
762+
}
763+
},
764+
],
745765
ready: [
746766
(u) => {
747767
let canvas = u.root.querySelector('.u-over')
@@ -819,6 +839,10 @@ export default {
819839
setSelect: [
820840
(chart) => {
821841
if (!this.zoomChart) {
842+
// Pause the graph while selecting an overview range to zoom
843+
if (this.state === 'start' && chart.select.width > 0) {
844+
this.$emit('pause')
845+
}
822846
this.zoomOverview = true
823847
let min = chart.posToVal(chart.select.left, 'x')
824848
let max = chart.posToVal(
@@ -997,7 +1021,7 @@ export default {
9971021
editGraphClose: function () {
9981022
this.editGraph = false
9991023
if (this.needToUpdate) {
1000-
if (this.subscription === null) {
1024+
if (this.subscription == null) {
10011025
this.startGraph()
10021026
} else {
10031027
// NOTE: removing and adding back to back broke the streaming_api
@@ -1291,7 +1315,7 @@ export default {
12911315
// Draw green limits & operational limits
12921316
ctx.fillStyle = 'rgba(0,255,0,0.15)'
12931317
// If there are no operational limits the interior is all green
1294-
if (this.limitsValues.length == 4) {
1318+
if (this.limitsValues.length === 4) {
12951319
// Determine if we show any green
12961320
if (
12971321
u.scales.y.min < this.limitsValues[2] && // yellowHigh
@@ -1378,7 +1402,7 @@ export default {
13781402
if (typeof rawValue === 'string' || isNaN(rawValue)) {
13791403
return 'NaN'
13801404
} else {
1381-
return rawValue === null ? '--' : rawValue.toFixed(2)
1405+
return rawValue == null ? '--' : rawValue.toFixed(2)
13821406
}
13831407
},
13841408
},
@@ -1469,7 +1493,7 @@ export default {
14691493
for (let i = 0; i < data.length; i++) {
14701494
let time = data[i].__time / 1_000_000_000.0 // Time in seconds
14711495
let length = data[0].length
1472-
if (length == 0 || time > data[0][length - 1]) {
1496+
if (length === 0 || time > data[0][length - 1]) {
14731497
// Nominal case - append new data to end
14741498
for (let j = 0; j < this.data.length; j++) {
14751499
this.data[j].push(null)
@@ -1491,7 +1515,7 @@ export default {
14911515
}
14921516
}
14931517
// If we weren't passed a startTime notify grapher of our start
1494-
if (this.startTime === null) {
1518+
if (this.startTime == null) {
14951519
let newStartTime = this.data[0][0] * 1_000_000_000
14961520
this.$emit('started', newStartTime)
14971521
}
@@ -1503,7 +1527,7 @@ export default {
15031527
set_data_at_index: function (index, time, new_data) {
15041528
this.data[0][index] = time
15051529
for (const [key, value] of Object.entries(new_data)) {
1506-
if (key == 'time') {
1530+
if (key === 'time') {
15071531
continue
15081532
}
15091533
let key_index = this.indexes[key]

openc3-cosmos-init/plugins/packages/openc3-tool-common/src/components/widgets/LinegraphWidget.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
:height="size.height"
3535
:width="size.width"
3636
:style="computedStyle"
37+
@pause="() => (state = 'pause')"
38+
@start="() => (state = 'start')"
3739
hide-system-bar
3840
hide-overview
3941
/>

0 commit comments

Comments
 (0)