@rokkit/chart 1.0.0-next.14 → 1.0.0-next.140
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 +1 -1
- package/README.md +150 -46
- package/dist/Plot/index.d.ts +5 -0
- package/dist/elements/index.d.ts +6 -0
- package/dist/index.d.ts +14 -0
- package/dist/lib/brewing/axes.svelte.d.ts +66 -0
- package/dist/lib/brewing/bars.svelte.d.ts +56 -0
- package/dist/lib/brewing/dimensions.svelte.d.ts +35 -0
- package/dist/lib/brewing/index.svelte.d.ts +118 -0
- package/dist/lib/brewing/legends.svelte.d.ts +48 -0
- package/dist/lib/brewing/scales.svelte.d.ts +24 -0
- package/dist/lib/brewing/types.d.ts +162 -0
- package/dist/lib/context.d.ts +13 -0
- package/dist/lib/scales.svelte.d.ts +35 -0
- package/dist/lib/utils.d.ts +60 -0
- package/dist/old_lib/brewer.d.ts +9 -0
- package/dist/old_lib/chart.d.ts +40 -0
- package/dist/old_lib/grid.d.ts +72 -0
- package/dist/old_lib/index.d.ts +4 -0
- package/dist/old_lib/plots.d.ts +3 -0
- package/dist/old_lib/swatch.d.ts +285 -0
- package/dist/old_lib/ticks.d.ts +36 -0
- package/dist/old_lib/utils.d.ts +1 -0
- package/dist/patterns/index.d.ts +9 -0
- package/dist/patterns/paths/constants.d.ts +1 -0
- package/dist/symbols/constants/index.d.ts +1 -0
- package/dist/symbols/index.d.ts +5 -0
- package/dist/template/constants.d.ts +43 -0
- package/dist/template/shapes/index.d.ts +4 -0
- package/package.json +34 -44
- package/src/Plot/Axis.svelte +95 -0
- package/src/Plot/Bar.svelte +96 -0
- package/src/Plot/Grid.svelte +68 -0
- package/src/Plot/Legend.svelte +127 -0
- package/src/Plot/Root.svelte +107 -0
- package/src/Plot/index.js +5 -0
- package/src/Symbol.svelte +21 -0
- package/src/Texture.svelte +18 -0
- package/src/elements/Bar.svelte +22 -24
- package/src/elements/ColorRamp.svelte +20 -22
- package/src/elements/ContinuousLegend.svelte +20 -17
- package/src/elements/DefinePatterns.svelte +24 -0
- package/src/elements/DiscreteLegend.svelte +15 -15
- package/src/elements/Label.svelte +4 -8
- package/src/elements/SymbolGrid.svelte +23 -0
- package/src/elements/index.js +6 -0
- package/src/examples/BarChartExample.svelte +81 -0
- package/src/index.js +18 -16
- package/src/lib/brewing/axes.svelte.js +265 -0
- package/src/lib/brewing/bars.svelte.js +177 -0
- package/src/lib/brewing/dimensions.svelte.js +56 -0
- package/src/lib/brewing/index.svelte.js +205 -0
- package/src/lib/brewing/legends.svelte.js +137 -0
- package/src/lib/brewing/scales.svelte.js +106 -0
- package/src/lib/brewing/types.js +73 -0
- package/src/lib/context.js +133 -0
- package/src/lib/scales.svelte.js +172 -0
- package/src/lib/utils.js +107 -120
- package/src/old_lib/brewer.js +25 -0
- package/src/old_lib/chart.js +213 -0
- package/src/old_lib/grid.js +85 -0
- package/src/old_lib/index.js +4 -0
- package/src/old_lib/plots.js +27 -0
- package/src/old_lib/swatch.js +16 -0
- package/src/old_lib/ticks.js +46 -0
- package/src/old_lib/utils.js +8 -0
- package/src/patterns/Brick.svelte +15 -0
- package/src/patterns/Circles.svelte +18 -0
- package/src/patterns/CrossHatch.svelte +12 -0
- package/src/patterns/CurvedWave.svelte +7 -0
- package/src/patterns/Dots.svelte +20 -0
- package/src/patterns/OutlineCircles.svelte +13 -0
- package/src/patterns/README.md +3 -0
- package/src/patterns/Tile.svelte +16 -0
- package/src/patterns/Triangles.svelte +13 -0
- package/src/patterns/Waves.svelte +9 -0
- package/src/patterns/index.js +14 -0
- package/src/patterns/paths/NamedPattern.svelte +9 -0
- package/src/patterns/paths/constants.js +4 -0
- package/src/symbols/RoundedSquare.svelte +33 -0
- package/src/symbols/Shape.svelte +37 -0
- package/src/symbols/constants/index.js +4 -0
- package/src/symbols/index.js +9 -0
- package/src/symbols/outline.svelte +60 -0
- package/src/symbols/solid.svelte +60 -0
- package/src/template/Texture.svelte +13 -0
- package/src/template/constants.js +43 -0
- package/src/template/shapes/Circles.svelte +15 -0
- package/src/template/shapes/Lines.svelte +16 -0
- package/src/template/shapes/Path.svelte +9 -0
- package/src/template/shapes/Polygons.svelte +15 -0
- package/src/template/shapes/index.js +4 -0
- package/src/chart/FacetGrid.svelte +0 -51
- package/src/chart/Grid.svelte +0 -34
- package/src/chart/Legend.svelte +0 -16
- package/src/chart/PatternDefs.svelte +0 -13
- package/src/chart/Swatch.svelte +0 -93
- package/src/chart/SwatchButton.svelte +0 -29
- package/src/chart/SwatchGrid.svelte +0 -55
- package/src/chart/Symbol.svelte +0 -37
- package/src/chart/Texture.svelte +0 -16
- package/src/chart/TexturedShape.svelte +0 -27
- package/src/chart/TimelapseChart.svelte +0 -97
- package/src/chart/Timer.svelte +0 -27
- package/src/chart.js +0 -9
- package/src/components/charts/Axis.svelte +0 -66
- package/src/components/charts/Chart.svelte +0 -35
- package/src/components/index.js +0 -23
- package/src/components/lib/axis.js +0 -0
- package/src/components/lib/chart.js +0 -187
- package/src/components/lib/color.js +0 -327
- package/src/components/lib/funnel.js +0 -204
- package/src/components/lib/index.js +0 -19
- package/src/components/lib/pattern.js +0 -190
- package/src/components/lib/rollup.js +0 -55
- package/src/components/lib/shape.js +0 -199
- package/src/components/lib/summary.js +0 -145
- package/src/components/lib/theme.js +0 -23
- package/src/components/lib/timer.js +0 -41
- package/src/components/lib/utils.js +0 -165
- package/src/components/plots/BarPlot.svelte +0 -36
- package/src/components/plots/BoxPlot.svelte +0 -54
- package/src/components/plots/ScatterPlot.svelte +0 -30
- package/src/components/store.js +0 -70
- package/src/constants.js +0 -66
- package/src/elements/PatternDefs.svelte +0 -13
- package/src/elements/PatternMask.svelte +0 -20
- package/src/elements/Symbol.svelte +0 -38
- package/src/elements/Tooltip.svelte +0 -23
- package/src/funnel.svelte +0 -35
- package/src/geom.js +0 -105
- package/src/lib/axis.js +0 -75
- package/src/lib/colors.js +0 -32
- package/src/lib/geom.js +0 -4
- package/src/lib/shapes.js +0 -144
- package/src/lib/timer.js +0 -44
- package/src/lookup.js +0 -29
- package/src/plots/BarPlot.svelte +0 -55
- package/src/plots/BoxPlot.svelte +0 -0
- package/src/plots/FunnelPlot.svelte +0 -33
- package/src/plots/HeatMap.svelte +0 -5
- package/src/plots/HeatMapCalendar.svelte +0 -129
- package/src/plots/LinePlot.svelte +0 -55
- package/src/plots/Plot.svelte +0 -25
- package/src/plots/RankBarPlot.svelte +0 -38
- package/src/plots/ScatterPlot.svelte +0 -20
- package/src/plots/ViolinPlot.svelte +0 -11
- package/src/plots/heatmap.js +0 -70
- package/src/plots/index.js +0 -10
- package/src/swatch.js +0 -11
package/src/chart/Swatch.svelte
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { createEventDispatcher } from 'svelte'
|
|
3
|
-
|
|
4
|
-
import { swatch } from '../lib/utils'
|
|
5
|
-
import { clamp } from 'yootils'
|
|
6
|
-
import Symbol from './Symbol.svelte'
|
|
7
|
-
import PatternDefs from './PatternDefs.svelte'
|
|
8
|
-
|
|
9
|
-
const dispatch = createEventDispatcher()
|
|
10
|
-
|
|
11
|
-
export let label
|
|
12
|
-
export let size = 30
|
|
13
|
-
export let items = []
|
|
14
|
-
export let type = 'square'
|
|
15
|
-
export let pad = 10
|
|
16
|
-
export let columns
|
|
17
|
-
export let rows
|
|
18
|
-
export let limit
|
|
19
|
-
export let start = 0
|
|
20
|
-
export let autoscale = false
|
|
21
|
-
export let interactive = false
|
|
22
|
-
export let activeIndex = -1
|
|
23
|
-
|
|
24
|
-
function fill(item) {
|
|
25
|
-
return item.fillUrl || item.fill || item
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function stroke(item) {
|
|
29
|
-
return item.stroke || item
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function swapType(inputType) {
|
|
33
|
-
return inputType === 'square'
|
|
34
|
-
? 'circle'
|
|
35
|
-
: inputType === 'circle'
|
|
36
|
-
? 'square'
|
|
37
|
-
: type
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function click(index) {
|
|
41
|
-
if (interactive) {
|
|
42
|
-
activeIndex = start + index
|
|
43
|
-
dispatch('click', { index: activeIndex, item: items[activeIndex] })
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function forwardEvent(event, index) {
|
|
48
|
-
if (interactive)
|
|
49
|
-
dispatch(event, {
|
|
50
|
-
index: start + index,
|
|
51
|
-
item: items[start + index]
|
|
52
|
-
})
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
$: grid = swatch(limit || items.length, size, pad, columns, rows)
|
|
56
|
-
$: data = grid.data.map((item, i) => ({
|
|
57
|
-
...item,
|
|
58
|
-
type: i == activeIndex ? swapType(type) : type
|
|
59
|
-
}))
|
|
60
|
-
$: start = clamp(start, 0, items.length - (limit || 0))
|
|
61
|
-
</script>
|
|
62
|
-
|
|
63
|
-
<div class="flex flex-col leading-loose">
|
|
64
|
-
{#if label}
|
|
65
|
-
<span class="py-2">{label}</span>
|
|
66
|
-
{/if}
|
|
67
|
-
<svg
|
|
68
|
-
viewBox="0 0 {grid.width} {grid.height}"
|
|
69
|
-
width="100%"
|
|
70
|
-
class="cursor-pointer"
|
|
71
|
-
>
|
|
72
|
-
{#if label}
|
|
73
|
-
<title>A swatch with label {label}</title>
|
|
74
|
-
{/if}
|
|
75
|
-
|
|
76
|
-
{#each data as { cx, cy, r, type }, i}
|
|
77
|
-
<Symbol
|
|
78
|
-
x={cx}
|
|
79
|
-
y={cy}
|
|
80
|
-
{size}
|
|
81
|
-
fill={fill(items[i + start])}
|
|
82
|
-
stroke={stroke(items[i + start])}
|
|
83
|
-
shape={items[i + start].shape || type}
|
|
84
|
-
thickness={i + start == activeIndex ? 2 : 0.5}
|
|
85
|
-
on:click={click(i + start)}
|
|
86
|
-
on:mouseover={forwardEvent('mouseover', i + start)}
|
|
87
|
-
on:mouseleave={forwardEvent('mouseleave', i + start)}
|
|
88
|
-
on:focus={forwardEvent('focus', i + start)}
|
|
89
|
-
/>
|
|
90
|
-
{/each}
|
|
91
|
-
<PatternDefs patterns={items} />
|
|
92
|
-
</svg>
|
|
93
|
-
</div>
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import TexturedShape from './TexturedShape.svelte'
|
|
3
|
-
|
|
4
|
-
export let pattern
|
|
5
|
-
export let shape = 'circle'
|
|
6
|
-
// export let type
|
|
7
|
-
export let fill
|
|
8
|
-
export let stroke
|
|
9
|
-
export let isCurrent = false
|
|
10
|
-
|
|
11
|
-
const size = 40
|
|
12
|
-
</script>
|
|
13
|
-
|
|
14
|
-
<button
|
|
15
|
-
class="bg-gray-100 rounded shadow-md w-10 h-10 p-1 flex items-center justify-center hover:bg-primary-300"
|
|
16
|
-
class:isCurrent
|
|
17
|
-
on:click
|
|
18
|
-
on:mouseover
|
|
19
|
-
on:mouseleave
|
|
20
|
-
on:focus
|
|
21
|
-
>
|
|
22
|
-
<TexturedShape {pattern} {fill} {stroke} {shape} {size} />
|
|
23
|
-
</button>
|
|
24
|
-
|
|
25
|
-
<style>
|
|
26
|
-
.isCurrent {
|
|
27
|
-
@apply bg-primary-200;
|
|
28
|
-
}
|
|
29
|
-
</style>
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import SwatchButton from './SwatchButton.svelte'
|
|
3
|
-
|
|
4
|
-
export let columns
|
|
5
|
-
export let rows
|
|
6
|
-
export let items
|
|
7
|
-
let grid
|
|
8
|
-
|
|
9
|
-
function toGrid(columns, rows, patterns) {
|
|
10
|
-
const count = patterns.length
|
|
11
|
-
if (columns > 0) {
|
|
12
|
-
rows = Math.ceil(count / columns)
|
|
13
|
-
} else if (rows > 0) {
|
|
14
|
-
columns = Math.ceil(count / rows)
|
|
15
|
-
} else {
|
|
16
|
-
columns = Math.ceil(Math.sqrt(count))
|
|
17
|
-
rows = Math.ceil(count / columns)
|
|
18
|
-
}
|
|
19
|
-
const grid = [...Array(rows).keys()].map((row) =>
|
|
20
|
-
[...Array(columns).keys()]
|
|
21
|
-
.filter((column) => row * columns + column < count)
|
|
22
|
-
.map((column) => ({
|
|
23
|
-
item: patterns[row * columns + column],
|
|
24
|
-
isCurrent: false,
|
|
25
|
-
}))
|
|
26
|
-
)
|
|
27
|
-
return grid
|
|
28
|
-
}
|
|
29
|
-
let previous
|
|
30
|
-
function handleClick(row, column) {
|
|
31
|
-
console.log(row, column, grid)
|
|
32
|
-
if (previous) {
|
|
33
|
-
grid[previous.row][previous.column].isCurrent = false
|
|
34
|
-
}
|
|
35
|
-
grid[row][column].isCurrent = true
|
|
36
|
-
previous = { row, column }
|
|
37
|
-
}
|
|
38
|
-
$: grid = toGrid(columns, rows, items)
|
|
39
|
-
$: console.log(grid)
|
|
40
|
-
</script>
|
|
41
|
-
|
|
42
|
-
<row class="flex flex-col gap-2">
|
|
43
|
-
{#each grid as items, row}
|
|
44
|
-
<div class="flex flex-row gap-2">
|
|
45
|
-
{#each items as { item, isCurrent }, column}
|
|
46
|
-
<SwatchButton
|
|
47
|
-
shape="shurikan"
|
|
48
|
-
pattern={item}
|
|
49
|
-
on:click={() => handleClick(row, column)}
|
|
50
|
-
{isCurrent}
|
|
51
|
-
/>
|
|
52
|
-
{/each}
|
|
53
|
-
</div>
|
|
54
|
-
{/each}
|
|
55
|
-
</row>
|
package/src/chart/Symbol.svelte
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { namedShapes } from '../components/lib/shape'
|
|
3
|
-
|
|
4
|
-
export let x = 0
|
|
5
|
-
export let y = 0
|
|
6
|
-
export let size = 10
|
|
7
|
-
export let fill = 'none'
|
|
8
|
-
export let stroke = 'currentColor'
|
|
9
|
-
export let thickness = 0.5
|
|
10
|
-
|
|
11
|
-
export let name = null
|
|
12
|
-
export let shape = null
|
|
13
|
-
|
|
14
|
-
$: x = x - size / 2
|
|
15
|
-
$: y = y - size / 2
|
|
16
|
-
|
|
17
|
-
$: d =
|
|
18
|
-
typeof shape === 'function'
|
|
19
|
-
? shape(size)
|
|
20
|
-
: (shape || name) in namedShapes
|
|
21
|
-
? namedShapes[shape || name](size)
|
|
22
|
-
: namedShapes.circle(size)
|
|
23
|
-
</script>
|
|
24
|
-
|
|
25
|
-
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
26
|
-
<path
|
|
27
|
-
{d}
|
|
28
|
-
{fill}
|
|
29
|
-
{stroke}
|
|
30
|
-
transform="translate({x},{y})"
|
|
31
|
-
stroke-width={thickness}
|
|
32
|
-
fill-rule="evenodd"
|
|
33
|
-
on:click
|
|
34
|
-
on:mouseover
|
|
35
|
-
on:mouseleave
|
|
36
|
-
on:focus
|
|
37
|
-
/>
|
package/src/chart/Texture.svelte
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
export let id
|
|
3
|
-
export let fill
|
|
4
|
-
export let path
|
|
5
|
-
export let contrast
|
|
6
|
-
export let thickness = 0.5
|
|
7
|
-
export let patternUnits = 'userSpaceOnUse'
|
|
8
|
-
export let size = 10
|
|
9
|
-
</script>
|
|
10
|
-
|
|
11
|
-
<pattern {id} {patternUnits} width={size} height={size}>
|
|
12
|
-
<rect width={size} height={size} {fill} />
|
|
13
|
-
{#if path}
|
|
14
|
-
<path d={path} fill="none" stroke={contrast} stroke-width={thickness} />
|
|
15
|
-
{/if}
|
|
16
|
-
</pattern>
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import Symbol from './Symbol.svelte'
|
|
3
|
-
import Texture from './Texture.svelte'
|
|
4
|
-
|
|
5
|
-
export let pattern
|
|
6
|
-
export let shape = 'circle'
|
|
7
|
-
export let fill
|
|
8
|
-
export let stroke
|
|
9
|
-
|
|
10
|
-
const size = 40
|
|
11
|
-
</script>
|
|
12
|
-
|
|
13
|
-
<svg viewBox="0 0 {size} {size}">
|
|
14
|
-
<Symbol
|
|
15
|
-
x={size / 2}
|
|
16
|
-
y={size / 2}
|
|
17
|
-
{size}
|
|
18
|
-
fill={pattern.fillUrl || fill}
|
|
19
|
-
{stroke}
|
|
20
|
-
{shape}
|
|
21
|
-
/>
|
|
22
|
-
{#if pattern}
|
|
23
|
-
<defs>
|
|
24
|
-
<Texture {...pattern} />
|
|
25
|
-
</defs>
|
|
26
|
-
{/if}
|
|
27
|
-
</svg>
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { setContext } from 'svelte'
|
|
3
|
-
import { writable } from 'svelte/store'
|
|
4
|
-
import { slidingWindow, uniques, brewer } from '../lib'
|
|
5
|
-
|
|
6
|
-
import Grid from './Grid.svelte'
|
|
7
|
-
import Axis from './Axis.svelte'
|
|
8
|
-
import BoxPlot from '../plots/BoxPlot.svelte'
|
|
9
|
-
import ViolinPlot from '../plots/ViolinPlot.svelte'
|
|
10
|
-
import ScatterPlot from '../plots/ScatterPlot.svelte'
|
|
11
|
-
|
|
12
|
-
let chart = writable({})
|
|
13
|
-
let axis
|
|
14
|
-
setContext('chart', chart)
|
|
15
|
-
|
|
16
|
-
export let data
|
|
17
|
-
export let x
|
|
18
|
-
export let y
|
|
19
|
-
export let time
|
|
20
|
-
export let theme
|
|
21
|
-
|
|
22
|
-
export let current
|
|
23
|
-
export let stages
|
|
24
|
-
|
|
25
|
-
function base(data, x, y) {
|
|
26
|
-
return {
|
|
27
|
-
data,
|
|
28
|
-
x,
|
|
29
|
-
y,
|
|
30
|
-
width: 800,
|
|
31
|
-
height: 350,
|
|
32
|
-
values: {
|
|
33
|
-
x: uniques(data, x),
|
|
34
|
-
y: uniques(data, y),
|
|
35
|
-
},
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function sliceBy(data, attr, size, step, offset) {
|
|
40
|
-
const values = uniques(data, attr)
|
|
41
|
-
const groups = slidingWindow(values, size, step, offset).map((x) => ({
|
|
42
|
-
...x,
|
|
43
|
-
data: data.filter(
|
|
44
|
-
(y) => y.Petal_Length >= x.lowerBound && y.Petal_Length < x.upperBound
|
|
45
|
-
),
|
|
46
|
-
}))
|
|
47
|
-
|
|
48
|
-
return groups
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function timed(data, x, y, time) {
|
|
52
|
-
let chart = base(data, x, y)
|
|
53
|
-
let temp = brewer().chart(data, x, y).use(theme).computeAxis()
|
|
54
|
-
axis = temp.axis
|
|
55
|
-
console.log(temp)
|
|
56
|
-
chart.data = sliceBy(chart.data, time, 3, 1)
|
|
57
|
-
stages = chart.data.length - 1
|
|
58
|
-
return chart
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function switchChart(index) {
|
|
62
|
-
let chart = {}
|
|
63
|
-
if (index != null) {
|
|
64
|
-
chart = brewer()
|
|
65
|
-
.chart(phased.data[index].data, x, y)
|
|
66
|
-
.use(theme)
|
|
67
|
-
.computeAxis()
|
|
68
|
-
chart.axis = axis
|
|
69
|
-
// chart.margin = { left: 40, right: 10, top: 10, bottom: 30 }
|
|
70
|
-
}
|
|
71
|
-
return chart
|
|
72
|
-
}
|
|
73
|
-
let phased
|
|
74
|
-
|
|
75
|
-
$: phased = timed(data, x, y, time)
|
|
76
|
-
$: $chart = switchChart(current)
|
|
77
|
-
// $: console.log(current, phased, chart)
|
|
78
|
-
|
|
79
|
-
// setup chart attributes that do not change over time
|
|
80
|
-
// get scales for x & y
|
|
81
|
-
// set margins
|
|
82
|
-
|
|
83
|
-
// nest data by time attribute
|
|
84
|
-
// set up sequence based on ascending values of time
|
|
85
|
-
// set up the timer to switch between data values
|
|
86
|
-
// On change set the context with new data set
|
|
87
|
-
// Old data set needs exit animation, new data set needs entry animation
|
|
88
|
-
</script>
|
|
89
|
-
|
|
90
|
-
<svg viewBox="0 0 {phased.width} {phased.height}" class="flex chart">
|
|
91
|
-
<Grid />
|
|
92
|
-
<Axis orient="bottom" />
|
|
93
|
-
<Axis orient="left" />
|
|
94
|
-
<BoxPlot />
|
|
95
|
-
<ViolinPlot />
|
|
96
|
-
<ScatterPlot jitterWidth={50} offset={50} />
|
|
97
|
-
</svg>
|
package/src/chart/Timer.svelte
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { createEventDispatcher } from 'svelte'
|
|
3
|
-
import { elapsed, timer } from '../lib/timer.js'
|
|
4
|
-
|
|
5
|
-
const dispatch = createEventDispatcher()
|
|
6
|
-
|
|
7
|
-
export let isEnabled = false
|
|
8
|
-
export let currentKeyframe = 0
|
|
9
|
-
export let keyframeCount = 0
|
|
10
|
-
export let duration = 1000
|
|
11
|
-
|
|
12
|
-
$: if (isEnabled) currentKeyframe = Math.floor($elapsed / duration)
|
|
13
|
-
$: if (currentKeyframe === keyframeCount) dispatch('end')
|
|
14
|
-
$: isEnabled && currentKeyframe < keyframeCount ? timer.start() : timer.stop()
|
|
15
|
-
|
|
16
|
-
function onReset() {
|
|
17
|
-
timer.reset()
|
|
18
|
-
isEnabled = false
|
|
19
|
-
currentKeyframe = 0
|
|
20
|
-
}
|
|
21
|
-
</script>
|
|
22
|
-
|
|
23
|
-
<div class="flex flex-row gap-2 timer">
|
|
24
|
-
<button on:click|preventDefault={() => (isEnabled = true)}>play</button>
|
|
25
|
-
<button on:click|preventDefault={() => (isEnabled = false)}>pause</button>
|
|
26
|
-
<button on:click|preventDefault={onReset}>reset</button>
|
|
27
|
-
</div>
|
package/src/chart.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { getContext } from 'svelte'
|
|
3
|
-
export let orient = 'bottom'
|
|
4
|
-
|
|
5
|
-
let chart = getContext('chart')
|
|
6
|
-
|
|
7
|
-
let top =
|
|
8
|
-
orient === 'bottom'
|
|
9
|
-
? $chart.height - $chart.margin.bottom
|
|
10
|
-
: $chart.margin.top
|
|
11
|
-
let left =
|
|
12
|
-
orient === 'right' ? $chart.width - $chart.margin.right : $chart.margin.left
|
|
13
|
-
let tickSizeInner = $chart.theme.tick.size.inner || 6
|
|
14
|
-
let tickSizeOuter = $chart.theme.tick.size.outer || 6
|
|
15
|
-
let tickPadding = $chart.theme.tick.size.padding || 3
|
|
16
|
-
|
|
17
|
-
function axisPath(vertical, scale) {
|
|
18
|
-
const range = scale.range()
|
|
19
|
-
return vertical
|
|
20
|
-
? `M${k * tickSizeOuter},${range[0]}H0V${range[1]}H${k * tickSizeOuter}`
|
|
21
|
-
: `M${range[0]},${k * tickSizeOuter}V0H${range[1]}V${k * tickSizeOuter}`
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
$: anchor =
|
|
25
|
-
orient === 'right' ? 'start' : orient === 'left' ? 'end' : 'middle'
|
|
26
|
-
$: k = orient === 'top' || orient === 'left' ? -1 : 1
|
|
27
|
-
$: dy = orient === 'top' ? '0em' : orient === 'bottom' ? '0.71em' : '0.32em'
|
|
28
|
-
$: vertical = orient === 'left' || orient === 'right'
|
|
29
|
-
// $: range = axis.scale.range()
|
|
30
|
-
$: axis = vertical ? $chart.axis.y : $chart.axis.x
|
|
31
|
-
</script>
|
|
32
|
-
|
|
33
|
-
<g
|
|
34
|
-
transform="translate({vertical ? left : 0},{vertical ? 0 : top})"
|
|
35
|
-
fill="none"
|
|
36
|
-
font-size="10"
|
|
37
|
-
font-family="sans-serif"
|
|
38
|
-
text-anchor={anchor}
|
|
39
|
-
class="axis"
|
|
40
|
-
>
|
|
41
|
-
<path
|
|
42
|
-
class="domain"
|
|
43
|
-
stroke="currentColor"
|
|
44
|
-
d="{axisPath(vertical, axis.scale)}}"
|
|
45
|
-
/>
|
|
46
|
-
{#each axis.ticks as tick}
|
|
47
|
-
<g
|
|
48
|
-
class="tick"
|
|
49
|
-
transform="translate({vertical ? 0 : tick.position},{vertical
|
|
50
|
-
? tick.position
|
|
51
|
-
: 0})"
|
|
52
|
-
>
|
|
53
|
-
<line
|
|
54
|
-
stroke="currentColor"
|
|
55
|
-
y2={vertical ? 0 : k * tickSizeInner}
|
|
56
|
-
x2={vertical ? k * tickSizeInner : 0}
|
|
57
|
-
/>
|
|
58
|
-
<text
|
|
59
|
-
fill="currentColor"
|
|
60
|
-
y={vertical ? 0 : k * (tickSizeInner + tickPadding)}
|
|
61
|
-
x={vertical ? k * (tickSizeInner + tickPadding) : 0}
|
|
62
|
-
{dy}>{tick.label}</text
|
|
63
|
-
>
|
|
64
|
-
</g>
|
|
65
|
-
{/each}
|
|
66
|
-
</g>
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { setContext } from 'svelte'
|
|
3
|
-
import { writable } from 'svelte/store'
|
|
4
|
-
import { compact } from '../lib/utils'
|
|
5
|
-
import { builtIn } from '../lib/theme'
|
|
6
|
-
|
|
7
|
-
let chart = writable({})
|
|
8
|
-
|
|
9
|
-
setContext('chart', chart)
|
|
10
|
-
|
|
11
|
-
export let width = 800
|
|
12
|
-
export let height = 450
|
|
13
|
-
export let data
|
|
14
|
-
export let theme = builtIn
|
|
15
|
-
export let x
|
|
16
|
-
export let y
|
|
17
|
-
export let fill
|
|
18
|
-
export let color
|
|
19
|
-
export let padding = 20
|
|
20
|
-
export let curve = 'basis'
|
|
21
|
-
export let stat = 'identity'
|
|
22
|
-
|
|
23
|
-
$: aes = compact({ x, y, fill, color, stat, curve, padding })
|
|
24
|
-
$: chart.set({
|
|
25
|
-
width,
|
|
26
|
-
height,
|
|
27
|
-
data,
|
|
28
|
-
theme,
|
|
29
|
-
aes,
|
|
30
|
-
})
|
|
31
|
-
</script>
|
|
32
|
-
|
|
33
|
-
<svg viewBox="0 0 {width} {height}" class="chart" width="100%">
|
|
34
|
-
<slot />
|
|
35
|
-
</svg>
|
package/src/components/index.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export { default as ColorRamp } from './elements/ColorRamp.svelte'
|
|
2
|
-
|
|
3
|
-
export { default as Symbol } from './chart/Symbol.svelte'
|
|
4
|
-
export { default as PatternDefs } from './chart/PatternDefs.svelte'
|
|
5
|
-
export { default as Swatch } from './chart/Swatch.svelte'
|
|
6
|
-
export { default as SwatchButton } from './chart/SwatchButton.svelte'
|
|
7
|
-
export { default as SwatchGrid } from './chart/SwatchGrid.svelte'
|
|
8
|
-
|
|
9
|
-
export { default as Axis } from './chart/Axis.svelte'
|
|
10
|
-
export { default as Grid } from './chart/Grid.svelte'
|
|
11
|
-
|
|
12
|
-
export { default as BoxPlot } from './plots/BoxPlot.svelte'
|
|
13
|
-
export { default as ViolinPlot } from '../plots/ViolinPlot.svelte'
|
|
14
|
-
export { default as ScatterPlot } from './plots/ScatterPlot.svelte'
|
|
15
|
-
export { default as FunnelPlot } from '../plots/FunnelPlot.svelte'
|
|
16
|
-
|
|
17
|
-
export { default as Chart } from './chart/Chart.svelte'
|
|
18
|
-
export { default as TimelapseChart } from './chart/TimelapseChart.svelte'
|
|
19
|
-
export { default as Timer } from './chart/Timer.svelte'
|
|
20
|
-
export { default as BarPlot } from './plots/BarPlot.svelte'
|
|
21
|
-
export { default as HeatMapCalendar } from '../plots/HeatMapCalendar.svelte'
|
|
22
|
-
export { toHexString, initCap, uniqueId, toNested } from './lib/utils'
|
|
23
|
-
export { brewer, uniques, slidingWindow, colors } from './lib/index'
|
|
File without changes
|