From 0708e91705fb8483c7f08eb17f198a90942c63f1 Mon Sep 17 00:00:00 2001 From: Jaroslav Drzik Date: Wed, 27 Mar 2024 06:07:09 +0100 Subject: [PATCH] Fix width of map --- resources/js/Pages/IkeaRoot.vue | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/resources/js/Pages/IkeaRoot.vue b/resources/js/Pages/IkeaRoot.vue index 6e7c9d7..22e4df2 100644 --- a/resources/js/Pages/IkeaRoot.vue +++ b/resources/js/Pages/IkeaRoot.vue @@ -4,8 +4,8 @@ import { ref, onMounted, onUnmounted, - nextTick, computed, + nextTick, watch, } from "vue"; import Swal from "sweetalert2"; @@ -49,18 +49,21 @@ const geoip = ref({}); const rates = ref([]); const options_items = ref([]); const itemCode = ref(null); +const googlemapbox = ref(null); +const googlemapchart = ref(null); + +const gChartWidth = computed(() => screenWidth.value > 420 ? 400 : (screenWidth.value - 12 - 5)); +const gChartHeight = computed(() => gChartWidth.value == 400 ? 250 : (screenWidth.value *65/100) - 20); +console.log('GCH',screenWidth.value, screenHeight.value, gChartWidth.value,gChartHeight.value); -const gChartWidth = screenWidth.value > 420 ? 400 : (screenWidth.value - 12 - 5); -const gChartHeight = gChartWidth == 400 ? 250 : (screenWidth.value *65/100) - 20; -console.log('GCH',screenWidth.value, screenHeight.value, gChartWidth,gChartHeight); const options = { region: 150, colorAxis: {colors: ['#0000ff']}, backgroundColor: '#81d4fa', datalessRegionColor: '#f8bbd0', //defaultColor: '#f5f5f5', - width: gChartWidth, - height: gChartHeight, + width: gChartWidth.value, + height: gChartHeight.value, }; const chart_settings = { @@ -380,7 +383,9 @@ const clear_all = () => { onMounted(fetch); onMounted(fetch_rates); onMounted(fetch_ccodes); - +onMounted(() => { + console.log('HEIGHT MAP', googlemapbox.value); +}); const showRow = async (item) => { console.log("ITEM=", item); @@ -396,6 +401,10 @@ const showRow = async (item) => { products.value = response.data.products; countryHash.value = response.data.countryHash; console.log("TEST=", response.data); + nextTick(() => { + options.width=googlemapbox.value.clientWidth; + googlemapchart.value += 1; + }) } catch (e) { const response = await Swal.fire({ title: __("are you want to try again") + "?", @@ -456,15 +465,16 @@ const selectedRowClassNameFunction = (item) => {
-
-