Skip to content
Merged
Show file tree
Hide file tree
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
10 changes: 8 additions & 2 deletions src/components/ui/AppChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
ref="chart"
style="overflow: initial;"
:option="opts"
:update-options="{ notMerge: true }"
:init-options="{ renderer: 'canvas' }"
:update-options="updateOptions"
:init-options="initOptions"
autoresize
/>
</div>
Expand Down Expand Up @@ -39,6 +39,12 @@ export default class AppChart extends Vue {
@Ref('chart')
readonly chart!: ECharts

// Stable references so component re-renders don't make vue-echarts dispose/
// re-init the chart or re-apply the options, both of which would wipe the
// imperatively-set dataset and blank the chart.
readonly updateOptions = Object.freeze({ notMerge: true })
readonly initOptions = Object.freeze({ renderer: 'canvas' })

ready = false

@Watch('data')
Expand Down
9 changes: 7 additions & 2 deletions src/components/widgets/bedmesh/BedMeshChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
<e-chart
ref="chart"
:option="opts"
:update-options="{ notMerge: false }"
:init-options="{ renderer: 'canvas' }"
:update-options="updateOptions"
:init-options="initOptions"
autoresize
/>

Expand Down Expand Up @@ -44,6 +44,11 @@ export default class BedMeshChart extends Mixins(BrowserMixin) {
@Ref('chart')
readonly chart!: ECharts

// Stable references so component re-renders don't make vue-echarts dispose/
// re-init the chart, which would reset the 3D camera (rotation/zoom) state.
readonly updateOptions = Object.freeze({ notMerge: false })
readonly initOptions = Object.freeze({ renderer: 'canvas' })

get flatSurface (): boolean {
return this.$typedState.mesh.flatSurface
}
Expand Down
53 changes: 50 additions & 3 deletions src/components/widgets/thermals/ThermalChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,31 @@
ref="chart"
style="overflow: initial;"
:option="options"
:update-options="{ notMerge: true }"
:init-options="{ renderer: 'canvas' }"
:update-options="updateOptions"
:init-options="initOptions"
autoresize
@legendselectchanged="handleLegendSelectChanged"
@legendselected="handleLegendSelectChanged"
@legendunselected="handleLegendSelectChanged"
/>

<div class="chart-options">
<v-tooltip bottom>
<template #activator="{ on, attrs }">
<v-btn
v-bind="attrs"
icon
small
tabindex="-1"
Comment on lines +23 to +27

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving as is for now.

v-on="on"
@click="togglePause"
>
<v-icon>{{ paused ? '$resume' : '$pause' }}</v-icon>
</v-btn>
</template>
<span>{{ paused ? $t('app.general.btn.resume') : $t('app.general.btn.pause') }}</span>
</v-tooltip>
</div>
</div>
</template>

Expand All @@ -34,10 +52,25 @@ export default class ThermalChart extends Mixins(BrowserMixin) {
@Ref('chart')
readonly chart!: ECharts

// Stable references so component re-renders (e.g. toggling pause) don't cause
// vue-echarts to dispose/re-init the chart or re-apply the options, both of
// which would wipe the imperatively-set dataset and blank the chart.
readonly updateOptions = Object.freeze({ notMerge: true })
readonly initOptions = Object.freeze({ renderer: 'canvas' })

loading = false
paused = false
series: LineSeriesOption[] = []
initialSelected: Record<string, boolean> = {}

togglePause () {
this.paused = !this.paused

if (!this.paused) {
this.onDataChange(this.chartData)
}
}

handleLegendSelectChanged (event: { selected: Record<string, boolean> }) {
this.$typedDispatch('charts/saveSelectedLegends', event.selected)

Expand Down Expand Up @@ -73,7 +106,11 @@ export default class ThermalChart extends Mixins(BrowserMixin) {

@Watch('chartData')
onDataChange (data: any) {
if (this.chart && !this.loading) {
if (
this.chart &&
!this.loading &&
!this.paused
) {
this.chart.setOption({
dataset: {
source: data
Expand Down Expand Up @@ -433,6 +470,16 @@ export default class ThermalChart extends Mixins(BrowserMixin) {

<style lang='scss' scoped>
.chart {
position: relative;
width: 100%;
}

.chart-options {
position: absolute;
top: 0;
right: 0;
padding: 2px 0px;
margin-right: 16px;
z-index: 1;
}
</style>