Skip to content

Commit

Permalink
fix: fix tooltip of tempchart (#1715)
Browse files Browse the repository at this point in the history
* fix: fix theme issue in tempchart

Signed-off-by: Stefan Dej <meteyou@gmail.com>

* fix: fix tooltip of tempchart

the tooltip will not go away after 1 second. the chart also will be "stopped" as long as your mouse is hoverd

Signed-off-by: Stefan Dej <meteyou@gmail.com>

* refactor: remove debug outputs

Signed-off-by: Stefan Dej <meteyou@gmail.com>

---------

Signed-off-by: Stefan Dej <meteyou@gmail.com>
  • Loading branch information
meteyou authored Dec 30, 2023
1 parent 74d4a48 commit 6beca12
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/components/charts/TempChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
:init-options="{ renderer: 'svg' }"
:autoresize="true"
:style="tempchartStyle"
class="tempchart" />
class="tempchart"
@mouseenter.native="hoverChart = true"
@mouseleave.native="hoverChart = false" />
</template>

<script lang="ts">
Expand Down Expand Up @@ -34,6 +36,7 @@ export default class TempChart extends Mixins(BaseMixin, ThemeMixin) {
tempchart: any
}
hoverChart = false
private isVisible = true
get chartOptions(): ECBasicOption {
return {
Expand Down Expand Up @@ -69,7 +72,9 @@ export default class TempChart extends Mixins(BaseMixin, ThemeMixin) {
},
yAxis: this.yAxis,
media: this.media,
dataset: { source: this.source },
dataset: {
source: [],
},
series: this.series,
}
}
Expand Down Expand Up @@ -355,8 +360,14 @@ export default class TempChart extends Mixins(BaseMixin, ThemeMixin) {
@Watch('source')
sourceChanged(newVal: PrinterTempHistoryStateSourceEntry[]) {
// break if chart isn't initialized or not visible
if (!this.chart || !this.isVisible) return
// break if the chart isn't initialized or not visible or is hovered
if (!this.chart || !this.isVisible || this.hoverChart) return
this.chart?.setOption({
dataset: {
source: newVal,
},
})
const limitDate = new Date(Date.now() - this.maxHistory * 1000)
let newSource = newVal.filter((entry: PrinterTempHistoryStateSourceEntry) => {
Expand Down

0 comments on commit 6beca12

Please sign in to comment.