Skip to content

Commit a74e84d

Browse files
authored
Perform createLegend at the same time as areas
Perform createLegend at the same time as areas
1 parent a10d957 commit a74e84d

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

Diff for: examples/advanced/legend_show_hide.html

+6-4
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@
8989
attrs: {
9090
fill: "#2579b5"
9191
},
92-
label: "Between 10 millions and 50 millions inhabitants"
92+
label: "Between 10 millions and 50 millions inhabitants",
93+
clicked: true
9394
},
9495
{
9596
min: 50000000,
@@ -101,8 +102,8 @@
101102
]
102103
},
103104
plot: {
104-
title: "Cities population"
105-
, slices: [
105+
title: "Cities population",
106+
slices: [
106107
{
107108
max: 500000,
108109
attrs: {
@@ -138,7 +139,8 @@
138139
"stroke-width": 1
139140
},
140141
label: "More than 1 million inhabitants",
141-
size: 30
142+
size: 30,
143+
clicked: true
142144
}
143145
]
144146
}

Diff for: examples/basic/legend_SVG_paths.html

+4-3
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
.mapael .zoomOut {
8282
top: 50px;
8383
}
84-
84+
8585
</style>
8686

8787
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js" charset="utf-8"></script>
@@ -124,7 +124,8 @@
124124
height: 30,
125125
attrs: {
126126
fill: "#8AD12C"
127-
}
127+
},
128+
clicked: true
128129
}, {
129130
label: "Value 2",
130131
sliceValue: "Value 2",
@@ -221,4 +222,4 @@ <h1>Map with SVG paths defined through the legend to plot some cities</h1>
221222

222223

223224
</body>
224-
</html>
225+
</html>

Diff for: js/jquery.mapael.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,6 @@
189189
if (self.options.map.width) {
190190
// NOT responsive: map has a fixed width
191191
self.paper.setSize(self.options.map.width, self.mapConf.height * (self.options.map.width / self.mapConf.width));
192-
193-
// Create the legends for plots taking into account the scale of the map
194-
self.createLegends("plot", self.plots, (self.options.map.width / self.mapConf.width));
195192
} else {
196193
// Responsive: handle resizing of the map
197194
self.initResponsiveSize();
@@ -249,6 +246,9 @@
249246
// Create the legends for areas
250247
self.createLegends("area", self.areas, 1);
251248

249+
// Create the legends for plots taking into account the scale of the map
250+
self.createLegends("plot", self.plots, self.paper.width / self.mapConf.width);
251+
252252
// Attach update event
253253
self.$container.on("update." + pluginName, function (e, opt) {
254254
self.onUpdateEvent(e, opt);
@@ -341,7 +341,8 @@
341341
self.paper.setSize(containerWidth, self.mapConf.height * newScale);
342342

343343
// Create plots legend again to take into account the new scale
344-
if (isInit || self.options.legend.redrawOnResize) {
344+
// Do not do this on init (it will be done later)
345+
if (isInit !== true && self.options.legend.redrawOnResize) {
345346
self.createLegends("plot", self.plots, newScale);
346347
}
347348
}

0 commit comments

Comments
 (0)