@fundar/data-chart-telling 0.0.33 → 0.0.35

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.
@@ -22,7 +22,7 @@ const text = (over) => ({
22
22
  color: 'inherit',
23
23
  leading: '1.3',
24
24
  spacing: 'normal',
25
- ...over,
25
+ ...over
26
26
  });
27
27
  export const DEFAULT_CONFIG = {
28
28
  font: 'inherit',
@@ -32,10 +32,14 @@ export const DEFAULT_CONFIG = {
32
32
  spacing: {
33
33
  headerPadding: '0.75rem 0 1rem',
34
34
  legendPadding: '0.75rem 0',
35
- captionPadding: '0.5rem 0',
35
+ captionPadding: '0.5rem 0'
36
36
  },
37
37
  title: text({ size: '1.5rem', weight: 500, leading: '1.2' }),
38
- subtitle: text({ size: '1rem', weight: 400, color: 'color-mix(in srgb, currentColor 85%, transparent)' }),
38
+ subtitle: text({
39
+ size: '1rem',
40
+ weight: 400,
41
+ color: 'color-mix(in srgb, currentColor 85%, transparent)'
42
+ }),
39
43
  caption: text({ size: '0.75rem', color: 'color-mix(in srgb, currentColor 75%, transparent)' }),
40
44
  legend: {
41
45
  font: 'inherit',
@@ -47,6 +51,13 @@ export const DEFAULT_CONFIG = {
47
51
  gap: '0.5rem 2rem',
48
52
  swatchSize: '1.25rem',
49
53
  disabledOpacity: 0.12,
54
+ navButton: {
55
+ background: 'transparent',
56
+ color: 'currentColor',
57
+ size: '1.5rem',
58
+ fontSize: '1rem',
59
+ disabledOpacity: 0.3
60
+ }
50
61
  },
51
62
  axis: {
52
63
  color: 'currentColor',
@@ -57,7 +68,7 @@ export const DEFAULT_CONFIG = {
57
68
  yTickSize: 5,
58
69
  xTickPadding: 10,
59
70
  yTickPadding: 10,
60
- grid: false,
71
+ grid: false
61
72
  },
62
73
  tooltip: {
63
74
  background: '#111827',
@@ -65,7 +76,7 @@ export const DEFAULT_CONFIG = {
65
76
  fontSize: '0.8125rem',
66
77
  padding: '0.5rem 0.75rem',
67
78
  radius: '0.375rem',
68
- border: 'none',
79
+ border: 'none'
69
80
  },
70
81
  margins: { top: 'auto', right: 'auto', bottom: 'auto', left: 'auto' },
71
82
  palette: ['#4f46e5', '#e6580d', '#16a34a', '#dc2626', '#0891b2', '#9333ea', '#ca8a04', '#db2777'],
@@ -75,15 +86,15 @@ export const DEFAULT_CONFIG = {
75
86
  dotRadius: 4,
76
87
  gap: {
77
88
  stroke: { strokeOpacity: 0.6, strokeDasharray: '4 4' },
78
- dots: {},
89
+ dots: {}
79
90
  },
80
91
  valueLabels: {
81
92
  elbowGap: 10,
82
93
  laneStep: 7,
83
94
  labelGap: 6,
84
95
  connectorColor: '#94a3b8',
85
- connectorWidth: 0.5,
86
- },
96
+ connectorWidth: 0.5
97
+ }
87
98
  },
88
99
  bar: { gap: { fillOpacity: 0.5 } },
89
100
  pyramid: { gap: { fillOpacity: 0.5 } },
@@ -93,7 +104,7 @@ export const DEFAULT_CONFIG = {
93
104
  rule: { stroke: '#e6580d', strokeOpacity: 0.35, strokeWidth: 1.5, strokeDasharray: '4 4' },
94
105
  dot: { dotRadius: 5, dotFill: 'currentColor' },
95
106
  font: { fill: 'currentColor', fontSize: 12, dy: -18 },
96
- area: { stroke: '#e6580d', strokeWidth: 2, fillOpacity: 0 },
107
+ area: { stroke: '#e6580d', strokeWidth: 2, fillOpacity: 0 }
97
108
  },
98
109
  facet: {
99
110
  indicator: {
@@ -101,16 +112,16 @@ export const DEFAULT_CONFIG = {
101
112
  color: '#ffffff',
102
113
  fontSize: '0.8125rem',
103
114
  padding: '0.125rem 0.5rem',
104
- radius: '999px',
115
+ radius: '999px'
105
116
  },
106
117
  navButton: {
107
118
  background: '#111827',
108
119
  color: '#ffffff',
109
120
  size: '2rem',
110
121
  fontSize: '1.1rem',
111
- disabledOpacity: 0.3,
112
- },
113
- },
122
+ disabledOpacity: 0.3
123
+ }
124
+ }
114
125
  };
115
126
  // ── Merge ─────────────────────────────────────────────────────────────────────
116
127
  function isPlainObject(v) {
@@ -151,7 +162,7 @@ export function configToCssVars(c) {
151
162
  [`--dct-${prefix}-weight`]: String(s.weight),
152
163
  [`--dct-${prefix}-color`]: s.color,
153
164
  [`--dct-${prefix}-leading`]: s.leading,
154
- [`--dct-${prefix}-spacing`]: s.spacing,
165
+ [`--dct-${prefix}-spacing`]: s.spacing
155
166
  });
156
167
  return {
157
168
  '--dct-font': c.font,
@@ -172,6 +183,11 @@ export function configToCssVars(c) {
172
183
  '--dct-legend-title-weight': String(c.legend.titleWeight),
173
184
  '--dct-legend-gap': c.legend.gap,
174
185
  '--dct-legend-swatch': c.legend.swatchSize,
186
+ '--dct-legend-nav-bg': c.legend.navButton.background,
187
+ '--dct-legend-nav-color': c.legend.navButton.color,
188
+ '--dct-legend-nav-size': c.legend.navButton.size,
189
+ '--dct-legend-nav-font-size': c.legend.navButton.fontSize,
190
+ '--dct-legend-nav-disabled-opacity': String(c.legend.navButton.disabledOpacity),
175
191
  '--dct-axis-color': c.axis.color,
176
192
  '--dct-tooltip-bg': c.tooltip.background,
177
193
  '--dct-tooltip-color': c.tooltip.color,
@@ -193,7 +209,7 @@ export function configToCssVars(c) {
193
209
  '--dct-facet-nav-color': c.facet.navButton.color,
194
210
  '--dct-facet-nav-btn-size': c.facet.navButton.size,
195
211
  '--dct-facet-nav-font-size': c.facet.navButton.fontSize,
196
- '--dct-facet-nav-disabled-opacity': String(c.facet.navButton.disabledOpacity),
212
+ '--dct-facet-nav-disabled-opacity': String(c.facet.navButton.disabledOpacity)
197
213
  };
198
214
  }
199
215
  /** Serialize a CSS-vars record into a `style` attribute string. */
@@ -49,6 +49,13 @@ export declare const THEMES: {
49
49
  gap?: string | undefined;
50
50
  swatchSize?: string | undefined;
51
51
  disabledOpacity?: number | undefined;
52
+ navButton?: {
53
+ background?: string | undefined;
54
+ color?: string | undefined;
55
+ size?: string | undefined;
56
+ fontSize?: string | undefined;
57
+ disabledOpacity?: number | undefined;
58
+ } | undefined;
52
59
  } | undefined;
53
60
  axis?: {
54
61
  color?: string | undefined;
@@ -249,6 +256,13 @@ export declare const THEMES: {
249
256
  gap?: string | undefined;
250
257
  swatchSize?: string | undefined;
251
258
  disabledOpacity?: number | undefined;
259
+ navButton?: {
260
+ background?: string | undefined;
261
+ color?: string | undefined;
262
+ size?: string | undefined;
263
+ fontSize?: string | undefined;
264
+ disabledOpacity?: number | undefined;
265
+ } | undefined;
252
266
  } | undefined;
253
267
  axis?: {
254
268
  color?: string | undefined;
@@ -449,6 +463,13 @@ export declare const THEMES: {
449
463
  gap?: string | undefined;
450
464
  swatchSize?: string | undefined;
451
465
  disabledOpacity?: number | undefined;
466
+ navButton?: {
467
+ background?: string | undefined;
468
+ color?: string | undefined;
469
+ size?: string | undefined;
470
+ fontSize?: string | undefined;
471
+ disabledOpacity?: number | undefined;
472
+ } | undefined;
452
473
  } | undefined;
453
474
  axis?: {
454
475
  color?: string | undefined;
@@ -649,6 +670,13 @@ export declare const THEMES: {
649
670
  gap?: string | undefined;
650
671
  swatchSize?: string | undefined;
651
672
  disabledOpacity?: number | undefined;
673
+ navButton?: {
674
+ background?: string | undefined;
675
+ color?: string | undefined;
676
+ size?: string | undefined;
677
+ fontSize?: string | undefined;
678
+ disabledOpacity?: number | undefined;
679
+ } | undefined;
652
680
  } | undefined;
653
681
  axis?: {
654
682
  color?: string | undefined;
package/dist/index.d.ts CHANGED
@@ -21,7 +21,7 @@ export { default as FacetLayout } from './layout/facet/FacetLayout.svelte';
21
21
  export { default as FacetIndicator } from './layout/facet/FacetIndicator.svelte';
22
22
  export { default as LegendLayout } from './layout/legend/LegendLayout.svelte';
23
23
  export { default as Tooltip } from './layout/tooltip/Tooltip.svelte';
24
- export { getLegendInteraction, provideLegendInteraction, createLegendInteraction, } from './layout/legend/interaction.svelte';
24
+ export { getLegendInteraction, provideLegendInteraction, createLegendInteraction } from './layout/legend/interaction.svelte';
25
25
  export { default as BarMarker } from './markers/BarMarker.svelte';
26
26
  export { default as CellMarker } from './markers/CellMarker.svelte';
27
27
  export { default as DeltaMarker } from './markers/DeltaMarker.svelte';
@@ -31,31 +31,31 @@ export { default as LineMarker } from './markers/LineMarker.svelte';
31
31
  export { default as PeakMarker } from './markers/PeakMarker.svelte';
32
32
  export { default as RuleMarker } from './markers/RuleMarker.svelte';
33
33
  export { default as TextMarker } from './markers/TextMarker.svelte';
34
- export { setConfiguration, getConfiguration, resetConfiguration, configToCssVars, cssVarsStyle, DEFAULT_CONFIG, } from './configuration/config.svelte';
34
+ export { setConfiguration, getConfiguration, resetConfiguration, configToCssVars, cssVarsStyle, DEFAULT_CONFIG } from './configuration/config.svelte';
35
35
  export { THEMES } from './configuration/themes';
36
36
  export type { ThemeName } from './configuration/themes';
37
37
  export { groupBy, buildSeries } from './utils/grouping';
38
38
  export { makeColorScale, normalize, resolveCssColor, paletteColor } from './utils/color';
39
39
  export type { AxisValue, AxisScale, AxisBasedScalesConfig } from './types/layout/scales';
40
40
  export type { Accessor, Series, SeriesProps, DataProps } from './types/plots/data/common';
41
- export type { BasePlotProps, StylesConfig, MarkersConfig, SegmentsConfig, ScalesConfig, MarginConfig, TooltipConfig, HoverConfig, PointMatchingStrategy, } from './types/plots/props';
42
- export type { ValuesStyle, ColorsStyle, FrameStyle, FrameProp, BasePlotStylesConfig, AxisBasedStylesConfig, GapsAwarePlotStylesConfig, GeoStylesConfig, GeoTileLayerConfig, } from './types/layout/styles';
43
- export type { GapsConfig, GapZonesConfig, GapZoneConfig, OpenGapZoneConfig, } from './types/plots/gaps';
41
+ export type { BasePlotProps, StylesConfig, MarkersConfig, SegmentsConfig, ScalesConfig, MarginConfig, TooltipConfig, HoverConfig, PointMatchingStrategy } from './types/plots/props';
42
+ export type { ValuesStyle, ColorsStyle, FrameStyle, FrameProp, BasePlotStylesConfig, AxisBasedStylesConfig, GapsAwarePlotStylesConfig, GeoStylesConfig, GeoTileLayerConfig } from './types/layout/styles';
43
+ export type { GapsConfig, GapZonesConfig, GapZoneConfig, OpenGapZoneConfig } from './types/plots/gaps';
44
44
  export type { LineSegmentStyle, BarSegmentStyle, CellSegmentStyle, GeoSegmentStyle, ScatterSegmentStyle } from './types/plots/segments/common';
45
45
  export type { Range, Area, Segment } from './types/plots/segments/config';
46
- export type { ValueAnchor, SymbolType, LineStyle, LineCap, LineJoin, FontWeight, FontStyleKeyword, TextAnchor, LineAnchor, } from './types/plots/constants';
46
+ export type { ValueAnchor, SymbolType, LineStyle, LineCap, LineJoin, FontWeight, FontStyleKeyword, TextAnchor, LineAnchor } from './types/plots/constants';
47
47
  export type { FontStyle, StrokeStyle, DotStyle, AreaStyle } from './types/plots/styling';
48
48
  export type { AxisBasedMarkersConfig } from './types/markers/common';
49
49
  export type { LineMarkersConfig, DeltaMarkerConfig, DeltaConfig, DeltaTarget } from './types/markers/line';
50
50
  export type { MarkerProps } from './types/markers/props';
51
51
  export type { GeoFeature, GeoJsonInput, GeoDataProps, Topology } from './types/plots/data/geo';
52
52
  export type { ScatterDataProps } from './types/plots/data/scatter';
53
- export type { GeoProjectionName, GeoProjectionConfig, GeoCustomProjection, GeoCustomProjectionFactory, GeoScalesConfig, GeoZoomConfig, CoordinatesConfig, } from './types/layout/coordinates';
54
- export type { GeoMarkersConfig, GeoInsetMarkerConfig, GeoInsetTooltipConfig, GeoInsetLocation, GeoInsetProjectionName, GeoInsetProjectionConfig, } from './types/markers/geo';
55
- export type { ChartPlotContext, ChartPlotSnippet, } from './types/charts/common';
56
- export type { TimeValue, Orientation, TimelineConfig, } from './types/layout/timeline';
57
- export type { Responsive, FacetColumns, FacetMode, FacetNavLayout, FacetConfig, FacetIndicatorContext, FacetIndicatorSnippet, FacetNavDirection, FacetNavContext, FacetNavSnippet, } from './types/layout/facet';
58
- export type { LegendSection, DiscreteLegendSection, ContinuousLegendSection, LegendItem, LegendDisabledStyle, LegendInteractionStore, LegendPlotContext, } from './types/layout/legend';
59
- export type { HoverStrategy, TooltipOptions, TooltipProp, TooltipAnchorX, TooltipAnchorY, } from './types/layout/tooltip';
53
+ export type { GeoProjectionName, GeoProjectionConfig, GeoCustomProjection, GeoCustomProjectionFactory, GeoScalesConfig, GeoZoomConfig, CoordinatesConfig } from './types/layout/coordinates';
54
+ export type { GeoMarkersConfig, GeoInsetMarkerConfig, GeoInsetTooltipConfig, GeoInsetLocation, GeoInsetProjectionName, GeoInsetProjectionConfig } from './types/markers/geo';
55
+ export type { ChartPlotContext, ChartPlotSnippet } from './types/charts/common';
56
+ export type { TimeValue, Orientation, TimelineConfig } from './types/layout/timeline';
57
+ export type { Responsive, FacetColumns, FacetMode, FacetNavLayout, FacetConfig, FacetIndicatorContext, FacetIndicatorSnippet, FacetNavDirection, FacetNavContext, FacetNavSnippet } from './types/layout/facet';
58
+ export type { LegendSection, DiscreteLegendSection, ContinuousLegendSection, LegendItem, LegendDisabledStyle, LegendItemsLayout, LegendNavDirection, LegendNavContext, LegendNavSnippet, LegendInteractionStore, LegendPlotContext } from './types/layout/legend';
59
+ export type { HoverStrategy, TooltipOptions, TooltipProp, TooltipAnchorX, TooltipAnchorY } from './types/layout/tooltip';
60
60
  export type { ChartConfig, ChartConfigInput, TextStyle } from './types/configuration/styling';
61
61
  export type { ChartProps, GapsAwareChartProps } from './types/charts/props';
package/dist/index.js CHANGED
@@ -27,7 +27,7 @@ export { default as FacetLayout } from './layout/facet/FacetLayout.svelte';
27
27
  export { default as FacetIndicator } from './layout/facet/FacetIndicator.svelte';
28
28
  export { default as LegendLayout } from './layout/legend/LegendLayout.svelte';
29
29
  export { default as Tooltip } from './layout/tooltip/Tooltip.svelte';
30
- export { getLegendInteraction, provideLegendInteraction, createLegendInteraction, } from './layout/legend/interaction.svelte';
30
+ export { getLegendInteraction, provideLegendInteraction, createLegendInteraction } from './layout/legend/interaction.svelte';
31
31
  // Markers
32
32
  export { default as BarMarker } from './markers/BarMarker.svelte';
33
33
  export { default as CellMarker } from './markers/CellMarker.svelte';
@@ -38,7 +38,7 @@ export { default as LineMarker } from './markers/LineMarker.svelte';
38
38
  export { default as PeakMarker } from './markers/PeakMarker.svelte';
39
39
  export { default as RuleMarker } from './markers/RuleMarker.svelte';
40
40
  export { default as TextMarker } from './markers/TextMarker.svelte';
41
- export { setConfiguration, getConfiguration, resetConfiguration, configToCssVars, cssVarsStyle, DEFAULT_CONFIG, } from './configuration/config.svelte';
41
+ export { setConfiguration, getConfiguration, resetConfiguration, configToCssVars, cssVarsStyle, DEFAULT_CONFIG } from './configuration/config.svelte';
42
42
  export { THEMES } from './configuration/themes';
43
43
  // ── Utils ─────────────────────────────────────────────────────────────────────
44
44
  export { groupBy, buildSeries } from './utils/grouping';
@@ -39,6 +39,14 @@ export type ChartConfig = {
39
39
  swatchSize: string;
40
40
  /** Fallback opacity for a legend-disabled series/value when a section doesn't set its own `disabledStyle`. */
41
41
  disabledOpacity: number;
42
+ /** Prev/next arrows shown when a `layout: { type: 'horizontal' }` discrete section overflows `maxRows`. */
43
+ navButton: {
44
+ background: string;
45
+ color: string;
46
+ size: string;
47
+ fontSize: string;
48
+ disabledOpacity: number;
49
+ };
42
50
  };
43
51
  axis: {
44
52
  color: string;
@@ -1,3 +1,4 @@
1
+ import type { Snippet } from 'svelte';
1
2
  import type { SvelteMap } from 'svelte/reactivity';
2
3
  import type { SymbolType, LineStyle } from '../plots/constants';
3
4
  import type { StrokeStyle, DotStyle } from '../plots/styling';
@@ -26,15 +27,37 @@ export type LegendItem = {
26
27
  /** Initial toggled-off state (uncontrolled — the user can still click it back on). */
27
28
  disabled?: boolean;
28
29
  };
30
+ /**
31
+ * How a discrete section's items flow. `'vertical'` (the default) stacks them
32
+ * in a `columns`-wide grid, as it always has. `'horizontal'` flows them left
33
+ * to right, wrapping to new rows as needed — and once wrapped rows exceed
34
+ * `maxRows` (default 1), the section paginates instead of growing taller,
35
+ * surfacing prev/next arrows to page through the rest.
36
+ */
37
+ export type LegendItemsLayout = {
38
+ type: 'vertical';
39
+ } | {
40
+ type: 'horizontal';
41
+ maxRows?: number;
42
+ };
43
+ export type LegendNavDirection = 'prev' | 'next';
44
+ export type LegendNavContext = {
45
+ direction: LegendNavDirection;
46
+ disabled: boolean;
47
+ onclick: () => void;
48
+ };
49
+ /** Custom prev/next button renderer for a paginated horizontal section. Falls back to a small default arrow button. */
50
+ export type LegendNavSnippet = Snippet<[LegendNavContext]>;
29
51
  export type DiscreteLegendSection = {
30
52
  type: 'discrete';
31
53
  title?: string;
32
54
  items: LegendItem[];
33
55
  columns?: number;
34
- /** Enables click-to-toggle on each item. */
56
+ /** Item flow direction. Defaults to `{ type: 'vertical' }` (unchanged prior behaviour). */
57
+ layout?: LegendItemsLayout;
35
58
  interactive?: boolean;
36
- /** Style applied to a toggled-off item's series. Falls back to `cfg.legend.disabledOpacity`. */
37
59
  disabledStyle?: LegendDisabledStyle;
60
+ navButton?: LegendNavSnippet;
38
61
  };
39
62
  export type ContinuousLegendSection = {
40
63
  type: 'continuous';
@@ -47,7 +70,6 @@ export type ContinuousLegendSection = {
47
70
  ticks?: number[];
48
71
  width?: number;
49
72
  format?: (v: number) => string;
50
- /** Enables drag handles on the bar's edges to narrow the visible range. */
51
73
  interactive?: boolean;
52
74
  /**
53
75
  * How the color ramp responds to a narrowed range: `'rescale'` reprojects
@@ -55,7 +77,6 @@ export type ContinuousLegendSection = {
55
77
  * excludes out-of-range values. Defaults to `'filter'`.
56
78
  */
57
79
  mode?: 'rescale' | 'filter';
58
- /** Style applied to values outside the active range. Falls back to `cfg.legend.disabledOpacity`. */
59
80
  disabledStyle?: LegendDisabledStyle;
60
81
  };
61
82
  export type LegendSection = DiscreteLegendSection | ContinuousLegendSection;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fundar/data-chart-telling",
3
- "version": "0.0.33",
3
+ "version": "0.0.35",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"