@opendata-ai/openchart-core 7.8.0 → 7.9.1
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/dist/index.d.ts +51 -10
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/responsive/metrics.ts +10 -0
- package/src/types/index.ts +1 -0
- package/src/types/layout.ts +37 -4
- package/src/types/spec.ts +8 -4
package/package.json
CHANGED
|
@@ -88,6 +88,11 @@ export const AXIS_TITLE_GAP = 7;
|
|
|
88
88
|
* visible clearance remains. Falls back to the viewport-minimum offset when the
|
|
89
89
|
* dynamic value would be smaller (short tick labels on wide containers).
|
|
90
90
|
*
|
|
91
|
+
* When `inline` is true the y-tick labels render inside the chart area (above
|
|
92
|
+
* their gridlines) rather than in a left gutter, so the title only needs to
|
|
93
|
+
* clear the chart edge — no tick-label width and no viewport-minimum floor,
|
|
94
|
+
* both of which would otherwise leave a dead gap between the title and the plot.
|
|
95
|
+
*
|
|
91
96
|
* Shared by the engine (margin reservation) and the renderer (title placement)
|
|
92
97
|
* so the reserved space always matches where the title is drawn.
|
|
93
98
|
*/
|
|
@@ -95,8 +100,13 @@ export function axisTitleOffset(
|
|
|
95
100
|
maxTickLabelWidth: number,
|
|
96
101
|
titleFontSize: number,
|
|
97
102
|
width: number,
|
|
103
|
+
inline = false,
|
|
98
104
|
): number {
|
|
99
105
|
const halfTitleGlyph = Math.ceil(titleFontSize / 2);
|
|
106
|
+
if (inline) {
|
|
107
|
+
// No gutter tick labels to clear: title edge + gap + half-glyph only.
|
|
108
|
+
return TICK_LABEL_OFFSET + AXIS_TITLE_GAP + halfTitleGlyph;
|
|
109
|
+
}
|
|
100
110
|
const dynamic = TICK_LABEL_OFFSET + maxTickLabelWidth + AXIS_TITLE_GAP + halfTitleGlyph;
|
|
101
111
|
return Math.max(dynamic, getAxisTitleOffset(width));
|
|
102
112
|
}
|
package/src/types/index.ts
CHANGED
package/src/types/layout.ts
CHANGED
|
@@ -211,11 +211,18 @@ export interface MarkAria {
|
|
|
211
211
|
*/
|
|
212
212
|
export interface LineMark {
|
|
213
213
|
type: 'line';
|
|
214
|
+
/** Stable identity key for data-update transitions. */
|
|
215
|
+
key?: string;
|
|
216
|
+
/** Per-point identity keys parallel to `points`, for data-update transitions. */
|
|
217
|
+
pointKeys?: string[];
|
|
214
218
|
/** Ordered array of points defining the line path. */
|
|
215
219
|
points: Point[];
|
|
216
220
|
/** Pre-computed SVG path string (D3 monotone curve). When present, renderers
|
|
217
221
|
* should use this instead of reconstructing straight M/L segments from points. */
|
|
218
222
|
path?: string;
|
|
223
|
+
/** Curve interpolation method used to build the path. Stored so the transition
|
|
224
|
+
* driver can reconstruct paths from interpolated point positions. */
|
|
225
|
+
interpolate?: string;
|
|
219
226
|
/** Stroke color. */
|
|
220
227
|
stroke: string;
|
|
221
228
|
/** Stroke width in pixels. */
|
|
@@ -254,6 +261,10 @@ export interface LineMark {
|
|
|
254
261
|
*/
|
|
255
262
|
export interface AreaMark {
|
|
256
263
|
type: 'area';
|
|
264
|
+
/** Stable identity key for data-update transitions. */
|
|
265
|
+
key?: string;
|
|
266
|
+
/** Per-point identity keys parallel to `topPoints`, for data-update transitions. */
|
|
267
|
+
pointKeys?: string[];
|
|
257
268
|
/** Upper boundary points. */
|
|
258
269
|
topPoints: Point[];
|
|
259
270
|
/** Lower boundary points (baseline, usually y=0). */
|
|
@@ -262,6 +273,8 @@ export interface AreaMark {
|
|
|
262
273
|
path: string;
|
|
263
274
|
/** SVG path string for just the top boundary (for stroking the data line only). */
|
|
264
275
|
topPath: string;
|
|
276
|
+
/** Curve interpolation method used to build the path. */
|
|
277
|
+
interpolate?: string;
|
|
265
278
|
/** Fill color or gradient. */
|
|
266
279
|
fill: string | GradientDef;
|
|
267
280
|
/** Fill opacity. */
|
|
@@ -298,6 +311,8 @@ export interface AreaMark {
|
|
|
298
311
|
*/
|
|
299
312
|
export interface RectMark {
|
|
300
313
|
type: 'rect';
|
|
314
|
+
/** Stable identity key for data-update transitions. */
|
|
315
|
+
key?: string;
|
|
301
316
|
/** X position. */
|
|
302
317
|
x: number;
|
|
303
318
|
/** Y position. */
|
|
@@ -371,6 +386,8 @@ export interface ArcMark {
|
|
|
371
386
|
label?: ResolvedLabel;
|
|
372
387
|
/** Accessibility attributes. */
|
|
373
388
|
aria: MarkAria;
|
|
389
|
+
/** Stable identity key for data-update transitions. */
|
|
390
|
+
key?: string;
|
|
374
391
|
/** Index for stagger animation ordering. */
|
|
375
392
|
animationIndex?: number;
|
|
376
393
|
}
|
|
@@ -381,6 +398,8 @@ export interface ArcMark {
|
|
|
381
398
|
*/
|
|
382
399
|
export interface PointMark {
|
|
383
400
|
type: 'point';
|
|
401
|
+
/** Stable identity key for data-update transitions. */
|
|
402
|
+
key?: string;
|
|
384
403
|
/** Center x position. */
|
|
385
404
|
cx: number;
|
|
386
405
|
/** Center y position. */
|
|
@@ -413,6 +432,8 @@ export interface PointMark {
|
|
|
413
432
|
*/
|
|
414
433
|
export interface TextMarkLayout {
|
|
415
434
|
type: 'textMark';
|
|
435
|
+
/** Stable identity key for data-update transitions. */
|
|
436
|
+
key?: string;
|
|
416
437
|
/** X position. */
|
|
417
438
|
x: number;
|
|
418
439
|
/** Y position. */
|
|
@@ -449,6 +470,8 @@ export interface TextMarkLayout {
|
|
|
449
470
|
*/
|
|
450
471
|
export interface RuleMarkLayout {
|
|
451
472
|
type: 'rule';
|
|
473
|
+
/** Stable identity key for data-update transitions. */
|
|
474
|
+
key?: string;
|
|
452
475
|
/** Start x position. */
|
|
453
476
|
x1: number;
|
|
454
477
|
/** Start y position. */
|
|
@@ -481,6 +504,8 @@ export interface RuleMarkLayout {
|
|
|
481
504
|
*/
|
|
482
505
|
export interface TickMarkLayout {
|
|
483
506
|
type: 'tick';
|
|
507
|
+
/** Stable identity key for data-update transitions. */
|
|
508
|
+
key?: string;
|
|
484
509
|
/** X position. */
|
|
485
510
|
x: number;
|
|
486
511
|
/** Y position. */
|
|
@@ -815,10 +840,8 @@ export interface A11yMetadata {
|
|
|
815
840
|
// Animation (resolved)
|
|
816
841
|
// ---------------------------------------------------------------------------
|
|
817
842
|
|
|
818
|
-
/**
|
|
819
|
-
export interface
|
|
820
|
-
/** Whether entrance animation is enabled. */
|
|
821
|
-
enabled: boolean;
|
|
843
|
+
/** One fully-resolved animation phase. */
|
|
844
|
+
export interface ResolvedAnimationPhase {
|
|
822
845
|
/** Duration in ms. */
|
|
823
846
|
duration: number;
|
|
824
847
|
/** Easing preset name. */
|
|
@@ -827,6 +850,16 @@ export interface ResolvedAnimation {
|
|
|
827
850
|
staggerDelay: number;
|
|
828
851
|
/** Stagger ordering. */
|
|
829
852
|
staggerOrder: 'index' | 'value' | 'reverse';
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
/** Resolved animation config. A phase is present iff that phase is enabled. */
|
|
856
|
+
export interface ResolvedAnimation {
|
|
857
|
+
/** Entrance animation phase. Present when enter animation is enabled. */
|
|
858
|
+
enter?: ResolvedAnimationPhase;
|
|
859
|
+
/** Data-update transition phase. Present when update animation is enabled. */
|
|
860
|
+
update?: ResolvedAnimationPhase;
|
|
861
|
+
/** Exit animation phase. Present when exit animation is enabled. */
|
|
862
|
+
exit?: ResolvedAnimationPhase;
|
|
830
863
|
/** Delay before annotations animate in (ms after marks). */
|
|
831
864
|
annotationDelay: number;
|
|
832
865
|
}
|
package/src/types/spec.ts
CHANGED
|
@@ -488,6 +488,12 @@ export interface Encoding<TData extends DataRow = DataRow> {
|
|
|
488
488
|
* Useful when you want separate lines per category but don't need the color to differ.
|
|
489
489
|
*/
|
|
490
490
|
detail?: EncodingChannel<TData>;
|
|
491
|
+
/**
|
|
492
|
+
* Identity channel for data-update transitions. Maps a field whose value
|
|
493
|
+
* uniquely identifies each datum across updates. Mirrors Vega-Lite's key channel.
|
|
494
|
+
* Not visually encoded. Optional: charts derive sensible default keys.
|
|
495
|
+
*/
|
|
496
|
+
key?: EncodingChannel<TData>;
|
|
491
497
|
/**
|
|
492
498
|
* Secondary x position. Used with `x` to define a horizontal span (rect marks, error bars).
|
|
493
499
|
* Both `x` and `x2` must be quantitative.
|
|
@@ -1158,15 +1164,13 @@ export interface AnimationPhaseConfig {
|
|
|
1158
1164
|
/**
|
|
1159
1165
|
* Full animation config object. Structured as enter/update/exit phases
|
|
1160
1166
|
* following Vega's encoding set model.
|
|
1161
|
-
*
|
|
1162
|
-
* v1 implements enter only. update and exit reserved for v2.
|
|
1163
1167
|
*/
|
|
1164
1168
|
export interface AnimationConfig {
|
|
1165
1169
|
/** Entrance animation when chart first renders. */
|
|
1166
1170
|
enter?: AnimationPhaseConfig | boolean;
|
|
1167
|
-
/** Transition animation when data updates.
|
|
1171
|
+
/** Transition animation when data updates. */
|
|
1168
1172
|
update?: AnimationPhaseConfig | boolean;
|
|
1169
|
-
/** Exit animation when marks are removed.
|
|
1173
|
+
/** Exit animation when marks are removed. */
|
|
1170
1174
|
exit?: AnimationPhaseConfig | boolean;
|
|
1171
1175
|
/** Delay before annotations animate in (ms after marks). Default: 200. */
|
|
1172
1176
|
annotationDelay?: number;
|