svgMap icon indicating copy to clipboard operation
svgMap copied to clipboard

Dynamic data update

Open ud-klee opened this issue 5 years ago • 8 comments
trafficstars

I figured that the applyData() method can be used to update the map data after the map has been rendered, but the tooltips are not aware of the data change. Can it expose the API to rebuild the tooltips, or use custom events to notify the tooltips on model change? Thanks!

ud-klee avatar Mar 30 '20 13:03 ud-klee

Aha! Looks like I also need to update options.data too... kind of hacky though, it'd be nice if there's a public API for this :)

ud-klee avatar Mar 30 '20 14:03 ud-klee

Yeah, the tooltips get the data from the options object. Maybe a new method updateData() would be a good solution.

StephanWagner avatar Apr 08 '20 20:04 StephanWagner

is there any public api methods? how to update map with new data?

xaja avatar May 05 '20 19:05 xaja

At the moment there are none. It's just really what's in the readme or here: https://stephanwagner.me/create-world-map-charts-with-svgmap

It definitely would be a good addition and I hope I'll get around to improve svgmap soon.

StephanWagner avatar May 05 '20 20:05 StephanWagner

Does anyone find a solution for this? I'm assuming it's not being developed anymore.

arelidev avatar Aug 23 '22 21:08 arelidev

Does anyone find a solution for this? I'm assuming it's not being developed anymore.

some thoughts and minimal demo

when you update your map data via computed you change the key with new unique value, that forces component <Svgmap> to rerender with your new data. it is not beautiful, but works

<template>
  <div>
    <Svgmap :data="mapData" :key="componentKeyForceRerender"></Svgmap>
  </div>
</template>
<script>
import Svgmap from "@/components/Svgmap.vue";

export default {
  components: {
    Svgmap
  },
  data() {
    return {
      componentKeyForceRerender: 0
    };
  },
  methods: {
    forceRerender() {
      this.componentKeyForceRerender += 1;
    }
  },
  computed: {
    mapData() {
      const result = "your data for map";
      this.forceRerender();
      return result;
    }
  }
};
</script>

xaja avatar Aug 23 '22 22:08 xaja