@tekkare/auriga 0.2.140 → 0.2.142
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/module.json +1 -1
- package/dist/runtime/components/argMapsJapan.vue +265 -0
- package/dist/runtime/components/argMapsJapan.vue.d.ts +111 -0
- package/dist/runtime/components/argMapsNewZealand.vue +232 -0
- package/dist/runtime/components/argMapsNewZealand.vue.d.ts +101 -0
- package/dist/runtime/components/argMapsPoland.vue +232 -0
- package/dist/runtime/components/argMapsPoland.vue.d.ts +101 -0
- package/dist/runtime/components/argMenuItem.vue +8 -7
- package/dist/runtime/components/maps/interfaces.d.ts +138 -0
- package/dist/runtime/components/maps/interfaces.mjs +142 -0
- package/dist/runtime/components/maps/regionsPathJp.json +284 -0
- package/dist/runtime/components/maps/regionsPathNz.json +62 -0
- package/dist/runtime/components/maps/regionsPathPl.json +50 -0
- package/dist/runtime/components/oneRegionJp.vue +62 -0
- package/dist/runtime/components/oneRegionJp.vue.d.ts +54 -0
- package/dist/runtime/components/oneRegionNz.vue +62 -0
- package/dist/runtime/components/oneRegionNz.vue.d.ts +54 -0
- package/dist/runtime/components/oneRegionPl.vue +62 -0
- package/dist/runtime/components/oneRegionPl.vue.d.ts +54 -0
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
class="oip_table_card map_card-container"
|
|
4
|
+
:id="`container_map-${title}-${uniqueID}`"
|
|
5
|
+
>
|
|
6
|
+
<div class="p-24">
|
|
7
|
+
<slot name="customTitle" v-if="haveCustomTitle" />
|
|
8
|
+
<div v-else class="oip_subtitle">
|
|
9
|
+
{{ title ? title : "Your map title" }}
|
|
10
|
+
</div>
|
|
11
|
+
<ArgSourceContainer v-if="source !== null" @click="openSource">
|
|
12
|
+
{{ source ? source : "Your source" }}
|
|
13
|
+
</ArgSourceContainer>
|
|
14
|
+
</div>
|
|
15
|
+
<div
|
|
16
|
+
v-if="hoveredRegion !== null"
|
|
17
|
+
:id="`tooltip_map-${title}`"
|
|
18
|
+
class="tooltip_container"
|
|
19
|
+
:style="{
|
|
20
|
+
top: tooltipPosition.y + 'px',
|
|
21
|
+
left: tooltipPosition.x + 'px',
|
|
22
|
+
width: tooltipPosition.width + 'px',
|
|
23
|
+
}"
|
|
24
|
+
>
|
|
25
|
+
<div class="tooltip">
|
|
26
|
+
<p class="card_title">{{ hoveredRegion }}</p>
|
|
27
|
+
<div class="card_text">
|
|
28
|
+
<slot
|
|
29
|
+
name="Tooltip"
|
|
30
|
+
v-bind:value="{
|
|
31
|
+
name: hoveredRegion,
|
|
32
|
+
value: data.find((x) => x.name == hoveredRegion)?.value,
|
|
33
|
+
}"
|
|
34
|
+
/>
|
|
35
|
+
</div>
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
<div class="p24">
|
|
39
|
+
<svg
|
|
40
|
+
v-if="lang === 'jp'"
|
|
41
|
+
class="map"
|
|
42
|
+
width="auto"
|
|
43
|
+
height="500"
|
|
44
|
+
viewBox="0 0 400 550"
|
|
45
|
+
fill="none"
|
|
46
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
47
|
+
>
|
|
48
|
+
<OneRegionJp
|
|
49
|
+
v-for="reg in RegionsJpJp"
|
|
50
|
+
:key="reg"
|
|
51
|
+
:data="{
|
|
52
|
+
color: getColor(data.find((x) => x.name == reg)?.value),
|
|
53
|
+
value: data.find((x) => x.name == reg)?.value,
|
|
54
|
+
}"
|
|
55
|
+
:current-region="reg"
|
|
56
|
+
:title="title"
|
|
57
|
+
:hoveredRegion="hoveredRegion"
|
|
58
|
+
@hover="handleHover(reg)"
|
|
59
|
+
@mouseleave="handleMouseLeave"
|
|
60
|
+
/>
|
|
61
|
+
</svg>
|
|
62
|
+
<svg
|
|
63
|
+
v-else
|
|
64
|
+
class="map"
|
|
65
|
+
width="auto"
|
|
66
|
+
height="500"
|
|
67
|
+
viewBox="0 0 400 550"
|
|
68
|
+
fill="none"
|
|
69
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
70
|
+
>
|
|
71
|
+
<oneRegionJp
|
|
72
|
+
v-for="region in RegionsJp"
|
|
73
|
+
:key="region"
|
|
74
|
+
:data="{
|
|
75
|
+
color: getColor(data.find((x) => x.name == region)?.value),
|
|
76
|
+
value: data.find((x) => x.name == region)?.value,
|
|
77
|
+
}"
|
|
78
|
+
:current-region="region"
|
|
79
|
+
:title="title"
|
|
80
|
+
:hoveredRegion="hoveredRegion"
|
|
81
|
+
@hover="handleHover(region)"
|
|
82
|
+
@mouseleave="handleMouseLeave"
|
|
83
|
+
/>
|
|
84
|
+
</svg>
|
|
85
|
+
<div class="legend">
|
|
86
|
+
<div :class="reverseColors ? 'reverse_scale' : 'scale'" />
|
|
87
|
+
<div class="legend-text">
|
|
88
|
+
<p v-for="value in scale" :key="value">
|
|
89
|
+
{{ Math.ceil(value)?.toLocaleString("fr-FR") }}
|
|
90
|
+
</p>
|
|
91
|
+
</div>
|
|
92
|
+
</div>
|
|
93
|
+
</div>
|
|
94
|
+
<slot name="Subcontent" />
|
|
95
|
+
</div>
|
|
96
|
+
</template>
|
|
97
|
+
|
|
98
|
+
<script>
|
|
99
|
+
import { onMounted, ref, watch, defineComponent, nextTick } from "vue";
|
|
100
|
+
import { RegionsJpJp, RegionsJp } from "./maps/interfaces";
|
|
101
|
+
import oneRegionJp from "./oneRegionJp.vue";
|
|
102
|
+
import ArgSourceContainer from "./argSourceContainer.vue";
|
|
103
|
+
export default defineComponent({
|
|
104
|
+
name: "argMapsJapan",
|
|
105
|
+
components: { oneRegionJp, ArgSourceContainer },
|
|
106
|
+
props: {
|
|
107
|
+
data: {
|
|
108
|
+
type: Array,
|
|
109
|
+
default: null,
|
|
110
|
+
required: true
|
|
111
|
+
},
|
|
112
|
+
title: {
|
|
113
|
+
type: [String, null],
|
|
114
|
+
default: null,
|
|
115
|
+
required: false
|
|
116
|
+
},
|
|
117
|
+
source: {
|
|
118
|
+
type: [String, null],
|
|
119
|
+
default: null
|
|
120
|
+
},
|
|
121
|
+
haveCustomTitle: {
|
|
122
|
+
type: [String, null],
|
|
123
|
+
default: null,
|
|
124
|
+
required: false
|
|
125
|
+
},
|
|
126
|
+
uniqueID: {
|
|
127
|
+
type: [String, null],
|
|
128
|
+
default: null,
|
|
129
|
+
required: false
|
|
130
|
+
},
|
|
131
|
+
lang: {
|
|
132
|
+
type: String,
|
|
133
|
+
default: "en",
|
|
134
|
+
required: false
|
|
135
|
+
},
|
|
136
|
+
reverseColors: {
|
|
137
|
+
type: Boolean,
|
|
138
|
+
default: false
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
emits: ["openSource"],
|
|
142
|
+
setup(props, { emit }) {
|
|
143
|
+
const minimalValue = ref(null);
|
|
144
|
+
const maximalValue = ref(null);
|
|
145
|
+
const hoveredRegion = ref(null);
|
|
146
|
+
const tooltipPosition = ref({ x: 0, y: 0, width: 0 });
|
|
147
|
+
const scale = ref([]);
|
|
148
|
+
function getColor(value) {
|
|
149
|
+
if (!value) return "var(--lightest)";
|
|
150
|
+
if (props.reverseColors ? value <= scale.value[0] : value >= scale.value[9]) {
|
|
151
|
+
return "#3F1151";
|
|
152
|
+
} else if (props.reverseColors ? value <= scale.value[1] : value >= scale.value[8]) {
|
|
153
|
+
return "#432974";
|
|
154
|
+
} else if (props.reverseColors ? value <= scale.value[2] : value >= scale.value[7]) {
|
|
155
|
+
return "#404A85";
|
|
156
|
+
} else if (props.reverseColors ? value <= scale.value[3] : value >= scale.value[6]) {
|
|
157
|
+
return "#3F668A";
|
|
158
|
+
} else if (props.reverseColors ? value <= scale.value[4] : value >= scale.value[5]) {
|
|
159
|
+
return "#43808C";
|
|
160
|
+
} else if (props.reverseColors ? value <= scale.value[5] : value >= scale.value[4]) {
|
|
161
|
+
return "#4C9C8A";
|
|
162
|
+
} else if (props.reverseColors ? value <= scale.value[6] : value >= scale.value[3]) {
|
|
163
|
+
return "#5FB57E";
|
|
164
|
+
} else if (props.reverseColors ? value <= scale.value[7] : value >= scale.value[2]) {
|
|
165
|
+
return "#85CB68";
|
|
166
|
+
} else if (props.reverseColors ? value <= scale.value[8] : value >= scale.value[1]) {
|
|
167
|
+
return "#BDDD51";
|
|
168
|
+
} else if (props.reverseColors ? value > scale.value[8] : value >= scale.value[0]) {
|
|
169
|
+
return "#F9E855";
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
function handleHover(region) {
|
|
173
|
+
hoveredRegion.value = region;
|
|
174
|
+
}
|
|
175
|
+
function handleMouseLeave() {
|
|
176
|
+
hoveredRegion.value = null;
|
|
177
|
+
}
|
|
178
|
+
function openSource() {
|
|
179
|
+
emit("openSource");
|
|
180
|
+
}
|
|
181
|
+
function setupScale() {
|
|
182
|
+
minimalValue.value = Math.floor(
|
|
183
|
+
Math.min(
|
|
184
|
+
...props.data.filter((f) => f.value !== null).map((x) => x.value)
|
|
185
|
+
)
|
|
186
|
+
);
|
|
187
|
+
maximalValue.value = Math.ceil(
|
|
188
|
+
Math.max(
|
|
189
|
+
...props.data.filter((f) => f.value !== null).map((x) => x.value)
|
|
190
|
+
)
|
|
191
|
+
);
|
|
192
|
+
const step = (maximalValue.value - minimalValue.value) / 10;
|
|
193
|
+
if (minimalValue.value !== null) {
|
|
194
|
+
scale.value = Array.from(
|
|
195
|
+
{ length: 10 },
|
|
196
|
+
(_, i) => (minimalValue.value !== null ? minimalValue.value : 0) + i * step
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
onMounted(() => {
|
|
201
|
+
setupScale();
|
|
202
|
+
});
|
|
203
|
+
watch(
|
|
204
|
+
() => props.data,
|
|
205
|
+
() => {
|
|
206
|
+
setupScale();
|
|
207
|
+
}
|
|
208
|
+
);
|
|
209
|
+
watch(
|
|
210
|
+
() => hoveredRegion.value,
|
|
211
|
+
() => {
|
|
212
|
+
if (hoveredRegion.value) {
|
|
213
|
+
const selectedRegion = document.getElementById(
|
|
214
|
+
`interactiveMap-${props.title}-${hoveredRegion.value}`
|
|
215
|
+
)?.getBoundingClientRect();
|
|
216
|
+
const containerPosition = document.getElementById(`container_map-${props.title}-${props.uniqueID}`)?.getBoundingClientRect();
|
|
217
|
+
if (!selectedRegion || !containerPosition) return;
|
|
218
|
+
tooltipPosition.value = {
|
|
219
|
+
x: selectedRegion?.x - containerPosition?.x,
|
|
220
|
+
y: selectedRegion?.top - containerPosition?.top - 60,
|
|
221
|
+
width: selectedRegion?.width
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
);
|
|
226
|
+
watch(
|
|
227
|
+
() => hoveredRegion.value,
|
|
228
|
+
async () => {
|
|
229
|
+
if (hoveredRegion.value) {
|
|
230
|
+
await nextTick();
|
|
231
|
+
const selectedRegion = document.getElementById(
|
|
232
|
+
`interactiveMap-${props.title}-${hoveredRegion.value}`
|
|
233
|
+
)?.getBoundingClientRect();
|
|
234
|
+
const containerPosition = document.getElementById(`container_map-${props.title}`)?.getBoundingClientRect();
|
|
235
|
+
const tooltipElement = document.getElementById(
|
|
236
|
+
`tooltip_map-${props.title}`
|
|
237
|
+
);
|
|
238
|
+
const tooltipHeight = tooltipElement ? tooltipElement.getBoundingClientRect().height : 60;
|
|
239
|
+
if (!selectedRegion || !containerPosition) return;
|
|
240
|
+
tooltipPosition.value = {
|
|
241
|
+
x: selectedRegion?.x - containerPosition?.x,
|
|
242
|
+
y: selectedRegion?.top - containerPosition?.top - tooltipHeight,
|
|
243
|
+
width: selectedRegion?.width
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
);
|
|
248
|
+
return {
|
|
249
|
+
getColor,
|
|
250
|
+
handleHover,
|
|
251
|
+
handleMouseLeave,
|
|
252
|
+
RegionsJp,
|
|
253
|
+
hoveredRegion,
|
|
254
|
+
tooltipPosition,
|
|
255
|
+
scale,
|
|
256
|
+
openSource,
|
|
257
|
+
RegionsJpJp
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
</script>
|
|
262
|
+
|
|
263
|
+
<style scoped>
|
|
264
|
+
.map{margin-top:24px;width:100%}.p24{padding:24px}.map path{stroke-width:2px;stroke:rgba(0,0,0,.2);max-height:400px;position:relative}.map path:hover{transition:all .2s}.map_card-container{display:flex;flex-direction:column;gap:8px;min-width:400px;position:relative;width:100%}.test{margin-bottom:200px}.tooltip_container{align-items:center;display:flex;flex-direction:column;justify-content:center;left:0;min-width:-moz-fit-content;min-width:fit-content;position:absolute;top:0;z-index:96}.tooltip{background:#fff;border:1px solid var(--light);border-radius:4px;box-shadow:var(--medium-shadow);color:var(--darkest);font-size:12px}.card_title{background-color:var(--light);border-radius:4px 4px 0 0;font-size:14px;font-weight:600;padding:2px 8px;width:calc(100% - 15px)}.card_text{color:var(--dark);font-size:12px;font-weight:400;line-height:160%;padding:8px;width:100%}.legend{display:flex;flex-direction:column;gap:8px;margin:auto;width:50%}.scale{background:linear-gradient(45deg,#3f1151,#432974,#404a85,#3f668a,#43808c,#4c9c8a,#5fb57e,#85cb68,#bddd51,#f9e855);height:10px;transform:rotate(180deg)}.legend-text{align-items:center;color:var(--dark);display:flex;font-size:12px;font-weight:400;justify-content:space-between;line-height:160%}.p-24{padding:0 24px}.reverse_scale{background:linear-gradient(45deg,#f9e855,#bddd51,#85cb68,#5fb57e,#4c9c8a,#43808c,#3f668a,#404a85,#432974,#3f1151);height:10px;transform:rotate(180deg)}
|
|
265
|
+
</style>
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import type { PropType } from "vue";
|
|
2
|
+
import { RegionsJpJp, RegionsJp } from "./maps/interfaces";
|
|
3
|
+
type dataRegion = {
|
|
4
|
+
name: RegionsJp;
|
|
5
|
+
value: number;
|
|
6
|
+
};
|
|
7
|
+
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
8
|
+
data: {
|
|
9
|
+
type: PropType<dataRegion[]>;
|
|
10
|
+
default: null;
|
|
11
|
+
required: true;
|
|
12
|
+
};
|
|
13
|
+
title: {
|
|
14
|
+
type: PropType<string | null>;
|
|
15
|
+
default: null;
|
|
16
|
+
required: false;
|
|
17
|
+
};
|
|
18
|
+
source: {
|
|
19
|
+
type: PropType<string | null>;
|
|
20
|
+
default: null;
|
|
21
|
+
};
|
|
22
|
+
haveCustomTitle: {
|
|
23
|
+
type: PropType<string | null>;
|
|
24
|
+
default: null;
|
|
25
|
+
required: false;
|
|
26
|
+
};
|
|
27
|
+
uniqueID: {
|
|
28
|
+
type: PropType<string | null>;
|
|
29
|
+
default: null;
|
|
30
|
+
required: false;
|
|
31
|
+
};
|
|
32
|
+
lang: {
|
|
33
|
+
type: StringConstructor;
|
|
34
|
+
default: string;
|
|
35
|
+
required: false;
|
|
36
|
+
};
|
|
37
|
+
reverseColors: {
|
|
38
|
+
type: BooleanConstructor;
|
|
39
|
+
default: boolean;
|
|
40
|
+
};
|
|
41
|
+
}>, {
|
|
42
|
+
getColor: (value?: number) => "var(--lightest)" | "#3F1151" | "#432974" | "#404A85" | "#3F668A" | "#43808C" | "#4C9C8A" | "#5FB57E" | "#85CB68" | "#BDDD51" | "#F9E855" | undefined;
|
|
43
|
+
handleHover: (region: RegionsJp) => void;
|
|
44
|
+
handleMouseLeave: () => void;
|
|
45
|
+
RegionsJp: typeof RegionsJp;
|
|
46
|
+
hoveredRegion: import("vue").Ref<RegionsJp | null, RegionsJp | null>;
|
|
47
|
+
tooltipPosition: import("vue").Ref<{
|
|
48
|
+
x: number;
|
|
49
|
+
y: number;
|
|
50
|
+
width: number;
|
|
51
|
+
}, {
|
|
52
|
+
x: number;
|
|
53
|
+
y: number;
|
|
54
|
+
width: number;
|
|
55
|
+
} | {
|
|
56
|
+
x: number;
|
|
57
|
+
y: number;
|
|
58
|
+
width: number;
|
|
59
|
+
}>;
|
|
60
|
+
scale: import("vue").Ref<number[], number[]>;
|
|
61
|
+
openSource: () => void;
|
|
62
|
+
RegionsJpJp: typeof RegionsJpJp;
|
|
63
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "openSource"[], "openSource", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
64
|
+
data: {
|
|
65
|
+
type: PropType<dataRegion[]>;
|
|
66
|
+
default: null;
|
|
67
|
+
required: true;
|
|
68
|
+
};
|
|
69
|
+
title: {
|
|
70
|
+
type: PropType<string | null>;
|
|
71
|
+
default: null;
|
|
72
|
+
required: false;
|
|
73
|
+
};
|
|
74
|
+
source: {
|
|
75
|
+
type: PropType<string | null>;
|
|
76
|
+
default: null;
|
|
77
|
+
};
|
|
78
|
+
haveCustomTitle: {
|
|
79
|
+
type: PropType<string | null>;
|
|
80
|
+
default: null;
|
|
81
|
+
required: false;
|
|
82
|
+
};
|
|
83
|
+
uniqueID: {
|
|
84
|
+
type: PropType<string | null>;
|
|
85
|
+
default: null;
|
|
86
|
+
required: false;
|
|
87
|
+
};
|
|
88
|
+
lang: {
|
|
89
|
+
type: StringConstructor;
|
|
90
|
+
default: string;
|
|
91
|
+
required: false;
|
|
92
|
+
};
|
|
93
|
+
reverseColors: {
|
|
94
|
+
type: BooleanConstructor;
|
|
95
|
+
default: boolean;
|
|
96
|
+
};
|
|
97
|
+
}>> & Readonly<{
|
|
98
|
+
onOpenSource?: ((...args: any[]) => any) | undefined;
|
|
99
|
+
}>, {
|
|
100
|
+
data: dataRegion[];
|
|
101
|
+
lang: string;
|
|
102
|
+
source: string | null;
|
|
103
|
+
title: string | null;
|
|
104
|
+
haveCustomTitle: string | null;
|
|
105
|
+
uniqueID: string | null;
|
|
106
|
+
reverseColors: boolean;
|
|
107
|
+
}, {}, {
|
|
108
|
+
oneRegionJp: any;
|
|
109
|
+
ArgSourceContainer: any;
|
|
110
|
+
}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
111
|
+
export default _default;
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
class="oip_table_card map_card-container"
|
|
4
|
+
:id="`container_map-${title}-${uniqueID}`"
|
|
5
|
+
>
|
|
6
|
+
<div class="p-24">
|
|
7
|
+
<slot name="customTitle" v-if="haveCustomTitle" />
|
|
8
|
+
<div v-else class="oip_subtitle">
|
|
9
|
+
{{ title ? title : "Your map title" }}
|
|
10
|
+
</div>
|
|
11
|
+
<ArgSourceContainer @click="openSource">
|
|
12
|
+
{{ source ? source : "Your source" }}
|
|
13
|
+
</ArgSourceContainer>
|
|
14
|
+
</div>
|
|
15
|
+
<div
|
|
16
|
+
v-if="hoveredRegion !== null"
|
|
17
|
+
:id="`tooltip_map-${title}`"
|
|
18
|
+
class="tooltip_container"
|
|
19
|
+
:style="{
|
|
20
|
+
top: tooltipPosition.y + 'px',
|
|
21
|
+
left: tooltipPosition.x + 'px',
|
|
22
|
+
width: tooltipPosition.width + 'px',
|
|
23
|
+
}"
|
|
24
|
+
>
|
|
25
|
+
<div class="tooltip">
|
|
26
|
+
<p class="card_title">{{ hoveredRegion }}</p>
|
|
27
|
+
<div class="card_text">
|
|
28
|
+
<slot
|
|
29
|
+
name="Tooltip"
|
|
30
|
+
v-bind:value="{
|
|
31
|
+
name: hoveredRegion,
|
|
32
|
+
value: data.find((x) => x.name == hoveredRegion)?.value,
|
|
33
|
+
}"
|
|
34
|
+
/>
|
|
35
|
+
</div>
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
<div class="p24">
|
|
39
|
+
<svg
|
|
40
|
+
class="map"
|
|
41
|
+
width="auto"
|
|
42
|
+
height="500"
|
|
43
|
+
viewBox="0 50 1500 2000"
|
|
44
|
+
fill="none"
|
|
45
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
46
|
+
>
|
|
47
|
+
<oneRegionNz
|
|
48
|
+
v-for="region in RegionsNz"
|
|
49
|
+
:key="region"
|
|
50
|
+
:data="{
|
|
51
|
+
color: getColor(data.find((x) => x.name == region)?.value),
|
|
52
|
+
value: data.find((x) => x.name == region)?.value,
|
|
53
|
+
}"
|
|
54
|
+
:current-region="region"
|
|
55
|
+
:title="title"
|
|
56
|
+
:hoveredRegion="hoveredRegion"
|
|
57
|
+
@hover="handleHover(region)"
|
|
58
|
+
@mouseleave="handleMouseLeave"
|
|
59
|
+
/>
|
|
60
|
+
</svg>
|
|
61
|
+
<div class="legend">
|
|
62
|
+
<div class="scale" />
|
|
63
|
+
<div class="legend-text">
|
|
64
|
+
<p v-for="value in scale" :key="value">
|
|
65
|
+
{{ Math.ceil(value)?.toLocaleString("fr-FR") }}
|
|
66
|
+
</p>
|
|
67
|
+
</div>
|
|
68
|
+
</div>
|
|
69
|
+
</div>
|
|
70
|
+
<slot name="Subcontent" />
|
|
71
|
+
</div>
|
|
72
|
+
</template>
|
|
73
|
+
|
|
74
|
+
<script>
|
|
75
|
+
import { onMounted, ref, watch, defineComponent, nextTick } from "vue";
|
|
76
|
+
import { RegionsNz } from "./maps/interfaces";
|
|
77
|
+
import ArgSourceContainer from "./argSourceContainer.vue";
|
|
78
|
+
import oneRegionNz from "./oneRegionNz.vue";
|
|
79
|
+
export default defineComponent({
|
|
80
|
+
name: "argMapsNewZealand",
|
|
81
|
+
components: { oneRegionNz, ArgSourceContainer },
|
|
82
|
+
props: {
|
|
83
|
+
data: {
|
|
84
|
+
type: Array,
|
|
85
|
+
default: null,
|
|
86
|
+
required: true
|
|
87
|
+
},
|
|
88
|
+
title: {
|
|
89
|
+
type: [String, null],
|
|
90
|
+
default: null,
|
|
91
|
+
required: false
|
|
92
|
+
},
|
|
93
|
+
source: {
|
|
94
|
+
type: [String, null],
|
|
95
|
+
default: null
|
|
96
|
+
},
|
|
97
|
+
haveCustomTitle: {
|
|
98
|
+
type: [String, null],
|
|
99
|
+
default: null,
|
|
100
|
+
required: false
|
|
101
|
+
},
|
|
102
|
+
uniqueID: {
|
|
103
|
+
type: [String, null],
|
|
104
|
+
default: null,
|
|
105
|
+
required: false
|
|
106
|
+
},
|
|
107
|
+
lang: {
|
|
108
|
+
type: String,
|
|
109
|
+
default: "en",
|
|
110
|
+
required: false
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
emits: ["openSource"],
|
|
114
|
+
setup(props, { emit }) {
|
|
115
|
+
const minimalValue = ref(null);
|
|
116
|
+
const maximalValue = ref(null);
|
|
117
|
+
const hoveredRegion = ref(null);
|
|
118
|
+
const tooltipPosition = ref({ x: 0, y: 0, width: 0 });
|
|
119
|
+
const scale = ref([]);
|
|
120
|
+
function getColor(value) {
|
|
121
|
+
if (!value) return "var(--lightest)";
|
|
122
|
+
if (value >= scale.value[9]) {
|
|
123
|
+
return "#3F1151";
|
|
124
|
+
} else if (value >= scale.value[8]) {
|
|
125
|
+
return "#432974";
|
|
126
|
+
} else if (value >= scale.value[7]) {
|
|
127
|
+
return "#404A85";
|
|
128
|
+
} else if (value >= scale.value[6]) {
|
|
129
|
+
return "#3F668A";
|
|
130
|
+
} else if (value >= scale.value[5]) {
|
|
131
|
+
return "#43808C";
|
|
132
|
+
} else if (value >= scale.value[4]) {
|
|
133
|
+
return "#4C9C8A";
|
|
134
|
+
} else if (value >= scale.value[3]) {
|
|
135
|
+
return "#5FB57E";
|
|
136
|
+
} else if (value >= scale.value[2]) {
|
|
137
|
+
return "#85CB68";
|
|
138
|
+
} else if (value >= scale.value[1]) {
|
|
139
|
+
return "#BDDD51";
|
|
140
|
+
} else if (value >= scale.value[0]) {
|
|
141
|
+
return "#F9E855";
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
function handleHover(region) {
|
|
145
|
+
hoveredRegion.value = region;
|
|
146
|
+
}
|
|
147
|
+
function handleMouseLeave() {
|
|
148
|
+
hoveredRegion.value = null;
|
|
149
|
+
}
|
|
150
|
+
function openSource() {
|
|
151
|
+
emit("openSource");
|
|
152
|
+
}
|
|
153
|
+
function setupScale() {
|
|
154
|
+
minimalValue.value = Math.floor(
|
|
155
|
+
Math.min(...props.data.map((x) => x.value))
|
|
156
|
+
);
|
|
157
|
+
maximalValue.value = Math.ceil(
|
|
158
|
+
Math.max(...props.data.map((x) => x.value))
|
|
159
|
+
);
|
|
160
|
+
const step = (maximalValue.value - minimalValue.value) / 10;
|
|
161
|
+
if (minimalValue.value !== null) {
|
|
162
|
+
scale.value = Array.from(
|
|
163
|
+
{ length: 10 },
|
|
164
|
+
(_, i) => (minimalValue.value !== null ? minimalValue.value : 0) + i * step
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
onMounted(() => {
|
|
169
|
+
setupScale();
|
|
170
|
+
});
|
|
171
|
+
watch(
|
|
172
|
+
() => props.data,
|
|
173
|
+
() => {
|
|
174
|
+
setupScale();
|
|
175
|
+
}
|
|
176
|
+
);
|
|
177
|
+
watch(
|
|
178
|
+
() => hoveredRegion.value,
|
|
179
|
+
() => {
|
|
180
|
+
if (hoveredRegion.value) {
|
|
181
|
+
const selectedRegion = document.getElementById(
|
|
182
|
+
`interactiveMap-${props.title}-${hoveredRegion.value}`
|
|
183
|
+
)?.getBoundingClientRect();
|
|
184
|
+
const containerPosition = document.getElementById(`container_map-${props.title}-${props.uniqueID}`)?.getBoundingClientRect();
|
|
185
|
+
if (!selectedRegion || !containerPosition) return;
|
|
186
|
+
tooltipPosition.value = {
|
|
187
|
+
x: selectedRegion?.x - containerPosition?.x,
|
|
188
|
+
y: selectedRegion?.top - containerPosition?.top - 60,
|
|
189
|
+
width: selectedRegion?.width
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
);
|
|
194
|
+
watch(
|
|
195
|
+
() => hoveredRegion.value,
|
|
196
|
+
async () => {
|
|
197
|
+
if (hoveredRegion.value) {
|
|
198
|
+
await nextTick();
|
|
199
|
+
const selectedRegion = document.getElementById(
|
|
200
|
+
`interactiveMap-${props.title}-${hoveredRegion.value}`
|
|
201
|
+
)?.getBoundingClientRect();
|
|
202
|
+
const containerPosition = document.getElementById(`container_map-${props.title}`)?.getBoundingClientRect();
|
|
203
|
+
const tooltipElement = document.getElementById(
|
|
204
|
+
`tooltip_map-${props.title}`
|
|
205
|
+
);
|
|
206
|
+
const tooltipHeight = tooltipElement ? tooltipElement.getBoundingClientRect().height : 60;
|
|
207
|
+
if (!selectedRegion || !containerPosition) return;
|
|
208
|
+
tooltipPosition.value = {
|
|
209
|
+
x: selectedRegion?.x - containerPosition?.x,
|
|
210
|
+
y: selectedRegion?.top - containerPosition?.top - tooltipHeight,
|
|
211
|
+
width: selectedRegion?.width
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
);
|
|
216
|
+
return {
|
|
217
|
+
getColor,
|
|
218
|
+
handleHover,
|
|
219
|
+
handleMouseLeave,
|
|
220
|
+
RegionsNz,
|
|
221
|
+
hoveredRegion,
|
|
222
|
+
tooltipPosition,
|
|
223
|
+
scale,
|
|
224
|
+
openSource
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
</script>
|
|
229
|
+
|
|
230
|
+
<style scoped>
|
|
231
|
+
.map{margin-top:24px;width:100%}.p24{padding:24px}.map path{stroke-width:2px;stroke:rgba(0,0,0,.2);max-height:400px;position:relative}.map path:hover{transition:all .2s}.map_card-container{display:flex;flex-direction:column;gap:8px;min-width:400px;position:relative;width:100%}.test{margin-bottom:200px}.tooltip_container{align-items:center;display:flex;flex-direction:column;justify-content:center;left:0;min-width:-moz-fit-content;min-width:fit-content;position:absolute;top:0;z-index:96}.tooltip{background:#fff;border:1px solid var(--light);border-radius:4px;box-shadow:var(--medium-shadow);color:var(--darkest);font-size:12px}.card_title{background-color:var(--light);border-radius:4px 4px 0 0;font-size:14px;font-weight:600;padding:2px 8px;text-transform:capitalize;width:calc(100% - 15px)}.card_text{color:var(--dark);font-size:12px;font-weight:400;line-height:160%;padding:8px;width:100%}.legend{display:flex;flex-direction:column;gap:8px;margin:auto;width:50%}.scale{background:linear-gradient(45deg,#3f1151,#432974,#404a85,#3f668a,#43808c,#4c9c8a,#5fb57e,#85cb68,#bddd51,#f9e855);height:10px;transform:rotate(180deg)}.legend-text{align-items:center;color:var(--dark);display:flex;font-size:12px;font-weight:400;justify-content:space-between;line-height:160%}.p-24{padding:0 24px}
|
|
232
|
+
</style>
|