99 ref =" chart"
1010 style =" overflow : initial ;"
1111 :option =" options"
12- :update-options =" { notMerge: true } "
13- :init-options =" { renderer: 'canvas' } "
12+ :update-options =" updateOptions "
13+ :init-options =" initOptions "
1414 autoresize
1515 @legendselectchanged =" handleLegendSelectChanged"
1616 @legendselected =" handleLegendSelectChanged"
1717 @legendunselected =" handleLegendSelectChanged"
1818 />
19+
20+ <div class =" chart-options" >
21+ <v-tooltip bottom >
22+ <template #activator =" { on , attrs } " >
23+ <v-btn
24+ v-bind =" attrs"
25+ icon
26+ small
27+ tabindex =" -1"
28+ v-on =" on"
29+ @click =" togglePause"
30+ >
31+ <v-icon >{{ paused ? '$resume' : '$pause' }}</v-icon >
32+ </v-btn >
33+ </template >
34+ <span >{{ paused ? $t('app.general.btn.resume') : $t('app.general.btn.pause') }}</span >
35+ </v-tooltip >
36+ </div >
1937 </div >
2038</template >
2139
@@ -34,10 +52,25 @@ export default class ThermalChart extends Mixins(BrowserMixin) {
3452 @Ref (' chart' )
3553 readonly chart! : ECharts
3654
55+ // Stable references so component re-renders (e.g. toggling pause) don't cause
56+ // vue-echarts to dispose/re-init the chart or re-apply the options, both of
57+ // which would wipe the imperatively-set dataset and blank the chart.
58+ readonly updateOptions = Object .freeze ({ notMerge: true })
59+ readonly initOptions = Object .freeze ({ renderer: ' canvas' })
60+
3761 loading = false
62+ paused = false
3863 series: LineSeriesOption [] = []
3964 initialSelected: Record <string , boolean > = {}
4065
66+ togglePause () {
67+ this .paused = ! this .paused
68+
69+ if (! this .paused ) {
70+ this .onDataChange (this .chartData )
71+ }
72+ }
73+
4174 handleLegendSelectChanged (event : { selected: Record <string , boolean > }) {
4275 this .$typedDispatch (' charts/saveSelectedLegends' , event .selected )
4376
@@ -73,7 +106,11 @@ export default class ThermalChart extends Mixins(BrowserMixin) {
73106
74107 @Watch (' chartData' )
75108 onDataChange (data : any ) {
76- if (this .chart && ! this .loading ) {
109+ if (
110+ this .chart &&
111+ ! this .loading &&
112+ ! this .paused
113+ ) {
77114 this .chart .setOption ({
78115 dataset: {
79116 source: data
@@ -433,6 +470,16 @@ export default class ThermalChart extends Mixins(BrowserMixin) {
433470
434471<style lang='scss' scoped>
435472 .chart {
473+ position : relative ;
436474 width : 100% ;
437475 }
476+
477+ .chart-options {
478+ position : absolute ;
479+ top : 0 ;
480+ right : 0 ;
481+ padding : 2px 0px ;
482+ margin-right : 16px ;
483+ z-index : 1 ;
484+ }
438485 </style >
0 commit comments