@opendata-ai/openchart-core 6.7.1 → 6.9.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.
package/dist/index.d.ts CHANGED
@@ -547,9 +547,17 @@ interface RefLineAnnotation extends AnnotationBase {
547
547
  type Annotation = TextAnnotation | RangeAnnotation | RefLineAnnotation;
548
548
  /**
549
549
  * Dark mode behavior.
550
- * - "auto": respect system preference (prefers-color-scheme)
551
- * - "force": always render in dark mode
552
- * - "off": always render in light mode (default)
550
+ *
551
+ * - `"auto"` - Checks the `prefers-color-scheme` media query to detect the
552
+ * user's system-level preference. This does NOT detect class-based dark mode
553
+ * toggles (e.g. `document.documentElement.classList.toggle('dark')`). If your
554
+ * app uses class-based dark mode, use VizThemeProvider with `"force"` or
555
+ * `"off"` instead of `"auto"` and toggle based on your app's state.
556
+ * - `"force"` - Always render in dark mode regardless of system preference.
557
+ * - `"off"` - Always render in light mode (default).
558
+ *
559
+ * All components (Chart, Sankey, Graph) inherit darkMode from VizThemeProvider
560
+ * when no explicit prop is passed.
553
561
  */
554
562
  type DarkMode = 'auto' | 'force' | 'off';
555
563
  /**
@@ -626,6 +634,8 @@ interface LegendConfig {
626
634
  columns?: number;
627
635
  /** Max number of legend entries before truncation. Remaining entries show as "+N more". */
628
636
  symbolLimit?: number;
637
+ /** Maximum number of rows for top-positioned legends before truncation. Defaults to 2. */
638
+ maxRows?: number;
629
639
  }
630
640
  /** Data row: a plain object with string keys. */
631
641
  type DataRow = Record<string, unknown>;
@@ -931,6 +941,15 @@ interface SankeySpec {
931
941
  iterations?: number;
932
942
  /** Link coloring strategy. Defaults to 'gradient'. */
933
943
  linkStyle?: SankeyLinkColor;
944
+ /** Link fill opacity (0-1). Defaults to 0.5 in light mode, 0.75 in dark mode. */
945
+ linkOpacity?: number;
946
+ /**
947
+ * Which side of each node to place labels. 'auto' uses the default heuristic
948
+ * (left-column right, right-column left, middle right). 'right' forces all
949
+ * labels to the right of their nodes. 'left' forces all labels to the left.
950
+ * Defaults to 'auto'.
951
+ */
952
+ nodeLabelAlign?: 'auto' | 'left' | 'right';
934
953
  /** Editorial chrome (title, subtitle, source, byline, footer). */
935
954
  chrome?: Chrome;
936
955
  /** Legend display configuration. */
@@ -941,6 +960,14 @@ interface SankeySpec {
941
960
  darkMode?: DarkMode;
942
961
  /** Animation configuration for entrance animations. */
943
962
  animation?: AnimationSpec;
963
+ /**
964
+ * d3-format string applied to flow values in tooltips and ARIA labels.
965
+ * Uses the literal suffix extension: ".0f%" appends "%" to the formatted
966
+ * number (data value 28 renders as "28%"). For currency: "$,.0f" or "$~s".
967
+ * For SI suffixes: "~s" (renders 1000 as "1k"). When not set, values use
968
+ * the default number formatter.
969
+ */
970
+ valueFormat?: string;
944
971
  }
945
972
  /**
946
973
  * Top-level visualization spec: union discriminated by structural shape.
package/dist/index.js CHANGED
@@ -1077,6 +1077,12 @@ function buildTextStyle(defaults, fontFamily, textColor, width, overrides) {
1077
1077
  }
1078
1078
  function estimateLineCount(text, style, maxWidth, _measureText) {
1079
1079
  if (maxWidth <= 0) return 1;
1080
+ const segments = text.split("\n");
1081
+ if (segments.length > 1) {
1082
+ return segments.reduce((total, segment) => {
1083
+ return total + (segment.length === 0 ? 1 : estimateLineCount(segment, style, maxWidth, _measureText));
1084
+ }, 0);
1085
+ }
1080
1086
  const charWidth = estimateCharWidth(style.fontSize, style.fontWeight);
1081
1087
  const maxChars = Math.floor(maxWidth / charWidth);
1082
1088
  if (text.length <= maxChars) return 1;