Skip to content

Commit 81c19fe

Browse files
Update documentation
1 parent 2edcfc2 commit 81c19fe

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

README.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ Vue.D3.Sunburst provides a reusable vue [sunburst charts](http://www.cc.gatech.e
1616

1717
`Sunburst` is the main component of this library and display sunburst chart based on `data` props using `children` property for hierarchy, `name` property for naming and `size` property for arcs size.
1818

19-
`Sunburst` component provides three optional slots:
19+
`Sunburst` component provides four optional slots:
2020

2121
* `legend` and `top` slots are intended to be used to display additional information such as legend
22+
* `pop-up` to create a pop-up for an arc
2223
* `default slot` is intended to receive renderless component providing behavior: for example, highlighting on mouse over or zoom on click
2324

2425
Components providing standard and reusable features are provided.
@@ -46,6 +47,7 @@ npm i vue-d3-sunburst
4647
<template slot-scope="{ on, actions }">
4748
<highlightOnHover v-bind="{ on, actions }"/>
4849
<zoomOnClick v-bind="{ on, actions }"/>
50+
<popUpOnHover v-bind="{ on, actions }"/>
4951
</template>
5052

5153
<!-- Add information to be displayed on top the graph -->
@@ -54,6 +56,11 @@ npm i vue-d3-sunburst
5456
<!-- Add bottom legend -->
5557
<breadcrumbTrail slot="legend" slot-scope="{ nodes, colorGetter, width }" :current="nodes.mouseOver" :root="nodes.root" :colorGetter="colorGetter" :from="nodes.clicked" :width="width" />
5658

59+
<!-- Add pop-up -->
60+
<template slot="pop-up" slot-scope="{ data }">
61+
<div class="pop-up">{{data.name}}</div>
62+
</template>
63+
5764
</sunburst>
5865
```
5966

@@ -62,6 +69,7 @@ import {
6269
breadcrumbTrail,
6370
highlightOnHover,
6471
nodeInfoDisplayer,
72+
popUpOnHover,
6573
sunburst,
6674
zoomOnClick
6775
} from 'vue-d3-sunburst';
@@ -136,6 +144,8 @@ Failing to do so may result in a component whose size that will keep increasing.
136144

137145
- `top` Use this slot to add information on top of the graph
138146

147+
- `pop-up` Use this slot to create a pop-up for arc: it receives as scope `data`, `node` and `actions` objects
148+
139149
- `default` Use this slot to add behaviors to the sunburst
140150

141151
#### props
@@ -372,6 +382,8 @@ These components can be used as a default slot of the `sunburst` component which
372382
* `highlightPath`: function that takes a node and highlight the path going from the root to the given node
373383
* `zoomToNode`: function that takes a node and zoom to the corresponding node
374384
* `resetHighlight`: function that resets the highlighting
385+
* `setContextMenu`: function that takes a node and display the corresponding pop-up
386+
* `closeContextMenu`: function that remove the current pop-up if any
375387

376388
Typical usage:
377389

@@ -403,6 +415,21 @@ Renderless component providing path highlighting on mouse over behavior.
403415

404416
##### props
405417

418+
- `on` ***Function*** (*required*)
419+
420+
Sunburst event listener. Same as component $on method.
421+
422+
- `actions` ***Object*** (*required*)
423+
424+
Sunburst nodes. Typically provided by sunburst default slot.
425+
426+
#### popUpOnHover
427+
428+
Renderless component displaying arc pop-up on mouse over.
429+
Can be used as a default slot of sunburst component.
430+
431+
##### props
432+
406433
- `on` ***Function*** (*required*)
407434

408435
Sunburst event listener. Same as component $on method.

src/components/sunburst.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
<template>
22
<div class="graph">
33
<div class="pop-up-tree" :style="popUpStyle">
4+
<!-- Use this slot as an arc pop-up-->
45
<slot v-if="popUpNode"
56
name="pop-up"
67
:node="popUpNode"
78
:data="popUpNode.data"
8-
:close="closeContextMenu"
9+
:actions="actions"
910
>
1011
</slot>
1112
</div>

0 commit comments

Comments
 (0)