@rokkit/chart 1.0.0-next.13 → 1.0.0-next.130
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 +140 -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 +72 -0
- package/dist/lib/brewing/bars.svelte.d.ts +54 -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 +54 -0
- package/dist/lib/brewing/scales.svelte.d.ts +29 -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 +58 -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 +28 -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 +10 -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 +11 -8
- package/src/elements/SymbolGrid.svelte +27 -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 +177 -0
- package/src/lib/brewing/bars.svelte.js +114 -0
- package/src/lib/brewing/dimensions.svelte.js +56 -0
- package/src/lib/brewing/index.svelte.js +202 -0
- package/src/lib/brewing/legends.svelte.js +94 -0
- package/src/lib/brewing/scales.svelte.js +85 -0
- package/src/lib/brewing/types.js +73 -0
- package/src/lib/context.js +132 -0
- package/src/lib/scales.svelte.js +122 -0
- package/src/lib/utils.js +96 -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/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 +22 -0
- package/src/symbols/Shape.svelte +24 -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 +13 -0
- package/src/template/shapes/Lines.svelte +14 -0
- package/src/template/shapes/Path.svelte +9 -0
- package/src/template/shapes/Polygons.svelte +9 -0
- package/src/template/shapes/index.js +4 -0
- package/LICENSE +0 -21
- 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/lib/axis.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
export function axis(scale) {
|
|
2
|
-
const origin = {
|
|
3
|
-
x: scale.x.ticks
|
|
4
|
-
? scale.x(Math.max(0, Math.min(...scale.x.domain())))
|
|
5
|
-
: scale.x.range()[0],
|
|
6
|
-
y: scale.y.ticks
|
|
7
|
-
? scale.y(Math.max(0, Math.min(...scale.y.domain())))
|
|
8
|
-
: scale.y.range()[0]
|
|
9
|
-
}
|
|
10
|
-
const ticks = {
|
|
11
|
-
x: axisTicks(scale.x, { axis: 'x', origin }),
|
|
12
|
-
y: axisTicks(scale.y, { axis: 'y', origin })
|
|
13
|
-
}
|
|
14
|
-
return { origin, ticks }
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function axisTicks(scale, opts) {
|
|
18
|
-
let [minRange, maxRange] = scale.range()
|
|
19
|
-
let count = Math.abs((maxRange - minRange) / 40)
|
|
20
|
-
let ticks = scale.domain()
|
|
21
|
-
let offset = 0
|
|
22
|
-
let { axis, format, origin } = {
|
|
23
|
-
axis: 'x',
|
|
24
|
-
format: (x) => x,
|
|
25
|
-
origin: { x: 0, y: 0 },
|
|
26
|
-
...opts
|
|
27
|
-
}
|
|
28
|
-
if (scale.ticks) {
|
|
29
|
-
ticks = scale.ticks(count)
|
|
30
|
-
} else {
|
|
31
|
-
offset = Math.sign(maxRange - minRange) * (scale.bandwidth() / 2)
|
|
32
|
-
count = Math.min(Math.round(count), scale.domain().length)
|
|
33
|
-
if (count < scale.domain().length) {
|
|
34
|
-
let diff = scale.domain().length - count
|
|
35
|
-
ticks = ticks.filter((d, i) => i % diff == 0)
|
|
36
|
-
}
|
|
37
|
-
// let diff = scale.domain().length - count
|
|
38
|
-
}
|
|
39
|
-
ticks = ticks
|
|
40
|
-
.map((t) => ({
|
|
41
|
-
label: format(t),
|
|
42
|
-
pos: scale(t)
|
|
43
|
-
}))
|
|
44
|
-
.map(({ label, pos }) => ({
|
|
45
|
-
label,
|
|
46
|
-
offset: { x: axis === 'x' ? offset : 0, y: axis === 'y' ? offset : 0 },
|
|
47
|
-
x: axis === 'x' ? pos : origin.x,
|
|
48
|
-
y: axis === 'y' ? pos : origin.y
|
|
49
|
-
}))
|
|
50
|
-
|
|
51
|
-
return ticks
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export class Axis {
|
|
55
|
-
constructor(name, chart, offset) {
|
|
56
|
-
this.name = ['x', 'y'].includes(name) ? name : 'x'
|
|
57
|
-
this.chart = chart
|
|
58
|
-
this.offset = offset
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
set offset(value) {
|
|
62
|
-
const [min, max] = this.chart.scale[this.name].range()
|
|
63
|
-
const otherAxis = this.name === 'x' ? 'y' : 'x'
|
|
64
|
-
const origin = this.chart.origin[otherAxis]
|
|
65
|
-
|
|
66
|
-
this.offset = value * (origin == min ? 1 : origin == max ? -1 : 0)
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// get domain() {
|
|
70
|
-
// let coords =
|
|
71
|
-
// (coords[axis + '1'] =
|
|
72
|
-
// coords[axis + '2'] =
|
|
73
|
-
// origin[axis] - offset[axis])
|
|
74
|
-
// }
|
|
75
|
-
}
|
package/src/lib/colors.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
// import { writable } from 'svelte/store'
|
|
2
|
-
import { repeatAcross } from '../lib/utils'
|
|
3
|
-
|
|
4
|
-
const palette = [
|
|
5
|
-
'#FFDE6B',
|
|
6
|
-
'#EF89EE',
|
|
7
|
-
'#F79F1E',
|
|
8
|
-
'#02B8FF',
|
|
9
|
-
'#9F84EC',
|
|
10
|
-
'#15CBC4',
|
|
11
|
-
'#0092FD',
|
|
12
|
-
'#F63A57',
|
|
13
|
-
'#A2CB39',
|
|
14
|
-
'#FF6E2F',
|
|
15
|
-
'#FEB8B9',
|
|
16
|
-
'#af7aa1',
|
|
17
|
-
'#7EFFF5'
|
|
18
|
-
]
|
|
19
|
-
|
|
20
|
-
export class Palette {
|
|
21
|
-
constructor(colors = palette) {
|
|
22
|
-
this.colors = colors
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
set colors(value) {
|
|
26
|
-
if (value && Array.isArray(value)) this.colors = value
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export function colorBrewer(values) {
|
|
31
|
-
return repeatAcross(palette, [...new Set(values)])
|
|
32
|
-
}
|
package/src/lib/geom.js
DELETED
package/src/lib/shapes.js
DELETED
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
const names = [
|
|
2
|
-
'circle',
|
|
3
|
-
'square',
|
|
4
|
-
'triangle',
|
|
5
|
-
'diamond',
|
|
6
|
-
'star',
|
|
7
|
-
'rhombus',
|
|
8
|
-
'heart'
|
|
9
|
-
]
|
|
10
|
-
const data = {
|
|
11
|
-
square: ['M', 1, 1, 'L', 9, 1, 'L', 9, 9, 'L', 1, 9, 'Z'],
|
|
12
|
-
circle: [
|
|
13
|
-
['M', 0, 5],
|
|
14
|
-
['A', 5, 5, 0, 0, 0, 10, 5],
|
|
15
|
-
['A', 5, 5, 0, 0, 0, 0, 5]
|
|
16
|
-
],
|
|
17
|
-
triangle: ['M', 5, 0, 'L', 10, 10, 'L', 0, 10, 'Z'],
|
|
18
|
-
diamond: [
|
|
19
|
-
['M', 5, 0],
|
|
20
|
-
['A', 7, 7, 0, 0, 0, 10, 5],
|
|
21
|
-
['A', 7, 7, 0, 0, 0, 5, 10],
|
|
22
|
-
['A', 7, 7, 0, 0, 0, 0, 5],
|
|
23
|
-
['A', 7, 7, 0, 0, 0, 5, 0]
|
|
24
|
-
],
|
|
25
|
-
rhombus: ['M', 0, 5, 'L', 5, 0, 'L', 10, 5, 'L', 5, 10, 'Z'],
|
|
26
|
-
heart: [
|
|
27
|
-
['M', 9, 5],
|
|
28
|
-
['A', 0.8, 0.8, 0, 0, 0, 5, 2],
|
|
29
|
-
['A', 0.8, 0.8, 0, 0, 0, 1, 5],
|
|
30
|
-
['L', 5, 9],
|
|
31
|
-
['L', 9, 5]
|
|
32
|
-
],
|
|
33
|
-
star: [
|
|
34
|
-
['M', 4.80001, 0],
|
|
35
|
-
['L', 5.92258, 3.45491],
|
|
36
|
-
['H', 9.55529],
|
|
37
|
-
['L', 6.61637, 5.59017],
|
|
38
|
-
['L', 7.73894, 9.04509],
|
|
39
|
-
['L', 4.80001, 6.90983],
|
|
40
|
-
['L', 1.86108, 9.04509],
|
|
41
|
-
['L', 2.98365, 5.59017],
|
|
42
|
-
['L', 0.0447266, 3.45491],
|
|
43
|
-
['H', 3.67744],
|
|
44
|
-
['L', 4.80001, 0],
|
|
45
|
-
['Z']
|
|
46
|
-
]
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function scaledPath(size, x) {
|
|
50
|
-
if (Array.isArray(x)) return x.map((x) => scaledPath(size, x)).join(' ')
|
|
51
|
-
return typeof size === 'number' ? x * size : x
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export const shapes = names.map((name) => ({
|
|
55
|
-
name,
|
|
56
|
-
path: (s) => scaledPath(s, data[name])
|
|
57
|
-
}))
|
|
58
|
-
|
|
59
|
-
export const namedShapes = {
|
|
60
|
-
square: (s) =>
|
|
61
|
-
`M${0.1 * s} 0` +
|
|
62
|
-
`A${0.1 * s} ${0.1 * s} 0 0 0 0 ${0.1 * s}V${0.9 * s}` +
|
|
63
|
-
`A${0.1 * s} ${0.1 * s} 0 0 0 ${0.1 * s} ${s}H${0.9 * s}` +
|
|
64
|
-
`A${0.1 * s} ${0.1 * s} 0 0 0 ${s} ${0.9 * s}V${0.1 * s}` +
|
|
65
|
-
`A${0.1 * s} ${0.1 * s} 0 0 0 ${0.9 * s} 0Z`,
|
|
66
|
-
circle: (s) =>
|
|
67
|
-
`M0 ${0.5 * s}` +
|
|
68
|
-
`A${0.5 * s} ${0.5 * s} 0 0 0 ${s} ${0.5 * s}` +
|
|
69
|
-
`A${0.5 * s} ${0.5 * s} 0 0 0 0 ${0.5 * s}`,
|
|
70
|
-
diamond: (s) =>
|
|
71
|
-
`M${0.5 * s} 0` +
|
|
72
|
-
`A${0.6 * s} ${0.6 * s} 0 0 0 ${s} ${0.5 * s}` +
|
|
73
|
-
`A${0.6 * s} ${0.6 * s} 0 0 0 ${0.5 * s} ${s}` +
|
|
74
|
-
`A${0.6 * s} ${0.6 * s} 0 0 0 0 ${0.5 * s}` +
|
|
75
|
-
`A${0.6 * s} ${0.6 * s} 0 0 0 ${0.5 * s} 0`,
|
|
76
|
-
triangle: (s) =>
|
|
77
|
-
`M${0.5 * s} ${0.0866 * s}L0 ${0.9234 * s}L${s} ${0.9234 * s}Z`,
|
|
78
|
-
rhombus: (s) =>
|
|
79
|
-
`M${0.5 * s} 0` +
|
|
80
|
-
`L${s} ${0.5 * s}` +
|
|
81
|
-
`L${0.5 * s} ${s}` +
|
|
82
|
-
`L0 ${0.5 * s}Z`,
|
|
83
|
-
star: (s) =>
|
|
84
|
-
`M${0.5 * s} ${0.05 * s}` +
|
|
85
|
-
`L${0.606 * s} ${0.36 * s}` +
|
|
86
|
-
`L${s} ${0.36 * s}` +
|
|
87
|
-
`L${0.685 * s} ${0.59 * s}` +
|
|
88
|
-
`L${0.81 * s} ${0.95 * s}` +
|
|
89
|
-
`L${0.5 * s} ${0.725 * s}` +
|
|
90
|
-
`L${0.19 * s} ${0.95 * s}` +
|
|
91
|
-
`L${0.315 * s} ${0.59 * s}` +
|
|
92
|
-
`L0 ${0.36 * s}` +
|
|
93
|
-
`L${0.394 * s} ${0.36 * s}Z`,
|
|
94
|
-
heart: (s) =>
|
|
95
|
-
`M${0.9 * s} ${0.5 * s}` +
|
|
96
|
-
`A${0.08 * s} ${0.08 * s} 0 0 0 ${0.5 * s} ${0.2 * s}` +
|
|
97
|
-
`A${0.08 * s} ${0.08 * s} 0 0 0 ${0.1 * s} ${0.5 * s}` +
|
|
98
|
-
`L${0.5 * s} ${0.9 * s}` +
|
|
99
|
-
`L${0.9 * s} ${0.5 * s}`,
|
|
100
|
-
shurikan: (s) =>
|
|
101
|
-
`M${0.3 * s} ${0.1 * s}L${0.5 * s} 0L${0.7 * s} ${0.1 * s}` +
|
|
102
|
-
`A ${0.05 * s} ${0.05 * s} 0 0 0 ${0.9 * s} ${0.35 * s}` +
|
|
103
|
-
`L${s} ${0.5 * s}L${0.9 * s} ${0.7 * s}` +
|
|
104
|
-
`A ${0.05 * s} ${0.05 * s} 0 0 0 ${0.7 * s} ${0.9 * s}` +
|
|
105
|
-
`L${0.5 * s} ${s}L${0.3 * s} ${0.9 * s}` +
|
|
106
|
-
`A${0.05 * s} ${0.05 * s} 0 0 0 ${0.1 * s} ${0.7 * s}` +
|
|
107
|
-
`L0 ${0.5 * s}L${0.1 * s} ${0.3 * s}` +
|
|
108
|
-
`A${0.05 * s} ${0.05 * s} 0 0 0 ${0.3 * s} ${0.1 * s}` +
|
|
109
|
-
`M${0.4 * s} ${0.5 * s}` +
|
|
110
|
-
`A${0.1 * s} ${0.1 * s} 0 0 0 ${0.6 * s} ${0.5 * s}` +
|
|
111
|
-
`A${0.1 * s} ${0.1 * s} 0 0 0 ${0.4 * s} ${0.5 * s}`,
|
|
112
|
-
crosshair: (s) =>
|
|
113
|
-
`M${0.2 * s} ${0.5 * s}` +
|
|
114
|
-
`A${0.3 * s} ${0.3 * s} 0 0 0 ${0.8 * s} ${0.5 * s}` +
|
|
115
|
-
`A${0.3 * s} ${0.3 * s} 0 0 0 ${0.2 * s} ${0.5 * s}` +
|
|
116
|
-
`M0 ${0.5 * s}` +
|
|
117
|
-
`L${s} ${0.5 * s}` +
|
|
118
|
-
`M${0.5 * s} 0` +
|
|
119
|
-
`L${0.5 * s} ${s}`,
|
|
120
|
-
crossboats: (s) =>
|
|
121
|
-
`M0 ${0.5 * s}` +
|
|
122
|
-
`A${0.6 * s} ${0.4 * s} 0 0 0 ${s} ${0.5 * s}` +
|
|
123
|
-
`A${0.6 * s} ${0.4 * s} 0 0 0 0 ${0.5 * s}` +
|
|
124
|
-
`M${0.5 * s} 0` +
|
|
125
|
-
`A${0.4 * s} ${0.6 * s} 0 0 0 ${0.5 * s} ${s}` +
|
|
126
|
-
`A${0.4 * s} ${0.6 * s} 0 0 0 ${0.5 * s} 0`,
|
|
127
|
-
curvedrhombus: (s) =>
|
|
128
|
-
`M${0.1 * s} ${0.1 * s}` +
|
|
129
|
-
`A${0.5 * s} ${0.5 * s} 0 0 0 ${0.9 * s} ${0.1 * s}` +
|
|
130
|
-
`A${0.5 * s} ${0.5 * s} 0 0 0 ${0.9 * s} ${0.9 * s}` +
|
|
131
|
-
`A${0.5 * s} ${0.5 * s} 0 0 0 ${0.1 * s} ${0.9 * s}` +
|
|
132
|
-
`A${0.5 * s} ${0.5 * s} 0 0 0 ${0.1 * s} ${0.1 * s}`,
|
|
133
|
-
fourflags: (s) =>
|
|
134
|
-
`M${0.5 * s} ${0.3 * s}` +
|
|
135
|
-
`A${0.2 * s} ${0.1 * s} 0 0 0 ${0.5 * s} ${0.1 * s}` +
|
|
136
|
-
`L${0.5 * s} ${0.9 * s}` +
|
|
137
|
-
`M${0.5 * s} ${0.7 * s}` +
|
|
138
|
-
`A${0.2 * s} ${0.1 * s} 0 0 0 ${0.5 * s} ${0.9 * s}` +
|
|
139
|
-
`M${0.3 * s} ${0.5 * s}` +
|
|
140
|
-
`A${0.1 * s} ${0.2 * s} 0 0 0 ${0.1 * s} ${0.5 * s}` +
|
|
141
|
-
`L${0.9 * s} ${0.5 * s}` +
|
|
142
|
-
`M${0.7 * s} ${0.5 * s}` +
|
|
143
|
-
`A${0.1 * s} ${0.2 * s} 0 0 0 ${0.9 * s} ${0.5 * s}`
|
|
144
|
-
}
|
package/src/lib/timer.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { writable } from 'svelte/store'
|
|
2
|
-
|
|
3
|
-
let req
|
|
4
|
-
let prev
|
|
5
|
-
const elapsed = writable(0)
|
|
6
|
-
|
|
7
|
-
const tick = (timestamp) => {
|
|
8
|
-
if (!prev) prev = timestamp
|
|
9
|
-
const diff = Math.round(timestamp - prev)
|
|
10
|
-
|
|
11
|
-
if (diff > 0) {
|
|
12
|
-
prev = timestamp
|
|
13
|
-
}
|
|
14
|
-
elapsed.update((e) => e + diff)
|
|
15
|
-
req = window.requestAnimationFrame(tick)
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const timer = {
|
|
19
|
-
start() {
|
|
20
|
-
if (typeof window === 'undefined') return
|
|
21
|
-
else if (!req) {
|
|
22
|
-
prev = null
|
|
23
|
-
req = window.requestAnimationFrame(tick)
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
stop() {
|
|
27
|
-
if (typeof window === 'undefined') return
|
|
28
|
-
else if (req) {
|
|
29
|
-
window.cancelAnimationFrame(req)
|
|
30
|
-
req = null
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
toggle() {
|
|
34
|
-
req ? timer.stop() : timer.start()
|
|
35
|
-
},
|
|
36
|
-
set(val) {
|
|
37
|
-
if (typeof val === 'number') elapsed.set(val)
|
|
38
|
-
},
|
|
39
|
-
reset() {
|
|
40
|
-
timer.set(0)
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export { timer, elapsed }
|
package/src/lookup.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { writable } from 'svelte/store'
|
|
2
|
-
|
|
3
|
-
// import { __patterns__, __colors__, __shapes__ } from './constants'
|
|
4
|
-
|
|
5
|
-
export const swatchStore = writable({})
|
|
6
|
-
|
|
7
|
-
// export function swatch(colors, patterns, shapes, defaults) {
|
|
8
|
-
// const limit = min([colors.length, patterns.length, shapes.length])
|
|
9
|
-
|
|
10
|
-
// swatchStore.set({
|
|
11
|
-
// colors: colors.slice(0, limit),
|
|
12
|
-
// patterns: patterns.slice(0, limit),
|
|
13
|
-
// shapes: shapes.slice(0, limit),
|
|
14
|
-
// defaults: {
|
|
15
|
-
// color: '#eeeeee',
|
|
16
|
-
// shape: __shapes__.circle,
|
|
17
|
-
// pattern: __patterns__.empty,
|
|
18
|
-
// ...defaults
|
|
19
|
-
// }
|
|
20
|
-
// })
|
|
21
|
-
// }
|
|
22
|
-
|
|
23
|
-
export function spread(values, across, filler) {
|
|
24
|
-
const unique = [...new Set(values)]
|
|
25
|
-
const lookup = unique.map((k, i) => ({
|
|
26
|
-
[k]: i < across.length ? across[i] : filler
|
|
27
|
-
}))
|
|
28
|
-
return (k) => lookup[k]
|
|
29
|
-
}
|
package/src/plots/BarPlot.svelte
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { getContext } from 'svelte'
|
|
3
|
-
import { colorBrewer } from '../lib/colors'
|
|
4
|
-
|
|
5
|
-
let chart = getContext('chart')
|
|
6
|
-
|
|
7
|
-
export let labels = false
|
|
8
|
-
export let fontSize = $chart.height / 32
|
|
9
|
-
export let color = 'white'
|
|
10
|
-
|
|
11
|
-
$: fills = colorBrewer($chart.data.map((d) => d.fill))
|
|
12
|
-
// export let limit = 8
|
|
13
|
-
|
|
14
|
-
$: data = $chart.data.map((d) => ({
|
|
15
|
-
x: $chart.flipCoords ? $chart.scale.x(0) : $chart.scale.x(d.x),
|
|
16
|
-
y: $chart.flipCoords ? $chart.scale.y(d.y) : $chart.scale.y(d.y),
|
|
17
|
-
y0: $chart.scale.y(0),
|
|
18
|
-
width: $chart.flipCoords
|
|
19
|
-
? $chart.scale.x(d.x) - $chart.scale.x(0)
|
|
20
|
-
: $chart.scale.x.bandwidth(),
|
|
21
|
-
height: $chart.flipCoords
|
|
22
|
-
? $chart.scale.y.bandwidth()
|
|
23
|
-
: $chart.scale.y(0) - $chart.scale.y(d.y),
|
|
24
|
-
fill: fills[d.fill],
|
|
25
|
-
label: {
|
|
26
|
-
x: $chart.flipCoords
|
|
27
|
-
? $chart.scale.x(d.x) - $chart.scale.x(0) - 10
|
|
28
|
-
: $chart.scale.x.bandwidth() / 2,
|
|
29
|
-
y: $chart.flipCoords ? $chart.scale.y.bandwidth() / 2 : 10,
|
|
30
|
-
angle: $chart.flipCoords ? 0 : -90,
|
|
31
|
-
text: $chart.flipCoords ? d.y + ' (' + d.x + ')' : d.x + ' (' + d.y + ')'
|
|
32
|
-
}
|
|
33
|
-
}))
|
|
34
|
-
|
|
35
|
-
// $: console.log(data)
|
|
36
|
-
</script>
|
|
37
|
-
|
|
38
|
-
{#each data as { x, y, width, height, fill, label }}
|
|
39
|
-
<rect {x} {y} {width} {height} {fill} />
|
|
40
|
-
{#if labels}
|
|
41
|
-
{@const tx = x + label.x}
|
|
42
|
-
{@const ty = y + label.y}
|
|
43
|
-
<text
|
|
44
|
-
x={tx}
|
|
45
|
-
y={ty}
|
|
46
|
-
transform="rotate({label.angle},{tx},{ty})"
|
|
47
|
-
font-size={fontSize}
|
|
48
|
-
text-anchor="end"
|
|
49
|
-
alignment-baseline="middle"
|
|
50
|
-
fill={color}
|
|
51
|
-
>
|
|
52
|
-
{label.text}
|
|
53
|
-
</text>
|
|
54
|
-
{/if}
|
|
55
|
-
{/each}
|
package/src/plots/BoxPlot.svelte
DELETED
|
File without changes
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { getContext } from 'svelte'
|
|
3
|
-
import { compact } from '../components/lib/utils'
|
|
4
|
-
import { funnel } from '../components/lib/funnel'
|
|
5
|
-
|
|
6
|
-
const chart = getContext('chart')
|
|
7
|
-
|
|
8
|
-
export let x
|
|
9
|
-
export let y
|
|
10
|
-
export let fill
|
|
11
|
-
export let curve = 'bump'
|
|
12
|
-
export let stat = 'count'
|
|
13
|
-
|
|
14
|
-
$: aes = { ...$chart.aes, ...compact({ x, y, fill, stat, curve }) }
|
|
15
|
-
$: data = funnel($chart.data, aes, $chart.width, $chart.height)
|
|
16
|
-
// $: console.log(data)
|
|
17
|
-
</script>
|
|
18
|
-
|
|
19
|
-
{#each data.stats as stat, i}
|
|
20
|
-
<path d={data.path(stat.value)} fill={$chart.theme.colors[i]} />
|
|
21
|
-
{/each}
|
|
22
|
-
{#each data.labels as label, index}
|
|
23
|
-
{#if index < data.labels.length - 1}
|
|
24
|
-
<line
|
|
25
|
-
x1={label.x1}
|
|
26
|
-
x2={label.x2}
|
|
27
|
-
y1={label.y1}
|
|
28
|
-
y2={label.y2}
|
|
29
|
-
stroke="currentColor"
|
|
30
|
-
/>
|
|
31
|
-
{/if}
|
|
32
|
-
<text x={label.x} y={label.y} fill="currentColor">{label.label}</text>
|
|
33
|
-
{/each}
|
package/src/plots/HeatMap.svelte
DELETED
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { summarize, heatmap } from './heatmap'
|
|
3
|
-
import { interpolateHsl } from 'd3-interpolate'
|
|
4
|
-
import { scaleLinear } from 'd3-scale'
|
|
5
|
-
import ContinuousLegend from '../elements/ContinuousLegend.svelte'
|
|
6
|
-
import DiscreteLegend from '../elements/DiscreteLegend.svelte'
|
|
7
|
-
import ColorRamp from '../elements/ColorRamp.svelte'
|
|
8
|
-
|
|
9
|
-
const dayLabelWidth = 20
|
|
10
|
-
const labelHeight = 6
|
|
11
|
-
|
|
12
|
-
export let data
|
|
13
|
-
export let dateField = 'date'
|
|
14
|
-
export let valueField = null
|
|
15
|
-
export let months = 12
|
|
16
|
-
export let colors = [transparent, '#FB8C00']
|
|
17
|
-
export let padding = 8
|
|
18
|
-
export let space = 2
|
|
19
|
-
export let size = 10
|
|
20
|
-
export let maximum = 10
|
|
21
|
-
export let tickCount = 5
|
|
22
|
-
export let discreteLegend = false
|
|
23
|
-
|
|
24
|
-
export let tooltipText = (d) => `${d.date} => ${d.value}`
|
|
25
|
-
|
|
26
|
-
let tooltip = null
|
|
27
|
-
|
|
28
|
-
function showToolTip(event, d) {
|
|
29
|
-
tooltip = d
|
|
30
|
-
}
|
|
31
|
-
function hideToolTip() {
|
|
32
|
-
tooltip = null
|
|
33
|
-
}
|
|
34
|
-
$: scale = scaleLinear()
|
|
35
|
-
.domain([0, maximum])
|
|
36
|
-
.range(colors)
|
|
37
|
-
.interpolate(interpolateHsl)
|
|
38
|
-
|
|
39
|
-
$: legendHeight = 2 * size + space * 3
|
|
40
|
-
$: sizeWithSpace = size + space
|
|
41
|
-
$: summary = summarize(data, dateField, valueField)
|
|
42
|
-
$: datamap = heatmap(summary, months)
|
|
43
|
-
$: width =
|
|
44
|
-
datamap.numberOfWeeks * sizeWithSpace + dayLabelWidth + 2 * padding - space
|
|
45
|
-
$: height = 7 * sizeWithSpace + labelHeight + 2 * padding + legendHeight
|
|
46
|
-
</script>
|
|
47
|
-
|
|
48
|
-
<div>
|
|
49
|
-
<svg class="chart" viewBox="0 0 {width} {height}">
|
|
50
|
-
{#if tooltip}
|
|
51
|
-
<text
|
|
52
|
-
x={padding + dayLabelWidth}
|
|
53
|
-
y={padding + legendHeight - labelHeight}
|
|
54
|
-
text-anchor="start"
|
|
55
|
-
font-size={labelHeight}
|
|
56
|
-
>
|
|
57
|
-
{tooltipText(tooltip)}
|
|
58
|
-
</text>
|
|
59
|
-
{/if}
|
|
60
|
-
{#if discreteLegend}
|
|
61
|
-
<DiscreteLegend
|
|
62
|
-
{scale}
|
|
63
|
-
x={width - (tickCount + 1) * sizeWithSpace - padding - space}
|
|
64
|
-
y={padding}
|
|
65
|
-
{tickCount}
|
|
66
|
-
/>
|
|
67
|
-
{:else}
|
|
68
|
-
<ColorRamp {scale} x={width - 100 - padding} y={padding} {tickCount} />
|
|
69
|
-
<!-- <ContinuousLegend
|
|
70
|
-
{scale}
|
|
71
|
-
x={width - 100 - padding}
|
|
72
|
-
y={padding}
|
|
73
|
-
{tickCount}
|
|
74
|
-
/> -->
|
|
75
|
-
{/if}
|
|
76
|
-
{#each datamap.weekdays as name, i}
|
|
77
|
-
<text
|
|
78
|
-
x={padding + dayLabelWidth - 2 * space}
|
|
79
|
-
y={padding +
|
|
80
|
-
legendHeight +
|
|
81
|
-
i * sizeWithSpace +
|
|
82
|
-
labelHeight +
|
|
83
|
-
(size - labelHeight) / 2}
|
|
84
|
-
text-anchor="end"
|
|
85
|
-
font-size={labelHeight}>{name}</text
|
|
86
|
-
>
|
|
87
|
-
{/each}
|
|
88
|
-
|
|
89
|
-
{#each datamap.grid as d}
|
|
90
|
-
<rect
|
|
91
|
-
x={d.x * sizeWithSpace + padding + dayLabelWidth}
|
|
92
|
-
y={d.y * sizeWithSpace + padding + legendHeight}
|
|
93
|
-
width={size}
|
|
94
|
-
height={size}
|
|
95
|
-
fill={scale(d.value)}
|
|
96
|
-
rx="1"
|
|
97
|
-
ry="1"
|
|
98
|
-
on:mouseover={(e) => showToolTip(e, d)}
|
|
99
|
-
on:focus={(e) => showToolTip(e, d)}
|
|
100
|
-
on:blur={hideToolTip}
|
|
101
|
-
on:mouseout={hideToolTip}
|
|
102
|
-
/>
|
|
103
|
-
{/each}
|
|
104
|
-
|
|
105
|
-
{#each Object.keys(datamap.months) as name}
|
|
106
|
-
<text
|
|
107
|
-
x={padding + dayLabelWidth + datamap.months[name] * sizeWithSpace}
|
|
108
|
-
y={padding + legendHeight + 7 * sizeWithSpace + 3 * space}
|
|
109
|
-
text-anchor="start"
|
|
110
|
-
font-size={labelHeight}
|
|
111
|
-
fill="currentColor">{name}</text
|
|
112
|
-
>
|
|
113
|
-
{/each}
|
|
114
|
-
</svg>
|
|
115
|
-
</div>
|
|
116
|
-
|
|
117
|
-
<style>
|
|
118
|
-
div {
|
|
119
|
-
position: relative;
|
|
120
|
-
}
|
|
121
|
-
rect {
|
|
122
|
-
stroke: currentColor;
|
|
123
|
-
stroke-width: 0.5;
|
|
124
|
-
stroke-opacity: 0.1;
|
|
125
|
-
}
|
|
126
|
-
text {
|
|
127
|
-
fill: currentColor;
|
|
128
|
-
}
|
|
129
|
-
</style>
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { getContext } from 'svelte'
|
|
3
|
-
import { colorBrewer } from '../lib/colors'
|
|
4
|
-
|
|
5
|
-
let chart = getContext('chart')
|
|
6
|
-
|
|
7
|
-
export let labels = false
|
|
8
|
-
export let fontSize = $chart.height / 32
|
|
9
|
-
// export let color = 'white'
|
|
10
|
-
|
|
11
|
-
$: colors = colorBrewer($chart.data.map((d) => d.color))
|
|
12
|
-
// export let limit = 8
|
|
13
|
-
|
|
14
|
-
$: data = $chart.data.map((d) => ({
|
|
15
|
-
x: $chart.flipCoords ? $chart.scale.x(0) : $chart.scale.x(d.x),
|
|
16
|
-
y: $chart.flipCoords ? $chart.scale.y(d.y) : $chart.scale.y(d.y),
|
|
17
|
-
y0: $chart.scale.y(0),
|
|
18
|
-
width: $chart.flipCoords
|
|
19
|
-
? $chart.scale.x(d.x) - $chart.scale.x(0)
|
|
20
|
-
: $chart.scale.x.bandwidth(),
|
|
21
|
-
height: $chart.flipCoords
|
|
22
|
-
? $chart.scale.y.bandwidth()
|
|
23
|
-
: $chart.scale.y(0) - $chart.scale.y(d.y),
|
|
24
|
-
color: colors[d.color],
|
|
25
|
-
label: {
|
|
26
|
-
x: $chart.flipCoords
|
|
27
|
-
? $chart.scale.x(d.x) - $chart.scale.x(0) - 10
|
|
28
|
-
: $chart.scale.x.bandwidth() / 2,
|
|
29
|
-
y: $chart.flipCoords ? $chart.scale.y.bandwidth() / 2 : 10,
|
|
30
|
-
angle: $chart.flipCoords ? 0 : -90,
|
|
31
|
-
text: $chart.flipCoords ? d.y + ' (' + d.x + ')' : d.x + ' (' + d.y + ')'
|
|
32
|
-
}
|
|
33
|
-
}))
|
|
34
|
-
|
|
35
|
-
// $: console.log(data)
|
|
36
|
-
</script>
|
|
37
|
-
|
|
38
|
-
{#each data as { x1, y1, x2, y2, color, label }}
|
|
39
|
-
<line {x1} {y1} {x2} {y2} stroke={color} />
|
|
40
|
-
{#if labels}
|
|
41
|
-
{@const tx = x1 + label.x}
|
|
42
|
-
{@const ty = y1 + label.y}
|
|
43
|
-
<text
|
|
44
|
-
x={tx}
|
|
45
|
-
y={ty}
|
|
46
|
-
transform="rotate({label.angle},{tx},{ty})"
|
|
47
|
-
font-size={fontSize}
|
|
48
|
-
text-anchor="end"
|
|
49
|
-
alignment-baseline="middle"
|
|
50
|
-
fill={color}
|
|
51
|
-
>
|
|
52
|
-
{label.text}
|
|
53
|
-
</text>
|
|
54
|
-
{/if}
|
|
55
|
-
{/each}
|
package/src/plots/Plot.svelte
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { aggregate, getScales } from '../lib/utils'
|
|
3
|
-
|
|
4
|
-
import BoxPlot from './BoxPlot.svelte'
|
|
5
|
-
import ScatterPlot from './ScatterPlot.svelte'
|
|
6
|
-
|
|
7
|
-
export let data
|
|
8
|
-
export let width
|
|
9
|
-
export let height
|
|
10
|
-
export let x
|
|
11
|
-
export let y
|
|
12
|
-
export let plots = []
|
|
13
|
-
|
|
14
|
-
$: nested = aggregate(data, x, y)
|
|
15
|
-
$: scales = getScales(data, x, y, width, height)
|
|
16
|
-
</script>
|
|
17
|
-
|
|
18
|
-
<svg viewBox="0 0 {width} {height}">
|
|
19
|
-
{#if plots.includes('box')}
|
|
20
|
-
<BoxPlot data={nested} {...scales} />
|
|
21
|
-
{/if}
|
|
22
|
-
{#if plots.includes('scatter')}
|
|
23
|
-
<ScatterPlot {data} {x} {y} {...scales} />
|
|
24
|
-
{/if}
|
|
25
|
-
</svg>
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import Bar from '../elements/Bar.svelte'
|
|
3
|
-
import { max } from 'd3-array'
|
|
4
|
-
import { writable } from 'svelte/store'
|
|
5
|
-
import { tweened } from 'svelte/motion'
|
|
6
|
-
import { scaleLinear } from 'd3-scale'
|
|
7
|
-
|
|
8
|
-
export let data
|
|
9
|
-
export let colors
|
|
10
|
-
export let width = 800
|
|
11
|
-
export let limit = 8
|
|
12
|
-
export let duration = 300
|
|
13
|
-
const h = 50
|
|
14
|
-
let height
|
|
15
|
-
const pad = 5
|
|
16
|
-
|
|
17
|
-
const xMax = tweened(null, { duration })
|
|
18
|
-
const scales = writable({})
|
|
19
|
-
|
|
20
|
-
$: xMax.set(max(data.map((d) => d.value)))
|
|
21
|
-
$: height = pad + (h + pad) * limit
|
|
22
|
-
$: scales.set({
|
|
23
|
-
x: scaleLinear()
|
|
24
|
-
.domain([0, $xMax])
|
|
25
|
-
.range([10, width - 10]),
|
|
26
|
-
y: scaleLinear().domain([0, limit]).range([0, height])
|
|
27
|
-
})
|
|
28
|
-
</script>
|
|
29
|
-
|
|
30
|
-
<svg viewBox="0 0 {width} {height}">
|
|
31
|
-
{#if Array.isArray(data)}
|
|
32
|
-
{#each data as item, i}
|
|
33
|
-
{#if item.rank < limit}
|
|
34
|
-
<Bar {...item} fill={colors[item.name]} {scales} />
|
|
35
|
-
{/if}
|
|
36
|
-
{/each}
|
|
37
|
-
{/if}
|
|
38
|
-
</svg>
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { getContext } from 'svelte'
|
|
3
|
-
import { colorBrewer } from '../lib/colors'
|
|
4
|
-
|
|
5
|
-
let chart = getContext('chart')
|
|
6
|
-
|
|
7
|
-
export let size = $chart.height / 128
|
|
8
|
-
|
|
9
|
-
$: colors = colorBrewer($chart.data.map((d) => d.fill))
|
|
10
|
-
$: points = $chart.data.map((d) => ({
|
|
11
|
-
cx: $chart.scale.x(d.x),
|
|
12
|
-
cy: $chart.scale.y(d.y),
|
|
13
|
-
fill: colors[d.fill]
|
|
14
|
-
}))
|
|
15
|
-
// support shapes and sizes for scatter
|
|
16
|
-
</script>
|
|
17
|
-
|
|
18
|
-
{#each points as { cx, cy, fill }}
|
|
19
|
-
<circle {cx} {cy} r={size} {fill} fill-opacity="0.5" />
|
|
20
|
-
{/each}
|