Skip to content
This repository has been archived by the owner on Jul 29, 2019. It is now read-only.

fix: Network edges dashes isArray comparison, for inheritied styling options. #3975

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

travomic
Copy link

This fixes being able to declare a default edge dash-array via: edges.dashes in the options.

Something in the guts of the option values converts arrays into array-like objects, that do not pass the Array.isArray comparison. The change in this pull-request loosens the comparison to ensure that the dashes property exists, and has .length.

@@ -110,7 +110,9 @@ class EdgeBase {
_drawDashedLine(ctx, values, viaNode, fromPoint, toPoint) { // eslint-disable-line no-unused-vars
ctx.lineCap = 'round';
let pattern = [5,5];
if (Array.isArray(values.dashes) === true) {
Copy link
Author

Choose a reason for hiding this comment

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

This comparison is ONLY truthy from direct edge object property values. The inherited values from the options.edges property, somehow get converted into an array-like object, that Array.isArray does not recognize, and as shown below, when using JSON.stringify to inspect values.dashes it spits out an empty object.

screen shot 2018-05-21 at 12 40 37 pm

@austinkelleher
Copy link

I am also seeing this issue. Can we please get this merged @yotamberk @mojoaxel?

@micahstubbs
Copy link

micahstubbs commented Sep 3, 2018

@travomic thanks for the contribution, this looks nice. can you provide an example of this improvement in action or point us to an existing example that demonstrates the new behavior?

https://github.com/almende/vis/tree/master/examples/network

@austinkelleher would be cool to see an example from you as well, if you have minimal example of this handy 😄

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

Successfully merging this pull request may close these issues.

5 participants