Add preferences support to DougalGraphArraysIJScatter

This commit is contained in:
D. Berge
2021-09-28 18:10:08 +02:00
parent 026cfb6f98
commit 04c0369923

View File

@@ -51,7 +51,7 @@ import unpack from '@/lib/unpack.js';
export default { export default {
name: 'DougalGraphArraysIJScatter', name: 'DougalGraphArraysIJScatter',
props: [ "data" ], props: [ "data", "settings" ],
data () { data () {
return { return {
@@ -72,8 +72,6 @@ export default {
watch: { watch: {
data (newVal, oldVal) { data (newVal, oldVal) {
console.log("scatter data changed");
if (newVal === null) { if (newVal === null) {
this.busy = true; this.busy = true;
} else { } else {
@@ -82,15 +80,21 @@ export default {
} }
}, },
settings () {
for (const key in this.settings) {
this[key] = this.settings[key];
}
},
histogram () { histogram () {
this.plot(); this.plot();
this.saveUserPreference([`${this.$options.name}.histogram`, this.histogram]); this.$emit("update:settings", {[`${this.$options.name}.histogram`]: this.histogram});
}, },
scatterplot () { scatterplot () {
this.plot(); 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 () { async mounted () {
@@ -347,9 +349,6 @@ export default {
this.resizeObserver.observe(this.$refs.graph0); this.resizeObserver.observe(this.$refs.graph0);
this.resizeObserver.observe(this.$refs.graph1); this.resizeObserver.observe(this.$refs.graph1);
this.resizeObserver.observe(this.$refs.graph2); 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 () { beforeDestroy () {