From 04c036992302d9434ded1133edd31e2c0e8808f0 Mon Sep 17 00:00:00 2001 From: "D. Berge" Date: Tue, 28 Sep 2021 18:10:08 +0200 Subject: [PATCH] Add preferences support to DougalGraphArraysIJScatter --- .../components/graph-arrays-ij-scatter.vue | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/www/client/source/src/components/graph-arrays-ij-scatter.vue b/lib/www/client/source/src/components/graph-arrays-ij-scatter.vue index b4435fb..82a1298 100644 --- a/lib/www/client/source/src/components/graph-arrays-ij-scatter.vue +++ b/lib/www/client/source/src/components/graph-arrays-ij-scatter.vue @@ -51,7 +51,7 @@ import unpack from '@/lib/unpack.js'; export default { name: 'DougalGraphArraysIJScatter', - props: [ "data" ], + props: [ "data", "settings" ], data () { return { @@ -72,8 +72,6 @@ export default { watch: { data (newVal, oldVal) { - console.log("scatter data changed"); - if (newVal === null) { this.busy = true; } else { @@ -82,15 +80,21 @@ export default { } }, + settings () { + for (const key in this.settings) { + this[key] = this.settings[key]; + } + }, + histogram () { this.plot(); - this.saveUserPreference([`${this.$options.name}.histogram`, this.histogram]); + this.$emit("update:settings", {[`${this.$options.name}.histogram`]: this.histogram}); }, scatterplot () { this.plot(); - this.saveUserPreference([`${this.$options.name}.scatterplot`, this.scatterplot]); + this.$emit("update:settings", {[`${this.$options.name}.scatterplot`]: this.scatterplot}); } }, @@ -331,8 +335,6 @@ export default { }); }, - ...mapActions(["loadUserPreference", "saveUserPreference"]) - }, async mounted () { @@ -347,9 +349,6 @@ export default { this.resizeObserver.observe(this.$refs.graph0); this.resizeObserver.observe(this.$refs.graph1); this.resizeObserver.observe(this.$refs.graph2); - - this.histogram = await this.loadUserPreference([`${this.$options.name}.histogram`, false]); - this.scatterplot = await this.loadUserPreference([`${this.$options.name}.scatterplot`, false]); }, beforeDestroy () {