@opendata-ai/openchart-core 7.1.3 → 7.2.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 +77 -13
- package/dist/index.js +171 -111
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/src/colors/__tests__/contrast.test.ts +32 -24
- package/src/colors/contrast.ts +18 -9
- package/src/colors/palettes.ts +11 -8
- package/src/index.ts +1 -0
- package/src/responsive/index.ts +1 -0
- package/src/responsive/metrics.ts +15 -0
- package/src/styles/chrome.css +20 -1
- package/src/theme/__tests__/dark-mode.test.ts +29 -0
- package/src/theme/__tests__/resolve.test.ts +30 -0
- package/src/theme/dark-mode.ts +43 -11
- package/src/theme/defaults.ts +2 -0
- package/src/theme/resolve.ts +39 -0
- package/src/types/spec.ts +43 -0
- package/src/types/theme.ts +4 -0
package/src/types/spec.ts
CHANGED
|
@@ -246,6 +246,8 @@ export interface AxisConfig {
|
|
|
246
246
|
labelPadding?: number;
|
|
247
247
|
/** Color override for axis tick labels and title. Useful in dual-axis charts to match axis color to its series. */
|
|
248
248
|
labelColor?: string;
|
|
249
|
+
/** Literal string appended to every formatted tick label. e.g. "B" gives "$4.5B" when format is "$,.1~f". */
|
|
250
|
+
labelSuffix?: string;
|
|
249
251
|
/** Secondary data field to display alongside each tick label. Renders in lighter weight/color. Only effective on categorical y-axis labels (horizontal bar charts). */
|
|
250
252
|
labelField?: string;
|
|
251
253
|
/**
|
|
@@ -810,6 +812,19 @@ export interface ThemeConfig {
|
|
|
810
812
|
family?: string;
|
|
811
813
|
/** Monospace font family (for tabular numbers). */
|
|
812
814
|
mono?: string;
|
|
815
|
+
/** Font size overrides in pixels. Partial — only specified keys are overridden. */
|
|
816
|
+
sizes?: {
|
|
817
|
+
/** Chart title. Default: 26. */
|
|
818
|
+
title?: number;
|
|
819
|
+
/** Subtitle below the title. Default: 14. */
|
|
820
|
+
subtitle?: number;
|
|
821
|
+
/** Body text (tooltips, legend labels). Default: 13. */
|
|
822
|
+
body?: number;
|
|
823
|
+
/** Small text (source line, footer). Default: 11. */
|
|
824
|
+
small?: number;
|
|
825
|
+
/** Axis tick labels. Default: 11. */
|
|
826
|
+
axisTick?: number;
|
|
827
|
+
};
|
|
813
828
|
};
|
|
814
829
|
/** Spacing overrides in pixels. */
|
|
815
830
|
spacing?: {
|
|
@@ -817,9 +832,33 @@ export interface ThemeConfig {
|
|
|
817
832
|
padding?: number;
|
|
818
833
|
/** Gap between chrome elements (title to subtitle, etc.). */
|
|
819
834
|
chromeGap?: number;
|
|
835
|
+
/** Height reserved below chart area for x-axis tick labels. Increase when large axisTick font sizes cause label clipping. */
|
|
836
|
+
xAxisHeight?: number;
|
|
837
|
+
/** Gap in pixels between the x-axis line and tick label text. Increase when larger axisTick fonts sit too close to the axis line. */
|
|
838
|
+
xAxisLabelPadding?: number;
|
|
820
839
|
};
|
|
821
840
|
/** Border radius for chart container and tooltips. */
|
|
822
841
|
borderRadius?: number;
|
|
842
|
+
/**
|
|
843
|
+
* Per-element chrome text color overrides. Font sizes and weights come
|
|
844
|
+
* from the typography scale and are not overridable here; only color is.
|
|
845
|
+
* An override survives dark-mode adaptation (adaptTheme preserves any
|
|
846
|
+
* chrome color the spec set explicitly).
|
|
847
|
+
*/
|
|
848
|
+
chrome?: {
|
|
849
|
+
/** Eyebrow (kicker) text color. */
|
|
850
|
+
eyebrow?: string;
|
|
851
|
+
/** Title text color. */
|
|
852
|
+
title?: string;
|
|
853
|
+
/** Subtitle text color. */
|
|
854
|
+
subtitle?: string;
|
|
855
|
+
/** Source/attribution text color. */
|
|
856
|
+
source?: string;
|
|
857
|
+
/** Byline text color. */
|
|
858
|
+
byline?: string;
|
|
859
|
+
/** Footer text color. */
|
|
860
|
+
footer?: string;
|
|
861
|
+
};
|
|
823
862
|
}
|
|
824
863
|
|
|
825
864
|
// ---------------------------------------------------------------------------
|
|
@@ -843,10 +882,14 @@ export interface LabelConfig {
|
|
|
843
882
|
format?: string;
|
|
844
883
|
/** Literal string prepended to each formatted label value (e.g. "-" or "$"). */
|
|
845
884
|
prefix?: string;
|
|
885
|
+
/** Literal string appended to each formatted label value (e.g. "%" or "x"). */
|
|
886
|
+
suffix?: string;
|
|
846
887
|
/** Fixed CSS color for all labels. Overrides the default fill-derived color. */
|
|
847
888
|
color?: string;
|
|
848
889
|
/** Per-series pixel offsets for fine-tuning label positions, keyed by series name. */
|
|
849
890
|
offsets?: Record<string, AnnotationOffset>;
|
|
891
|
+
/** Font size in pixels for bar/column value labels. */
|
|
892
|
+
fontSize?: number;
|
|
850
893
|
}
|
|
851
894
|
|
|
852
895
|
/** Shorthand: `false` disables all labels, `true` uses defaults, or pass a full config object. */
|
package/src/types/theme.ts
CHANGED
|
@@ -93,6 +93,10 @@ export interface ThemeSpacing {
|
|
|
93
93
|
chartToFooter: number;
|
|
94
94
|
/** Internal padding within the chart area (axes margins). */
|
|
95
95
|
axisMargin: number;
|
|
96
|
+
/** Height reserved below the chart area for x-axis tick labels (and optional axis title). */
|
|
97
|
+
xAxisHeight: number;
|
|
98
|
+
/** Gap in pixels between the x-axis line and the top of non-rotated tick label text. */
|
|
99
|
+
xAxisLabelPadding: number;
|
|
96
100
|
}
|
|
97
101
|
|
|
98
102
|
// ---------------------------------------------------------------------------
|