Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

Allow user to specify hoverinfo #1

Merged

Conversation

nickmelnikov82
Copy link
Member

app/scripts/fornac.js Outdated Show resolved Hide resolved
Copy link

@HammadTheOne HammadTheOne left a comment

Choose a reason for hiding this comment

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

This looks pretty good, just a couple of points before merging.

I think calling the prop hoverPattern instead of titlePattern might be a more accurate description, and would make a little more sense in this case.

It seems like the default structName key is not set; if I leave the prop unassigned in my component, the hovertext is empty - 3 rather than the base name. Setting the prop to '${name}:${num}' instead does give us the correct hovertext (eg. A - 3).

image

And lastly, I think we should explicitly state in the prop description which keys are accepted for this pattern. If it's the following node properties, we should include a list of them in the prop description and possibly output a warning if unsupported keys are passed to the pattern.

self.nodes = [{ 'name': 'P',
	        'num': 1,
	        'radius': 3 * Math.sqrt(size),
	        'rna': self,
	        'nodeType': 'protein',
	        'structName': structName,
	        'elemType': 'p',
	        'size': size,
	        'uid': generateUUID() }];

@nickmelnikov82
Copy link
Member Author

It seems like the default structName key is not set; if I leave the prop unassigned in my component, the hovertext is empty - 3 rather than the base name. Setting the prop to '${name}:${num}' instead does give us the correct hovertext (eg. A - 3).

By default, we use the 'empty' structName property. So if custom structName isn't passed, the empty:3 hover text is correct.

Show warning if prop key not allowed
@nickmelnikov82 nickmelnikov82 force-pushed the allow-users-to-set-hoverinfo-config branch from 602ca51 to 47a0437 Compare September 23, 2021 15:54
@nickmelnikov82
Copy link
Member Author

@HammadTheOne I've renamed props and added console warning if unsupported keys are passed to the pattern.

@HammadTheOne
Copy link

By default, we use the 'empty' structName property. So if custom structName isn't passed, the empty:3 hover text is correct.

I see, so that way if we have multiple molecule sequences, it will show their structure name's by default on hover. That makes sense.

In that case, can we maybe use a ternary operator to set the default hoverTest, checking to see if structName is passed or not, and if it is not, we can default it to maybe '${nodeType}:${num}' instead?

@nickmelnikov82
Copy link
Member Author

In that case, can we maybe use a ternary operator to set the default hoverTest, checking to see if structName is passed or not, and if it is not, we can default it to maybe '${nodeType}:${num}' instead?

Yes, we can. In this case, we should remove default props from fornactontainer component in dash_bio and implement this functionality in this repo.

@nickmelnikov82
Copy link
Member Author

@HammadTheOne
image

Can you please check my function for getting hoverPattern? Is my understanding correct?

@HammadTheOne
Copy link

@nickmelnikov82 That looks good to me, the only change I would make is changing name in the defaultPattern to nodeType instead.

Copy link

@HammadTheOne HammadTheOne left a comment

Choose a reason for hiding this comment

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

💃

Tested it out, and the hoverPattern default works like we described. Fantastic!

@nickmelnikov82
Copy link
Member Author

@HammadTheOne so, can we merge this PR?

@HammadTheOne HammadTheOne merged commit 794ebd4 into plotly:master Sep 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants