@genome-spy/core 0.14.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.
Files changed (226) hide show
  1. package/dist/index.js +224 -0
  2. package/dist/style.css +1 -0
  3. package/package.json +54 -0
  4. package/src/data/collector.js +178 -0
  5. package/src/data/collector.test.js +82 -0
  6. package/src/data/dataFlow.js +109 -0
  7. package/src/data/dataFlow.test.js +3 -0
  8. package/src/data/facetNode.js +17 -0
  9. package/src/data/flow.test.js +71 -0
  10. package/src/data/flowBatch.d.ts +40 -0
  11. package/src/data/flowNode.js +283 -0
  12. package/src/data/flowNode.test.js +49 -0
  13. package/src/data/flowOptimizer.js +117 -0
  14. package/src/data/flowOptimizer.test.js +192 -0
  15. package/src/data/flowTestUtils.js +63 -0
  16. package/src/data/formats/fasta.js +32 -0
  17. package/src/data/formats/fasta.test.js +26 -0
  18. package/src/data/sources/dataSource.js +22 -0
  19. package/src/data/sources/dataSourceFactory.js +24 -0
  20. package/src/data/sources/dataUtils.js +31 -0
  21. package/src/data/sources/dynamicCallbackSource.js +56 -0
  22. package/src/data/sources/dynamicSource.js +36 -0
  23. package/src/data/sources/inlineSource.js +69 -0
  24. package/src/data/sources/inlineSource.test.js +55 -0
  25. package/src/data/sources/namedSource.js +74 -0
  26. package/src/data/sources/sequenceSource.js +46 -0
  27. package/src/data/sources/sequenceSource.test.js +45 -0
  28. package/src/data/sources/urlSource.js +74 -0
  29. package/src/data/transforms/aggregate.js +69 -0
  30. package/src/data/transforms/clone.js +40 -0
  31. package/src/data/transforms/clone.test.js +10 -0
  32. package/src/data/transforms/coverage.js +187 -0
  33. package/src/data/transforms/coverage.test.js +122 -0
  34. package/src/data/transforms/filter.js +37 -0
  35. package/src/data/transforms/filter.test.js +17 -0
  36. package/src/data/transforms/filterScoredLabels.js +134 -0
  37. package/src/data/transforms/flattenCompressedExons.js +57 -0
  38. package/src/data/transforms/flattenDelimited.js +68 -0
  39. package/src/data/transforms/flattenDelimited.test.js +86 -0
  40. package/src/data/transforms/flattenSequence.js +39 -0
  41. package/src/data/transforms/flattenSequence.test.js +33 -0
  42. package/src/data/transforms/formula.js +39 -0
  43. package/src/data/transforms/formula.test.js +18 -0
  44. package/src/data/transforms/identifier.js +108 -0
  45. package/src/data/transforms/identifier.test.js +82 -0
  46. package/src/data/transforms/linearizeGenomicCoordinate.js +101 -0
  47. package/src/data/transforms/measureText.js +44 -0
  48. package/src/data/transforms/pileup.js +128 -0
  49. package/src/data/transforms/pileup.test.js +69 -0
  50. package/src/data/transforms/project.js +41 -0
  51. package/src/data/transforms/project.test.js +31 -0
  52. package/src/data/transforms/regexExtract.js +61 -0
  53. package/src/data/transforms/regexExtract.test.js +66 -0
  54. package/src/data/transforms/regexFold.js +141 -0
  55. package/src/data/transforms/regexFold.test.js +159 -0
  56. package/src/data/transforms/sample.js +101 -0
  57. package/src/data/transforms/sample.test.js +37 -0
  58. package/src/data/transforms/stack.js +137 -0
  59. package/src/data/transforms/stack.test.js +90 -0
  60. package/src/data/transforms/transformFactory.js +60 -0
  61. package/src/encoder/accessor.js +82 -0
  62. package/src/encoder/accessor.test.js +46 -0
  63. package/src/encoder/encoder.js +369 -0
  64. package/src/encoder/encoder.test.js +97 -0
  65. package/src/fonts/Lato-Regular.json +1267 -0
  66. package/src/fonts/Lato-Regular.png +0 -0
  67. package/src/fonts/OFL.txt +93 -0
  68. package/src/fonts/README.md +3 -0
  69. package/src/fonts/bmFont.d.ts +58 -0
  70. package/src/fonts/bmFontManager.js +357 -0
  71. package/src/fonts/bmFontMetrics.js +108 -0
  72. package/src/genome/genome.js +305 -0
  73. package/src/genome/genome.test.js +152 -0
  74. package/src/genome/genomeStore.js +54 -0
  75. package/src/genome/locusFormat.js +31 -0
  76. package/src/genome/scaleIndex.js +199 -0
  77. package/src/genome/scaleIndex.test.js +61 -0
  78. package/src/genome/scaleLocus.js +112 -0
  79. package/src/genome/scaleLocus.test.js +3 -0
  80. package/src/genomeSpy.js +753 -0
  81. package/src/gl/arrayBuilder.js +199 -0
  82. package/src/gl/dataToVertices.js +621 -0
  83. package/src/gl/includes/common.glsl +63 -0
  84. package/src/gl/includes/fp64-arithmetic.glsl +187 -0
  85. package/src/gl/includes/fp64-utils.js +132 -0
  86. package/src/gl/includes/picking.fragment.glsl +3 -0
  87. package/src/gl/includes/picking.vertex.glsl +29 -0
  88. package/src/gl/includes/sampleFacet.glsl +107 -0
  89. package/src/gl/includes/scales.glsl +79 -0
  90. package/src/gl/includes/scales_fp64.glsl +30 -0
  91. package/src/gl/link.fragment.glsl +18 -0
  92. package/src/gl/link.vertex.glsl +111 -0
  93. package/src/gl/point.fragment.glsl +123 -0
  94. package/src/gl/point.vertex.glsl +128 -0
  95. package/src/gl/rect.fragment.glsl +51 -0
  96. package/src/gl/rect.vertex.glsl +114 -0
  97. package/src/gl/rule.fragment.glsl +52 -0
  98. package/src/gl/rule.vertex.glsl +89 -0
  99. package/src/gl/text.fragment.glsl +31 -0
  100. package/src/gl/text.vertex.glsl +246 -0
  101. package/src/gl/webGLHelper.js +490 -0
  102. package/src/img/bowtie.svg +1 -0
  103. package/src/img/genomespy-favicon.svg +34 -0
  104. package/src/index.html +11 -0
  105. package/src/index.js +151 -0
  106. package/src/marks/link.js +189 -0
  107. package/src/marks/mark.js +867 -0
  108. package/src/marks/markUtils.js +109 -0
  109. package/src/marks/pointMark.js +279 -0
  110. package/src/marks/rectMark.js +236 -0
  111. package/src/marks/rule.js +231 -0
  112. package/src/marks/text.js +274 -0
  113. package/src/options.d.ts +9 -0
  114. package/src/scale/colorUtils.js +184 -0
  115. package/src/scale/glslScaleGenerator.js +462 -0
  116. package/src/scale/scale.js +441 -0
  117. package/src/scale/scale.test.js +323 -0
  118. package/src/scale/ticks.js +198 -0
  119. package/src/scale/ticks.test.js +39 -0
  120. package/src/singlePageApp.js +13 -0
  121. package/src/spec/axis.d.ts +296 -0
  122. package/src/spec/channel.d.ts +127 -0
  123. package/src/spec/data.d.ts +185 -0
  124. package/src/spec/font.d.ts +15 -0
  125. package/src/spec/genome.d.ts +35 -0
  126. package/src/spec/mark.d.ts +432 -0
  127. package/src/spec/root.d.ts +22 -0
  128. package/src/spec/scale.d.ts +265 -0
  129. package/src/spec/tooltip.d.ts +9 -0
  130. package/src/spec/transform.d.ts +479 -0
  131. package/src/spec/view.d.ts +215 -0
  132. package/src/styles/genome-spy.scss +153 -0
  133. package/src/tooltip/dataTooltipHandler.js +59 -0
  134. package/src/tooltip/refseqGeneTooltipHandler.js +77 -0
  135. package/src/tooltip/tooltipHandler.ts +12 -0
  136. package/src/types/filetypes.d.ts +4 -0
  137. package/src/types/flatqueue.d.ts +53 -0
  138. package/src/types/glsl.d.ts +4 -0
  139. package/src/types/object.d.ts +21 -0
  140. package/src/types/vega-scale.d.ts +60 -0
  141. package/src/utils/animator.js +83 -0
  142. package/src/utils/arrayUtils.js +55 -0
  143. package/src/utils/binnedRangeIndex.js +83 -0
  144. package/src/utils/clamp.js +8 -0
  145. package/src/utils/cloner.js +32 -0
  146. package/src/utils/cloner.test.js +23 -0
  147. package/src/utils/coalesce.js +11 -0
  148. package/src/utils/coalesce.test.js +15 -0
  149. package/src/utils/concatIterables.js +26 -0
  150. package/src/utils/concatIterables.test.js +7 -0
  151. package/src/utils/debounce.js +37 -0
  152. package/src/utils/domainArray.js +224 -0
  153. package/src/utils/domainArray.test.js +129 -0
  154. package/src/utils/eerp.js +13 -0
  155. package/src/utils/expression.js +32 -0
  156. package/src/utils/field.js +28 -0
  157. package/src/utils/fisheye.js +60 -0
  158. package/src/utils/formatObject.js +31 -0
  159. package/src/utils/html.js +23 -0
  160. package/src/utils/html.test.js +13 -0
  161. package/src/utils/indexer.js +43 -0
  162. package/src/utils/indexer.test.js +46 -0
  163. package/src/utils/inertia.js +124 -0
  164. package/src/utils/interactionEvent.js +33 -0
  165. package/src/utils/iterateNestedMaps.js +21 -0
  166. package/src/utils/iterateNestedMaps.test.js +32 -0
  167. package/src/utils/kWayMerge.js +42 -0
  168. package/src/utils/kWayMerge.test.js +25 -0
  169. package/src/utils/layout/flexLayout.js +336 -0
  170. package/src/utils/layout/flexLayout.test.js +296 -0
  171. package/src/utils/layout/padding.js +107 -0
  172. package/src/utils/layout/point.js +23 -0
  173. package/src/utils/layout/rectangle.js +282 -0
  174. package/src/utils/layout/rectangle.test.js +171 -0
  175. package/src/utils/mergeObjects.js +99 -0
  176. package/src/utils/mergeObjects.test.js +41 -0
  177. package/src/utils/numberExtractor.js +24 -0
  178. package/src/utils/numberExtractor.test.js +5 -0
  179. package/src/utils/point.js +14 -0
  180. package/src/utils/propertyCacher.js +70 -0
  181. package/src/utils/propertyCacher.test.js +84 -0
  182. package/src/utils/propertyCoalescer.js +37 -0
  183. package/src/utils/propertyCoalescer.test.js +21 -0
  184. package/src/utils/reservationMap.js +103 -0
  185. package/src/utils/reservationMap.test.js +19 -0
  186. package/src/utils/scaleNull.js +19 -0
  187. package/src/utils/setOperations.js +75 -0
  188. package/src/utils/smoothstep.js +10 -0
  189. package/src/utils/throttle.js +34 -0
  190. package/src/utils/topK.js +76 -0
  191. package/src/utils/topK.test.js +63 -0
  192. package/src/utils/transition.js +74 -0
  193. package/src/utils/ui/tooltip.js +189 -0
  194. package/src/utils/url.js +22 -0
  195. package/src/utils/variableTools.js +24 -0
  196. package/src/utils/variableTools.test.js +12 -0
  197. package/src/view/axisResolution.js +135 -0
  198. package/src/view/axisResolution.test.js +200 -0
  199. package/src/view/axisView.js +746 -0
  200. package/src/view/channel.js +5 -0
  201. package/src/view/concatView.js +296 -0
  202. package/src/view/containerView.js +141 -0
  203. package/src/view/decoratorView.js +510 -0
  204. package/src/view/facetView.js +488 -0
  205. package/src/view/flowBuilder.js +362 -0
  206. package/src/view/flowBuilder.test.js +124 -0
  207. package/src/view/importView.js +19 -0
  208. package/src/view/layerView.js +60 -0
  209. package/src/view/rendering.d.ts +44 -0
  210. package/src/view/renderingContext/compositeViewRenderingContext.js +51 -0
  211. package/src/view/renderingContext/deferredViewRenderingContext.js +174 -0
  212. package/src/view/renderingContext/layoutRecorderViewRenderingContext.js +128 -0
  213. package/src/view/renderingContext/simpleViewRenderingContext.js +62 -0
  214. package/src/view/renderingContext/svgViewRenderingContext.js +121 -0
  215. package/src/view/renderingContext/viewRenderingContext.js +41 -0
  216. package/src/view/scaleResolution.js +756 -0
  217. package/src/view/scaleResolution.test.js +571 -0
  218. package/src/view/scaleResolutionApi.d.ts +40 -0
  219. package/src/view/testUtils.js +48 -0
  220. package/src/view/unitView.js +368 -0
  221. package/src/view/view.js +589 -0
  222. package/src/view/view.test.js +213 -0
  223. package/src/view/viewContext.d.ts +57 -0
  224. package/src/view/viewFactory.js +179 -0
  225. package/src/view/viewFactory.test.js +16 -0
  226. package/src/view/viewUtils.js +420 -0
@@ -0,0 +1,296 @@
1
+ import { Align, Baseline, FontStyle, FontWeight } from "./font";
2
+
3
+ export interface GenomeAxis extends Axis {
4
+ chromTicks?: boolean;
5
+ chromTickSize?: number;
6
+ chromTickWidth?: number;
7
+ chromTickColor?: string;
8
+ chromTickDash?: number[];
9
+ chromTickDashOffset?: number;
10
+
11
+ chromLabels?: boolean;
12
+ chromLabelFont?: string;
13
+ chromLabelFontSize?: number;
14
+ chromLabelFontWeight?: FontWeight;
15
+ chromLabelFontStyle?: FontStyle;
16
+ chromLabelColor?: string;
17
+ chromLabelPadding?: number;
18
+ chromLabelAlign?: Align;
19
+ // TODO: chromLabelPerpendicularPadding
20
+ }
21
+
22
+ /*!
23
+ * Adapted from
24
+ * https://github.com/vega/vega/blob/master/packages/vega-typings/types/spec/axis.d.ts
25
+ *
26
+ * Copyright (c) 2015-2018, University of Washington Interactive Data Lab
27
+ * All rights reserved.
28
+ *
29
+ * BSD-3-Clause License: https://github.com/vega/vega/blob/master/LICENSE
30
+ */
31
+
32
+ export type AxisOrient = "top" | "bottom" | "left" | "right";
33
+
34
+ export interface Axis extends BaseAxis {
35
+ /**
36
+ * The orientation of the axis. One of `"top"`, `"bottom"`, `"left"` or `"right"`. The orientation can be used to further specialize the axis type (e.g., a y axis oriented for the right edge of the chart).
37
+ *
38
+ * __Default value:__ `"bottom"` for x-axes and `"left"` for y-axes.
39
+ */
40
+ orient?: AxisOrient;
41
+
42
+ /**
43
+ * The format specifier pattern for axis labels.
44
+ * Must be a legal [d3-format](https://github.com/d3/d3-format#locale_format) specifier.
45
+ */
46
+ format?: string;
47
+
48
+ /**
49
+ * A title for the axis (none by default).
50
+ */
51
+ title?: string;
52
+
53
+ /**
54
+ * The orthogonal offset in pixels by which to displace the axis from its position along the edge of the chart.
55
+ */
56
+ offset?: number;
57
+
58
+ /**
59
+ * A desired number of ticks, for axes visualizing quantitative scales. The resulting number may be different so that values are "nice" (multiples of `2`, `5`, `10`) and lie within the underlying scale's range.
60
+ *
61
+ * @minimum 0
62
+ */
63
+ tickCount?: number;
64
+
65
+ /**
66
+ * The minimum desired step between axis ticks, in terms of scale domain values. For example, a value of `1` indicates that ticks should not be less than 1 unit apart. If `tickMinStep` is specified, the `tickCount` value will be adjusted, if necessary, to enforce the minimum step value.
67
+ */
68
+ tickMinStep?: number;
69
+
70
+ /**
71
+ * Explicitly set the visible axis tick and label values.
72
+ */
73
+ values?: any[];
74
+ }
75
+
76
+ export interface BaseAxis<
77
+ N = number,
78
+ NS = number,
79
+ B = boolean,
80
+ BNS = number | boolean,
81
+ S = string,
82
+ C = string,
83
+ FW = string,
84
+ FS = string
85
+ > {
86
+ /**
87
+ * The minimum extent in pixels that axis ticks and labels should use. This determines a minimum offset value for axis titles.
88
+ *
89
+ * __Default value:__ `30` for y-axis; `undefined` for x-axis.
90
+ */
91
+ minExtent?: N;
92
+
93
+ /**
94
+ * The maximum extent in pixels that axis ticks and labels should use. This determines a maximum offset value for axis titles.
95
+ *
96
+ * __Default value:__ `undefined`.
97
+ */
98
+ maxExtent?: N;
99
+
100
+ // ---------- Title ----------
101
+ /**
102
+ * The padding, in pixels, between title and axis.
103
+ */
104
+ titlePadding?: N;
105
+
106
+ /**
107
+ * Color of the title, can be in hex color code or regular color name.
108
+ */
109
+ titleColor?: C;
110
+
111
+ /**
112
+ * Font of the title. (e.g., `"Helvetica Neue"`).
113
+ */
114
+ titleFont?: S;
115
+
116
+ /**
117
+ * Font size of the title.
118
+ *
119
+ * @minimum 0
120
+ */
121
+ titleFontSize?: N;
122
+
123
+ /**
124
+ * Font style of the title.
125
+ */
126
+ titleFontStyle?: FS;
127
+
128
+ /**
129
+ * Font weight of the title.
130
+ * This can be either a string (e.g `"bold"`, `"normal"`) or a number (`100`, `200`, `300`, ..., `900` where `"normal"` = `400` and `"bold"` = `700`).
131
+ */
132
+ titleFontWeight?: FW;
133
+
134
+ /**
135
+ * Opacity of the axis title.
136
+ */
137
+ titleOpacity?: N;
138
+
139
+ // ---------- Domain ----------
140
+ /**
141
+ * A boolean flag indicating if the domain (the axis baseline) should be included as part of the axis.
142
+ *
143
+ * __Default value:__ `true`
144
+ */
145
+ domain?: boolean;
146
+
147
+ /**
148
+ * The stroke cap for the domain line's ending style. One of `"butt"`, `"round"` or `"square"`.
149
+ *
150
+ * __Default value:__ `"butt"`
151
+ */
152
+ domainCap?: "butt" | "round" | "square";
153
+
154
+ /**
155
+ * An array of alternating [stroke, space] lengths for dashed domain lines.
156
+ */
157
+ domainDash?: number[];
158
+
159
+ /**
160
+ * The pixel offset at which to start drawing with the domain dash array.
161
+ */
162
+ domainDashOffset?: number;
163
+
164
+ /**
165
+ * Color of axis domain line.
166
+ *
167
+ * __Default value:__ `"gray"`.
168
+ */
169
+ domainColor?: C;
170
+
171
+ /**
172
+ * Stroke width of axis domain line
173
+ *
174
+ * __Default value:__ `1`
175
+ */
176
+ domainWidth?: N;
177
+
178
+ // ---------- Ticks ----------
179
+ /**
180
+ * Boolean value that determines whether the axis should include ticks.
181
+ *
182
+ * __Default value:__ `true`
183
+ */
184
+ ticks?: B;
185
+
186
+ /**
187
+ * The stroke cap for the tick lines' ending style. One of `"butt"`, `"round"` or `"square"`.
188
+ *
189
+ * __Default value:__ `"butt"`
190
+ */
191
+ tickCap?: "butt" | "round" | "square";
192
+
193
+ /**
194
+ * The color of the axis's tick.
195
+ *
196
+ * __Default value:__ `"gray"`
197
+ */
198
+ tickColor?: C;
199
+
200
+ /**
201
+ * An array of alternating [stroke, space] lengths for dashed tick mark lines.
202
+ */
203
+ tickDash?: number[];
204
+
205
+ /**
206
+ * The pixel offset at which to start drawing with the tick mark dash array.
207
+ */
208
+ tickDashOffset?: number;
209
+
210
+ /**
211
+ * The size in pixels of axis ticks.
212
+ *
213
+ * __Default value:__ `5`
214
+ * @minimum 0
215
+ */
216
+ tickSize?: N;
217
+
218
+ /**
219
+ * The width, in pixels, of ticks.
220
+ *
221
+ * __Default value:__ `1`
222
+ * @minimum 0
223
+ */
224
+ tickWidth?: N;
225
+
226
+ // ---------- Labels ----------
227
+ /**
228
+ * A boolean flag indicating if labels should be included as part of the axis.
229
+ *
230
+ * __Default value:__ `true`.
231
+ */
232
+ labels?: boolean;
233
+
234
+ /**
235
+ * Horizontal text alignment of axis tick labels, overriding the default setting for the current axis orientation.
236
+ */
237
+ labelAlign?: Align;
238
+
239
+ /**
240
+ * The rotation angle of the axis labels.
241
+ *
242
+ * __Default value:__ `-90` for nominal and ordinal fields; `0` otherwise.
243
+ *
244
+ * @minimum -360
245
+ * @maximum 360
246
+ */
247
+ labelAngle?: number;
248
+
249
+ /**
250
+ * Vertical text baseline of axis tick labels, overriding the default setting for the current axis orientation.
251
+ * One of `"alphabetic"` (default), `"top"`, `"middle"`, `"bottom"`.
252
+ */
253
+ labelBaseline?: Baseline;
254
+
255
+ /**
256
+ * The color of the tick label, can be in hex color code or regular color name.
257
+ */
258
+ labelColor?: C;
259
+
260
+ /**
261
+ * The font of the tick label.
262
+ */
263
+ labelFont?: S;
264
+
265
+ /**
266
+ * The font size of the label, in pixels.
267
+ *
268
+ * @minimum 0
269
+ */
270
+ labelFontSize?: N;
271
+
272
+ /**
273
+ * Font style of the title.
274
+ */
275
+ labelFontStyle?: FS;
276
+
277
+ /**
278
+ * Font weight of axis tick labels.
279
+ */
280
+ labelFontWeight?: FW;
281
+
282
+ /**
283
+ * Maximum allowed pixel width of axis tick labels.
284
+ *
285
+ * __Default value:__ `180`
286
+ */
287
+ labelLimit?: N;
288
+
289
+ /**
290
+ * The padding, in pixels, between axis and text labels.
291
+ *
292
+ * __Default value:__ `2`
293
+ */
294
+
295
+ labelPadding?: N;
296
+ }
@@ -0,0 +1,127 @@
1
+ import { Scale } from "./scale";
2
+ import { Axis } from "./axis";
3
+
4
+ export type Scalar = string | number | boolean;
5
+ export type FieldName = string;
6
+
7
+ export type PositionalChannel = "x" | "y";
8
+
9
+ export type SecondaryPositionalChannel = "x2" | "y2";
10
+
11
+ export type Channel =
12
+ | PositionalChannel
13
+ | SecondaryPositionalChannel
14
+ | "color"
15
+ | "fill"
16
+ | "stroke"
17
+ | "opacity"
18
+ | "fillOpacity"
19
+ | "strokeOpacity"
20
+ | "strokeWidth"
21
+ | "size"
22
+ | "shape"
23
+ | "text"
24
+ | "size2"
25
+ | "color2"
26
+ | "angle"
27
+ | "sample"
28
+ | "uniqueId"
29
+ | "search"
30
+ | "facetIndex"
31
+ | "semanticScore"
32
+ | "dx"
33
+ | "dy";
34
+
35
+ export interface ChannelDefBase {
36
+ title?: string | null;
37
+ }
38
+
39
+ export interface ValueDef extends ChannelDefBase {
40
+ /** A constant value in the context of the range */
41
+ value: Scalar;
42
+ }
43
+
44
+ export interface ChannelDefWithScale extends ChannelDefBase {
45
+ type: string;
46
+
47
+ /**
48
+ * Offset within a band of a band scale, [0, 1]
49
+ *
50
+ * TODO: rename to bandPosition: https://github.com/vega/vega-lite/pull/7190
51
+ */
52
+ band?: number;
53
+
54
+ scale?: Scale;
55
+ axis?: Axis | null;
56
+
57
+ format?: string;
58
+
59
+ /**
60
+ * Use emulated 64 bit floating points to increase precision of scales
61
+ * computed on the GPU. By default, 32 bit floats are used.
62
+ */
63
+ fp64?: boolean;
64
+
65
+ /**
66
+ * Use an alternative channel for scale resolution.
67
+ *
68
+ * This is mainly for internal use and allows using `color` channel to resolve
69
+ * `fill` and `stroke` channels under certain circumstances.
70
+ */
71
+ resolutionChannel?: Channel;
72
+ }
73
+
74
+ export interface FieldDef extends ChannelDefWithScale {
75
+ field: FieldName;
76
+ }
77
+
78
+ export interface DatumDef extends ChannelDefWithScale {
79
+ /** A constant value on the data domain */
80
+ datum: Scalar;
81
+ }
82
+
83
+ export interface ExprDef extends ChannelDefWithScale {
84
+ /** An expression. Properties of the data can be accessed through the `datum` object. */
85
+ expr: string;
86
+ }
87
+ export interface ChromPosDef extends ChannelDefWithScale {
88
+ type: "locus";
89
+
90
+ /**
91
+ * The field having the chromosome or contig.
92
+ */
93
+ chrom: FieldName;
94
+
95
+ /**
96
+ * The field having an intra-chromosomal position.
97
+ */
98
+ pos?: FieldName;
99
+
100
+ /**
101
+ * An offset or offsets that allow for adjusting the numbering base. The offset
102
+ * is subtracted from the positions.
103
+ *
104
+ * GenomeSpy uses internally zero-based indexing with half-open intervals.
105
+ * UCSC-based formats (BED, etc.) generally use this scheme. However, for example,
106
+ * VCF files use one-based indexing and must be adjusted by setting the offset to
107
+ * `1`.
108
+ *
109
+ * **Default:** `0`
110
+ */
111
+ offset?: number;
112
+ }
113
+
114
+ export interface FacetFieldDef extends ChannelDefBase {
115
+ field: FieldName;
116
+ spacing?: number;
117
+ }
118
+
119
+ export type ChannelDef =
120
+ | FieldDef
121
+ | DatumDef
122
+ | ValueDef
123
+ | ExprDef
124
+ | ChromPosDef
125
+ | FacetFieldDef;
126
+
127
+ export type Encoding = Partial<Record<Channel, ChannelDef | null>>;
@@ -0,0 +1,185 @@
1
+ /*!
2
+ * Adapted from
3
+ * https://github.com/vega/vega-lite/blob/master/src/data.ts
4
+ *
5
+ * Copyright (c) 2015-2018, University of Washington Interactive Data Lab
6
+ * All rights reserved.
7
+ *
8
+ * BSD-3-Clause License: https://github.com/vega/vega-lite/blob/master/LICENSE
9
+ */
10
+
11
+ /*
12
+ * Constants and utilities for data.
13
+ */
14
+ import { FieldName } from "./channel";
15
+
16
+ export type ParseValue =
17
+ | null
18
+ | string
19
+ | "string"
20
+ | "boolean"
21
+ | "date"
22
+ | "number";
23
+
24
+ export interface Parse {
25
+ [field: string]: ParseValue;
26
+ }
27
+
28
+ export interface DataFormatBase {
29
+ /**
30
+ * If set to `null`, disable type inference based on the spec and only use type inference based on the data.
31
+ * Alternatively, a parsing directive object can be provided for explicit data types. Each property of the object corresponds to a field name, and the value to the desired data type (one of `"number"`, `"boolean"`, `"date"`, or null (do not parse the field)).
32
+ * For example, `"parse": {"modified_on": "date"}` parses the `modified_on` field in each input record a Date value.
33
+ *
34
+ * For `"date"`, we parse data based using Javascript's [`Date.parse()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse).
35
+ * For Specific date formats can be provided (e.g., `{foo: "date:'%m%d%Y'"}`), using the [d3-time-format syntax](https://github.com/d3/d3-time-format#locale_format). UTC date format parsing is supported similarly (e.g., `{foo: "utc:'%m%d%Y'"}`). See more about [UTC time](https://vega.github.io/vega-lite/docs/timeunit.html#utc)
36
+ */
37
+ parse?: Parse | null;
38
+
39
+ /**
40
+ * Type of input data: `"json"`, `"csv"`, `"tsv"`, `"dsv"`.
41
+ *
42
+ * __Default value:__ The default format type is determined by the extension of the file URL.
43
+ * If no extension is detected, `"json"` will be used by default.
44
+ */
45
+ type?: "csv" | "tsv" | "dsv" | "json";
46
+ }
47
+
48
+ export interface CsvDataFormat extends DataFormatBase {
49
+ type?: "csv" | "tsv";
50
+ }
51
+
52
+ export interface DsvDataFormat extends DataFormatBase {
53
+ type?: "dsv";
54
+
55
+ /**
56
+ * The delimiter between records. The delimiter must be a single character (i.e., a single 16-bit code unit); so, ASCII delimiters are fine, but emoji delimiters are not.
57
+ *
58
+ * @minLength 1
59
+ * @maxLength 1
60
+ */
61
+ delimiter: string;
62
+ }
63
+
64
+ export interface JsonDataFormat extends DataFormatBase {
65
+ type?: "json";
66
+
67
+ /**
68
+ * The JSON property containing the desired data.
69
+ * This parameter can be used when the loaded JSON file may have surrounding structure or meta-data.
70
+ * For example `"property": "values.features"` is equivalent to retrieving `json.values.features`
71
+ * from the loaded JSON object.
72
+ */
73
+ property?: string;
74
+ }
75
+
76
+ export type DataFormat = CsvDataFormat | DsvDataFormat | JsonDataFormat;
77
+
78
+ export type DataFormatType = "json" | "csv" | "tsv" | "dsv";
79
+
80
+ export type DataSource =
81
+ | UrlData
82
+ | InlineData
83
+ | NamedData
84
+ | DynamicCallbackData
85
+ | DynamicData;
86
+
87
+ export type Data = DataSource | Generator;
88
+
89
+ export type InlineDataset =
90
+ | number[]
91
+ | string[]
92
+ | boolean[]
93
+ | object[]
94
+ | string
95
+ | object;
96
+
97
+ export interface DataBase {
98
+ /**
99
+ * An object that specifies the format for parsing the data.
100
+ */
101
+ format?: DataFormat;
102
+
103
+ /**
104
+ * Provide a placeholder name and bind data at runtime.
105
+ */
106
+ name?: string;
107
+ }
108
+
109
+ export interface UrlData extends DataBase {
110
+ /**
111
+ * An URL or an array of URLs from which to load the data set.
112
+ * Use the `format.type` property to ensure the loaded data is correctly parsed.
113
+ */
114
+ url: string | string[];
115
+ }
116
+
117
+ export interface InlineData extends DataBase {
118
+ /**
119
+ * The full data set, included inline. This can be an array of objects or primitive values, an object, or a string.
120
+ * Arrays of primitive values are ingested as objects with a `data` property. Strings are parsed according to the specified format type.
121
+ */
122
+ values: InlineDataset;
123
+ }
124
+
125
+ export interface NamedData extends DataBase {
126
+ /**
127
+ * Provide a placeholder name and bind data at runtime.
128
+ */
129
+ name: string;
130
+ }
131
+
132
+ export interface DynamicCallbackData extends DataBase {
133
+ /**
134
+ * The View class has `getDynamicData()` methods that provides the data.
135
+ * This is intended for internal use.
136
+ */
137
+ dynamicCallbackSource: boolean;
138
+ }
139
+
140
+ export interface DynamicData extends DataBase {
141
+ /**
142
+ * For internal use.
143
+ */
144
+ dynamicSource: boolean;
145
+ }
146
+
147
+ export type Generator = SequenceGenerator;
148
+
149
+ export interface GeneratorBase {
150
+ /**
151
+ * Provide a placeholder name and bind data at runtime.
152
+ */
153
+ name?: string;
154
+ }
155
+
156
+ export interface SequenceGenerator extends GeneratorBase {
157
+ /**
158
+ * Generate a sequence of numbers.
159
+ */
160
+ sequence: SequenceParams;
161
+ }
162
+
163
+ export interface SequenceParams {
164
+ /**
165
+ * The starting value of the sequence (inclusive).
166
+ */
167
+ start: number;
168
+ /**
169
+ * The ending value of the sequence (exclusive).
170
+ */
171
+ stop: number;
172
+ /**
173
+ * The step value between sequence entries.
174
+ *
175
+ * __Default value:__ `1`
176
+ */
177
+ step?: number;
178
+
179
+ /**
180
+ * The name of the generated sequence field.
181
+ *
182
+ * __Default value:__ `"data"`
183
+ */
184
+ as?: FieldName;
185
+ }
@@ -0,0 +1,15 @@
1
+ export type FontStyle = "normal" | "italic";
2
+
3
+ export type FontWeight =
4
+ | number
5
+ | "thin"
6
+ | "light"
7
+ | "regular"
8
+ | "normal"
9
+ | "medium"
10
+ | "bold"
11
+ | "black";
12
+
13
+ export type Align = "left" | "center" | "right";
14
+
15
+ export type Baseline = "top" | "middle" | "bottom" | "alphabetic";
@@ -0,0 +1,35 @@
1
+ export interface Contig {
2
+ name: string;
3
+ size: number;
4
+ }
5
+
6
+ export interface GenomeConfig {
7
+ /**
8
+ * Name of the genome assembly, e.g., `hg19` or `hg38`.
9
+ */
10
+ name: string;
11
+
12
+ /**
13
+ * Base url of data files: chromsizes, cytobands, and gene annotations.
14
+ *
15
+ * **Default:** `"https://genomespy.app/data/genomes/"`
16
+ */
17
+ baseUrl?: string;
18
+
19
+ /**
20
+ * As an alternative for chromSizes, the contigs can be provided inline.
21
+ */
22
+ contigs?: Contig[];
23
+ }
24
+
25
+ export interface ChromosomalLocus {
26
+ /**
27
+ * The name of the chromosome. For example: `"chr1"`, `"CHR1"`, or `"1"`.
28
+ */
29
+ chrom: string;
30
+
31
+ /**
32
+ * The zero-based position inside the chromosome or contig.
33
+ */
34
+ pos?: number;
35
+ }