diff --git a/src/components/chart/EffectScatter.vue b/src/components/chart/EffectScatter.vue index 3893e4e..2ac30af 100644 --- a/src/components/chart/EffectScatter.vue +++ b/src/components/chart/EffectScatter.vue @@ -10,7 +10,7 @@ const props = defineProps({ svg: Object, getCoordinate: { type: Function, - default: null + default: null, }, }); @@ -22,7 +22,7 @@ async function updateSvg(svg, option) { if (!chart.value && dom.value && svg) { init(); } else { - clear() + clear(); } axios.get(svg.path).then(({ data }) => { echarts.registerMap(svg.full_name, { svg: data }); @@ -30,24 +30,33 @@ async function updateSvg(svg, option) { if (props.getCoordinate) { chart.value.getZr().on("click", function (params) { var pixelPoint = [params.offsetX, params.offsetY]; - var dataPoint = chart.value.convertFromPixel({ geoIndex: 0 }, pixelPoint); + var dataPoint = chart.value.convertFromPixel( + { geoIndex: 0 }, + pixelPoint + ); currentClickPosition.value = dataPoint; props.getCoordinate(dataPoint); + const updatedData = option.series.data + .filter( + (point) => !(point.itemStyle && point.itemStyle.color === "#0000FF") + ) + .concat({ + value: dataPoint, // 當前座標值 + itemStyle: { color: "#0000FF" }, // 設為藍色 + }); chart.value.setOption({ series: { - data: [dataPoint], + data: updatedData, }, }); - }); } - }); console.log("updateSvg", svg.path); } function clear() { - chart.value.clear() + chart.value.clear(); } function init() { diff --git a/src/components/customUI/Menu.vue b/src/components/customUI/Menu.vue index 157fae1..054a6a3 100644 --- a/src/components/customUI/Menu.vue +++ b/src/components/customUI/Menu.vue @@ -21,7 +21,7 @@ const props = defineProps({ /> -
+
{{ item.name }}