|
287 | 287 |
|
288 | 288 | handleMapResizing: function () {
|
289 | 289 | var self = this;
|
290 |
| - // Create the legends for plots taking into account the scale of the map |
291 |
| - var createPlotLegend = function () { |
292 |
| - self.createLegends("plot", self.plots, (self.$map.width() / self.mapConf.width)); |
293 |
| - |
294 |
| - self.$map.off("resizeEnd." + pluginName, createPlotLegend); |
295 |
| - }; |
296 | 290 |
|
297 | 291 | // onResizeEvent: call when the window element trigger the resize event
|
298 | 292 | // We create it inside this function (and not in the prototype) in order to have a closure
|
|
309 | 303 | // Attach resize handler
|
310 | 304 | $(window).on("resize." + pluginName, self.onResizeEvent);
|
311 | 305 |
|
| 306 | + // Attach resize end handler, and call it once |
312 | 307 | self.$map.on("resizeEnd." + pluginName, function () {
|
313 | 308 | var containerWidth = self.$map.width();
|
314 | 309 | if (self.paper.width != containerWidth) {
|
315 |
| - self.paper.setSize(containerWidth, self.mapConf.height * (containerWidth / self.mapConf.width)); |
| 310 | + var newScale = containerWidth / self.mapConf.width; |
| 311 | + // Set new size |
| 312 | + self.paper.setSize(containerWidth, self.mapConf.height * newScale); |
| 313 | + // Create plots legend again to take into account the new scale |
| 314 | + self.createLegends("plot", self.plots, newScale); |
316 | 315 | }
|
317 |
| - }).on("resizeEnd." + pluginName, createPlotLegend).trigger("resizeEnd." + pluginName); |
| 316 | + }).trigger("resizeEnd." + pluginName); |
318 | 317 | },
|
319 | 318 |
|
320 | 319 | /*
|
|
1365 | 1364 |
|
1366 | 1365 | $legend = $("." + legendOptions.cssClass, self.$container).empty();
|
1367 | 1366 | legendPaper = new Raphael($legend.get(0));
|
| 1367 | + // Set some data to object |
| 1368 | + $(legendPaper.canvas).attr({"data-type": legendType, "data-index": legendIndex}); |
| 1369 | + |
1368 | 1370 | height = width = 0;
|
1369 | 1371 |
|
1370 | 1372 | // Set the title of the legend
|
|
1542 | 1544 | width = legendOptions.VMLWidth;
|
1543 | 1545 |
|
1544 | 1546 | legendPaper.setSize(width, height);
|
1545 |
| - return legendPaper; |
1546 | 1547 | },
|
1547 | 1548 |
|
1548 | 1549 | /*
|
|
1642 | 1643 | createLegends: function (legendType, elems, scale) {
|
1643 | 1644 | var self = this;
|
1644 | 1645 | var legendsOptions = self.options.legend[legendType];
|
1645 |
| - var legends = []; |
1646 | 1646 |
|
1647 | 1647 | if (!$.isArray(self.options.legend[legendType])) {
|
1648 | 1648 | legendsOptions = [self.options.legend[legendType]];
|
|
1654 | 1654 | throw new Error("The legend class `" + legendsOptions[j].cssClass + "` doesn't exists.");
|
1655 | 1655 | }
|
1656 | 1656 | if (legendsOptions[j].display === true && $.isArray(legendsOptions[j].slices) && legendsOptions[j].slices.length > 0) {
|
1657 |
| - legends.push(self.drawLegend(legendsOptions[j], legendType, elems, scale, j)); |
| 1657 | + self.drawLegend(legendsOptions[j], legendType, elems, scale, j); |
1658 | 1658 | }
|
1659 | 1659 | }
|
1660 |
| - return legends; |
1661 | 1660 | },
|
1662 | 1661 |
|
1663 | 1662 | /*
|
|
0 commit comments