svelte-tiny-linked-charts 2.2.0 → 2.3.1
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 +3 -0
- package/dist/LinkedChart.svelte +16 -4
- package/dist/LinkedChart.svelte.d.ts +24 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -104,6 +104,9 @@ scaleMax | 0 | Use this to overwrite the automatic scale set to the highest valu
|
|
|
104
104
|
scaleMax | 0 | Use this to overwrite the default value floor of 0.
|
|
105
105
|
type | bar | Can be set to "line" to display a line chart instead.
|
|
106
106
|
lineColor | fill | Color of the line if used with type="line".
|
|
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".
|
|
107
110
|
preserveAspectRatio | false | Sets whether or not the SVG will preserve it's aspect ratio.
|
|
108
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.
|
|
109
112
|
title | "" | Title that describes the chart for screen readers.
|
package/dist/LinkedChart.svelte
CHANGED
|
@@ -61,6 +61,9 @@
|
|
|
61
61
|
* @property {number} [scaleMin] Use this to overwrite the default value floor of 0.
|
|
62
62
|
* @property {"bar" | "line"} [type] Can be set to "line" to display a line chart instead.
|
|
63
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".
|
|
64
67
|
* @property {boolean} [preserveAspectRatio] Sets whether or not the SVG will preserve it's aspect ratio.
|
|
65
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.
|
|
66
69
|
* @property {string} [title] Title that describes the chart for screen readers.
|
|
@@ -101,6 +104,9 @@
|
|
|
101
104
|
scaleMin = 0,
|
|
102
105
|
type = "bar",
|
|
103
106
|
lineColor = fill,
|
|
107
|
+
lineFill = "transparent",
|
|
108
|
+
lineWidth = 1,
|
|
109
|
+
lineDotRadius = 0,
|
|
104
110
|
preserveAspectRatio = false,
|
|
105
111
|
tabindex = -1,
|
|
106
112
|
title = "",
|
|
@@ -186,6 +192,8 @@
|
|
|
186
192
|
points.push([i * ((barWidth + gap) + (barWidth / (Object.keys(data).length))), height - getHeight(Object.values(data)[i])])
|
|
187
193
|
}
|
|
188
194
|
|
|
195
|
+
points[points.length - 1][0] = width
|
|
196
|
+
|
|
189
197
|
return points
|
|
190
198
|
}
|
|
191
199
|
|
|
@@ -238,7 +246,11 @@
|
|
|
238
246
|
|
|
239
247
|
<g transform="translate({alignmentOffset}, 0)">
|
|
240
248
|
{#if type == "line"}
|
|
241
|
-
|
|
249
|
+
{#if lineFill && lineFill !== "transparent"}
|
|
250
|
+
<polyline points={[...polyline, [width, height], [0, height]].join(" ")} fill={lineFill} />
|
|
251
|
+
{/if}
|
|
252
|
+
|
|
253
|
+
<polyline points={polyline.join(" ")} stroke={lineColor} stroke-width={lineWidth} fill="transparent" />
|
|
242
254
|
{/if}
|
|
243
255
|
|
|
244
256
|
{#each Object.entries(data) as [key, value], i}
|
|
@@ -254,9 +266,9 @@
|
|
|
254
266
|
{:else if type == "line"}
|
|
255
267
|
<circle
|
|
256
268
|
fill={hover && $hoveringKey[linkedKey] !== null && $hoveringKey[linkedKey] == key ? (fillArray[i] || fill) : "transparent"}
|
|
257
|
-
r={grow ? barMinWidth : barWidth / 2}
|
|
258
|
-
cy={
|
|
259
|
-
cx={
|
|
269
|
+
r={lineDotRadius || (grow ? barMinWidth : barWidth / 2)}
|
|
270
|
+
cy={polyline?.[i]?.[1]}
|
|
271
|
+
cx={polyline?.[i]?.[0]} />
|
|
260
272
|
{/if}
|
|
261
273
|
|
|
262
274
|
<!-- svelte-ignore a11y_no_noninteractive_tabindex -->
|
|
@@ -118,6 +118,18 @@ declare const LinkedChart: import("svelte").Component<{
|
|
|
118
118
|
* Color of the line if used with type="line".
|
|
119
119
|
*/
|
|
120
120
|
lineColor?: string | undefined;
|
|
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;
|
|
121
133
|
/**
|
|
122
134
|
* Sets whether or not the SVG will preserve it's aspect ratio.
|
|
123
135
|
*/
|
|
@@ -314,6 +326,18 @@ type Props = {
|
|
|
314
326
|
* Color of the line if used with type="line".
|
|
315
327
|
*/
|
|
316
328
|
lineColor?: string | undefined;
|
|
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;
|
|
317
341
|
/**
|
|
318
342
|
* Sets whether or not the SVG will preserve it's aspect ratio.
|
|
319
343
|
*/
|