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

Add enabled option to legend #248

Merged
merged 5 commits into from
Jan 27, 2017
Merged

Conversation

parikhshiv
Copy link
Contributor

@parikhshiv parikhshiv commented Jan 4, 2017

This PR is for #236.

As requested in the issue, I've added an enabled option specific to legend, and created a
VisInstanceContainer#setVisibility(<bool>) function to show/hide individual visualizations.

Here is a jsfiddle that illustrates use of both these features - http://jsfiddle.net/q1psy5t3/2/

setVisibility: function (visible) {
var node = this.layer.node();

visible ? $(node).show() : $(node).hide();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't this jquery, which is not a contour dependency? Or have we aliased $ elsewhere?

Copy link
Contributor Author

@parikhshiv parikhshiv Jan 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jquery is a contour dependency. regardless, I could use pure javascript (node.style.display = 'none') or even possibly d3. IMHO, doesn't really matter, as long as it works, which the above jsfiddle proves.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jquery is definitely not a contour dependency - only d3 and lodash are. It's only included in the jsfiddles for the domready hook, and even that may be un-necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we may have different definitions of what contour dependencies are. Regardless, for me, if jquery is available on the global scope, then I don't see the harm in using it.

I guess what I'm trying to say is, I'm not sure what you're trying to say.

Copy link
Contributor

@narenranjit narenranjit Jan 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is with your assumption that jquery is available on the global scope --- Are you saying every project which uses Contour now needs to also have jquery on the global scope? If yes, that's a dependency (and an un-necessary one).

For e.g., see the docs on http://forio.com/contour/documentation.html#quickstart for including contour on a project; that (correctly) has no mention of jquery. If someone just followed the directions on that page to include contour, your code will not work.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This (finally) makes sense. I've replaced the jquery code with javascript in my latest commit - you can see this in action at http://jsfiddle.net/q1psy5t3/3/.

setVisibility: function (visible) {
var node = this.layer.node();

visible ? node.style.display = 'block' : node.style.display = 'none';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

double-checking - will the default display always be block? is there never a case when it's inline/inline-block etc?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe (am fairly certain) it will always be block (since it is an svg element), but I could hunt down some proof if you'd like?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure display will always be block for svg elements (See circle in screenshot of contour dom for e.g.), but if you're sure it will be for this specific case that's good enough

screen shot 2017-01-20 at 2 49 17 pm

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah good point.

But agreed, I think we are okay for this specific case.

@@ -5,6 +5,7 @@
vAlign: 'middle',
hAlign: 'right',
direction: 'vertical',
enabled: true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a reason to change the default? If not i'd recommend leaving the defaults as they were -- otherwise we'd need to go through all the published examples in the gallery and make sure they don't look weird.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This property has been added to the defaults, not changed. Otherwise you would see a red line removing the previous value of this default (something like - enabled: false).

Possible that I may be misinterpreting.

Copy link
Contributor

@narenranjit narenranjit Jan 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nvm, thought contour already had a legend: { enabled property, didn't realize it was just added in this commit. ignore.

Copy link
Contributor

@narenranjit narenranjit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if you double-check the display thing this is good enough to merge.

setVisibility: function (visible) {
var node = this.layer.node();

visible ? node.style.display = 'block' : node.style.display = 'none';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure display will always be block for svg elements (See circle in screenshot of contour dom for e.g.), but if you're sure it will be for this specific case that's good enough

screen shot 2017-01-20 at 2 49 17 pm

@@ -5,6 +5,7 @@
vAlign: 'middle',
hAlign: 'right',
direction: 'vertical',
enabled: true,
Copy link
Contributor

@narenranjit narenranjit Jan 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nvm, thought contour already had a legend: { enabled property, didn't realize it was just added in this commit. ignore.

@parikhshiv parikhshiv dismissed narenranjit’s stale review January 27, 2017 18:20

Discussed all recommended changes.

@parikhshiv
Copy link
Contributor Author

PR ready for merge.

@narenranjit narenranjit merged commit 3f7f2b6 into master Jan 27, 2017
@narenranjit narenranjit deleted the add-enabled-option-to-legend branch January 27, 2017 18:24
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

Successfully merging this pull request may close these issues.

2 participants