Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions docs/network/nodes.html
Original file line number Diff line number Diff line change
Expand Up @@ -1113,6 +1113,22 @@ <h3>Options</h3>
<td><code>50</code></td>
<td>The size of the icon.</td>
</tr>
<tr parent="icon" class="hidden">
<td class="indent">icon.inheritSize</td>
<td>Boolean</td>
<td><code>false</code></td>
<td>
When <code>true</code>, inherit <code>size</code> from
<code>node.size</code>. Takes precedence over
<code>icon.size</code>. <br /><i
>Note: This flag exists to preserve the original behavior of
icons. If using groups to set icons, you may want to set this to
<code>true</code>
so you can drive icon size without overwriting the group icon
object.
</i>
</td>
</tr>
<tr parent="icon" class="hidden">
<td class="indent">icon.color</td>
<td>String</td>
Expand Down
4 changes: 2 additions & 2 deletions lib/network/modules/NodesHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class NodesHandler {
icon: {
face: "FontAwesome", //'FontAwesome',
code: undefined, //'\uf007',
size: 50, //50,
size: undefined, //set to 50 in NodeBase to allow inheriting Node.size,
color: "#2B7CE9", //'#aa00ff'
},
image: undefined, // --> URL
Expand Down Expand Up @@ -142,7 +142,7 @@ class NodesHandler {
useBorderWithImage: false, // only for image shape
coordinateOrigin: "center", // only for image and circularImage shapes
},
size: 25,
size: undefined, // set to 25 in NodeBase to allow icon to inherit size,
title: undefined,
value: undefined,
x: undefined,
Expand Down
8 changes: 8 additions & 0 deletions lib/network/modules/components/nodes/util/NodeBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ class NodeBase {
* @param {object} options
*/
setOptions(options) {
if (options.icon) {
if (options.icon.inheritSize) {
options.icon.size = options.size || 50;
} else {
options.icon.size = options.icon.size || 50;
}
}
options.size = options.size || 25;
this.options = options;
}

Expand Down
1 change: 1 addition & 0 deletions lib/network/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ const nodeOptions: OptionsConfig = {
face: { string },
code: { string }, //'\uf007',
size: { number }, //50,
inheritSize: { boolean: bool },
color: { string },
weight: { string, number },
__type__: { object },
Expand Down
1 change: 1 addition & 0 deletions types/network/Network.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,7 @@ export interface NodeOptions {
size?: number, // 50,
color?: string,
weight?: number | string,
inheritSize?: boolean,
};

image?: string | Image;
Expand Down