Skip to content

Commit

Permalink
Fix elements hidding through clicks on legend items when some values …
Browse files Browse the repository at this point in the history
…are straddling two different slices in hideMapElems() function
  • Loading branch information
neveldo committed Jan 18, 2017
1 parent dfaba33 commit 7f38564
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
17 changes: 11 additions & 6 deletions js/jquery.mapael.js
Expand Up @@ -1724,7 +1724,7 @@
self.setHoverOptions(elem, sliceOptions[i].attrs, sliceOptions[i].attrs);
self.setHoverOptions(label, legendOptions.labelAttrs, legendOptions.labelAttrsHover);
self.setHover(elem, label);
self.handleClickOnLegendElem(legendOptions, sliceOptions[i], label, elem, elems, legendIndex);
self.handleClickOnLegendElem(legendOptions, legendOptions.slices[i], label, elem, elems, legendIndex);
}
}
}
Expand All @@ -1748,6 +1748,14 @@
*/
handleClickOnLegendElem: function (legendOptions, sliceOptions, label, elem, elems, legendIndex) {
var self = this;

/**
*
* @param e
* @param hideOtherElems : option used for the 'exclusive' mode to enabled only one item from the legend
* at once
* @param animDuration : used in the 'update' event in order to apply the same animDuration on the legend items
*/
var hideMapElems = function (e, hideOtherElems, animDuration) {
var elemValue = 0;
var hidden = $(label.node).attr('data-hidden');
Expand Down Expand Up @@ -1777,11 +1785,8 @@
elemValue = elems[id].value;
}

if ((sliceOptions.sliceValue !== undefined && elemValue == sliceOptions.sliceValue)
|| ((sliceOptions.sliceValue === undefined)
&& (sliceOptions.min === undefined || elemValue >= sliceOptions.min)
&& (sliceOptions.max === undefined || elemValue <= sliceOptions.max))
) {
// Hide elements whose value matches with the slice of the clicked legend item
if (self.getLegendSlice(elemValue, legendOptions) === sliceOptions) {
(function (id) {
if (hidden === '0') { // we want to hide this element
hiddenBy[legendIndex] = true; // add legendIndex to the data object for later use
Expand Down

0 comments on commit 7f38564

Please sign in to comment.