@carbon/charts-svelte 1.0.3 → 1.2.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/CHANGELOG.md +27 -0
- package/README.md +35 -11
- package/package.json +2 -4
- package/src/BaseChart.svelte +7 -1
- package/types/BaseChart.d.ts +6 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,33 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [1.2.0](https://github.com/carbon-design-system/carbon-charts/compare/v1.1.0...v1.2.0) (2022-06-13)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **svelte:** add theme prop ([#1389](https://github.com/carbon-design-system/carbon-charts/issues/1389)) ([b2ff145](https://github.com/carbon-design-system/carbon-charts/commit/b2ff14578ec3e1c319adedb4c8bf96e9a3766a9b))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# [1.1.0](https://github.com/carbon-design-system/carbon-charts/compare/v1.0.4...v1.1.0) (2022-06-08)
|
|
18
|
+
|
|
19
|
+
**Note:** Version bump only for package @carbon/charts-svelte
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## [1.0.4](https://github.com/carbon-design-system/carbon-charts/compare/v1.0.3...v1.0.4) (2022-05-27)
|
|
26
|
+
|
|
27
|
+
**Note:** Version bump only for package @carbon/charts-svelte
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
6
33
|
## [1.0.3](https://github.com/carbon-design-system/carbon-charts/compare/v1.0.2...v1.0.3) (2022-05-25)
|
|
7
34
|
|
|
8
35
|
|
package/README.md
CHANGED
|
@@ -224,20 +224,20 @@ module.exports = {
|
|
|
224
224
|
|
|
225
225
|
## Usage
|
|
226
226
|
|
|
227
|
-
|
|
227
|
+
Styles must be imported from both `@carbon/charts` and `@carbon/styles`.
|
|
228
228
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
229
|
+
```js
|
|
230
|
+
import '@carbon/styles/css/styles.css';
|
|
231
|
+
import '@carbon/charts/styles.css';
|
|
232
|
+
```
|
|
233
233
|
|
|
234
234
|
### Basic
|
|
235
235
|
|
|
236
236
|
```svelte
|
|
237
237
|
<script>
|
|
238
|
+
import "@carbon/styles/css/styles.css";
|
|
239
|
+
import "@carbon/charts/styles.css";
|
|
238
240
|
import { BarChartSimple } from "@carbon/charts-svelte";
|
|
239
|
-
import "@carbon/charts/styles.min.css";
|
|
240
|
-
import "carbon-components/css/carbon-components.min.css";
|
|
241
241
|
</script>
|
|
242
242
|
|
|
243
243
|
<BarChartSimple
|
|
@@ -260,6 +260,30 @@ Import chart styles from `@carbon/charts`:
|
|
|
260
260
|
|
|
261
261
|
```
|
|
262
262
|
|
|
263
|
+
### Theming
|
|
264
|
+
|
|
265
|
+
`@carbon/styles` uses
|
|
266
|
+
[CSS custom properties](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties)
|
|
267
|
+
for dynamic, client-side theming. Update the Carbon theme using the `theme`
|
|
268
|
+
prop.
|
|
269
|
+
|
|
270
|
+
Supported themes include:
|
|
271
|
+
|
|
272
|
+
- `"white"`
|
|
273
|
+
- `"g10"` (Gray 10)
|
|
274
|
+
- `"g90"` (Gray 90)
|
|
275
|
+
- `"g100"` (Gray 100)
|
|
276
|
+
|
|
277
|
+
The default theme is `"white"`.
|
|
278
|
+
|
|
279
|
+
```svelte
|
|
280
|
+
<BarChartSimple
|
|
281
|
+
theme="g90"
|
|
282
|
+
data={/* ... */}
|
|
283
|
+
options={/* ... */}
|
|
284
|
+
/>
|
|
285
|
+
```
|
|
286
|
+
|
|
263
287
|
### Dispatched events
|
|
264
288
|
|
|
265
289
|
Each Svelte chart component dispatches the following events:
|
|
@@ -287,9 +311,9 @@ Dynamically import a chart and instantiate it using the
|
|
|
287
311
|
|
|
288
312
|
```svelte
|
|
289
313
|
<script>
|
|
314
|
+
import "@carbon/styles/css/styles.css";
|
|
315
|
+
import "@carbon/charts/styles.css";
|
|
290
316
|
import { onMount } from "svelte";
|
|
291
|
-
import "@carbon/charts/styles.min.css";
|
|
292
|
-
import "carbon-components/css/carbon-components.min.css";
|
|
293
317
|
|
|
294
318
|
let chart;
|
|
295
319
|
|
|
@@ -327,10 +351,10 @@ that fires when hovering over a bar.
|
|
|
327
351
|
|
|
328
352
|
```svelte
|
|
329
353
|
<script>
|
|
354
|
+
import "@carbon/styles/css/styles.css";
|
|
355
|
+
import "@carbon/charts/styles.css";
|
|
330
356
|
import { onMount } from "svelte";
|
|
331
357
|
import { BarChartSimple } from "@carbon/charts-svelte";
|
|
332
|
-
import "@carbon/charts/styles.min.css";
|
|
333
|
-
import "carbon-components/css/carbon-components.min.css";
|
|
334
358
|
|
|
335
359
|
let chart;
|
|
336
360
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carbon/charts-svelte",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Carbon charting components for Svelte",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
},
|
|
51
51
|
"homepage": "https://github.com/carbon-design-system/carbon-charts#readme",
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@carbon/charts": "^1.0
|
|
53
|
+
"@carbon/charts": "^1.2.0",
|
|
54
54
|
"@carbon/telemetry": "0.1.0"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
@@ -86,14 +86,12 @@
|
|
|
86
86
|
"maintainers": [
|
|
87
87
|
{
|
|
88
88
|
"name": "Eric Liu",
|
|
89
|
-
"email": "eric.young.liu@ibm.com",
|
|
90
89
|
"url": "https://github.com/metonym"
|
|
91
90
|
}
|
|
92
91
|
],
|
|
93
92
|
"contributors": [
|
|
94
93
|
{
|
|
95
94
|
"name": "Eric Liu",
|
|
96
|
-
"email": "eric.young.liu@ibm.com",
|
|
97
95
|
"url": "https://github.com/metonym"
|
|
98
96
|
}
|
|
99
97
|
]
|
package/src/BaseChart.svelte
CHANGED
|
@@ -24,6 +24,12 @@
|
|
|
24
24
|
*/
|
|
25
25
|
export let options = {};
|
|
26
26
|
|
|
27
|
+
/**
|
|
28
|
+
* Specify the Carbon theme
|
|
29
|
+
* @type {"white" | "g10" | "g90" | "g100"}
|
|
30
|
+
*/
|
|
31
|
+
export let theme = "white";
|
|
32
|
+
|
|
27
33
|
/** Specify the id for the chart holder element */
|
|
28
34
|
export let id = "chart-" + Math.random().toString(36);
|
|
29
35
|
|
|
@@ -70,4 +76,4 @@
|
|
|
70
76
|
}
|
|
71
77
|
</script>
|
|
72
78
|
|
|
73
|
-
<div {...$$restProps} bind:this={ref} {id} />
|
|
79
|
+
<div {...$$restProps} data-carbon-theme={theme} bind:this={ref} {id} />
|
package/types/BaseChart.d.ts
CHANGED
|
@@ -32,6 +32,12 @@ export interface BaseChartProps<Chart = BC, ChartOptions = BaseChartOptions, Cha
|
|
|
32
32
|
*/
|
|
33
33
|
options?: ChartOptions;
|
|
34
34
|
|
|
35
|
+
/**
|
|
36
|
+
* Specify the Carbon theme
|
|
37
|
+
* @default "white"
|
|
38
|
+
*/
|
|
39
|
+
theme?: "white" | "g10" | "g90" | "g100";
|
|
40
|
+
|
|
35
41
|
/**
|
|
36
42
|
* Specify the id for the chart holder element
|
|
37
43
|
* @default "chart-" + Math.random().toString(36)
|