jvectormap-rails 1.0.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -1
- data/README.md +9 -4
- data/Rakefile +8 -8
- data/jvectormap-rails.gemspec +7 -7
- data/lib/jvectormap-rails.rb +2 -10
- data/lib/jvectormap/rails/engine.rb +11 -2
- data/lib/jvectormap/rails/version.rb +3 -5
- data/tasks/jvectormap.rake +6 -3
- data/vendor/assets/javascripts/jvectormap.js +32 -25
- data/vendor/assets/javascripts/jvectormap/jquery-jvectormap.js +5 -6
- data/vendor/assets/javascripts/jvectormap/lib/jquery-mousewheel.js +201 -0
- data/vendor/assets/javascripts/jvectormap/maps/africa_merc.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/africa_mill.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/ar_merc.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/ar_mill.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/asia_merc.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/asia_mill.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/at_merc.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/at_mill.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/au_merc.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/au_mill.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/be_merc.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/be_mill.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/ca_lcc.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/ca_merc.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/ca_mill.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/ch_merc.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/ch_mill.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/cn_merc.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/cn_mill.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/co_merc.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/co_mill.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/continents_merc.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/continents_mill.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/de_merc.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/de_mill.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/dk_merc.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/dk_mill.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/es_merc.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/es_mill.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/europe_merc.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/europe_mill.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/fr_merc.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/fr_mill.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/fr_regions_2016_merc.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/fr_regions_2016_mill.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/fr_regions_merc.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/fr_regions_mill.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/in_merc.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/in_mill.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/it_merc.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/it_mill.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/it_regions_merc.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/it_regions_mill.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/kr_merc.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/kr_mill.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/nl_merc.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/nl_mill.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/no_merc.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/no_mill.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/north_america_merc.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/north_america_mill.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/nz_merc.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/nz_mill.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/oceania_merc.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/oceania_mill.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/pl_merc.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/pl_mill.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/pt_merc.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/pt_mill.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/ru_fd_merc.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/ru_fd_mill.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/ru_merc.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/ru_mill.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/se_merc.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/se_mill.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/south_america_merc.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/south_america_mill.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/th_merc.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/th_mill.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/uk_countries_merc.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/uk_countries_mill.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/uk_regions_merc.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/uk_regions_mill.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/us-il-chicago_merc.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/us-il-chicago_mill.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/us-ny-newyork_merc.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/us-ny-newyork_mill.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/us_aea.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/us_lcc.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/us_merc.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/us_mill.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/ve_merc.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/ve_mill.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/world_merc.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/world_mill.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/za_merc.js +1 -0
- data/vendor/assets/javascripts/jvectormap/maps/za_mill.js +1 -0
- data/vendor/assets/javascripts/jvectormap/{lib → src}/abstract-canvas-element.js +26 -0
- data/vendor/assets/javascripts/jvectormap/{lib → src}/abstract-element.js +0 -0
- data/vendor/assets/javascripts/jvectormap/{lib → src}/abstract-shape-element.js +1 -24
- data/vendor/assets/javascripts/jvectormap/{lib → src}/color-scale.js +0 -0
- data/vendor/assets/javascripts/jvectormap/{lib → src}/data-series.js +36 -17
- data/vendor/assets/javascripts/jvectormap/src/jvectormap.js +185 -0
- data/vendor/assets/javascripts/jvectormap/src/legend.js +83 -0
- data/vendor/assets/javascripts/jvectormap/src/map-object.js +73 -0
- data/vendor/assets/javascripts/jvectormap/{lib/world-map.js → src/map.js} +357 -148
- data/vendor/assets/javascripts/jvectormap/src/marker.js +76 -0
- data/vendor/assets/javascripts/jvectormap/src/multimap.js +139 -0
- data/vendor/assets/javascripts/jvectormap/{lib → src}/numeric-scale.js +41 -3
- data/vendor/assets/javascripts/jvectormap/src/ordinal-scale.js +21 -0
- data/vendor/assets/javascripts/jvectormap/{lib → src}/proj.js +0 -0
- data/vendor/assets/javascripts/jvectormap/src/region.js +45 -0
- data/vendor/assets/javascripts/jvectormap/{lib → src}/simple-scale.js +0 -0
- data/vendor/assets/javascripts/jvectormap/{lib → src}/svg-canvas-element.js +4 -0
- data/vendor/assets/javascripts/jvectormap/{lib → src}/svg-circle-element.js +0 -0
- data/vendor/assets/javascripts/jvectormap/{lib → src}/svg-element.js +0 -0
- data/vendor/assets/javascripts/jvectormap/{lib → src}/svg-group-element.js +0 -0
- data/vendor/assets/javascripts/jvectormap/src/svg-image-element.js +36 -0
- data/vendor/assets/javascripts/jvectormap/{lib → src}/svg-path-element.js +0 -0
- data/vendor/assets/javascripts/jvectormap/src/svg-shape-element.js +49 -0
- data/vendor/assets/javascripts/jvectormap/src/svg-text-element.js +13 -0
- data/vendor/assets/javascripts/jvectormap/{lib → src}/vector-canvas.js +2 -0
- data/vendor/assets/javascripts/jvectormap/{lib → src}/vml-canvas-element.js +0 -0
- data/vendor/assets/javascripts/jvectormap/{lib → src}/vml-circle-element.js +0 -0
- data/vendor/assets/javascripts/jvectormap/{lib → src}/vml-element.js +1 -0
- data/vendor/assets/javascripts/jvectormap/{lib → src}/vml-group-element.js +0 -0
- data/vendor/assets/javascripts/jvectormap/src/vml-image-element.js +47 -0
- data/vendor/assets/javascripts/jvectormap/{lib → src}/vml-path-element.js +1 -14
- data/vendor/assets/javascripts/jvectormap/{lib → src}/vml-shape-element.js +0 -0
- data/vendor/assets/stylesheets/jvectormap.css +107 -9
- metadata +127 -103
- data/History.txt +0 -7
- data/lib/jvectormap/rails/railtie.rb +0 -17
- data/vendor/assets/javascripts/jvectormap/jquery-mousewheel.js +0 -84
- data/vendor/assets/javascripts/jvectormap/lib/jvectormap.js +0 -99
- data/vendor/assets/javascripts/jvectormap/lib/ordinal-scale.js +0 -7
- data/vendor/assets/javascripts/jvectormap/lib/svg-shape-element.js +0 -7
- data/vendor/assets/javascripts/jvectormap/maps/ar_merc_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/ar_mill_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/at_merc_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/at_mill_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/au_merc_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/au_mill_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/be_merc_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/be_mill_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/ca_lcc_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/ca_merc_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/ca_mill_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/ch_merc_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/ch_mill_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/cn_merc_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/cn_mill_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/co_merc_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/co_mill_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/de_merc_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/de_mill_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/dk_merc_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/dk_mill_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/es_merc_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/es_mill_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/europe_merc_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/europe_mill_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/fr_merc_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/fr_mill_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/in_merc_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/in_mill_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/it_merc_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/it_mill_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/nl_merc_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/nl_mill_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/no_merc_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/no_mill_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/nz_merc_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/nz_mill_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/ph_regions_merc_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/ph_regions_mill_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/pl_merc_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/pl_mill_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/pt_merc_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/pt_mill_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/se_merc_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/se_mill_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/th_merc_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/th_mill_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/th_regions_merc_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/th_regions_mill_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/uk_merc_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/uk_mill_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/us-il-chicago_mill_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/us-ny-newyork_mill_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/us_aea_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/us_lcc_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/us_merc_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/us_mill_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/ve_merc_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/ve_mill_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/world_merc_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/world_mill_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/za_merc_en.js +0 -1
- data/vendor/assets/javascripts/jvectormap/maps/za_mill_en.js +0 -1
@@ -0,0 +1,76 @@
|
|
1
|
+
jvm.Marker = function(config){
|
2
|
+
var text,
|
3
|
+
offsets;
|
4
|
+
|
5
|
+
this.config = config;
|
6
|
+
this.map = this.config.map;
|
7
|
+
|
8
|
+
this.isImage = !!this.config.style.initial.image;
|
9
|
+
this.createShape();
|
10
|
+
|
11
|
+
text = this.getLabelText(config.index);
|
12
|
+
if (this.config.label && text) {
|
13
|
+
this.offsets = this.getLabelOffsets(config.index);
|
14
|
+
this.labelX = config.cx / this.map.scale - this.map.transX;
|
15
|
+
this.labelY = config.cy / this.map.scale - this.map.transY;
|
16
|
+
this.label = config.canvas.addText({
|
17
|
+
text: text,
|
18
|
+
'data-index': config.index,
|
19
|
+
dy: "0.6ex",
|
20
|
+
x: this.labelX,
|
21
|
+
y: this.labelY
|
22
|
+
}, config.labelStyle, config.labelsGroup);
|
23
|
+
|
24
|
+
this.label.addClass('jvectormap-marker jvectormap-element');
|
25
|
+
}
|
26
|
+
};
|
27
|
+
|
28
|
+
jvm.inherits(jvm.Marker, jvm.MapObject);
|
29
|
+
|
30
|
+
jvm.Marker.prototype.createShape = function(){
|
31
|
+
var that = this;
|
32
|
+
|
33
|
+
if (this.shape) {
|
34
|
+
this.shape.remove();
|
35
|
+
}
|
36
|
+
this.shape = this.config.canvas[this.isImage ? 'addImage' : 'addCircle']({
|
37
|
+
"data-index": this.config.index,
|
38
|
+
cx: this.config.cx,
|
39
|
+
cy: this.config.cy
|
40
|
+
}, this.config.style, this.config.group);
|
41
|
+
|
42
|
+
this.shape.addClass('jvectormap-marker jvectormap-element');
|
43
|
+
|
44
|
+
if (this.isImage) {
|
45
|
+
jvm.$(this.shape.node).on('imageloaded', function(){
|
46
|
+
that.updateLabelPosition();
|
47
|
+
});
|
48
|
+
}
|
49
|
+
};
|
50
|
+
|
51
|
+
jvm.Marker.prototype.updateLabelPosition = function(){
|
52
|
+
if (this.label) {
|
53
|
+
this.label.set({
|
54
|
+
x: this.labelX * this.map.scale + this.offsets[0] +
|
55
|
+
this.map.transX * this.map.scale + 5 + (this.isImage ? (this.shape.width || 0) / 2 : this.shape.properties.r),
|
56
|
+
y: this.labelY * this.map.scale + this.map.transY * this.map.scale + this.offsets[1]
|
57
|
+
});
|
58
|
+
}
|
59
|
+
};
|
60
|
+
|
61
|
+
jvm.Marker.prototype.setStyle = function(property, value){
|
62
|
+
var isImage;
|
63
|
+
|
64
|
+
jvm.Marker.parentClass.prototype.setStyle.apply(this, arguments);
|
65
|
+
|
66
|
+
if (property === 'r') {
|
67
|
+
this.updateLabelPosition();
|
68
|
+
}
|
69
|
+
|
70
|
+
isImage = !!this.shape.get('image');
|
71
|
+
if (isImage != this.isImage) {
|
72
|
+
this.isImage = isImage;
|
73
|
+
this.config.style = jvm.$.extend(true, {}, this.shape.style);
|
74
|
+
this.createShape();
|
75
|
+
}
|
76
|
+
};
|
@@ -0,0 +1,139 @@
|
|
1
|
+
/**
|
2
|
+
* Creates map with drill-down functionality.
|
3
|
+
* @constructor
|
4
|
+
* @param {Object} params Parameters to initialize map with.
|
5
|
+
* @param {Number} params.maxLevel Maximum number of levels user can go through
|
6
|
+
* @param {Object} params.main Config of the main map. See <a href="./jvm-map/">jvm.Map</a> for more information.
|
7
|
+
* @param {Function} params.mapNameByCode Function go generate map name by region code. Default value is:
|
8
|
+
<pre>
|
9
|
+
function(code, multiMap) {
|
10
|
+
return code.toLowerCase()+'_'+
|
11
|
+
multiMap.defaultProjection+'_en';
|
12
|
+
}
|
13
|
+
</pre>
|
14
|
+
* @param {Function} params.mapUrlByCode Function to generate map url by region code. Default value is:
|
15
|
+
<pre>
|
16
|
+
function(code, multiMap){
|
17
|
+
return 'jquery-jvectormap-data-'+
|
18
|
+
code.toLowerCase()+'-'+
|
19
|
+
multiMap.defaultProjection+'-en.js';
|
20
|
+
}
|
21
|
+
</pre>
|
22
|
+
*/
|
23
|
+
jvm.MultiMap = function(params) {
|
24
|
+
var that = this;
|
25
|
+
|
26
|
+
this.maps = {};
|
27
|
+
this.params = jvm.$.extend(true, {}, jvm.MultiMap.defaultParams, params);
|
28
|
+
this.params.maxLevel = this.params.maxLevel || Number.MAX_VALUE;
|
29
|
+
this.params.main = this.params.main || {};
|
30
|
+
this.params.main.multiMapLevel = 0;
|
31
|
+
this.history = [ this.addMap(this.params.main.map, this.params.main) ];
|
32
|
+
this.defaultProjection = this.history[0].mapData.projection.type;
|
33
|
+
this.mapsLoaded = {};
|
34
|
+
|
35
|
+
this.params.container.css({position: 'relative'});
|
36
|
+
this.backButton = jvm.$('<div/>').addClass('jvectormap-goback').text('Back').appendTo(this.params.container);
|
37
|
+
this.backButton.hide();
|
38
|
+
this.backButton.click(function(){
|
39
|
+
that.goBack();
|
40
|
+
});
|
41
|
+
|
42
|
+
this.spinner = jvm.$('<div/>').addClass('jvectormap-spinner').appendTo(this.params.container);
|
43
|
+
this.spinner.hide();
|
44
|
+
};
|
45
|
+
|
46
|
+
jvm.MultiMap.prototype = {
|
47
|
+
addMap: function(name, config){
|
48
|
+
var cnt = jvm.$('<div/>').css({
|
49
|
+
width: '100%',
|
50
|
+
height: '100%'
|
51
|
+
});
|
52
|
+
|
53
|
+
this.params.container.append(cnt);
|
54
|
+
|
55
|
+
this.maps[name] = new jvm.Map(jvm.$.extend(config, {container: cnt}));
|
56
|
+
if (this.params.maxLevel > config.multiMapLevel) {
|
57
|
+
this.maps[name].container.on('regionClick.jvectormap', {scope: this}, function(e, code){
|
58
|
+
var multimap = e.data.scope,
|
59
|
+
mapName = multimap.params.mapNameByCode(code, multimap);
|
60
|
+
|
61
|
+
if (!multimap.drillDownPromise || multimap.drillDownPromise.state() !== 'pending') {
|
62
|
+
multimap.drillDown(mapName, code);
|
63
|
+
}
|
64
|
+
});
|
65
|
+
}
|
66
|
+
|
67
|
+
|
68
|
+
return this.maps[name];
|
69
|
+
},
|
70
|
+
|
71
|
+
downloadMap: function(code){
|
72
|
+
var that = this,
|
73
|
+
deferred = jvm.$.Deferred();
|
74
|
+
|
75
|
+
if (!this.mapsLoaded[code]) {
|
76
|
+
jvm.$.get(this.params.mapUrlByCode(code, this)).then(function(){
|
77
|
+
that.mapsLoaded[code] = true;
|
78
|
+
deferred.resolve();
|
79
|
+
}, function(){
|
80
|
+
deferred.reject();
|
81
|
+
});
|
82
|
+
} else {
|
83
|
+
deferred.resolve();
|
84
|
+
}
|
85
|
+
return deferred;
|
86
|
+
},
|
87
|
+
|
88
|
+
drillDown: function(name, code){
|
89
|
+
var currentMap = this.history[this.history.length - 1],
|
90
|
+
that = this,
|
91
|
+
focusPromise = currentMap.setFocus({region: code, animate: true}),
|
92
|
+
downloadPromise = this.downloadMap(code);
|
93
|
+
|
94
|
+
focusPromise.then(function(){
|
95
|
+
if (downloadPromise.state() === 'pending') {
|
96
|
+
that.spinner.show();
|
97
|
+
}
|
98
|
+
});
|
99
|
+
downloadPromise.always(function(){
|
100
|
+
that.spinner.hide();
|
101
|
+
});
|
102
|
+
this.drillDownPromise = jvm.$.when(downloadPromise, focusPromise);
|
103
|
+
this.drillDownPromise.then(function(){
|
104
|
+
currentMap.params.container.hide();
|
105
|
+
if (!that.maps[name]) {
|
106
|
+
that.addMap(name, {map: name, multiMapLevel: currentMap.params.multiMapLevel + 1});
|
107
|
+
} else {
|
108
|
+
that.maps[name].params.container.show();
|
109
|
+
}
|
110
|
+
that.history.push( that.maps[name] );
|
111
|
+
that.backButton.show();
|
112
|
+
});
|
113
|
+
},
|
114
|
+
|
115
|
+
goBack: function(){
|
116
|
+
var currentMap = this.history.pop(),
|
117
|
+
prevMap = this.history[this.history.length - 1],
|
118
|
+
that = this;
|
119
|
+
|
120
|
+
currentMap.setFocus({scale: 1, x: 0.5, y: 0.5, animate: true}).then(function(){
|
121
|
+
currentMap.params.container.hide();
|
122
|
+
prevMap.params.container.show();
|
123
|
+
prevMap.updateSize();
|
124
|
+
if (that.history.length === 1) {
|
125
|
+
that.backButton.hide();
|
126
|
+
}
|
127
|
+
prevMap.setFocus({scale: 1, x: 0.5, y: 0.5, animate: true});
|
128
|
+
});
|
129
|
+
}
|
130
|
+
};
|
131
|
+
|
132
|
+
jvm.MultiMap.defaultParams = {
|
133
|
+
mapNameByCode: function(code, multiMap){
|
134
|
+
return code.toLowerCase()+'_'+multiMap.defaultProjection+'_en';
|
135
|
+
},
|
136
|
+
mapUrlByCode: function(code, multiMap){
|
137
|
+
return 'jquery-jvectormap-data-'+code.toLowerCase()+'-'+multiMap.defaultProjection+'-en.js';
|
138
|
+
}
|
139
|
+
}
|
@@ -5,8 +5,8 @@ jvm.NumericScale = function(scale, normalizeFunction, minValue, maxValue) {
|
|
5
5
|
|
6
6
|
if (scale) this.setScale(scale);
|
7
7
|
if (normalizeFunction) this.setNormalizeFunction(normalizeFunction);
|
8
|
-
if (minValue) this.setMin(minValue);
|
9
|
-
if (maxValue) this.setMax(maxValue);
|
8
|
+
if (typeof minValue !== 'undefined' ) this.setMin(minValue);
|
9
|
+
if (typeof maxValue !== 'undefined' ) this.setMax(maxValue);
|
10
10
|
};
|
11
11
|
|
12
12
|
jvm.NumericScale.prototype = {
|
@@ -31,6 +31,7 @@ jvm.NumericScale.prototype = {
|
|
31
31
|
setScale: function(scale) {
|
32
32
|
var i;
|
33
33
|
|
34
|
+
this.scale = [];
|
34
35
|
for (i = 0; i < scale.length; i++) {
|
35
36
|
this.scale[i] = [scale[i]];
|
36
37
|
}
|
@@ -143,5 +144,42 @@ jvm.NumericScale.prototype = {
|
|
143
144
|
result += vector[i] * vector[i];
|
144
145
|
}
|
145
146
|
return Math.sqrt(result);
|
147
|
+
},
|
148
|
+
|
149
|
+
/* Derived from d3 implementation https://github.com/mbostock/d3/blob/master/src/scale/linear.js#L94 */
|
150
|
+
getTicks: function(){
|
151
|
+
var m = 5,
|
152
|
+
extent = [this.clearMinValue, this.clearMaxValue],
|
153
|
+
span = extent[1] - extent[0],
|
154
|
+
step = Math.pow(10, Math.floor(Math.log(span / m) / Math.LN10)),
|
155
|
+
err = m / span * step,
|
156
|
+
ticks = [],
|
157
|
+
tick,
|
158
|
+
v;
|
159
|
+
|
160
|
+
if (err <= .15) step *= 10;
|
161
|
+
else if (err <= .35) step *= 5;
|
162
|
+
else if (err <= .75) step *= 2;
|
163
|
+
|
164
|
+
extent[0] = Math.floor(extent[0] / step) * step;
|
165
|
+
extent[1] = Math.ceil(extent[1] / step) * step;
|
166
|
+
|
167
|
+
tick = extent[0];
|
168
|
+
while (tick <= extent[1]) {
|
169
|
+
if (tick == extent[0]) {
|
170
|
+
v = this.clearMinValue;
|
171
|
+
} else if (tick == extent[1]) {
|
172
|
+
v = this.clearMaxValue;
|
173
|
+
} else {
|
174
|
+
v = tick;
|
175
|
+
}
|
176
|
+
ticks.push({
|
177
|
+
label: tick,
|
178
|
+
value: this.getValue(v)
|
179
|
+
});
|
180
|
+
tick += step;
|
181
|
+
}
|
182
|
+
|
183
|
+
return ticks;
|
146
184
|
}
|
147
|
-
};
|
185
|
+
};
|
@@ -0,0 +1,21 @@
|
|
1
|
+
jvm.OrdinalScale = function(scale){
|
2
|
+
this.scale = scale;
|
3
|
+
};
|
4
|
+
|
5
|
+
jvm.OrdinalScale.prototype.getValue = function(value){
|
6
|
+
return this.scale[value];
|
7
|
+
};
|
8
|
+
|
9
|
+
jvm.OrdinalScale.prototype.getTicks = function(){
|
10
|
+
var ticks = [],
|
11
|
+
key;
|
12
|
+
|
13
|
+
for (key in this.scale) {
|
14
|
+
ticks.push({
|
15
|
+
label: key,
|
16
|
+
value: this.scale[key]
|
17
|
+
});
|
18
|
+
}
|
19
|
+
|
20
|
+
return ticks;
|
21
|
+
};
|
File without changes
|
@@ -0,0 +1,45 @@
|
|
1
|
+
jvm.Region = function(config){
|
2
|
+
var bbox,
|
3
|
+
text,
|
4
|
+
offsets,
|
5
|
+
labelDx,
|
6
|
+
labelDy;
|
7
|
+
|
8
|
+
this.config = config;
|
9
|
+
this.map = this.config.map;
|
10
|
+
|
11
|
+
this.shape = config.canvas.addPath({
|
12
|
+
d: config.path,
|
13
|
+
'data-code': config.code
|
14
|
+
}, config.style, config.canvas.rootElement);
|
15
|
+
this.shape.addClass('jvectormap-region jvectormap-element');
|
16
|
+
|
17
|
+
bbox = this.shape.getBBox();
|
18
|
+
|
19
|
+
text = this.getLabelText(config.code);
|
20
|
+
if (this.config.label && text) {
|
21
|
+
offsets = this.getLabelOffsets(config.code);
|
22
|
+
this.labelX = bbox.x + bbox.width / 2 + offsets[0];
|
23
|
+
this.labelY = bbox.y + bbox.height / 2 + offsets[1];
|
24
|
+
this.label = config.canvas.addText({
|
25
|
+
text: text,
|
26
|
+
'text-anchor': 'middle',
|
27
|
+
'alignment-baseline': 'central',
|
28
|
+
x: this.labelX,
|
29
|
+
y: this.labelY,
|
30
|
+
'data-code': config.code
|
31
|
+
}, config.labelStyle, config.labelsGroup);
|
32
|
+
this.label.addClass('jvectormap-region jvectormap-element');
|
33
|
+
}
|
34
|
+
};
|
35
|
+
|
36
|
+
jvm.inherits(jvm.Region, jvm.MapObject);
|
37
|
+
|
38
|
+
jvm.Region.prototype.updateLabelPosition = function(){
|
39
|
+
if (this.label) {
|
40
|
+
this.label.set({
|
41
|
+
x: this.labelX * this.map.scale + this.map.transX * this.map.scale,
|
42
|
+
y: this.labelY * this.map.scale + this.map.transY * this.map.scale
|
43
|
+
});
|
44
|
+
}
|
45
|
+
};
|
File without changes
|
@@ -1,6 +1,10 @@
|
|
1
1
|
jvm.SVGCanvasElement = function(container, width, height){
|
2
2
|
this.classPrefix = 'SVG';
|
3
3
|
jvm.SVGCanvasElement.parentClass.call(this, 'svg');
|
4
|
+
|
5
|
+
this.defsElement = new jvm.SVGElement('defs');
|
6
|
+
this.node.appendChild( this.defsElement.node );
|
7
|
+
|
4
8
|
jvm.AbstractCanvasElement.apply(this, arguments);
|
5
9
|
}
|
6
10
|
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,36 @@
|
|
1
|
+
jvm.SVGImageElement = function(config, style){
|
2
|
+
jvm.SVGImageElement.parentClass.call(this, 'image', config, style);
|
3
|
+
};
|
4
|
+
|
5
|
+
jvm.inherits(jvm.SVGImageElement, jvm.SVGShapeElement);
|
6
|
+
|
7
|
+
jvm.SVGImageElement.prototype.applyAttr = function(attr, value){
|
8
|
+
var that = this;
|
9
|
+
|
10
|
+
if (attr == 'image') {
|
11
|
+
jvm.whenImageLoaded(value).then(function(img){
|
12
|
+
that.node.setAttributeNS('http://www.w3.org/1999/xlink', 'href', value);
|
13
|
+
that.width = img[0].width;
|
14
|
+
that.height = img[0].height;
|
15
|
+
that.applyAttr('width', that.width);
|
16
|
+
that.applyAttr('height', that.height);
|
17
|
+
|
18
|
+
that.applyAttr('x', that.cx - that.width / 2);
|
19
|
+
that.applyAttr('y', that.cy - that.height / 2);
|
20
|
+
|
21
|
+
jvm.$(that.node).trigger('imageloaded', [img]);
|
22
|
+
});
|
23
|
+
} else if(attr == 'cx') {
|
24
|
+
this.cx = value;
|
25
|
+
if (this.width) {
|
26
|
+
this.applyAttr('x', value - this.width / 2);
|
27
|
+
}
|
28
|
+
} else if(attr == 'cy') {
|
29
|
+
this.cy = value;
|
30
|
+
if (this.height) {
|
31
|
+
this.applyAttr('y', value - this.height / 2);
|
32
|
+
}
|
33
|
+
} else {
|
34
|
+
jvm.SVGImageElement.parentClass.prototype.applyAttr.apply(this, arguments);
|
35
|
+
}
|
36
|
+
};
|
File without changes
|
@@ -0,0 +1,49 @@
|
|
1
|
+
jvm.SVGShapeElement = function(name, config, style){
|
2
|
+
jvm.SVGShapeElement.parentClass.call(this, name, config);
|
3
|
+
jvm.AbstractShapeElement.apply(this, arguments);
|
4
|
+
};
|
5
|
+
|
6
|
+
jvm.inherits(jvm.SVGShapeElement, jvm.SVGElement);
|
7
|
+
jvm.mixin(jvm.SVGShapeElement, jvm.AbstractShapeElement);
|
8
|
+
|
9
|
+
jvm.SVGShapeElement.prototype.applyAttr = function(attr, value){
|
10
|
+
var patternEl,
|
11
|
+
imageEl,
|
12
|
+
that = this;
|
13
|
+
|
14
|
+
if (attr === 'fill' && jvm.isImageUrl(value)) {
|
15
|
+
if (!jvm.SVGShapeElement.images[value]) {
|
16
|
+
jvm.whenImageLoaded(value).then(function(img){
|
17
|
+
imageEl = new jvm.SVGElement('image');
|
18
|
+
imageEl.node.setAttributeNS('http://www.w3.org/1999/xlink', 'href', value);
|
19
|
+
imageEl.applyAttr('x', '0');
|
20
|
+
imageEl.applyAttr('y', '0');
|
21
|
+
imageEl.applyAttr('width', img[0].width);
|
22
|
+
imageEl.applyAttr('height', img[0].height);
|
23
|
+
|
24
|
+
patternEl = new jvm.SVGElement('pattern');
|
25
|
+
patternEl.applyAttr('id', 'image'+jvm.SVGShapeElement.imageCounter);
|
26
|
+
patternEl.applyAttr('x', 0);
|
27
|
+
patternEl.applyAttr('y', 0);
|
28
|
+
patternEl.applyAttr('width', img[0].width / 2);
|
29
|
+
patternEl.applyAttr('height', img[0].height / 2);
|
30
|
+
patternEl.applyAttr('viewBox', '0 0 '+img[0].width+' '+img[0].height);
|
31
|
+
patternEl.applyAttr('patternUnits', 'userSpaceOnUse');
|
32
|
+
patternEl.node.appendChild( imageEl.node );
|
33
|
+
|
34
|
+
that.canvas.defsElement.node.appendChild( patternEl.node );
|
35
|
+
|
36
|
+
jvm.SVGShapeElement.images[value] = jvm.SVGShapeElement.imageCounter++;
|
37
|
+
|
38
|
+
that.applyAttr('fill', 'url(#image'+jvm.SVGShapeElement.images[value]+')');
|
39
|
+
});
|
40
|
+
} else {
|
41
|
+
this.applyAttr('fill', 'url(#image'+jvm.SVGShapeElement.images[value]+')');
|
42
|
+
}
|
43
|
+
} else {
|
44
|
+
jvm.SVGShapeElement.parentClass.prototype.applyAttr.apply(this, arguments);
|
45
|
+
}
|
46
|
+
};
|
47
|
+
|
48
|
+
jvm.SVGShapeElement.imageCounter = 1;
|
49
|
+
jvm.SVGShapeElement.images = {};
|