Skip to content

Commit cf1b2c6

Browse files
Update readme
1 parent f8e7894 commit cf1b2c6

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

readme.md

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

99
## Usage
1010

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

1351
## License

0 commit comments

Comments
 (0)