@fundar/data-chart-telling 0.0.40 → 0.0.41
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.
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
validateSegments,
|
|
22
22
|
buildScopedMarkerGroups
|
|
23
23
|
} from '../utils/segments';
|
|
24
|
-
import type { BasePlotProps } from '../../types/plots/props';
|
|
24
|
+
import type { BasePlotProps, MarginConfig } from '../../types/plots/props';
|
|
25
25
|
import type { AxisValue, AxisBasedScalesConfig } from '../../types/layout/scales';
|
|
26
26
|
import type { Series, SeriesProps, DataProps } from '../../types/plots/data/common';
|
|
27
27
|
import type { GapsAwarePlotStylesConfig } from '../../types/layout/styles';
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
segments = {},
|
|
51
51
|
markers = [],
|
|
52
52
|
scales = {},
|
|
53
|
-
margins,
|
|
53
|
+
margins = $bindable(),
|
|
54
54
|
tooltip = undefined
|
|
55
55
|
}: Props = $props();
|
|
56
56
|
|
|
@@ -169,6 +169,26 @@
|
|
|
169
169
|
() => margins,
|
|
170
170
|
() => resolvedSeries
|
|
171
171
|
);
|
|
172
|
+
|
|
173
|
+
// Writes the resolved margin back into the bindable `margins` prop once it
|
|
174
|
+
// settles, so a caller binding it (`bind:margins`) can capture and reuse a
|
|
175
|
+
// fixed margin later. `lastWritten` is a plain variable (not `$state`) so
|
|
176
|
+
// the effect only depends on `resolvedMargins`, never on `margins` itself.
|
|
177
|
+
let lastWritten: MarginConfig | undefined;
|
|
178
|
+
$effect(() => {
|
|
179
|
+
const next = labelMargin.resolvedMargins;
|
|
180
|
+
if (!next) return;
|
|
181
|
+
const changed =
|
|
182
|
+
!lastWritten ||
|
|
183
|
+
next.top !== lastWritten.top ||
|
|
184
|
+
next.right !== lastWritten.right ||
|
|
185
|
+
next.bottom !== lastWritten.bottom ||
|
|
186
|
+
next.left !== lastWritten.left;
|
|
187
|
+
if (changed) {
|
|
188
|
+
lastWritten = { top: next.top, right: next.right, bottom: next.bottom, left: next.left };
|
|
189
|
+
margins = next;
|
|
190
|
+
}
|
|
191
|
+
});
|
|
172
192
|
</script>
|
|
173
193
|
|
|
174
194
|
<BasePlotLayout
|
|
@@ -7,7 +7,7 @@ import type { LineMarkersConfig } from '../../types/markers/line';
|
|
|
7
7
|
declare function $$render<TData extends Record<string, unknown>>(): {
|
|
8
8
|
props: BasePlotProps<SeriesProps<TData> | DataProps<TData>, TData, GapsAwarePlotStylesConfig<LineSegmentStyle>, LineSegmentStyle, LineMarkersConfig, AxisBasedScalesConfig<TData>>;
|
|
9
9
|
exports: {};
|
|
10
|
-
bindings: "";
|
|
10
|
+
bindings: "margins";
|
|
11
11
|
slots: {};
|
|
12
12
|
events: {};
|
|
13
13
|
};
|
|
@@ -15,7 +15,7 @@ declare class __sveltets_Render<TData extends Record<string, unknown>> {
|
|
|
15
15
|
props(): ReturnType<typeof $$render<TData>>['props'];
|
|
16
16
|
events(): ReturnType<typeof $$render<TData>>['events'];
|
|
17
17
|
slots(): ReturnType<typeof $$render<TData>>['slots'];
|
|
18
|
-
bindings(): "";
|
|
18
|
+
bindings(): "margins";
|
|
19
19
|
exports(): {};
|
|
20
20
|
}
|
|
21
21
|
interface $$IsomorphicComponent {
|
|
@@ -160,15 +160,18 @@ export function createLabelMarginTracker(margins, resetKey) {
|
|
|
160
160
|
out.bottom = AUTO_MARGIN_ESTIMATE.bottom + measured.bottom;
|
|
161
161
|
return out;
|
|
162
162
|
});
|
|
163
|
-
// Bundles `resolvedMargins` with a remount key
|
|
164
|
-
//
|
|
165
|
-
//
|
|
166
|
-
//
|
|
167
|
-
//
|
|
168
|
-
//
|
|
163
|
+
// Bundles `resolvedMargins` with a remount key, ready to spread straight
|
|
164
|
+
// onto `<BasePlotLayout>` as its `margins`/`marginRemountKey` props (see
|
|
165
|
+
// that prop's doc comment for *why* a remount key is needed here at all)
|
|
166
|
+
// — keeps the caller from re-deriving the same key by hand. Tracks both
|
|
167
|
+
// `measured` (this tracker's own auto-grown overflow) and the caller's
|
|
168
|
+
// own `margins()` — a caller that changes its explicit margins prop
|
|
169
|
+
// after mount (e.g. locking in a previously-measured value) needs that
|
|
170
|
+
// picked up just as cleanly as internal growth does; keying only on
|
|
171
|
+
// `measured` would silently miss it.
|
|
169
172
|
const plotProps = $derived.by(() => ({
|
|
170
173
|
margins: resolvedMargins,
|
|
171
|
-
marginRemountKey: JSON.stringify(measured)
|
|
174
|
+
marginRemountKey: JSON.stringify({ base: margins(), measured })
|
|
172
175
|
}));
|
|
173
176
|
return {
|
|
174
177
|
report,
|