Skip to content

Commit 99bcc47

Browse files
author
Xing Han Lu
authored
Merge pull request #26 from plotly/dev
Extensively Updated Docstring for Proptypes
2 parents 15ea6c3 + a75e996 commit 99bcc47

File tree

6 files changed

+333
-104
lines changed

6 files changed

+333
-104
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,5 @@ __pycache__/
3636

3737
*.pyc
3838
.idea
39-
*.iml
39+
*.iml
40+
temp.py

assets/override.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.cytoscape-reference p {
2+
display: inline
3+
}

dash_cytoscape/Cytoscape.py

Lines changed: 141 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -8,43 +8,149 @@ class Cytoscape(Component):
88
99
1010
Keyword arguments:
11-
- id (string; optional): The ID used to identify this component in Dash callbacks
12-
- className (string; optional): Html Class of the component
13-
- style (dict; optional): Add inline styles to the root element
14-
- elements (list; optional): The flat list of Cytoscape elements to be included in the graph, each
15-
represented as non-stringified JSON.
16-
- stylesheet (list; optional): The Cytoscape stylesheet as non-stringified JSON. N.b. the prop key is
17-
stylesheet rather than style, the key used by Cytoscape itself, so as
18-
to not conflict with the HTML style attribute.
19-
- layout (dict; optional): The function of a layout is to set the positions on the nodes in the
20-
graph.
21-
- pan (dict; optional): The initial panning position of the graph. Make sure to disable viewport
22-
manipulation options, such as fit, in your layout so that it is not
23-
overridden when the layout is applied.
24-
- zoom (number; optional): The initial zoom level of the graph. Make sure to disable viewport
25-
manipulation options, such as fit, in your layout so that it is not
26-
overridden when the layout is applied. You can set options.minZoom and
27-
options.maxZoom to set restrictions on the zoom level.
28-
- panningEnabled (boolean; optional): Whether panning the graph is enabled, both by user events and programmatically.
29-
- userPanningEnabled (boolean; optional): Whether user events (e.g. dragging the graph background) are allowed to pan the graph. Programmatic changes to pan are unaffected by this option.
30-
- minZoom (number; optional): A minimum bound on the zoom level of the graph. The viewport can not be scaled smaller than this zoom level.
11+
- id (string; optional): The ID used to identify this component in Dash callbacks.
12+
- className (string; optional): Sets the class name of the element (the value of an element's html
13+
class attribute).
14+
- style (dict; optional): Add inline styles to the root element.
15+
- elements (list; optional): A list of dictionaries representing the elements of the networks.
16+
1. Each dictionary describes an element, and specifies its purpose.
17+
- `group` (string): Either 'nodes' or 'edges'. If not given, it's automatically inferred.
18+
- `data` (dictionary): Element specific data.
19+
- `id` (string): Reference to the element, useful for selectors and edges. Randomly assigned if not given.
20+
- `label` (string): Optional name for the element, useful when `data(label)` is given to a style's `content` or `label`. It is only a convention.
21+
- `parent` (string): Only for nodes. Optional reference to another node. Needed to create compound nodes.
22+
- `source` (string): Only for edges. The id of the source node, which is where the edge starts.
23+
- `target` (string): Only for edges. The id of the target node, where the edge ends.
24+
- `position` (dictionary): Only for nodes. The position of the node.
25+
- `x` (number): The x-coordinate of the node.
26+
- `y` (number): The y-coordinate of the node.
27+
- `selected` (boolean): If the element is selected upon initialisation.
28+
- `selectable` (boolean): If the element can be selected.
29+
- `locked` (boolean): Only for nodes. If the position is immutable.
30+
- `grabbable` (boolean): Only for nodes. If the node can be grabbed and moved by the user.
31+
- `classes` (string): Space separated string of class names of the element. Those classes can be selected by a style selector.
32+
33+
2. The [official Cytoscape.js documentation](http://js.cytoscape.org/#notation/elements-json) offers an extensive overview and examples of element declaration.
34+
- stylesheet (list; optional): A list of dictionaries representing the styles of the elements.
35+
1. Each dictionary requires the following keys:
36+
- `selector` (string): Which elements you are styling. Generally, you select a group of elements (node, edges, both), a class (that you declare in the element dictionary), or an element by ID.
37+
- `style` (dictionary): What aspects of the elements you want to modify. This could be the size or color of a node, the shape of an edge arrow, or many more.
38+
39+
2. Both [the selector string](http://js.cytoscape.org/#selectors) and
40+
[the style dictionary](http://js.cytoscape.org/#style/node-body) are
41+
exhaustively documented in the Cytoscape.js docs. Although methods such
42+
as `cy.elements(...)` and `cy.filter(...)` are not available, the selector
43+
string syntax stays the same.
44+
- layout (dict; optional): A dictionary specifying how to set the position of the elements in your
45+
graph. * The `'name'` key is required, and indicates which layout (algorithm) to
46+
use.
47+
1. The layouts available by default are:
48+
- `random`: Randomly assigns positions
49+
- `preset`: Assigns position based on the `position` key in element dictionaries
50+
- `circle`: Single-level circle, with optional radius
51+
- `concentric`: Multi-level circle, with optional radius
52+
- `grid`: Square grid, optionally with numbers of `rows` and `cols`
53+
- `breadthfirst`: Tree structure built using BFS, with optional `roots`
54+
- `cose`: Force-directed physics simulation
55+
56+
2. The keys accepted by `layout` vary depending on the algorithm, but some
57+
keys are accepted by all layouts:
58+
- `fit` (boolean): Whether to render the nodes in order to fit the canvas.
59+
- `padding` (number): Padding around the sides of the canvas, if fit is enabled.
60+
- `animate` (boolean): Whether to animate change in position when the layout changes.
61+
- `animationDuration` (number): Duration of animation in milliseconds, if enabled.
62+
- `boundingBox` (dictionary): How to constrain the layout in a specific area. Keys accepted are either `x1, y1, x2, y2` or `x1, y1, w, h`, all of which receive a pixel value.
63+
64+
3. The complete list of layouts and their accepted options are available
65+
on the [Cytoscape.js docs](http://js.cytoscape.org/#layouts).
66+
Note that certain keys are not supported in Dash since the value is a
67+
JavaScript function or a callback. Please visit [this issue](https://github.com/plotly/dash-cytoscape/issues/25)
68+
for more information.
69+
- pan (dict; optional): Dictionary indicating the initial panning position of the graph. The
70+
following keys are accepted:
71+
- `x` (number): The x-coordinate of the position.
72+
- `y` (number): The y-coordinate of the position.
73+
- zoom (number; optional): The initial zoom level of the graph. You can set `minZoom` and
74+
`maxZoom` to set restrictions on the zoom level.
75+
- panningEnabled (boolean; optional): Whether panning the graph is enabled (i.e., the position of the graph is
76+
mutable overall).
77+
- userPanningEnabled (boolean; optional): Whether user events (e.g. dragging the graph background) are allowed to
78+
pan the graph.
79+
- minZoom (number; optional): A minimum bound on the zoom level of the graph. The viewport can not be
80+
scaled smaller than this zoom level.
3181
- maxZoom (number; optional): A maximum bound on the zoom level of the graph. The viewport can not be
3282
scaled larger than this zoom level.
33-
- zoomingEnabled (boolean; optional): Whether zooming the graph is enabled, both by user events and programmatically.
34-
- userZoomingEnabled (boolean; optional): Whether user events (e.g. dragging the graph background) are allowed to pan the graph. Programmatic changes to pan are unaffected by this option.
35-
- boxSelectionEnabled (boolean; optional): Whether box selection (i.e. drag a box overlay around, and release it to select) is enabled. If enabled, the user must taphold to pan the graph.
36-
- autoungrabify (boolean; optional): Whether nodes should be ungrabified (not grabbable by user) by default (if true, overrides individual node state).
37-
- autolock (boolean; optional): Whether nodes should be locked (not draggable at all) by default (if true, overrides individual node state).
38-
- autounselectify (boolean; optional): Whether nodes should be unselectified (immutable selection state) by default (if true, overrides individual element state).
39-
- autoRefreshLayout (boolean; optional): Whether the layout should be refreshed when elements are added or removed
40-
- tapNode (dict; optional): The trimmed node object returned when you tap a node
41-
- tapNodeData (dict; optional): The data property of the node object returned when you tap a node
42-
- tapEdge (dict; optional): The trimmed edge object returned when you tap a node
43-
- tapEdgeData (dict; optional): The data property of the edge object returned when you tap a node
44-
- mouseoverNodeData (dict; optional): The data property of the edge object returned when you hover over a node
45-
- mouseoverEdgeData (dict; optional): The data property of the edge object returned when you hover over an edge
46-
- selectedNodeData (list; optional): The array of node data currently selected by taps and boxes
47-
- selectedEdgeData (list; optional): The array of edge data currently selected by taps and boxes
83+
- zoomingEnabled (boolean; optional): Whether zooming the graph is enabled (i.e., the zoom level of the graph
84+
is mutable overall).
85+
- userZoomingEnabled (boolean; optional): Whether user events (e.g. dragging the graph background) are allowed
86+
to pan the graph.
87+
- boxSelectionEnabled (boolean; optional): Whether box selection (i.e. drag a box overlay around, and release it
88+
to select) is enabled. If enabled, the user must taphold to pan the graph.
89+
- autoungrabify (boolean; optional): Whether nodes should be ungrabified (not grabbable by user) by
90+
default (if true, overrides individual node state).
91+
- autolock (boolean; optional): Whether nodes should be locked (not draggable at all) by default
92+
(if true, overrides individual node state).
93+
- autounselectify (boolean; optional): Whether nodes should be unselectified (immutable selection state) by
94+
default (if true, overrides individual element state).
95+
- autoRefreshLayout (boolean; optional): Whether the layout should be refreshed when elements are added or removed.
96+
- tapNode (dict; optional): The complete node dictionary returned when you tap or click it.
97+
98+
1. Node-specific items:
99+
- `edgesData` (dictionary)
100+
- `renderedPosition` (dictionary)
101+
- `timeStamp` (number)
102+
103+
2. General items (for all elements):
104+
- `classes` (string)
105+
- `data` (dictionary)
106+
- `grabbable` (boolean)
107+
- `group` (string)
108+
- `locked` (boolean)
109+
- `position` (dictionary)
110+
- `selectable` (boolean)
111+
- `selected` (boolean)
112+
- `style` (dictionary)
113+
114+
3. Items for compound nodes:
115+
- `ancestorsData` (dictionary)
116+
- `childrenData` (dictionary)
117+
- `descendantsData` (dictionary)
118+
- `parentData` (dictionary)
119+
- `siblingsData` (dictionary)
120+
- `isParent` (boolean)
121+
- `isChildless` (boolean)
122+
- `isChild` (boolean)
123+
- `isOrphan` (boolean)
124+
- `relativePosition` (dictionary)
125+
- tapNodeData (dict; optional): The data dictionary of a node returned when you tap or click it.
126+
- tapEdge (dict; optional): The complete edge dictionary returned when you tap or click it.
127+
128+
1. Edge-specific items:
129+
- `isLoop` (boolean)
130+
- `isSimple` (boolean)
131+
- `midpoint` (dictionary)
132+
- `sourceData` (dictionary)
133+
- `sourceEndpoint` (dictionary)
134+
- `targetData` (dictionary)
135+
- `targetEndpoint` (dictionary)
136+
- `timeStamp` (number)
137+
138+
2. General items (for all elements):
139+
- `classes` (string)
140+
- `data` (dictionary)
141+
- `grabbable` (boolean)
142+
- `group` (string)
143+
- `locked` (boolean)
144+
- `selectable` (boolean)
145+
- `selected` (boolean)
146+
- `style` (dictionary)
147+
- tapEdgeData (dict; optional): The data dictionary of an edge returned when you tap or click it.
148+
- mouseoverNodeData (dict; optional): The data dictionary of a node returned when you hover over it.
149+
- mouseoverEdgeData (dict; optional): The data dictionary of an edge returned when you hover over it.
150+
- selectedNodeData (list; optional): The list of data dictionaries of all selected nodes (e.g. using
151+
Shift+Click to select multiple nodes, or Shift+Drag to use box selection).
152+
- selectedEdgeData (list; optional): The list of data dictionaries of all selected edges (e.g. using
153+
Shift+Click to select multiple nodes, or Shift+Drag to use box selection).
48154
49155
Available events: """
50156
@_explicitize_args

dash_cytoscape/bundle.js

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)