@revolist/svelte-charts 0.0.0-stage → 3.0.2
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 +100 -2
- package/dist/RevoChart.svelte +23 -0
- package/dist/RevoChart.svelte.d.ts +10 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1 -0
- package/package.json +46 -3
package/README.md
CHANGED
|
@@ -1,3 +1,101 @@
|
|
|
1
|
-
#
|
|
1
|
+
# RevoGrid Svelte Charts
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
One generic `RevoChart` component backed by the standalone chart engine.
|
|
4
|
+
|
|
5
|
+
## Installation: public wrapper, private engine
|
|
6
|
+
|
|
7
|
+
The four wrapper packages are configured for public npm publishing. `@revolist/charts` remains a
|
|
8
|
+
private commercial package on GitHub Packages; you need licensed access to
|
|
9
|
+
install and use it. The wrapper imports the engine and does not bundle it.
|
|
10
|
+
|
|
11
|
+
### Before the first release
|
|
12
|
+
|
|
13
|
+
The wrappers are not published yet; registry install commands below apply after
|
|
14
|
+
publication. In this monorepo, replace `your-app` with your consumer workspace
|
|
15
|
+
name and use the local package:
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
pnpm --filter your-app add "@revolist/svelte-charts@workspace:*" "@revolist/charts@workspace:*"
|
|
19
|
+
pnpm build
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Source: `packages/charts/packages/svelte-charts`. The public import name is unchanged.
|
|
23
|
+
|
|
24
|
+
### Registry installation after publication
|
|
25
|
+
|
|
26
|
+
Configure your project's `.npmrc` for the engine, keeping credentials in your
|
|
27
|
+
environment:
|
|
28
|
+
|
|
29
|
+
```ini
|
|
30
|
+
@revolist:registry=https://npm.pkg.github.com/
|
|
31
|
+
//npm.pkg.github.com/:_authToken=${GITHUB_PACKAGES_TOKEN}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Both registries use the `@revolist` scope. Install the public wrapper by its
|
|
35
|
+
explicit npm tarball URL so the scope mapping continues to send the engine to
|
|
36
|
+
GitHub Packages. A plain `pnpm add @revolist/svelte-charts` with that mapping
|
|
37
|
+
would look for the wrapper on GitHub instead. Changing only the default
|
|
38
|
+
`--registry` does not override the scope mapping.
|
|
39
|
+
|
|
40
|
+
```sh
|
|
41
|
+
pnpm add @revolist/charts@3.0.0
|
|
42
|
+
pnpm add https://registry.npmjs.org/@revolist/svelte-charts/-/svelte-charts-3.0.0.tgz
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Use matching released wrapper and engine versions; replace `3.0.0` in these
|
|
46
|
+
examples when upgrading. Commit your lockfile so CI retains both registries'
|
|
47
|
+
resolved tarball URLs, and provide `GITHUB_PACKAGES_TOKEN` during CI installs.
|
|
48
|
+
Missing or unauthorized engine access causes installation to fail. No separate
|
|
49
|
+
wrapper trial package is published.
|
|
50
|
+
|
|
51
|
+
```svelte
|
|
52
|
+
<script lang="ts">
|
|
53
|
+
import { RevoChart, type ChartComponentOptions } from '@revolist/svelte-charts';
|
|
54
|
+
let options = $state.raw<ChartComponentOptions>({
|
|
55
|
+
chartType: 'line',
|
|
56
|
+
data: [{ month: 'Jan', revenue: 120 }, { month: 'Feb', revenue: 180 }],
|
|
57
|
+
mapping: { category: { field: 'month' }, series: [{ field: 'revenue' }] },
|
|
58
|
+
});
|
|
59
|
+
</script>
|
|
60
|
+
<RevoChart {options} onReady={chart => console.log(chart.model)}
|
|
61
|
+
style="height:400px" class="sales-chart" />
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Updates and lifecycle
|
|
65
|
+
|
|
66
|
+
`options` has type `Omit<ChartOptions, 'container'>`. It accepts the same rows and
|
|
67
|
+
mapping, dataset, saved model, renderer, data source and chart settings as
|
|
68
|
+
`@revolist/charts`. Existing callbacks such as `onNodeClick`, `onChange` and
|
|
69
|
+
`onError` belong inside `options`. Callback replacements take effect without
|
|
70
|
+
recreating a chart.
|
|
71
|
+
|
|
72
|
+
Replace `options` and changed nested values to update the chart; do not mutate
|
|
73
|
+
nested objects in place. In Vue, replace the ref value; in Svelte, prefer
|
|
74
|
+
`$state.raw` for chart configuration. Ordinary data/settings changes update the
|
|
75
|
+
current chart. Source replacements use `setDataSource`. Initialization settings,
|
|
76
|
+
input-mode changes and removed settings recreate it to restore engine defaults.
|
|
77
|
+
|
|
78
|
+
The host defaults to width `100%` and height `300px`. Override its dimensions with
|
|
79
|
+
framework styles. The engine observes resizing. No stylesheet, element
|
|
80
|
+
registration or manual mount call is needed.
|
|
81
|
+
|
|
82
|
+
The readiness callback/event receives `ChartRef` for `download`, `getCSV`,
|
|
83
|
+
`getImageDataURL`, selection and transactions. It fires again after recreation;
|
|
84
|
+
replace any stored ref on each readiness event. The component owns destruction,
|
|
85
|
+
so do not destroy its ref yourself.
|
|
86
|
+
|
|
87
|
+
Creation and updates are asynchronous. Pending work is cancelled on unmount or
|
|
88
|
+
superseding configuration, and stale results are destroyed. Failures call
|
|
89
|
+
`options.onError`, or `console.error` when no error handler is supplied. Server
|
|
90
|
+
rendering produces an empty host; chart creation starts after client mounting.
|
|
91
|
+
|
|
92
|
+
## Building and distribution
|
|
93
|
+
|
|
94
|
+
The package compiles with the monorepo's root `pnpm build`. Framework runtimes and
|
|
95
|
+
`@revolist/charts` stay external. Install the framework peers listed in
|
|
96
|
+
`package.json`; the engine version follows the wrapper version.
|
|
97
|
+
|
|
98
|
+
The normal charts release publishes this wrapper to public npmjs using the
|
|
99
|
+
repository's `NPM_TOKEN` secret. The private engine is published separately to
|
|
100
|
+
GitHub Packages using GitHub credentials. No wrapper `build:trial` or trial
|
|
101
|
+
publication is needed.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { onMount } from 'svelte';
|
|
3
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
4
|
+
import { createChartComponentController } from '@revolist/charts/framework';
|
|
5
|
+
import type { ChartComponentController, ChartComponentOptions } from '@revolist/charts/framework';
|
|
6
|
+
import type { ChartRef } from '@revolist/charts';
|
|
7
|
+
|
|
8
|
+
interface Props extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
9
|
+
options: ChartComponentOptions;
|
|
10
|
+
onReady?: (chart: ChartRef) => void;
|
|
11
|
+
}
|
|
12
|
+
let { options, onReady, style = '', ...attributes }: Props = $props();
|
|
13
|
+
let host: HTMLDivElement;
|
|
14
|
+
let controller: ChartComponentController | undefined;
|
|
15
|
+
onMount(() => {
|
|
16
|
+
controller = createChartComponentController(host, chart => onReady?.(chart));
|
|
17
|
+
void controller.setOptions(options);
|
|
18
|
+
return () => { controller?.destroy(); controller = undefined; };
|
|
19
|
+
});
|
|
20
|
+
$effect(() => { const next = options; void controller?.setOptions(next); });
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<div {...attributes} bind:this={host} style={`width:100%;height:300px;${style}`}></div>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
2
|
+
import type { ChartComponentOptions } from '@revolist/charts/framework';
|
|
3
|
+
import type { ChartRef } from '@revolist/charts';
|
|
4
|
+
interface Props extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
5
|
+
options: ChartComponentOptions;
|
|
6
|
+
onReady?: (chart: ChartRef) => void;
|
|
7
|
+
}
|
|
8
|
+
declare const RevoChart: import("svelte").Component<Props, {}, "">;
|
|
9
|
+
type RevoChart = ReturnType<typeof RevoChart>;
|
|
10
|
+
export default RevoChart;
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as RevoChart } from './RevoChart.svelte';
|
package/package.json
CHANGED
|
@@ -1,6 +1,49 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@revolist/svelte-charts",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "3.0.2",
|
|
4
|
+
"description": "Svelte components for RevoGrid Charts",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "Commercial",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist",
|
|
9
|
+
"README.md"
|
|
10
|
+
],
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"module": "./dist/index.js",
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"import": "./dist/index.js",
|
|
18
|
+
"svelte": "./dist/index.js",
|
|
19
|
+
"default": "./dist/index.js"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@revolist/charts": "3.0.2"
|
|
24
|
+
},
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"svelte": "^5.55.0"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"svelte": "^5.55.0",
|
|
30
|
+
"typescript": "~6.0.3",
|
|
31
|
+
"@sveltejs/package": "^2.5.0",
|
|
32
|
+
"svelte-check": "^4.0.0"
|
|
33
|
+
},
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"registry": "https://registry.npmjs.org/",
|
|
36
|
+
"access": "public"
|
|
37
|
+
},
|
|
38
|
+
"repository": {
|
|
39
|
+
"type": "git",
|
|
40
|
+
"url": "https://github.com/revolist/revogrid-pro.git",
|
|
41
|
+
"directory": "packages/charts/packages/svelte-charts"
|
|
42
|
+
},
|
|
43
|
+
"svelte": "./dist/index.js",
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "svelte-package -i src -o dist",
|
|
46
|
+
"lint": "svelte-check --tsconfig ./tsconfig.json",
|
|
47
|
+
"test": "node --test --test-name-pattern=\"^svelte charts\" ../../../../.github/workflows/chart-frameworks.test.mjs"
|
|
48
|
+
}
|
|
6
49
|
}
|