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

Update flowchart click docs #25

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
1 change: 1 addition & 0 deletions content/book.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"./scripts/index.js"
],
"css": [
"./styles/website.css"
]
}
}
Expand Down
52 changes: 31 additions & 21 deletions content/flowchart.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,36 +200,46 @@ graph TB
It is possible to bind a click event to a node, the click can lead to either a javascript callback or to a link which will be opened in a new browser tab.

```
click nodeId callback
```

* nodeId is the id of the node
* callback is the name of a javascript function defined on the page displaying the graph, the function will be called with the nodeId as parameter.
click nodeId callbackFunction "Tooltip text"
click nodeId link "Tooltip text"
```

* `nodeId` - id of the node
* `callbackFunction` - name of a javascript function defined on the page displaying the graph. The function will be called with the `nodeId` as parameter.
* `link` - url of the page that will open in a new browser tab
* `"Tooltip text"` (optional) - text that will display in the tooltip when hovering over the node. It must be defined in quotes. Tooltip styling is not set by default but can be defined with the class `.mermaidTooltip`, such as:
```
.mermaidTooltip {
position: absolute;
text-align: center;
max-width: 200px;
padding: 2px;
font-family: 'trebuchet ms', verdana, arial;
font-size: 12px;
background: #ffffde;
border: 1px solid #aaaa33;
border-radius: 2px;
pointer-events: none;
z-index: 100;
}
```

Examples of tooltip usage below:
### Examples:

```
# Example of a callback function to be defined on the page.
<script>
var callback = function(){
var callbackFunction = function(nodeId){
alert('A callback was triggered');
}
<script>
```

```
graph LR;
A-->B;
click A callback "Tooltip for a callback"
click B "http://www.github.com" "This is a tooltip for a link"
</script>
```

The tooltip text is surrounded in double quotes. The styles of the tooltip are set by the class .mermaidTooltip.

```mermaid
graph LR;
A-->B;
click A callback "Tooltip"
click B "http://www.github.com" "This is a link"
graph LR;
A-->B;
click A callbackFunction "Tooltip for a callback"
click B "http://www.github.com" "This is a tooltip for node that will open a new window on click"
```
> **Success** The tooltip functionality and the ability to link to urls are available from version 0.5.2.

Expand Down
14 changes: 14 additions & 0 deletions content/styles/website.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,17 @@ html {
.gitbook-link {
display: none !important;
}

.mermaidTooltip {
position: absolute;
text-align: center;
max-width: 200px;
padding: 2px;
font-family: 'trebuchet ms', verdana, arial;
font-size: 12px;
background: #ffffde;
border: 1px solid #aaaa33;
border-radius: 2px;
pointer-events: none;
z-index: 100;
}