Skip to content

Commit 7dcdc82

Browse files
Update readme
1 parent 0a0995c commit 7dcdc82

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

readme.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,50 @@ Web component implementation of a two-stacked-bar.
88

99
## Usage
1010

11+
Import `two-stacked-bar` and set CSS custom properties:
12+
13+
```html
14+
<head>
15+
<script type="module">
16+
import "https://cdn.skypack.dev/@nextbitlabs/two-stacked-bar";
17+
</script>
18+
<style>
19+
/*
20+
CSS custom properties penetrate the Shadow DOM.
21+
They are useful to provide custom styling.
22+
*/
23+
two-stacked-bar {
24+
--color-top: #999; /* default #999 */
25+
--color-bottom: #333; /* default #333 */
26+
--background: #eee; /* default transparent */
27+
}
28+
</style>
29+
</head>
30+
```
31+
32+
Use the custom element:
33+
34+
```html
35+
<body>
36+
<two-stacked-bar
37+
gap="2"
38+
bar-width="2"
39+
width="100"
40+
height="100"
41+
margin="20"
42+
></two-stacked-bar>
43+
</body>
44+
```
45+
46+
Set the data to plot:
47+
48+
```html
49+
<script>
50+
const element = document.querySelector("two-stacked-bar");
51+
element.data = [[1, [12, 4]], [2, [3, 10]], [3, [5, 25]]];
52+
</script>
53+
```
54+
1155
Please have a look at the [demo](https://xbbzw.csb.app/).
1256

1357
## License

0 commit comments

Comments
 (0)