Fix width of map

This commit is contained in:
2024-03-27 06:07:09 +01:00
parent 5377bdf0a6
commit 0708e91705

View File

@@ -4,8 +4,8 @@ import {
ref, ref,
onMounted, onMounted,
onUnmounted, onUnmounted,
nextTick,
computed, computed,
nextTick,
watch, watch,
} from "vue"; } from "vue";
import Swal from "sweetalert2"; import Swal from "sweetalert2";
@@ -49,18 +49,21 @@ const geoip = ref({});
const rates = ref([]); const rates = ref([]);
const options_items = ref([]); const options_items = ref([]);
const itemCode = ref(null); 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 = { const options = {
region: 150, region: 150,
colorAxis: {colors: ['#0000ff']}, colorAxis: {colors: ['#0000ff']},
backgroundColor: '#81d4fa', backgroundColor: '#81d4fa',
datalessRegionColor: '#f8bbd0', datalessRegionColor: '#f8bbd0',
//defaultColor: '#f5f5f5', //defaultColor: '#f5f5f5',
width: gChartWidth, width: gChartWidth.value,
height: gChartHeight, height: gChartHeight.value,
}; };
const chart_settings = { const chart_settings = {
@@ -380,7 +383,9 @@ const clear_all = () => {
onMounted(fetch); onMounted(fetch);
onMounted(fetch_rates); onMounted(fetch_rates);
onMounted(fetch_ccodes); onMounted(fetch_ccodes);
onMounted(() => {
console.log('HEIGHT MAP', googlemapbox.value);
});
const showRow = async (item) => { const showRow = async (item) => {
console.log("ITEM=", item); console.log("ITEM=", item);
@@ -396,6 +401,10 @@ const showRow = async (item) => {
products.value = response.data.products; products.value = response.data.products;
countryHash.value = response.data.countryHash; countryHash.value = response.data.countryHash;
console.log("TEST=", response.data); console.log("TEST=", response.data);
nextTick(() => {
options.width=googlemapbox.value.clientWidth;
googlemapchart.value += 1;
})
} catch (e) { } catch (e) {
const response = await Swal.fire({ const response = await Swal.fire({
title: __("are you want to try again") + "?", title: __("are you want to try again") + "?",
@@ -456,15 +465,16 @@ const selectedRowClassNameFunction = (item) => {
</div> </div>
<div class="flex flex-col start-0 row-start-1"> <div class="flex flex-col start-0 row-start-1">
<div <div ref="googlemapbox"
class="justify-center rounded-md border-black border-8 max-h-[328px]" class="justify-center rounded-md border-black border-8 max-h-[328px]"
> >
<GChart <GChart :key="googlemapchart"
:events="gchartEvents" :events="gchartEvents"
:type="type" :type="type"
:data="chart_coutries" :data="chart_coutries"
:options="options" :options="options"
:settings="chart_settings" :settings="chart_settings"
:resizeDebounce="500"
/> />
</div> </div>