layerchart 0.0.1 → 0.0.5
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 +2 -37
- package/components/Arc.svelte +77 -0
- package/components/Arc.svelte.d.ts +34 -0
- package/components/Area.svelte +47 -0
- package/components/Area.svelte.d.ts +31 -0
- package/components/AreaStack.svelte +40 -0
- package/components/AreaStack.svelte.d.ts +20 -0
- package/components/AxisX.svelte +52 -0
- package/components/AxisX.svelte.d.ts +23 -0
- package/components/AxisY.svelte +66 -0
- package/components/AxisY.svelte.d.ts +23 -0
- package/components/Bars.svelte +102 -0
- package/components/Bars.svelte.d.ts +35 -0
- package/components/Baseline.svelte +21 -0
- package/components/Baseline.svelte.d.ts +17 -0
- package/components/Chart.svelte +50 -0
- package/components/Chart.svelte.d.ts +24 -0
- package/components/Circle.svelte +15 -0
- package/components/Circle.svelte.d.ts +22 -0
- package/components/ConnectedPoints.svelte +68 -0
- package/components/ConnectedPoints.svelte.d.ts +18 -0
- package/components/Group.svelte +26 -0
- package/components/Group.svelte.d.ts +21 -0
- package/components/HighlightLine.svelte +52 -0
- package/components/HighlightLine.svelte.d.ts +17 -0
- package/components/HighlightRect.svelte +27 -0
- package/components/HighlightRect.svelte.d.ts +18 -0
- package/components/Labels.svelte +96 -0
- package/components/Labels.svelte.d.ts +22 -0
- package/components/Line.svelte +18 -0
- package/components/Line.svelte.d.ts +23 -0
- package/components/LinearGradient.svelte +27 -0
- package/components/LinearGradient.svelte.d.ts +27 -0
- package/components/Path.svelte +40 -0
- package/components/Path.svelte.d.ts +27 -0
- package/components/Points.svelte +58 -0
- package/components/Points.svelte.d.ts +19 -0
- package/components/Rect.svelte +25 -0
- package/components/Rect.svelte.d.ts +25 -0
- package/components/Text.svelte +129 -0
- package/components/Text.svelte.d.ts +28 -0
- package/components/Threshold.svelte +86 -0
- package/components/Threshold.svelte.d.ts +35 -0
- package/components/Tooltip.svelte +120 -0
- package/components/Tooltip.svelte.d.ts +33 -0
- package/components/index.d.ts +19 -0
- package/components/index.js +19 -0
- package/docs/Blockquote.svelte +7 -0
- package/docs/Blockquote.svelte.d.ts +23 -0
- package/docs/Code.svelte +6 -0
- package/docs/Code.svelte.d.ts +23 -0
- package/docs/Layout.svelte +20 -0
- package/docs/Layout.svelte.d.ts +29 -0
- package/docs/Link.svelte +7 -0
- package/docs/Link.svelte.d.ts +27 -0
- package/docs/Preview.svelte +23 -0
- package/docs/Preview.svelte.d.ts +21 -0
- package/index.d.ts +3 -0
- package/index.js +3 -0
- package/package.json +84 -26
- package/stores/motionStore.d.ts +8 -0
- package/stores/motionStore.js +16 -0
- package/utils/event.d.ts +4 -0
- package/utils/event.js +42 -0
- package/utils/genData.d.ts +32 -0
- package/utils/genData.js +59 -0
- package/utils/index.d.ts +1 -0
- package/utils/index.js +1 -0
- package/utils/math.d.ts +4 -0
- package/utils/math.js +6 -0
- package/utils/path.d.ts +5 -0
- package/utils/path.js +14 -0
- package/utils/pivot.d.ts +14 -0
- package/utils/pivot.js +36 -0
- package/utils/scales.d.ts +10 -0
- package/utils/scales.js +21 -0
- package/utils/stack.d.ts +14 -0
- package/utils/stack.js +69 -0
- package/utils/string.d.ts +4 -0
- package/utils/string.js +27 -0
- package/utils/ticks.d.ts +3 -0
- package/utils/ticks.js +157 -0
- package/.prettierrc +0 -6
- package/src/app.html +0 -12
- package/src/global.d.ts +0 -1
- package/src/routes/index.svelte +0 -2
- package/static/favicon.png +0 -0
- package/svelte.config.js +0 -15
- package/tsconfig.json +0 -31
package/utils/ticks.js
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { timeYear, timeMonth, timeWeek, timeDay, timeHour, timeMinute, timeSecond, timeMillisecond } from 'd3-time';
|
|
2
|
+
import { format } from 'date-fns';
|
|
3
|
+
import { formatDate, PeriodType } from 'svelte-ux/utils/date';
|
|
4
|
+
import { getDuration } from 'svelte-ux/utils/duration';
|
|
5
|
+
import { fail } from 'svelte-ux/types';
|
|
6
|
+
// TODO: Use PeriodType along with Duration to format (and possibly select intervals)
|
|
7
|
+
const majorTicks = [
|
|
8
|
+
{
|
|
9
|
+
predicate: (duration) => duration == null,
|
|
10
|
+
interval: timeYear.every(1),
|
|
11
|
+
format: (date) => date.toString()
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
predicate: (duration) => duration.years > 1,
|
|
15
|
+
interval: timeYear.every(1),
|
|
16
|
+
format: (date) => formatDate(date, PeriodType.CalendarYear, 'short')
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
predicate: (duration) => duration.years,
|
|
20
|
+
interval: timeMonth.every(1),
|
|
21
|
+
format: (date) => formatDate(date, PeriodType.Month, 'short')
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
predicate: (duration) => duration.days > 30,
|
|
25
|
+
interval: timeMonth.every(1),
|
|
26
|
+
format: (date) => formatDate(date, PeriodType.Month, 'short')
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
predicate: (duration) => duration.days,
|
|
30
|
+
interval: timeDay.every(1),
|
|
31
|
+
format: (date) => formatDate(date, PeriodType.Day, 'short')
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
predicate: (duration) => duration.hours,
|
|
35
|
+
interval: timeHour.every(1),
|
|
36
|
+
format: (date) => format(date, 'h:mm a')
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
predicate: (duration) => duration.minutes > 10,
|
|
40
|
+
interval: timeMinute.every(10),
|
|
41
|
+
format: (date) => format(date, 'h:mm a')
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
predicate: (duration) => duration.minutes,
|
|
45
|
+
interval: timeMinute.every(1),
|
|
46
|
+
format: (date) => format(date, 'h:mm a')
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
predicate: (duration) => duration.seconds > 10,
|
|
50
|
+
interval: timeSecond.every(10),
|
|
51
|
+
format: (date) => format(date, 'h:mm:ss')
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
predicate: (duration) => duration.seconds,
|
|
55
|
+
interval: timeSecond.every(1),
|
|
56
|
+
format: (date) => format(date, 'h:mm:ss')
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
predicate: (duration) => true,
|
|
60
|
+
interval: timeMillisecond.every(100),
|
|
61
|
+
format: (date) => format(date, 'h:mm:ss.SSS')
|
|
62
|
+
}
|
|
63
|
+
];
|
|
64
|
+
const minorTicks = [
|
|
65
|
+
{
|
|
66
|
+
predicate: (duration) => duration == null,
|
|
67
|
+
interval: timeYear.every(1),
|
|
68
|
+
format: (date) => date.toString()
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
predicate: (duration) => duration.years,
|
|
72
|
+
interval: timeMonth.every(1),
|
|
73
|
+
format: (date) => formatDate(date, PeriodType.Month, 'short')
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
predicate: (duration) => duration.days > 90,
|
|
77
|
+
interval: timeMonth.every(1),
|
|
78
|
+
format: (date) => formatDate(date, PeriodType.Month, 'short')
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
predicate: (duration) => duration.days > 30,
|
|
82
|
+
interval: timeWeek.every(1),
|
|
83
|
+
format: (date) => formatDate(date, PeriodType.WeekSun, 'short')
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
predicate: (duration) => duration.days > 7,
|
|
87
|
+
interval: timeDay.every(1),
|
|
88
|
+
format: (date) => formatDate(date, PeriodType.Day, 'short')
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
predicate: (duration) => duration.days > 3,
|
|
92
|
+
interval: timeHour.every(8),
|
|
93
|
+
format: (date) => format(date, 'h:mm a')
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
predicate: (duration) => duration.days,
|
|
97
|
+
interval: timeHour.every(1),
|
|
98
|
+
format: (date) => format(date, 'h:mm a')
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
predicate: (duration) => duration.hours,
|
|
102
|
+
interval: timeMinute.every(15),
|
|
103
|
+
format: (date) => format(date, 'h:mm a')
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
predicate: (duration) => duration.minutes > 10,
|
|
107
|
+
interval: timeMinute.every(10),
|
|
108
|
+
format: (date) => format(date, 'h:mm a')
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
predicate: (duration) => duration.minutes > 2,
|
|
112
|
+
interval: timeMinute.every(1),
|
|
113
|
+
format: (date) => format(date, 'h:mm a')
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
predicate: (duration) => duration.minutes,
|
|
117
|
+
interval: timeSecond.every(10),
|
|
118
|
+
format: (date) => format(date, 'h:mm:ss')
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
predicate: (duration) => duration.seconds,
|
|
122
|
+
interval: timeSecond.every(1),
|
|
123
|
+
format: (date) => format(date, 'h:mm:ss')
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
predicate: (duration) => true,
|
|
127
|
+
interval: timeMillisecond.every(10),
|
|
128
|
+
format: (date) => format(date, 'h:mm:ss.SSS')
|
|
129
|
+
}
|
|
130
|
+
];
|
|
131
|
+
export function getMajorTicks(start, end) {
|
|
132
|
+
const duration = getDuration(start, end);
|
|
133
|
+
for (var t of majorTicks) {
|
|
134
|
+
if (t.predicate(duration)) {
|
|
135
|
+
return t.interval;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
fail(`Unable to locate major ticks for duration: ${duration}`);
|
|
139
|
+
}
|
|
140
|
+
export function formatMajorTick(date, rangeStart, rangeEnd) {
|
|
141
|
+
const duration = getDuration(rangeStart, rangeEnd);
|
|
142
|
+
for (var t of majorTicks) {
|
|
143
|
+
if (t.predicate(duration)) {
|
|
144
|
+
return t.format(date);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
fail(`Unable to format major ticks for duration: ${duration}`);
|
|
148
|
+
}
|
|
149
|
+
export function getMinorTicks(start, end) {
|
|
150
|
+
const duration = getDuration(start, end);
|
|
151
|
+
for (var t of minorTicks) {
|
|
152
|
+
if (t.predicate(duration)) {
|
|
153
|
+
return t.interval;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
fail(`Unable to locate minor ticks for duration: ${duration}`);
|
|
157
|
+
}
|
package/.prettierrc
DELETED
package/src/app.html
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8" />
|
|
5
|
-
<link rel="icon" href="/favicon.png" />
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
7
|
-
%svelte.head%
|
|
8
|
-
</head>
|
|
9
|
-
<body>
|
|
10
|
-
<div id="svelte">%svelte.body%</div>
|
|
11
|
-
</body>
|
|
12
|
-
</html>
|
package/src/global.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/// <reference types="@sveltejs/kit" />
|
package/src/routes/index.svelte
DELETED
package/static/favicon.png
DELETED
|
Binary file
|
package/svelte.config.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import preprocess from 'svelte-preprocess';
|
|
2
|
-
|
|
3
|
-
/** @type {import('@sveltejs/kit').Config} */
|
|
4
|
-
const config = {
|
|
5
|
-
// Consult https://github.com/sveltejs/svelte-preprocess
|
|
6
|
-
// for more information about preprocessors
|
|
7
|
-
preprocess: preprocess(),
|
|
8
|
-
|
|
9
|
-
kit: {
|
|
10
|
-
// hydrate the <div id="svelte"> element in src/app.html
|
|
11
|
-
target: '#svelte'
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export default config;
|
package/tsconfig.json
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"moduleResolution": "node",
|
|
4
|
-
"module": "es2020",
|
|
5
|
-
"lib": ["es2020", "DOM"],
|
|
6
|
-
"target": "es2019",
|
|
7
|
-
/**
|
|
8
|
-
svelte-preprocess cannot figure out whether you have a value or a type, so tell TypeScript
|
|
9
|
-
to enforce using \`import type\` instead of \`import\` for Types.
|
|
10
|
-
*/
|
|
11
|
-
"importsNotUsedAsValues": "error",
|
|
12
|
-
"isolatedModules": true,
|
|
13
|
-
"resolveJsonModule": true,
|
|
14
|
-
/**
|
|
15
|
-
To have warnings/errors of the Svelte compiler at the correct position,
|
|
16
|
-
enable source maps by default.
|
|
17
|
-
*/
|
|
18
|
-
"sourceMap": true,
|
|
19
|
-
"esModuleInterop": true,
|
|
20
|
-
"skipLibCheck": true,
|
|
21
|
-
"forceConsistentCasingInFileNames": true,
|
|
22
|
-
"baseUrl": ".",
|
|
23
|
-
"allowJs": true,
|
|
24
|
-
"checkJs": true,
|
|
25
|
-
"paths": {
|
|
26
|
-
"$lib": ["src/lib"],
|
|
27
|
-
"$lib/*": ["src/lib/*"]
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
"include": ["src/**/*.d.ts", "src/**/*.js", "src/**/*.ts", "src/**/*.svelte"]
|
|
31
|
-
}
|