@visuallyjs/browser-ui-svelte 1.1.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/AreaChartComponent.svelte +24 -15
- package/BarChartComponent.svelte +24 -12
- package/BubbleChartComponent.svelte +23 -11
- package/ColumnChartComponent.svelte +23 -11
- package/ControlsComponent.svelte +12 -34
- package/DecoratorComponent.svelte +15 -23
- package/DiagramComponent.svelte +2 -2
- package/DiagramPaletteComponent.svelte +24 -31
- package/DiagramProvider.svelte +3 -1
- package/ExportControlsComponent.svelte +15 -33
- package/GaugeChartComponent.svelte +2 -7
- package/InspectorComponent.svelte +24 -36
- package/LineChartComponent.svelte +23 -13
- package/MiniviewComponent.svelte +30 -46
- package/PaletteComponent.svelte +28 -41
- package/PieChartComponent.svelte +23 -8
- package/SankeyChartComponent.svelte +35 -14
- package/ScatterChartComponent.svelte +23 -11
- package/ShapePaletteComponent.svelte +11 -22
- package/SurfaceProvider.svelte +3 -1
- package/XYChartComponent.svelte +33 -12
- package/charts/definitions.d.ts +119 -0
- package/charts/definitions.js +1 -0
- package/definitions.d.ts +30 -256
- package/diagram-store.d.ts +0 -5
- package/diagram-store.js +0 -15
- package/index.d.ts +4 -0
- package/index.js +4 -0
- package/package.json +1 -1
- package/surface-store.d.ts +0 -5
- package/surface-store.js +5 -15
- package/use-diagram.svelte.d.ts +8 -0
- package/use-diagram.svelte.js +18 -0
- package/use-surface.svelte.d.ts +7 -0
- package/use-surface.svelte.js +18 -0
- package/use-visuallyjs-update.svelte.d.ts +19 -0
- package/use-visuallyjs-update.svelte.js +37 -0
- package/use-zoom.svelte.d.ts +1 -3
- package/use-zoom.svelte.js +14 -11
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
import { onMount } from "svelte";
|
|
4
4
|
|
|
5
|
-
import {LineChart, type BrowserElement} from "@visuallyjs/browser-ui"
|
|
6
|
-
import {type LineChartComponentProps} from "./definitions";
|
|
5
|
+
import {LineChart, type BrowserElement, type LineChartOptions} from "@visuallyjs/browser-ui"
|
|
6
|
+
import {type LineChartComponentProps} from "./charts/definitions";
|
|
7
|
+
import {useVisuallyJsModel} from "./surface-store";
|
|
7
8
|
|
|
8
9
|
let container:BrowserElement;
|
|
9
10
|
|
|
10
|
-
// BarChartOptions
|
|
11
11
|
let {options, className = "", data, url, dataSourceFilter }:LineChartComponentProps = $props();
|
|
12
12
|
|
|
13
13
|
let chart:LineChart;
|
|
@@ -17,21 +17,31 @@
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
$effect(() => {
|
|
20
|
-
if (chart) {
|
|
20
|
+
if (chart && dataSourceFilter != null) {
|
|
21
21
|
chart.setDataSourceFilter(dataSourceFilter)
|
|
22
22
|
}
|
|
23
23
|
})
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
function init(opts:LineChartOptions) {
|
|
26
|
+
chart = new LineChart(container, opts)
|
|
27
|
+
if (url != null) {
|
|
28
|
+
chart.load({url});
|
|
29
|
+
} else if (data != null) {
|
|
30
|
+
chart.load({data});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
28
33
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
onMount(async () => {
|
|
35
|
+
const opts:LineChartOptions = Object.assign({dataSourceFilter}, options)
|
|
36
|
+
if (url == null && data == null) {
|
|
37
|
+
useVisuallyJsModel().then(m => {
|
|
38
|
+
opts.dataSource = m
|
|
39
|
+
init(opts)
|
|
40
|
+
})
|
|
41
|
+
} else {
|
|
42
|
+
init(opts)
|
|
43
|
+
}
|
|
44
|
+
})
|
|
35
45
|
|
|
36
46
|
</script>
|
|
37
47
|
|
package/MiniviewComponent.svelte
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
import {type MiniviewComponentProps} from "./definitions";
|
|
8
|
-
import {internal_getDiagramContext} from "./diagram-store";
|
|
3
|
+
import {MiniviewPlugin, Surface} from "@visuallyjs/browser-ui"
|
|
4
|
+
import {type MiniviewComponentProps} from "./definitions";
|
|
5
|
+
import {useSurface} from "./use-surface.svelte";
|
|
6
|
+
import {useDiagram} from "./use-diagram.svelte";
|
|
9
7
|
|
|
10
8
|
let container:HTMLElement
|
|
11
|
-
|
|
9
|
+
|
|
12
10
|
let initialised = false
|
|
11
|
+
const surface = useSurface()
|
|
12
|
+
const diagram = useDiagram()
|
|
13
|
+
const surfaceRef = $derived(surface.current || diagram.current?.$ui as Surface)
|
|
13
14
|
|
|
14
15
|
let {
|
|
15
16
|
collapsible,
|
|
@@ -21,52 +22,35 @@
|
|
|
21
22
|
wheelReverse,
|
|
22
23
|
activeTracking,
|
|
23
24
|
clickToCenter,
|
|
25
|
+
showLasso,
|
|
26
|
+
trackSelection,
|
|
24
27
|
className = ""
|
|
25
28
|
}:MiniviewComponentProps = $props()
|
|
26
29
|
|
|
27
|
-
const sc = internal_getSurfaceContext(true)
|
|
28
|
-
if (sc != null) {
|
|
29
|
-
sc.listen(s => {
|
|
30
|
-
surface = s
|
|
31
|
-
_maybeInit()
|
|
32
|
-
})
|
|
33
|
-
} else {
|
|
34
|
-
const dc = internal_getDiagramContext(true)
|
|
35
|
-
if (dc != null) {
|
|
36
|
-
dc.listen(d => {
|
|
37
|
-
surface = d.$ui as Surface
|
|
38
|
-
_maybeInit()
|
|
39
|
-
})
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
log(`WARN: MiniviewComponent did not find a Surface or Diagram context. Cannot mount.`)
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
30
|
|
|
46
|
-
|
|
47
|
-
if (!initialised &&
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
31
|
+
$effect(() => {
|
|
32
|
+
if (!initialised && container != null && surfaceRef != null) {
|
|
33
|
+
initialised = true
|
|
34
|
+
surfaceRef.addPlugin({
|
|
35
|
+
type:MiniviewPlugin.type,
|
|
36
|
+
options:{
|
|
52
37
|
collapsible,
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
38
|
+
visible,
|
|
39
|
+
container,
|
|
40
|
+
typeFunction,
|
|
41
|
+
elementFilter,
|
|
42
|
+
wheelSensitivity,
|
|
43
|
+
wheelReverse,
|
|
44
|
+
enableWheelZoom,
|
|
45
|
+
activeTracking,
|
|
46
|
+
clickToCenter,
|
|
47
|
+
showLasso,
|
|
48
|
+
trackSelection
|
|
49
|
+
}
|
|
50
|
+
})
|
|
64
51
|
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
onMount(async () => {
|
|
68
|
-
_maybeInit()
|
|
69
52
|
})
|
|
53
|
+
|
|
70
54
|
</script>
|
|
71
55
|
<div bind:this={container} class={className}>
|
|
72
56
|
|
package/PaletteComponent.svelte
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
import {internal_getSurfaceContext} from "./surface-store";
|
|
6
|
-
import {log, Palette, Surface} from "@visuallyjs/browser-ui"
|
|
3
|
+
import {Palette, Surface} from "@visuallyjs/browser-ui"
|
|
7
4
|
import {type PaletteComponentProps} from "./definitions";
|
|
5
|
+
import {useSurface} from "./use-surface.svelte";
|
|
6
|
+
import {useDiagram} from "./use-diagram.svelte";
|
|
8
7
|
|
|
9
8
|
let container:HTMLElement
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
let initialised = false
|
|
10
|
+
const surface = useSurface()
|
|
11
|
+
const diagram = useDiagram()
|
|
12
|
+
const surfaceRef = $derived(surface.current || diagram.current?.$ui as Surface)
|
|
12
13
|
|
|
13
14
|
let {
|
|
14
15
|
selector = "[data-vjs-type]",
|
|
@@ -29,42 +30,28 @@
|
|
|
29
30
|
ignoreDropOnNode = false
|
|
30
31
|
}:PaletteComponentProps = $props()
|
|
31
32
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
clickToAddOnly,
|
|
54
|
-
dragSize,
|
|
55
|
-
canvasDropFilter,
|
|
56
|
-
mode,
|
|
57
|
-
allowDropOnNode,
|
|
58
|
-
allowDropOnEdge,
|
|
59
|
-
allowDropOnCanvas,
|
|
60
|
-
allowDropOnGroup,
|
|
61
|
-
ignoreDropOnNode
|
|
62
|
-
})
|
|
63
|
-
}
|
|
64
|
-
}
|
|
33
|
+
$effect(() => {
|
|
34
|
+
if (!initialised && container != null && surfaceRef != null) {
|
|
35
|
+
initialised = true
|
|
36
|
+
new Palette(surfaceRef, {
|
|
37
|
+
source:container,
|
|
38
|
+
selector,
|
|
39
|
+
dataGenerator,
|
|
40
|
+
onVertexAdded,
|
|
41
|
+
selectAfterAdd,
|
|
42
|
+
allowClickToAdd,
|
|
43
|
+
clickToAddOnly,
|
|
44
|
+
dragSize,
|
|
45
|
+
canvasDropFilter,
|
|
46
|
+
mode,
|
|
47
|
+
allowDropOnNode,
|
|
48
|
+
allowDropOnEdge,
|
|
49
|
+
allowDropOnCanvas,
|
|
50
|
+
allowDropOnGroup,
|
|
51
|
+
ignoreDropOnNode
|
|
52
|
+
})
|
|
53
|
+
}
|
|
65
54
|
|
|
66
|
-
onMount(async () => {
|
|
67
|
-
_maybeInit()
|
|
68
55
|
})
|
|
69
56
|
|
|
70
57
|
</script>
|
package/PieChartComponent.svelte
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
import { onMount } from "svelte";
|
|
4
4
|
|
|
5
|
-
import {PieChart, type BrowserElement} from "@visuallyjs/browser-ui"
|
|
6
|
-
import {type PieChartComponentProps} from "./definitions";
|
|
5
|
+
import {PieChart, type BrowserElement, type PieChartOptions} from "@visuallyjs/browser-ui"
|
|
6
|
+
import {type PieChartComponentProps} from "./charts/definitions";
|
|
7
|
+
import {useVisuallyJsModel} from "./surface-store";
|
|
7
8
|
|
|
8
9
|
let container:BrowserElement;
|
|
9
10
|
|
|
@@ -16,20 +17,34 @@
|
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
$effect(() => {
|
|
19
|
-
if (chart) {
|
|
20
|
+
if (chart && dataSourceFilter != null) {
|
|
20
21
|
chart.setDataSourceFilter(dataSourceFilter)
|
|
21
22
|
}
|
|
22
23
|
})
|
|
23
24
|
|
|
25
|
+
function init(opts:PieChartOptions) {
|
|
26
|
+
chart = new PieChart(container, opts)
|
|
27
|
+
|
|
28
|
+
if (url != null) {
|
|
29
|
+
chart.load({url});
|
|
30
|
+
} else if (data != null) {
|
|
31
|
+
chart.load({data});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
24
35
|
onMount(async () => {
|
|
25
36
|
|
|
26
|
-
|
|
37
|
+
const opts:PieChartOptions = Object.assign({dataSourceFilter}, options)
|
|
27
38
|
|
|
28
|
-
if (url
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
39
|
+
if (url == null && data == null) {
|
|
40
|
+
useVisuallyJsModel().then(m => {
|
|
41
|
+
opts.dataSource = m
|
|
42
|
+
init(opts)
|
|
43
|
+
})
|
|
44
|
+
} else {
|
|
45
|
+
init(opts)
|
|
32
46
|
}
|
|
47
|
+
|
|
33
48
|
})
|
|
34
49
|
|
|
35
50
|
</script>
|
|
@@ -2,41 +2,62 @@
|
|
|
2
2
|
|
|
3
3
|
import { onMount } from "svelte";
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
|
|
5
|
+
import {
|
|
6
|
+
SankeyChart,
|
|
7
|
+
type BrowserElement,
|
|
8
|
+
type SankeyOptions
|
|
9
|
+
} from "@visuallyjs/browser-ui"
|
|
10
|
+
import {type SankeyChartComponentProps} from "./charts/definitions";
|
|
11
|
+
import {useVisuallyJsModel} from "./surface-store";
|
|
7
12
|
|
|
8
13
|
let container:BrowserElement;
|
|
9
14
|
|
|
10
15
|
let {options, className = "", jsonData, csvData, url, interactive, pivot }:SankeyChartComponentProps = $props();
|
|
11
16
|
|
|
12
|
-
let chart:SankeyChart;
|
|
17
|
+
let chart:SankeyChart|null = $state(null);
|
|
13
18
|
|
|
14
19
|
$effect(() => {
|
|
15
|
-
|
|
20
|
+
if (pivot != null && chart != null) {
|
|
21
|
+
chart.pivot(pivot as string)
|
|
22
|
+
}
|
|
16
23
|
})
|
|
17
24
|
|
|
18
25
|
export function getChart() {
|
|
19
26
|
return chart;
|
|
20
27
|
}
|
|
21
28
|
|
|
22
|
-
|
|
29
|
+
function init(opts:SankeyOptions) {
|
|
30
|
+
|
|
31
|
+
chart = new SankeyChart(container, opts)
|
|
32
|
+
|
|
33
|
+
if (url != null) {
|
|
34
|
+
chart.load({url});
|
|
35
|
+
} else if (csvData != null) {
|
|
36
|
+
chart.load({csvData});
|
|
37
|
+
} else if (jsonData != null) {
|
|
38
|
+
chart.load({jsonData})
|
|
39
|
+
}
|
|
40
|
+
}
|
|
23
41
|
|
|
24
|
-
|
|
42
|
+
|
|
43
|
+
onMount(async () => {
|
|
44
|
+
const _options:SankeyOptions = Object.assign({}, options)
|
|
25
45
|
if (interactive != null) {
|
|
26
46
|
_options.interactive = interactive
|
|
27
47
|
}
|
|
28
48
|
if (pivot != null) {
|
|
29
49
|
_options.pivot = pivot
|
|
30
50
|
}
|
|
31
|
-
chart = new SankeyChart(container, _options)
|
|
32
51
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
52
|
+
if (url == null && csvData == null && jsonData == null) {
|
|
53
|
+
useVisuallyJsModel().then(m => {
|
|
54
|
+
_options.dataSource = m
|
|
55
|
+
init(_options)
|
|
56
|
+
})
|
|
57
|
+
} else {
|
|
58
|
+
init(_options)
|
|
59
|
+
}
|
|
60
|
+
|
|
40
61
|
})
|
|
41
62
|
|
|
42
63
|
</script>
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
import { onMount } from "svelte";
|
|
4
4
|
|
|
5
|
-
import {type BrowserElement, ScatterChart} from "@visuallyjs/browser-ui"
|
|
6
|
-
import {type ScatterChartComponentProps} from "./definitions";
|
|
5
|
+
import {type BrowserElement, type ScatterChartOptions, ScatterChart} from "@visuallyjs/browser-ui"
|
|
6
|
+
import {type ScatterChartComponentProps} from "./charts/definitions";
|
|
7
|
+
import {useVisuallyJsModel} from "./surface-store";
|
|
7
8
|
|
|
8
9
|
let container:BrowserElement;
|
|
9
10
|
|
|
@@ -17,21 +18,32 @@
|
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
$effect(() => {
|
|
20
|
-
if (chart) {
|
|
21
|
+
if (chart && dataSourceFilter != null) {
|
|
21
22
|
chart.setDataSourceFilter(dataSourceFilter)
|
|
22
23
|
}
|
|
23
24
|
})
|
|
24
25
|
|
|
25
|
-
|
|
26
|
+
function init(opts:ScatterChartOptions) {
|
|
27
|
+
chart = new ScatterChart(container, opts)
|
|
28
|
+
if (url != null) {
|
|
29
|
+
chart.load({url});
|
|
30
|
+
} else if (data != null) {
|
|
31
|
+
chart.load({data});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
26
34
|
|
|
27
|
-
|
|
35
|
+
onMount(async () => {
|
|
36
|
+
const opts:ScatterChartOptions = Object.assign({dataSourceFilter}, options)
|
|
37
|
+
if (url == null && data == null) {
|
|
38
|
+
useVisuallyJsModel().then(m => {
|
|
39
|
+
opts.dataSource = m
|
|
40
|
+
init(opts)
|
|
41
|
+
})
|
|
42
|
+
} else {
|
|
43
|
+
init(opts)
|
|
44
|
+
}
|
|
45
|
+
})
|
|
28
46
|
|
|
29
|
-
if (url != null) {
|
|
30
|
-
chart.load({url});
|
|
31
|
-
} else if (data != null) {
|
|
32
|
-
chart.load({data});
|
|
33
|
-
}
|
|
34
|
-
})
|
|
35
47
|
|
|
36
48
|
</script>
|
|
37
49
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
import { onMount } from "svelte"
|
|
2
|
+
|
|
4
3
|
import {log, ShapePalette, Surface} from "@visuallyjs/browser-ui"
|
|
5
4
|
import {type ShapePaletteComponentProps} from "./definitions";
|
|
5
|
+
import {useSurface} from "./use-surface.svelte";
|
|
6
|
+
import {useDiagram} from "./use-diagram.svelte";
|
|
6
7
|
|
|
7
8
|
let {
|
|
8
9
|
className = "",
|
|
@@ -24,30 +25,22 @@
|
|
|
24
25
|
preparedShapes
|
|
25
26
|
}:ShapePaletteComponentProps = $props()
|
|
26
27
|
|
|
27
|
-
let surface:Surface
|
|
28
28
|
let container:HTMLElement
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
sc.listen(s => {
|
|
34
|
-
surface = s
|
|
35
|
-
_maybeInit()
|
|
36
|
-
})
|
|
37
|
-
} else {
|
|
38
|
-
log(`WARN: ShapePaletteComponent did not find a Surface context - ensure the ShapePaletteComponent is declared inside a SurfaceComponent or SurfaceProvider`)
|
|
39
|
-
}
|
|
29
|
+
let initialised = false
|
|
30
|
+
const surface = useSurface()
|
|
31
|
+
const diagram = useDiagram()
|
|
32
|
+
const surfaceRef = $derived(surface.current || diagram.current?.$ui as Surface)
|
|
40
33
|
|
|
41
|
-
|
|
42
|
-
if (!initialised &&
|
|
34
|
+
$effect(() => {
|
|
35
|
+
if (!initialised && surfaceRef != null && container != null) {
|
|
43
36
|
initialised = true
|
|
44
37
|
|
|
45
|
-
const shapeLibrary =
|
|
38
|
+
const shapeLibrary = surfaceRef.getShapeLibrary()
|
|
46
39
|
if (shapeLibrary == null) {
|
|
47
40
|
log("WARN: no shape library set on surface; ShapePaletteComponent cannot render")
|
|
48
41
|
} else {
|
|
49
42
|
|
|
50
|
-
new ShapePalette(
|
|
43
|
+
new ShapePalette(surfaceRef, {
|
|
51
44
|
container,
|
|
52
45
|
dataGenerator,
|
|
53
46
|
autoExitDrawMode,
|
|
@@ -71,10 +64,6 @@
|
|
|
71
64
|
}
|
|
72
65
|
|
|
73
66
|
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
onMount(async () => {
|
|
77
|
-
_maybeInit()
|
|
78
67
|
})
|
|
79
68
|
|
|
80
69
|
|
package/SurfaceProvider.svelte
CHANGED
package/XYChartComponent.svelte
CHANGED
|
@@ -2,30 +2,51 @@
|
|
|
2
2
|
|
|
3
3
|
import { onMount } from "svelte";
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
import {
|
|
6
|
+
CategoryValueChart,
|
|
7
|
+
type CategoryValueChartOptions
|
|
8
|
+
} from "@visuallyjs/browser-ui"
|
|
9
|
+
import {type XYChartComponentProps} from "./charts/definitions";
|
|
10
|
+
import {useVisuallyJsModel} from "./surface-store";
|
|
7
11
|
|
|
8
12
|
let container:HTMLElement;
|
|
9
13
|
|
|
10
14
|
// XYChartOptions
|
|
11
|
-
let {options, className = "", data, url }:XYChartComponentProps = $props()
|
|
15
|
+
let {options, className = "", data, url, dataSourceFilter }:XYChartComponentProps = $props()
|
|
12
16
|
|
|
13
|
-
let chart:CategoryValueChart
|
|
17
|
+
let chart:CategoryValueChart
|
|
14
18
|
|
|
15
19
|
export function getChart() {
|
|
16
20
|
return chart;
|
|
17
21
|
}
|
|
18
22
|
|
|
19
|
-
|
|
23
|
+
function init(opts:CategoryValueChartOptions) {
|
|
24
|
+
chart = new CategoryValueChart(container, opts)
|
|
25
|
+
if (url != null) {
|
|
26
|
+
chart.load({url});
|
|
27
|
+
} else if (data != null) {
|
|
28
|
+
chart.load({data});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
20
31
|
|
|
21
|
-
|
|
32
|
+
$effect(() => {
|
|
33
|
+
if (chart && dataSourceFilter != null) {
|
|
34
|
+
chart.setDataSourceFilter(dataSourceFilter)
|
|
35
|
+
}
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
onMount(async () => {
|
|
39
|
+
const opts:CategoryValueChartOptions = Object.assign({}, options)
|
|
40
|
+
if (url == null && data == null) {
|
|
41
|
+
useVisuallyJsModel().then(m => {
|
|
42
|
+
opts.dataSource = m
|
|
43
|
+
init(opts)
|
|
44
|
+
})
|
|
45
|
+
} else {
|
|
46
|
+
init(opts)
|
|
47
|
+
}
|
|
48
|
+
})
|
|
22
49
|
|
|
23
|
-
if (url != null) {
|
|
24
|
-
chart.load({url});
|
|
25
|
-
} else if (data != null) {
|
|
26
|
-
chart.load({data});
|
|
27
|
-
}
|
|
28
|
-
})
|
|
29
50
|
|
|
30
51
|
</script>
|
|
31
52
|
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { DOMAttributes } from "svelte/elements";
|
|
2
|
+
import { CategoryValueChartOptions, ObjectData, ChartModelFilter, ColumnChartOptions, BarChartOptions, LineChartOptions, PieChartOptions, ScatterChartOptions, AreaChartOptions, GaugeChartOptions, SankeyOptions, VisuallyJsDefaultJSON } from "@visuallyjs/browser-ui";
|
|
3
|
+
/**
|
|
4
|
+
* @group Props
|
|
5
|
+
*/
|
|
6
|
+
export interface BaseXYChartComponentProps<O> extends DOMAttributes<HTMLDivElement> {
|
|
7
|
+
/**
|
|
8
|
+
* Options for the chart
|
|
9
|
+
*/
|
|
10
|
+
options: Omit<O, "data" | "url" | "model">;
|
|
11
|
+
/**
|
|
12
|
+
* Optional class name to set on the chart component's container
|
|
13
|
+
*/
|
|
14
|
+
className?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Optional data to load after the chart has been mounted.
|
|
17
|
+
*/
|
|
18
|
+
data?: Array<ObjectData>;
|
|
19
|
+
/**
|
|
20
|
+
* Optional url from which to load data after the component has been mounted. If you provide this and also data, this will take precedence.
|
|
21
|
+
*/
|
|
22
|
+
url?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Optional filter to apply to the data source.
|
|
25
|
+
*/
|
|
26
|
+
dataSourceFilter?: ChartModelFilter;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Props for the AreaChartComponent
|
|
30
|
+
* @group Props
|
|
31
|
+
*/
|
|
32
|
+
export interface AreaChartComponentProps extends BaseXYChartComponentProps<AreaChartOptions> {
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Props for the ColumnChartComponent
|
|
36
|
+
* @group Props
|
|
37
|
+
*/
|
|
38
|
+
export interface ColumnChartComponentProps extends BaseXYChartComponentProps<ColumnChartOptions> {
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Props for the BarChartComponent
|
|
42
|
+
* @group Props
|
|
43
|
+
*/
|
|
44
|
+
export interface BarChartComponentProps extends BaseXYChartComponentProps<BarChartOptions> {
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Props for the LineChartComponent
|
|
48
|
+
* @group Props
|
|
49
|
+
*/
|
|
50
|
+
export interface LineChartComponentProps extends BaseXYChartComponentProps<LineChartOptions> {
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Props for the PieChartComponent
|
|
54
|
+
* @group Props
|
|
55
|
+
*/
|
|
56
|
+
export interface PieChartComponentProps extends BaseXYChartComponentProps<PieChartOptions> {
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Props for the BarChartComponent
|
|
60
|
+
* @group Props
|
|
61
|
+
*/
|
|
62
|
+
export interface ScatterChartComponentProps extends BaseXYChartComponentProps<ScatterChartOptions> {
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Props for the XYChartComponent
|
|
66
|
+
* @group Props
|
|
67
|
+
*/
|
|
68
|
+
export interface XYChartComponentProps extends BaseXYChartComponentProps<CategoryValueChartOptions> {
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* @group Props
|
|
72
|
+
*/
|
|
73
|
+
export interface GaugeChartComponentProps extends DOMAttributes<HTMLDivElement> {
|
|
74
|
+
/**
|
|
75
|
+
* Options for the chart
|
|
76
|
+
*/
|
|
77
|
+
options: Omit<GaugeChartOptions, "data" | "url" | "model">;
|
|
78
|
+
/**
|
|
79
|
+
* Optional class name to set on the chart component's container
|
|
80
|
+
*/
|
|
81
|
+
className?: string;
|
|
82
|
+
/**
|
|
83
|
+
* Optional data to load after the chart has been mounted.
|
|
84
|
+
*/
|
|
85
|
+
data?: Array<ObjectData>;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* @group Props
|
|
89
|
+
*/
|
|
90
|
+
export interface SankeyChartComponentProps extends DOMAttributes<HTMLDivElement> {
|
|
91
|
+
/**
|
|
92
|
+
* Options for the chart
|
|
93
|
+
*/
|
|
94
|
+
options: Omit<SankeyOptions, "data" | "url" | "model">;
|
|
95
|
+
/**
|
|
96
|
+
* Optional class name to set on the chart component's container
|
|
97
|
+
*/
|
|
98
|
+
className?: string;
|
|
99
|
+
/**
|
|
100
|
+
* Optional data to load into the chart (in CSV format)
|
|
101
|
+
*/
|
|
102
|
+
csvData?: string;
|
|
103
|
+
/**
|
|
104
|
+
* Optional data to load into the chart (in VisuallyJs default json format)
|
|
105
|
+
*/
|
|
106
|
+
jsonData?: VisuallyJsDefaultJSON;
|
|
107
|
+
/**
|
|
108
|
+
* Optional url from which to load data after the component has been mounted. If you provide this and also data, this will take precedence.
|
|
109
|
+
*/
|
|
110
|
+
url?: string;
|
|
111
|
+
/**
|
|
112
|
+
* Whether the chart is interactive.
|
|
113
|
+
*/
|
|
114
|
+
interactive?: boolean;
|
|
115
|
+
/**
|
|
116
|
+
* Optional property to pivot the sankey chart on.
|
|
117
|
+
*/
|
|
118
|
+
pivot?: string;
|
|
119
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|