hazo_dataviz 0.4.2 → 0.5.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/CHANGE_LOG.md +8 -0
- package/dist/charts/radial_gauge.d.ts +17 -0
- package/dist/charts/radial_gauge.d.ts.map +1 -0
- package/dist/charts/radial_gauge.js +24 -0
- package/dist/index.client.d.ts +2 -0
- package/dist/index.client.d.ts.map +1 -1
- package/dist/index.client.js +2 -0
- package/package.json +5 -5
package/CHANGE_LOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# hazo_dataviz — Change Log
|
|
2
2
|
|
|
3
|
+
## 0.5.0 — 2026-07-21
|
|
4
|
+
|
|
5
|
+
New pure inline-SVG chart primitive, extracted from a first consumer (stocktools' bespoke `ProgressRing`).
|
|
6
|
+
|
|
7
|
+
- **`RadialGauge`** (`src/charts/radial_gauge.tsx`) — new donut/radial-gauge micro-viz component exported from `./client`; accepts `value` (0–100, clamped), optional `size` (default 72), `strokeWidth` (default 7), `color` (defaults to `pickColor(0)` from the package's own Studio palette), `trackColor` (default `#E5E7EB`), `label` (`ReactNode`, rendered centered — omitted entirely when not supplied), `className`, `style`. Pure inline SVG (two concentric `<circle>`s, `strokeDasharray`/`strokeDashoffset` arc math, no recharts dependency) — headless like `ChartControls`, styleable by the consumer via `color`/`trackColor`/`style`. Faithfully ports the stroke-dashoffset/clamp math from stocktools' bespoke `progress-ring.tsx`, which is being rewritten as a thin wrapper around this component (variant→color mapping only, zero visual change for its 2 existing consumers).
|
|
8
|
+
- **Tests**: `src/charts/__tests__/radial_gauge.test.tsx` — value clamping (below 0 / above 100 / mid-range), exact stroke-dashoffset for known values, label rendering (string, `ReactNode`, omitted), color/trackColor overrides, size/strokeWidth defaults (15 cases, `@testing-library/react` — pure SVG renders cleanly under jsdom like `ChartControls`).
|
|
9
|
+
- **Test-app**: new "RadialGauge — 0.5.0" demo section on the **Widgets** page (`test-app/app/widgets/page.tsx`) — five gauges showing 0%/38%/62%/100% with default vs. overridden colors, plus a larger custom size/stroke/trackColor/label example. Test-app's `hazo_dataviz` dep range bumped `^0.4.0` → `^0.5.0`.
|
|
10
|
+
|
|
3
11
|
## 0.4.2 — 2026-06-14
|
|
4
12
|
|
|
5
13
|
- **Fix (`TimeSeriesChart` tooltip readability)**: on dark/transparent themes the hover tooltip used `theme.surface` as its background, which is typically `'transparent'` so the bars showed through and the text washed out. Added an optional `ChartTheme.tooltipSurface` (opaque tooltip background, falls back to `surface`, and defaults to a solid dark `#171717` when `surface` is `'transparent'`). Consumers can set `tooltipSurface` to match their card; the chart area itself stays transparent.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export interface RadialGaugeProps {
|
|
3
|
+
/** 0–100; values outside that range are clamped. */
|
|
4
|
+
value: number;
|
|
5
|
+
size?: number;
|
|
6
|
+
strokeWidth?: number;
|
|
7
|
+
/** Arc (progress) stroke color. Defaults to the package's own palette[0]. */
|
|
8
|
+
color?: string;
|
|
9
|
+
/** Track (background) stroke color. */
|
|
10
|
+
trackColor?: string;
|
|
11
|
+
/** Content rendered in the center of the ring, e.g. "62%". */
|
|
12
|
+
label?: React.ReactNode;
|
|
13
|
+
className?: string;
|
|
14
|
+
style?: React.CSSProperties;
|
|
15
|
+
}
|
|
16
|
+
export declare function RadialGauge({ value, size, strokeWidth, color, trackColor, label, className, style, }: RadialGaugeProps): React.ReactElement;
|
|
17
|
+
//# sourceMappingURL=radial_gauge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"radial_gauge.d.ts","sourceRoot":"","sources":["../../src/charts/radial_gauge.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,MAAM,WAAW,gBAAgB;IAC/B,oDAAoD;IACpD,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,6EAA6E;IAC7E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uCAAuC;IACvC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,8DAA8D;IAC9D,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC7B;AAID,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,IAAS,EACT,WAAe,EACf,KAAK,EACL,UAAgC,EAChC,KAAK,EACL,SAAS,EACT,KAAK,GACN,EAAE,gBAAgB,GAAG,KAAK,CAAC,YAAY,CA2DvC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { pickColor } from '../visualizers/palette.js';
|
|
4
|
+
const DEFAULT_TRACK_COLOR = '#E5E7EB';
|
|
5
|
+
export function RadialGauge({ value, size = 72, strokeWidth = 7, color, trackColor = DEFAULT_TRACK_COLOR, label, className, style, }) {
|
|
6
|
+
const pct = Math.min(100, Math.max(0, value));
|
|
7
|
+
const radius = (size - strokeWidth) / 2;
|
|
8
|
+
const circumference = 2 * Math.PI * radius;
|
|
9
|
+
const offset = circumference * (1 - pct / 100);
|
|
10
|
+
const arcColor = color ?? pickColor(0);
|
|
11
|
+
return (_jsxs("div", { className: className, style: {
|
|
12
|
+
position: 'relative',
|
|
13
|
+
flexShrink: 0,
|
|
14
|
+
width: size,
|
|
15
|
+
height: size,
|
|
16
|
+
...style,
|
|
17
|
+
}, children: [_jsxs("svg", { width: size, height: size, viewBox: `0 0 ${size} ${size}`, style: { transform: 'rotate(-90deg)' }, children: [_jsx("circle", { cx: size / 2, cy: size / 2, r: radius, fill: "none", stroke: trackColor, strokeWidth: strokeWidth }), _jsx("circle", { cx: size / 2, cy: size / 2, r: radius, fill: "none", stroke: arcColor, strokeWidth: strokeWidth, strokeLinecap: "round", strokeDasharray: circumference, strokeDashoffset: offset })] }), label != null && (_jsx("div", { style: {
|
|
18
|
+
position: 'absolute',
|
|
19
|
+
inset: 0,
|
|
20
|
+
display: 'flex',
|
|
21
|
+
alignItems: 'center',
|
|
22
|
+
justifyContent: 'center',
|
|
23
|
+
}, children: label }))] }));
|
|
24
|
+
}
|
package/dist/index.client.d.ts
CHANGED
|
@@ -19,4 +19,6 @@ export type { MultiLineChartProps } from './charts/multi_line_chart.js';
|
|
|
19
19
|
export type { TimeSeriesChartProps, TimeSeriesSeries } from './charts/time_series_chart.js';
|
|
20
20
|
export type { ChartControlsProps, ChartType, ChartTheme } from './charts/chart_controls.js';
|
|
21
21
|
export type { ChartDataPoint, ChartDataSeries, MultiSeries } from './types/index.js';
|
|
22
|
+
export { RadialGauge } from './charts/radial_gauge.js';
|
|
23
|
+
export type { RadialGaugeProps } from './charts/radial_gauge.js';
|
|
22
24
|
//# sourceMappingURL=index.client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.client.d.ts","sourceRoot":"","sources":["../src/index.client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,YAAY,EACV,iBAAiB,EACjB,KAAK,EACL,GAAG,EACH,SAAS,EACT,MAAM,EACN,QAAQ,GACT,MAAM,wBAAwB,CAAC;AAChC,YAAY,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
|
|
|
12
12
|
export { TimeSeriesChart } from './charts/time_series_chart.js';
|
|
13
13
|
export { ChartControls } from './charts/chart_controls.js';
|
|
14
14
|
export { aggregateSeries, bucketDate } from './lib/time_bucket.js';
|
|
15
|
+
// Bespoke chart components (pure inline-SVG, no recharts dependency)
|
|
16
|
+
export { RadialGauge } from './charts/radial_gauge.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hazo_dataviz",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Headless data visualization primitives for hazo apps",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -45,10 +45,10 @@
|
|
|
45
45
|
"zod": "^4.1.12"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"hazo_api": "^2.
|
|
49
|
-
"hazo_connect": "^3.
|
|
50
|
-
"hazo_core": "^1.
|
|
51
|
-
"hazo_ui": "^
|
|
48
|
+
"hazo_api": "^2.6.0",
|
|
49
|
+
"hazo_connect": "^3.9.2",
|
|
50
|
+
"hazo_core": "^1.2.1",
|
|
51
|
+
"hazo_ui": "^6.1.0",
|
|
52
52
|
"react": "^18.0.0 || ^19.0.0",
|
|
53
53
|
"react-dom": "^18.0.0 || ^19.0.0",
|
|
54
54
|
"recharts": "^2.15.4 || ^3.0.0"
|