Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance feature setLegendElemsState with element type and value selectivity #110

Closed
Indigo744 opened this issue Nov 13, 2015 · 6 comments
Closed

Comments

@Indigo744
Copy link
Collaborator

Enhance feature setLegendElemsState: be able to tell which kind of elements we want to hide or show : 'areas', 'plots' or 'links', and for which interval of values (if the elements are associated to one or more value(s), it has to be compatible with multiple valued elements). For example : "I want to show only the plots which the associated value is between 1000 and 1200) :

{ 'plot' : {'min': 1000, 'max': 1200},  'area' : {'min': 10, 'max': 20}}
{ 'plot' : 'all'} 
{ 'plot' : 'none'}
(...)

It would allow to play with some sliders in order to allow users to select ranges of values for which we want to show the elements.

@Indigo744
Copy link
Collaborator Author

I think there are two different side for this:

First: regarding setLegendElemsState
Right now, it is only possible to show/hide all legends at once.
But there can be multiple legends on a map (example: http://jsfiddle.net/neveldo/VqwUZ/ or http://jsfiddle.net/neveldo/xd2azoxL). Maybe the user want to show/hide all elements of one of these legends?
Hence the setLegendElemsState should be extended to allow the following:

setLegendElemsState = "show"    // will show all legend element (current behavior)
// OR
setLegendElemsState = {
    "areaLegend": "show",        // will show all element in areaLegend
    "plotLegend": "hide",        // will hide all element in plotLegend
    "myLegendClassName": "hide", // will hide all element in myLegendClassName
    ...
},

The user pass the CSS class name of the legend it want to show/hide.

Now, with this out of the way...
Second: regarding setting some range to display (and allow sliders)
Regarding this feature, I think it should not interact with the legend.
I mean that when setting "show only area from X to Y", it should not show/hide legends out of these bounds.
It should be separated from the setLegendElemsState option: this one should be kept to show/hide all legends element at once.
Hence I suggest adding a specific event showElementsInRange which accept an object:

{
    'plot' : {'min': 1000, 'max': 1200}, 
    'area' : {'min': 10, 'max': 20}
}

@neveldo
Copy link
Owner

neveldo commented Nov 16, 2015

Hello,

Thank for your study on this new feature. I agree with you on all the things. However, as in this example : http://jsfiddle.net/neveldo/xd2azoxL/, the elements can be tied to more than one value :

'sf' : {
    latitude: 37.792032,
    longitude: -122.394613,
    tooltip: {content : "San Francisco"},
                    value: [150000, 20]
},

This is why the 'showElementsInRange' option should also accept an object of the form :

{
    'plot' : {'min': 1000, 'max': 1200, 'valueIndex' : 0}, 
    'area' : {'min': 10, 'max': 20, 'valueIndex' : 0}
}

Or maybe :

{
    'plot' : {0 : {'min': 1000, 'max': 1200}}, 
    'area' : {0 : {'min': 10, 'max': 20}}
}

In order to tell which value we want to filter ?

@Indigo744
Copy link
Collaborator Author

I performed a PR for the first part (the easiest, actually ^^).

You are right, I forgot the multiple values.
The second option is preferred, as multiple index can easily be passed.

{
    'plot' : {
        0 : {                        // valueIndex
            'min': 1000,
            'max': 1200
        },
        1 : {                        // valueIndex
            'min': 10,
            'max': 12
        }
    }, 
    'area' : {
        {'min': 10, 'max': 20}    // No valueIndex, only an object, use 0 as valueIndex (easy case)
    }
}

@neveldo
Copy link
Owner

neveldo commented Nov 17, 2015

Thank you, I saw it, nice work ! I just added some little comments.

@Indigo744
Copy link
Collaborator Author

This issue can be closed! 😎

@neveldo
Copy link
Owner

neveldo commented Dec 15, 2015

You are right, thank you for all your great work !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants