34
34
{{ $t('simulator.panel_body.timing_diagram.units') }}
35
35
<span id =" timing-diagram-log" ></span >
36
36
</div >
37
- <div id =" plot" ref = " plotRef " >
37
+ <div id =" plot" :style = " { width: plotWidth + 'px', height: plotHeight + 'px' } " >
38
38
<canvas id =" plotArea" ></canvas >
39
39
</div >
40
40
</div >
@@ -48,6 +48,7 @@ import { timingDiagramButtonActions } from '#/simulator/src/plotArea'
48
48
import TimingDiagramButtons from ' ./TimingDiagramButtons.vue'
49
49
import buttonsJSON from ' #/assets/constants/Panels/TimingDiagramPanel/buttons.json'
50
50
import PanelHeader from ' ../Shared/PanelHeader.vue'
51
+ import { sh } from ' #/simulator/src/plotArea.js'
51
52
52
53
interface TimingDiagramButton {
53
54
title: string
@@ -66,25 +67,22 @@ const plotArea: PlotArea = _plotArea
66
67
const buttons = ref <TimingDiagramButton []>(buttonsJSON )
67
68
const plotRef = ref <HTMLElement | null >(null )
68
69
const cycleUnits = ref (1000 )
70
+ const plotWidth = ref (sh (560 ));
71
+ const plotHeight = ref (sh (20 ));
69
72
70
73
function handleButtonClick(button : string ) {
71
74
if (button === ' smaller' ) {
72
- if (plotRef .value ) {
73
- plotRef .value .style .width = ` ${Math .max (
74
- plotRef .value .offsetWidth - 20 ,
75
- 560
76
- )}px `
77
- }
78
- plotArea .resize ()
75
+ plotWidth .value = Math .max (plotWidth .value - sh (20 ), sh (560 ));
76
+ plotArea .resize ();
79
77
} else if (button === ' larger' ) {
80
- if (plotRef .value ) {
81
- plotRef .value .style .width = ` ${plotRef .value .offsetWidth + 20 }px `
82
- }
78
+ plotWidth .value += sh (20 );
83
79
plotArea .resize ()
84
80
} else if (button === ' smallHeight' ) {
85
- timingDiagramButtonActions .smallHeight ()
81
+ plotHeight .value = Math .max (plotHeight .value - sh (20 ), sh (20 ));
82
+ plotArea .resize ()
86
83
} else if (button === ' largeHeight' ) {
87
- timingDiagramButtonActions .largeHeight ()
84
+ plotHeight .value = Math .min (plotHeight .value + sh (20 ), sh (100 ));
85
+ plotArea .resize ()
88
86
} else {
89
87
plotArea [button ]()
90
88
}
0 commit comments