svgmap 2.11.1 → 2.12.2
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/README.md +3 -3
- package/demo/html/index.html +2 -2
- package/demo/react/app/package-lock.json +615 -288
- package/dist/svgMap.js +30 -3
- package/dist/svgMap.min.js +1 -1
- package/gulpfile.js +0 -2
- package/package.json +5 -5
- package/src/js/svgMap.js +30 -3
- package/src/scss/main.scss +2 -3
- package/src/scss/map.scss +2 -0
- package/src/scss/tooltip.scss +2 -0
package/gulpfile.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svgmap",
|
|
3
3
|
"description": "svgMap is a JavaScript library that lets you easily create an interactable world map comparing customizable data for each country.",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.12.2",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "dist/svgMap.min.js",
|
|
@@ -20,14 +20,14 @@
|
|
|
20
20
|
"gulp-concat": "^2.6.1",
|
|
21
21
|
"gulp-header": "^2.0.9",
|
|
22
22
|
"gulp-rename": "^2.0.0",
|
|
23
|
-
"gulp-sass": "^
|
|
23
|
+
"gulp-sass": "^6.0.0",
|
|
24
24
|
"gulp-sourcemaps": "^3.0.0",
|
|
25
25
|
"gulp-uglify": "^3.0.2",
|
|
26
|
-
"jest": "^
|
|
27
|
-
"sass": "^1.
|
|
26
|
+
"jest": "^29.7.0",
|
|
27
|
+
"sass": "^1.83.1"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"svg-pan-zoom": "^3.6.
|
|
30
|
+
"svg-pan-zoom": "^3.6.2"
|
|
31
31
|
},
|
|
32
32
|
"scripts": {
|
|
33
33
|
"watch": "gulp watch",
|
package/src/js/svgMap.js
CHANGED
|
@@ -412,7 +412,7 @@ function svgMapWrapper(svgPanZoom) {
|
|
|
412
412
|
return;
|
|
413
413
|
}
|
|
414
414
|
if (!data.values[countryID]) {
|
|
415
|
-
element.setAttribute('fill', this.options.colorNoData);
|
|
415
|
+
element.setAttribute('fill', this.toHex(this.options.colorNoData));
|
|
416
416
|
return;
|
|
417
417
|
}
|
|
418
418
|
if (typeof data.values[countryID].color != 'undefined') {
|
|
@@ -425,8 +425,8 @@ function svgMapWrapper(svgPanZoom) {
|
|
|
425
425
|
);
|
|
426
426
|
var ratio = Math.max(0, Math.min(1, (value - min) / (max - min)));
|
|
427
427
|
var color = this.getColor(
|
|
428
|
-
this.options.colorMax,
|
|
429
|
-
this.options.colorMin,
|
|
428
|
+
this.toHex(this.options.colorMax),
|
|
429
|
+
this.toHex(this.options.colorMin),
|
|
430
430
|
ratio || ratio === 0 ? ratio : 1
|
|
431
431
|
);
|
|
432
432
|
element.setAttribute('fill', color);
|
|
@@ -2126,6 +2126,33 @@ function svgMapWrapper(svgPanZoom) {
|
|
|
2126
2126
|
return '#' + this.getHex(r) + this.getHex(g) + this.getHex(b);
|
|
2127
2127
|
};
|
|
2128
2128
|
|
|
2129
|
+
/**
|
|
2130
|
+
* convert color to hex to allow users of the map to pass in
|
|
2131
|
+
* colors in formats other than full hex value.
|
|
2132
|
+
* @param color
|
|
2133
|
+
* @param element
|
|
2134
|
+
* @returns {string}
|
|
2135
|
+
*/
|
|
2136
|
+
svgMap.prototype.toHex = function (color, element = document.documentElement) {
|
|
2137
|
+
|
|
2138
|
+
// Resolve CSS variables
|
|
2139
|
+
if (color.startsWith('var(')) {
|
|
2140
|
+
const cssVar = color.slice(4, -1).trim().replaceAll(/["']+/g, '');
|
|
2141
|
+
color = getComputedStyle(element).getPropertyValue(cssVar).trim();
|
|
2142
|
+
}
|
|
2143
|
+
|
|
2144
|
+
// Create an offscreen canvas
|
|
2145
|
+
const canvas = new OffscreenCanvas(1, 1);
|
|
2146
|
+
const ctx = canvas.getContext('2d');
|
|
2147
|
+
|
|
2148
|
+
// Use canvas to parse the color
|
|
2149
|
+
ctx.fillStyle = color;
|
|
2150
|
+
|
|
2151
|
+
// computed color is full hex code in the case of one color only
|
|
2152
|
+
return ctx.fillStyle
|
|
2153
|
+
}
|
|
2154
|
+
|
|
2155
|
+
|
|
2129
2156
|
// Get a hex value
|
|
2130
2157
|
|
|
2131
2158
|
svgMap.prototype.getHex = function (value) {
|
package/src/scss/main.scss
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
@
|
|
2
|
-
@
|
|
3
|
-
@import 'tooltip.scss';
|
|
1
|
+
@use 'map';
|
|
2
|
+
@use 'tooltip';
|
package/src/scss/map.scss
CHANGED