diff --git a/src/components/components/ComponentContainer.vue b/src/components/components/ComponentContainer.vue index f4dc90022..c12d0d479 100644 --- a/src/components/components/ComponentContainer.vue +++ b/src/components/components/ComponentContainer.vue @@ -9,6 +9,7 @@ import { useDialogStore } from "../../store/dialogStore"; import { useContentStore } from "../../store/contentStore"; import ComponentTag from "../utilities/ComponentTag.vue"; +import TagTooltip from "../utilities/TagTooltip.vue"; import { chartTypes } from "../../assets/configs/apexcharts/chartTypes"; const dialogStore = useDialogStore(); @@ -23,6 +24,9 @@ const props = defineProps({ // The default active chart is the first one in the list defined in the dashboard component const activeChart = ref(props.content.chart_config.types[0]); +// stores the location of the mouse when tags are hovered over +const mousePosition = ref({ x: null, y: null }); +const showTagTooltip = ref(false); // Parses time data into display format const dataTime = computed(() => { @@ -54,6 +58,13 @@ const updateFreq = computed(() => { unitRef[props.content.update_freq_unit] }更新`; }); +// The style for the tag tooltip +const tooltipPosition = computed(() => { + return { + left: `${mousePosition.value.x - 40}px`, + top: `${mousePosition.value.y - 110}px`, + }; +}); // Toggles between chart types defined in the dashboard component function changeActiveChart(chartName) { @@ -66,6 +77,15 @@ function toggleFavorite() { contentStore.favoriteComponent(props.content.id); } } +// Updates the location for the tag tooltip +function updateMouseLocation(e) { + mousePosition.value.x = e.pageX; + mousePosition.value.y = e.pageY; +} +// Updates whether to show the tag tooltip +function changeShowTagTooltipState(state) { + showTagTooltip.value = state; +} diff --git a/src/components/components/ComponentMapChart.vue b/src/components/components/ComponentMapChart.vue index e46531c8f..a3643c98c 100644 --- a/src/components/components/ComponentMapChart.vue +++ b/src/components/components/ComponentMapChart.vue @@ -8,6 +8,7 @@ import { ref, computed } from "vue"; import { useMapStore } from "../../store/mapStore"; import { useDialogStore } from "../../store/dialogStore"; +import TagTooltip from "../utilities/TagTooltip.vue"; import { chartTypes } from "../../assets/configs/apexcharts/chartTypes"; const mapStore = useMapStore(); @@ -23,6 +24,9 @@ const props = defineProps({ const activeChart = ref(props.content.chart_config.types[0]); // Stores whether the component is toggled on or not const checked = ref(false); +// stores the location of the mouse when tags are hovered over +const mousePosition = ref({ x: null, y: null }); +const showTagTooltip = ref(false); // Parses time data into display format const dataTime = computed(() => { @@ -52,6 +56,14 @@ const shouldDisable = computed(() => { ); }); +// The style for the tag tooltip +const tooltipPosition = computed(() => { + return { + left: `${mousePosition.value.x - 40}px`, + top: `${mousePosition.value.y - 110}px`, + }; +}); + // Open and closes the component as well as communicates to the mapStore to turn on and off map layers function handleToggle() { if (!props.content.map_config) { @@ -77,6 +89,15 @@ function changeActiveChart(chartName) { `${props.content.map_config[0].index}-${props.content.map_config[0].type}` ); } +// Updates the location for the tag tooltip +function updateMouseLocation(e) { + mousePosition.value.x = e.pageX; + mousePosition.value.y = e.pageY; +} +// Updates whether to show the tag tooltip +function changeShowTagTooltipState(state) { + showTagTooltip.value = state; +} diff --git a/src/components/utilities/ComponentTag.vue b/src/components/utilities/ComponentTag.vue index b7b830e22..ea0d5632e 100644 --- a/src/components/utilities/ComponentTag.vue +++ b/src/components/utilities/ComponentTag.vue @@ -3,10 +3,6 @@ + + + +