svelte-tiny-linked-charts 2.0.0 → 2.3.0
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/LICENSE +24 -0
- package/README.md +8 -2
- package/dist/LinkedChart.svelte +69 -39
- package/dist/LinkedChart.svelte.d.ts +250 -4
- package/dist/LinkedLabel.svelte +1 -0
- package/dist/LinkedValue.svelte +1 -0
- package/package.json +5 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
This is free and unencumbered software released into the public domain.
|
|
2
|
+
|
|
3
|
+
Anyone is free to copy, modify, publish, use, compile, sell, or
|
|
4
|
+
distribute this software, either in source code form or as a compiled
|
|
5
|
+
binary, for any purpose, commercial or non-commercial, and by any
|
|
6
|
+
means.
|
|
7
|
+
|
|
8
|
+
In jurisdictions that recognize copyright laws, the author or authors
|
|
9
|
+
of this software dedicate any and all copyright interest in the
|
|
10
|
+
software to the public domain. We make this dedication for the benefit
|
|
11
|
+
of the public at large and to the detriment of our heirs and
|
|
12
|
+
successors. We intend this dedication to be an overt act of
|
|
13
|
+
relinquishment in perpetuity of all present and future rights to this
|
|
14
|
+
software under copyright law.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
20
|
+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
21
|
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
+
|
|
24
|
+
For more information, please refer to <https://unlicense.org>
|
package/README.md
CHANGED
|
@@ -90,6 +90,7 @@ grow | false | Whether or not the bar should grow to fill out the full width of
|
|
|
90
90
|
align | right | The side the bars should align to when they do not completely fill out the chart.
|
|
91
91
|
gap | 1 | Gap between the bars in pixels.
|
|
92
92
|
fill | #ff3e00 | Color of the bars, can be any valid CSS color.
|
|
93
|
+
fillArray | [] | Array of colors for each individual bar.
|
|
93
94
|
fadeOpacity | 0.5 | The opacity the faded out bars should display in.
|
|
94
95
|
hover | true | Boolean whether or not this chart can be hovered at all.
|
|
95
96
|
transition | 0 | Transition the chart between different stats. Value is time in milliseconds.
|
|
@@ -103,8 +104,13 @@ scaleMax | 0 | Use this to overwrite the automatic scale set to the highest valu
|
|
|
103
104
|
scaleMax | 0 | Use this to overwrite the default value floor of 0.
|
|
104
105
|
type | bar | Can be set to "line" to display a line chart instead.
|
|
105
106
|
lineColor | fill | Color of the line if used with type="line".
|
|
106
|
-
|
|
107
|
-
|
|
107
|
+
lineFill | transparent | Color of the fill area if used with type="line".
|
|
108
|
+
lineWidth | 1 | Width of the line if used with type="line".
|
|
109
|
+
lineDotRadius | 0 (derived) | The size of the dot when hovering a line if used with type="line".
|
|
110
|
+
preserveAspectRatio | false | Sets whether or not the SVG will preserve it's aspect ratio.
|
|
111
|
+
tabindex | -1 | Sets the tabindex of each bar. When a tabindex of 0 is given, each bar will contain a title that describes the bar's label and value.
|
|
112
|
+
title | "" | Title that describes the chart for screen readers.
|
|
113
|
+
description | "" | Description that describes the chart for screen readers.
|
|
108
114
|
onclick | null | Function that executes on click and returns the key and index for the clicked data.
|
|
109
115
|
onhover | null | Function that executes on hover of each bar.
|
|
110
116
|
onblur | null | Function that executes when focus leaves the chart.
|
package/dist/LinkedChart.svelte
CHANGED
|
@@ -33,39 +33,45 @@
|
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
35
|
* @typedef {Object} Props
|
|
36
|
-
* @property {string} [uid]
|
|
37
|
-
* @property {Record<string, number>} [data]
|
|
38
|
-
* @property {string[]} [labels]
|
|
39
|
-
* @property {number[]} [values]
|
|
40
|
-
* @property {string} [linked]
|
|
41
|
-
* @property {number} [height]
|
|
42
|
-
* @property {number} [width]
|
|
43
|
-
* @property {number} [barMinWidth]
|
|
44
|
-
* @property {number} [barMinHeight]
|
|
45
|
-
* @property {number} [hideBarBelow]
|
|
46
|
-
* @property {boolean} [grow]
|
|
47
|
-
* @property {"left" | "right"} [align]
|
|
48
|
-
* @property {number} [gap]
|
|
49
|
-
* @property {string} [fill]
|
|
50
|
-
* @property {
|
|
51
|
-
* @property {
|
|
52
|
-
* @property {
|
|
53
|
-
* @property {
|
|
54
|
-
* @property {
|
|
55
|
-
* @property {string} [
|
|
56
|
-
* @property {string} [
|
|
57
|
-
* @property {
|
|
58
|
-
* @property {number} [valueUndefined]
|
|
59
|
-
* @property {
|
|
60
|
-
* @property {number} [
|
|
61
|
-
* @property {
|
|
62
|
-
* @property {
|
|
63
|
-
* @property {
|
|
64
|
-
* @property {
|
|
65
|
-
* @property {
|
|
66
|
-
* @property {
|
|
67
|
-
* @property {
|
|
68
|
-
* @property {
|
|
36
|
+
* @property {string} [uid] Unique ID to link this chart to a LinkedValue component with the same uid.
|
|
37
|
+
* @property {Record<string, number>} [data] Data that will be displayed in the chart supplied in key:value object. Key should be a string, value a number.
|
|
38
|
+
* @property {string[]} [labels] Labels supplied separately, to be used together with `values` property.
|
|
39
|
+
* @property {number[]} [values] Values supplied separately, to be used together with `labels` property.
|
|
40
|
+
* @property {string} [linked] Key to link this chart to other charts with the same key.
|
|
41
|
+
* @property {number} [height] Height of the chart in pixels.
|
|
42
|
+
* @property {number} [width] Width of the chart in pixels.
|
|
43
|
+
* @property {number} [barMinWidth] Width of the bars in the chart in pixels.
|
|
44
|
+
* @property {number} [barMinHeight] Minimum height of the bars in the chart in pixels.
|
|
45
|
+
* @property {number} [hideBarBelow] Bars below this value will be hidden, showing as 0 height.
|
|
46
|
+
* @property {boolean} [grow] Whether or not the bar should grow to fill out the full width of the chart.
|
|
47
|
+
* @property {"left" | "right"} [align] The side the bars should align to when they do not completely fill out the chart.
|
|
48
|
+
* @property {number} [gap] Gap between the bars in pixels.
|
|
49
|
+
* @property {string} [fill] Color of the bars, can be any valid CSS color.
|
|
50
|
+
* @property {Array<string | null>} [fillArray] Array of colors for each individual bar.
|
|
51
|
+
* @property {number} [fadeOpacity] The opacity the faded out bars should display in.
|
|
52
|
+
* @property {boolean} [hover] Boolean whether or not this chart can be hovered at all.
|
|
53
|
+
* @property {number} [transition] Transition the chart between different stats. Value is time in milliseconds.
|
|
54
|
+
* @property {boolean} [showValue] Boolean whether or not a value will be shown.
|
|
55
|
+
* @property {string} [valueDefault] Default value when not hovering.
|
|
56
|
+
* @property {string} [valuePrepend] String to prepend the value.
|
|
57
|
+
* @property {string} [valueAppend] String to append to the value.
|
|
58
|
+
* @property {number} [valueUndefined] For when the hovering value returns undefined.
|
|
59
|
+
* @property {"static" | "floating"} [valuePosition] Can be set to "floating" to follow the position of the hover.
|
|
60
|
+
* @property {number} [scaleMax] Use this to overwrite the automatic scale set to the highest value in your array.
|
|
61
|
+
* @property {number} [scaleMin] Use this to overwrite the default value floor of 0.
|
|
62
|
+
* @property {"bar" | "line"} [type] Can be set to "line" to display a line chart instead.
|
|
63
|
+
* @property {string} [lineColor] Color of the line if used with type="line".
|
|
64
|
+
* @property {string} [lineFill] Color of the fill area if used with type="line".
|
|
65
|
+
* @property {number} [lineWidth] Width of the line if used with type="line".
|
|
66
|
+
* @property {number} [lineDotRadius] The size of the dot when hovering a line if used with type="line".
|
|
67
|
+
* @property {boolean} [preserveAspectRatio] Sets whether or not the SVG will preserve it's aspect ratio.
|
|
68
|
+
* @property {-1 | 0} [tabindex] Sets the tabindex of each bar. When a tabindex of 0 is given, each bar will contain a title that describes the bar's label and value.
|
|
69
|
+
* @property {string} [title] Title that describes the chart for screen readers.
|
|
70
|
+
* @property {string} [description] Description that describes the chart for screen readers.
|
|
71
|
+
* @property {(args: OnClick) => void} [onclick] Function that executes on click and returns the key and index for the clicked data.
|
|
72
|
+
* @property {(args: OnValueUpdate) => void} [onvalueupdate] Function that executes when a value in the chart updates.
|
|
73
|
+
* @property {(args: OnHover) => void} [onhover] Function that executes on hover of each bar, also fires on tab focus.
|
|
74
|
+
* @property {(args: OnBlur) => void} [onblur] Function that executes when hover or focus leaves the chart.
|
|
69
75
|
*/
|
|
70
76
|
|
|
71
77
|
/** @type {Props & { [key: string]: any }} */
|
|
@@ -84,6 +90,7 @@
|
|
|
84
90
|
align = "right",
|
|
85
91
|
gap = 1,
|
|
86
92
|
fill = "#ff3e00",
|
|
93
|
+
fillArray = [],
|
|
87
94
|
fadeOpacity = 0.5,
|
|
88
95
|
hover = true,
|
|
89
96
|
transition = 0,
|
|
@@ -97,8 +104,13 @@
|
|
|
97
104
|
scaleMin = 0,
|
|
98
105
|
type = "bar",
|
|
99
106
|
lineColor = fill,
|
|
100
|
-
|
|
107
|
+
lineFill = "transparent",
|
|
108
|
+
lineWidth = 1,
|
|
109
|
+
lineDotRadius = 0,
|
|
101
110
|
preserveAspectRatio = false,
|
|
111
|
+
tabindex = -1,
|
|
112
|
+
title = "",
|
|
113
|
+
description = "",
|
|
102
114
|
onclick = ({ key, index }) => null,
|
|
103
115
|
onvalueupdate = ({ value, uid, linkedKey, valueElement }) => null,
|
|
104
116
|
onhover = ({ uid, key, index, linkedKey, value, valueElement, eventElement }) => null,
|
|
@@ -219,11 +231,24 @@
|
|
|
219
231
|
preserveAspectRatio={preserveAspectRatio ? "true" : "none"}
|
|
220
232
|
onmouseleave={endHover}
|
|
221
233
|
onblur={endHover}
|
|
234
|
+
aria-labelledby={title ? `${uid}-title` : null}
|
|
222
235
|
{...rest}>
|
|
223
236
|
|
|
237
|
+
{#if title}
|
|
238
|
+
<title id="{uid}-title">{title}</title>
|
|
239
|
+
{/if}
|
|
240
|
+
|
|
241
|
+
{#if description}
|
|
242
|
+
<desc>{description}</desc>
|
|
243
|
+
{/if}
|
|
244
|
+
|
|
224
245
|
<g transform="translate({alignmentOffset}, 0)">
|
|
225
246
|
{#if type == "line"}
|
|
226
|
-
|
|
247
|
+
{#if lineFill && lineFill !== "transparent"}
|
|
248
|
+
<polyline points={[...polyline, [width, height], [0, height]].join(" ")} fill={lineFill} />
|
|
249
|
+
{/if}
|
|
250
|
+
|
|
251
|
+
<polyline points={polyline.join(" ")} stroke={lineColor} stroke-width={lineWidth} fill="transparent" />
|
|
227
252
|
{/if}
|
|
228
253
|
|
|
229
254
|
{#each Object.entries(data) as [key, value], i}
|
|
@@ -231,15 +256,15 @@
|
|
|
231
256
|
<rect
|
|
232
257
|
style={transition ? `transition: all ${transition}ms` : null}
|
|
233
258
|
opacity={hover && $hoveringKey[linkedKey] && $hoveringKey[linkedKey] != key ? fadeOpacity : 1}
|
|
234
|
-
fill={fill}
|
|
259
|
+
fill={fillArray[i] || fill}
|
|
235
260
|
width={barWidth}
|
|
236
261
|
height={getHeight(value)}
|
|
237
262
|
x={(gap + barWidth) * i}
|
|
238
263
|
y={(height - getHeight(value))} />
|
|
239
264
|
{:else if type == "line"}
|
|
240
265
|
<circle
|
|
241
|
-
fill={hover && $hoveringKey[linkedKey] !== null && $hoveringKey[linkedKey] == key ? fill : "transparent"}
|
|
242
|
-
r={grow ? barMinWidth : barWidth / 2}
|
|
266
|
+
fill={hover && $hoveringKey[linkedKey] !== null && $hoveringKey[linkedKey] == key ? (fillArray[i] || fill) : "transparent"}
|
|
267
|
+
r={lineDotRadius || (grow ? barMinWidth : barWidth / 2)}
|
|
243
268
|
cy={height - getHeight(value)}
|
|
244
269
|
cx={((gap + barWidth) + (barWidth / (Object.keys(data).length))) * i} />
|
|
245
270
|
{/if}
|
|
@@ -256,7 +281,11 @@
|
|
|
256
281
|
height={height}
|
|
257
282
|
fill="transparent"
|
|
258
283
|
x={(gap + barWidth) * i}
|
|
259
|
-
{tabindex}
|
|
284
|
+
{tabindex}>
|
|
285
|
+
{#if tabindex !== -1}
|
|
286
|
+
<title>{key}: {value}</title>
|
|
287
|
+
{/if}
|
|
288
|
+
</rect>
|
|
260
289
|
{/each}
|
|
261
290
|
</g>
|
|
262
291
|
</svg>
|
|
@@ -268,6 +297,7 @@
|
|
|
268
297
|
<span bind:this={valueElement}>{$hoveringValue[uid] || valueUndefined}</span>
|
|
269
298
|
{valueAppend}
|
|
270
299
|
{:else}
|
|
300
|
+
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
|
|
271
301
|
{@html valueDefault}
|
|
272
302
|
{/if}
|
|
273
303
|
</div>
|
|
@@ -6,45 +6,165 @@ type LinkedChart = {
|
|
|
6
6
|
}>): void;
|
|
7
7
|
};
|
|
8
8
|
declare const LinkedChart: import("svelte").Component<{
|
|
9
|
+
/**
|
|
10
|
+
* Unique ID to link this chart to a LinkedValue component with the same uid.
|
|
11
|
+
*/
|
|
9
12
|
uid?: string | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Data that will be displayed in the chart supplied in key:value object. Key should be a string, value a number.
|
|
15
|
+
*/
|
|
10
16
|
data?: Record<string, number> | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Labels supplied separately, to be used together with `values` property.
|
|
19
|
+
*/
|
|
11
20
|
labels?: string[] | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Values supplied separately, to be used together with `labels` property.
|
|
23
|
+
*/
|
|
12
24
|
values?: number[] | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Key to link this chart to other charts with the same key.
|
|
27
|
+
*/
|
|
13
28
|
linked?: string | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Height of the chart in pixels.
|
|
31
|
+
*/
|
|
14
32
|
height?: number | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Width of the chart in pixels.
|
|
35
|
+
*/
|
|
15
36
|
width?: number | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Width of the bars in the chart in pixels.
|
|
39
|
+
*/
|
|
16
40
|
barMinWidth?: number | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Minimum height of the bars in the chart in pixels.
|
|
43
|
+
*/
|
|
17
44
|
barMinHeight?: number | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Bars below this value will be hidden, showing as 0 height.
|
|
47
|
+
*/
|
|
18
48
|
hideBarBelow?: number | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* Whether or not the bar should grow to fill out the full width of the chart.
|
|
51
|
+
*/
|
|
19
52
|
grow?: boolean | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* The side the bars should align to when they do not completely fill out the chart.
|
|
55
|
+
*/
|
|
20
56
|
align?: "left" | "right" | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* Gap between the bars in pixels.
|
|
59
|
+
*/
|
|
21
60
|
gap?: number | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* Color of the bars, can be any valid CSS color.
|
|
63
|
+
*/
|
|
22
64
|
fill?: string | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* Array of colors for each individual bar.
|
|
67
|
+
*/
|
|
68
|
+
fillArray?: (string | null)[] | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* The opacity the faded out bars should display in.
|
|
71
|
+
*/
|
|
23
72
|
fadeOpacity?: number | undefined;
|
|
73
|
+
/**
|
|
74
|
+
* Boolean whether or not this chart can be hovered at all.
|
|
75
|
+
*/
|
|
24
76
|
hover?: boolean | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* Transition the chart between different stats. Value is time in milliseconds.
|
|
79
|
+
*/
|
|
25
80
|
transition?: number | undefined;
|
|
81
|
+
/**
|
|
82
|
+
* Boolean whether or not a value will be shown.
|
|
83
|
+
*/
|
|
26
84
|
showValue?: boolean | undefined;
|
|
85
|
+
/**
|
|
86
|
+
* Default value when not hovering.
|
|
87
|
+
*/
|
|
27
88
|
valueDefault?: string | undefined;
|
|
89
|
+
/**
|
|
90
|
+
* String to prepend the value.
|
|
91
|
+
*/
|
|
28
92
|
valuePrepend?: string | undefined;
|
|
93
|
+
/**
|
|
94
|
+
* String to append to the value.
|
|
95
|
+
*/
|
|
29
96
|
valueAppend?: string | undefined;
|
|
30
|
-
|
|
97
|
+
/**
|
|
98
|
+
* For when the hovering value returns undefined.
|
|
99
|
+
*/
|
|
31
100
|
valueUndefined?: number | undefined;
|
|
101
|
+
/**
|
|
102
|
+
* Can be set to "floating" to follow the position of the hover.
|
|
103
|
+
*/
|
|
104
|
+
valuePosition?: "static" | "floating" | undefined;
|
|
105
|
+
/**
|
|
106
|
+
* Use this to overwrite the automatic scale set to the highest value in your array.
|
|
107
|
+
*/
|
|
32
108
|
scaleMax?: number | undefined;
|
|
109
|
+
/**
|
|
110
|
+
* Use this to overwrite the default value floor of 0.
|
|
111
|
+
*/
|
|
33
112
|
scaleMin?: number | undefined;
|
|
113
|
+
/**
|
|
114
|
+
* Can be set to "line" to display a line chart instead.
|
|
115
|
+
*/
|
|
34
116
|
type?: "bar" | "line" | undefined;
|
|
117
|
+
/**
|
|
118
|
+
* Color of the line if used with type="line".
|
|
119
|
+
*/
|
|
35
120
|
lineColor?: string | undefined;
|
|
36
|
-
|
|
121
|
+
/**
|
|
122
|
+
* Color of the fill area if used with type="line".
|
|
123
|
+
*/
|
|
124
|
+
lineFill?: string | undefined;
|
|
125
|
+
/**
|
|
126
|
+
* Width of the line if used with type="line".
|
|
127
|
+
*/
|
|
128
|
+
lineWidth?: number | undefined;
|
|
129
|
+
/**
|
|
130
|
+
* The size of the dot when hovering a line if used with type="line".
|
|
131
|
+
*/
|
|
132
|
+
lineDotRadius?: number | undefined;
|
|
133
|
+
/**
|
|
134
|
+
* Sets whether or not the SVG will preserve it's aspect ratio.
|
|
135
|
+
*/
|
|
37
136
|
preserveAspectRatio?: boolean | undefined;
|
|
137
|
+
/**
|
|
138
|
+
* Sets the tabindex of each bar. When a tabindex of 0 is given, each bar will contain a title that describes the bar's label and value.
|
|
139
|
+
*/
|
|
140
|
+
tabindex?: 0 | -1 | undefined;
|
|
141
|
+
/**
|
|
142
|
+
* Title that describes the chart for screen readers.
|
|
143
|
+
*/
|
|
144
|
+
title?: string | undefined;
|
|
145
|
+
/**
|
|
146
|
+
* Description that describes the chart for screen readers.
|
|
147
|
+
*/
|
|
148
|
+
description?: string | undefined;
|
|
149
|
+
/**
|
|
150
|
+
* Function that executes on click and returns the key and index for the clicked data.
|
|
151
|
+
*/
|
|
38
152
|
onclick?: ((args: {
|
|
39
153
|
key?: string | undefined;
|
|
40
154
|
index?: number | undefined;
|
|
41
155
|
}) => void) | undefined;
|
|
156
|
+
/**
|
|
157
|
+
* Function that executes when a value in the chart updates.
|
|
158
|
+
*/
|
|
42
159
|
onvalueupdate?: ((args: {
|
|
43
160
|
value?: number | null | undefined;
|
|
44
161
|
uid?: string | undefined;
|
|
45
162
|
linkedKey?: string | undefined;
|
|
46
163
|
valueElement?: HTMLElement | null | undefined;
|
|
47
164
|
}) => void) | undefined;
|
|
165
|
+
/**
|
|
166
|
+
* Function that executes on hover of each bar, also fires on tab focus.
|
|
167
|
+
*/
|
|
48
168
|
onhover?: ((args: {
|
|
49
169
|
/**
|
|
50
170
|
* ,
|
|
@@ -72,6 +192,9 @@ declare const LinkedChart: import("svelte").Component<{
|
|
|
72
192
|
valueElement: HTMLElement;
|
|
73
193
|
eventElement: EventTarget | null;
|
|
74
194
|
}) => void) | undefined;
|
|
195
|
+
/**
|
|
196
|
+
* Function that executes when hover or focus leaves the chart.
|
|
197
|
+
*/
|
|
75
198
|
onblur?: ((args: {
|
|
76
199
|
/**
|
|
77
200
|
* ,
|
|
@@ -91,45 +214,165 @@ declare const LinkedChart: import("svelte").Component<{
|
|
|
91
214
|
[key: string]: any;
|
|
92
215
|
}, {}, "data">;
|
|
93
216
|
type Props = {
|
|
217
|
+
/**
|
|
218
|
+
* Unique ID to link this chart to a LinkedValue component with the same uid.
|
|
219
|
+
*/
|
|
94
220
|
uid?: string | undefined;
|
|
221
|
+
/**
|
|
222
|
+
* Data that will be displayed in the chart supplied in key:value object. Key should be a string, value a number.
|
|
223
|
+
*/
|
|
95
224
|
data?: Record<string, number> | undefined;
|
|
225
|
+
/**
|
|
226
|
+
* Labels supplied separately, to be used together with `values` property.
|
|
227
|
+
*/
|
|
96
228
|
labels?: string[] | undefined;
|
|
229
|
+
/**
|
|
230
|
+
* Values supplied separately, to be used together with `labels` property.
|
|
231
|
+
*/
|
|
97
232
|
values?: number[] | undefined;
|
|
233
|
+
/**
|
|
234
|
+
* Key to link this chart to other charts with the same key.
|
|
235
|
+
*/
|
|
98
236
|
linked?: string | undefined;
|
|
237
|
+
/**
|
|
238
|
+
* Height of the chart in pixels.
|
|
239
|
+
*/
|
|
99
240
|
height?: number | undefined;
|
|
241
|
+
/**
|
|
242
|
+
* Width of the chart in pixels.
|
|
243
|
+
*/
|
|
100
244
|
width?: number | undefined;
|
|
245
|
+
/**
|
|
246
|
+
* Width of the bars in the chart in pixels.
|
|
247
|
+
*/
|
|
101
248
|
barMinWidth?: number | undefined;
|
|
249
|
+
/**
|
|
250
|
+
* Minimum height of the bars in the chart in pixels.
|
|
251
|
+
*/
|
|
102
252
|
barMinHeight?: number | undefined;
|
|
253
|
+
/**
|
|
254
|
+
* Bars below this value will be hidden, showing as 0 height.
|
|
255
|
+
*/
|
|
103
256
|
hideBarBelow?: number | undefined;
|
|
257
|
+
/**
|
|
258
|
+
* Whether or not the bar should grow to fill out the full width of the chart.
|
|
259
|
+
*/
|
|
104
260
|
grow?: boolean | undefined;
|
|
261
|
+
/**
|
|
262
|
+
* The side the bars should align to when they do not completely fill out the chart.
|
|
263
|
+
*/
|
|
105
264
|
align?: "left" | "right" | undefined;
|
|
265
|
+
/**
|
|
266
|
+
* Gap between the bars in pixels.
|
|
267
|
+
*/
|
|
106
268
|
gap?: number | undefined;
|
|
269
|
+
/**
|
|
270
|
+
* Color of the bars, can be any valid CSS color.
|
|
271
|
+
*/
|
|
107
272
|
fill?: string | undefined;
|
|
273
|
+
/**
|
|
274
|
+
* Array of colors for each individual bar.
|
|
275
|
+
*/
|
|
276
|
+
fillArray?: (string | null)[] | undefined;
|
|
277
|
+
/**
|
|
278
|
+
* The opacity the faded out bars should display in.
|
|
279
|
+
*/
|
|
108
280
|
fadeOpacity?: number | undefined;
|
|
281
|
+
/**
|
|
282
|
+
* Boolean whether or not this chart can be hovered at all.
|
|
283
|
+
*/
|
|
109
284
|
hover?: boolean | undefined;
|
|
285
|
+
/**
|
|
286
|
+
* Transition the chart between different stats. Value is time in milliseconds.
|
|
287
|
+
*/
|
|
110
288
|
transition?: number | undefined;
|
|
289
|
+
/**
|
|
290
|
+
* Boolean whether or not a value will be shown.
|
|
291
|
+
*/
|
|
111
292
|
showValue?: boolean | undefined;
|
|
293
|
+
/**
|
|
294
|
+
* Default value when not hovering.
|
|
295
|
+
*/
|
|
112
296
|
valueDefault?: string | undefined;
|
|
297
|
+
/**
|
|
298
|
+
* String to prepend the value.
|
|
299
|
+
*/
|
|
113
300
|
valuePrepend?: string | undefined;
|
|
301
|
+
/**
|
|
302
|
+
* String to append to the value.
|
|
303
|
+
*/
|
|
114
304
|
valueAppend?: string | undefined;
|
|
115
|
-
|
|
305
|
+
/**
|
|
306
|
+
* For when the hovering value returns undefined.
|
|
307
|
+
*/
|
|
116
308
|
valueUndefined?: number | undefined;
|
|
309
|
+
/**
|
|
310
|
+
* Can be set to "floating" to follow the position of the hover.
|
|
311
|
+
*/
|
|
312
|
+
valuePosition?: "static" | "floating" | undefined;
|
|
313
|
+
/**
|
|
314
|
+
* Use this to overwrite the automatic scale set to the highest value in your array.
|
|
315
|
+
*/
|
|
117
316
|
scaleMax?: number | undefined;
|
|
317
|
+
/**
|
|
318
|
+
* Use this to overwrite the default value floor of 0.
|
|
319
|
+
*/
|
|
118
320
|
scaleMin?: number | undefined;
|
|
321
|
+
/**
|
|
322
|
+
* Can be set to "line" to display a line chart instead.
|
|
323
|
+
*/
|
|
119
324
|
type?: "bar" | "line" | undefined;
|
|
325
|
+
/**
|
|
326
|
+
* Color of the line if used with type="line".
|
|
327
|
+
*/
|
|
120
328
|
lineColor?: string | undefined;
|
|
121
|
-
|
|
329
|
+
/**
|
|
330
|
+
* Color of the fill area if used with type="line".
|
|
331
|
+
*/
|
|
332
|
+
lineFill?: string | undefined;
|
|
333
|
+
/**
|
|
334
|
+
* Width of the line if used with type="line".
|
|
335
|
+
*/
|
|
336
|
+
lineWidth?: number | undefined;
|
|
337
|
+
/**
|
|
338
|
+
* The size of the dot when hovering a line if used with type="line".
|
|
339
|
+
*/
|
|
340
|
+
lineDotRadius?: number | undefined;
|
|
341
|
+
/**
|
|
342
|
+
* Sets whether or not the SVG will preserve it's aspect ratio.
|
|
343
|
+
*/
|
|
122
344
|
preserveAspectRatio?: boolean | undefined;
|
|
345
|
+
/**
|
|
346
|
+
* Sets the tabindex of each bar. When a tabindex of 0 is given, each bar will contain a title that describes the bar's label and value.
|
|
347
|
+
*/
|
|
348
|
+
tabindex?: 0 | -1 | undefined;
|
|
349
|
+
/**
|
|
350
|
+
* Title that describes the chart for screen readers.
|
|
351
|
+
*/
|
|
352
|
+
title?: string | undefined;
|
|
353
|
+
/**
|
|
354
|
+
* Description that describes the chart for screen readers.
|
|
355
|
+
*/
|
|
356
|
+
description?: string | undefined;
|
|
357
|
+
/**
|
|
358
|
+
* Function that executes on click and returns the key and index for the clicked data.
|
|
359
|
+
*/
|
|
123
360
|
onclick?: ((args: {
|
|
124
361
|
key?: string | undefined;
|
|
125
362
|
index?: number | undefined;
|
|
126
363
|
}) => void) | undefined;
|
|
364
|
+
/**
|
|
365
|
+
* Function that executes when a value in the chart updates.
|
|
366
|
+
*/
|
|
127
367
|
onvalueupdate?: ((args: {
|
|
128
368
|
value?: number | null | undefined;
|
|
129
369
|
uid?: string | undefined;
|
|
130
370
|
linkedKey?: string | undefined;
|
|
131
371
|
valueElement?: HTMLElement | null | undefined;
|
|
132
372
|
}) => void) | undefined;
|
|
373
|
+
/**
|
|
374
|
+
* Function that executes on hover of each bar, also fires on tab focus.
|
|
375
|
+
*/
|
|
133
376
|
onhover?: ((args: {
|
|
134
377
|
/**
|
|
135
378
|
* ,
|
|
@@ -157,6 +400,9 @@ type Props = {
|
|
|
157
400
|
valueElement: HTMLElement;
|
|
158
401
|
eventElement: EventTarget | null;
|
|
159
402
|
}) => void) | undefined;
|
|
403
|
+
/**
|
|
404
|
+
* Function that executes when hover or focus leaves the chart.
|
|
405
|
+
*/
|
|
160
406
|
onblur?: ((args: {
|
|
161
407
|
/**
|
|
162
408
|
* ,
|
package/dist/LinkedLabel.svelte
CHANGED
package/dist/LinkedValue.svelte
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svelte-tiny-linked-charts",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "vite dev",
|
|
6
6
|
"build": "vite build && npm run package",
|
|
@@ -35,8 +35,10 @@
|
|
|
35
35
|
"@sveltejs/vite-plugin-svelte": "^4.0.0",
|
|
36
36
|
"@sveltejs/package": "^2.3.7",
|
|
37
37
|
"@testing-library/svelte": "^5.2.6",
|
|
38
|
-
"eslint": "^9.
|
|
39
|
-
"eslint-config-prettier": "^
|
|
38
|
+
"eslint": "^9.18.0",
|
|
39
|
+
"eslint-config-prettier": "^10.0.1",
|
|
40
|
+
"eslint-plugin-svelte": "^2.46.1",
|
|
41
|
+
"globals": "^15.14.0",
|
|
40
42
|
"happy-dom": "^16.5.3",
|
|
41
43
|
"prettier": "^3.1.0",
|
|
42
44
|
"prettier-plugin-svelte": "^3.2.6",
|