svelte-tiny-linked-charts 1.1.2 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Tiny Linked Charts for Svelte
2
2
 
3
+ [![tests passing](https://github.com/MitchelJager/svelte-tiny-linked-charts/actions/workflows/node.js.yml/badge.svg)](https://github.com/Mitcheljager/svelte-tiny-linked-charts/actions/workflows/node.js.yml)
4
+ [![npm version](https://badgen.net/npm/v/svelte-tiny-linked-charts)](https://www.npmjs.com/package/svelte-tiny-linked-charts)
5
+ [![npm downloads](https://badgen.net/npm/dt/svelte-tiny-linked-charts)](https://www.npmjs.com/package/svelte-tiny-linked-charts)
6
+ [![MadeWithSvelte.com shield](https://madewithsvelte.com/storage/repo-shields/3278-shield.svg)](https://madewithsvelte.com/p/tiny-linked-charts/shield-link)
7
+
3
8
  This is a library to display tiny bar charts. These charts are more so meant for graphic aids, rather than scientific representations. There's no axis labels, no extensive data visualisation, just bars.
4
9
 
5
10
  **Demo and Docs**: https://mitcheljager.github.io/svelte-tiny-linked-charts/
@@ -7,25 +12,25 @@ This is a library to display tiny bar charts. These charts are more so meant for
7
12
  ### Installation
8
13
 
9
14
  Install using Yarn or NPM.
10
- ```
15
+ ```js
11
16
  yarn add svelte-tiny-linked-charts
12
17
  ```
13
- ```
18
+ ```js
14
19
  npm install --save svelte-tiny-linked-charts
15
20
  ```
16
21
 
17
22
  Include the chart in your app.
18
- ```
23
+ ```js
19
24
  import { LinkedChart, LinkedLabel, LinkedValue } from "svelte-tiny-linked-charts"
20
25
  ```
21
- ```
22
- <LinkedChart { data } />
26
+ ```svelte
27
+ <LinkedChart />
23
28
  <LinkedLabel />
24
29
  <LinkedValue />
25
30
  ```
26
31
 
27
32
  Supply your data in a simple key:value object:
28
- ```
33
+ ```js
29
34
  let data = {
30
35
  "2005-01-01": 25,
31
36
  "2005-01-02": 20,
@@ -33,11 +38,13 @@ let data = {
33
38
  "2005-01-04": 17,
34
39
  "2005-01-05": 21
35
40
  }
41
+ ```
42
+ ```svelte
36
43
  <LinkedChart { data } />
37
44
  ```
38
45
 
39
46
  Or if you prefer supply the labels and values separately:
40
- ```
47
+ ```js
41
48
  let labels = [
42
49
  "2005-01-01",
43
50
  "2005-01-02",
@@ -52,6 +59,8 @@ let values = [
52
59
  17,
53
60
  21
54
61
  ]
62
+ ```
63
+ ```svelte
55
64
  <LinkedChart { labels } { values } />
56
65
  ```
57
66
 
@@ -90,6 +99,7 @@ type | bar | Can be set to "line" to display a line chart instead.
90
99
  lineColor | fill | Color of the line if used with type="line".
91
100
  tabindex | -1 | Sets the tabindex of each bar.
92
101
  dispatchEvents | false | Boolean whether or not to dispatch events on certain actions.
102
+ clickHandler | null | Function that executes on click and returns the key and index for the clicked data.
93
103
 
94
104
  `<LinkedLabel />` component.
95
105
  Property | Default | Description
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-tiny-linked-charts",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "build": "rollup -c",
@@ -28,6 +28,7 @@
28
28
  export let lineColor = fill
29
29
  export let tabindex = -1
30
30
  export let dispatchEvents = false
31
+ export let clickHandler = (key, i) => null
31
32
 
32
33
  const dispatch = createEventDispatcher()
33
34
 
@@ -120,6 +121,7 @@
120
121
  on:mouseover={ () => startHover(key, i) }
121
122
  on:focus={ () => startHover(key, i) }
122
123
  on:touchstart={ () => startHover(key, i) }
124
+ on:click={ () => clickHandler(key, i) }
123
125
  style={ transition ? `transition: all ${ transition }ms` : null }
124
126
  opacity={ hover && $hoveringKey[linkedKey] && $hoveringKey[linkedKey] != key ? fadeOpacity : 1 }
125
127
  fill={ type == "line" ? "transparent" : fill }