@funnest/charts-react 0.1.1 → 0.2.1
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.js +859 -223
- package/dist/viz/annotations.d.ts +13 -2
- package/dist/viz/axes.d.ts +3 -1
- package/dist/viz/bar.d.ts +7 -1
- package/dist/viz/cartesian-chart.d.ts +28 -6
- package/dist/viz/charts.d.ts +55 -11
- package/dist/viz/context.d.ts +45 -7
- package/dist/viz/horizontal-bar.d.ts +37 -0
- package/dist/viz/index.d.ts +7 -6
- package/dist/viz/legend.d.ts +9 -4
- package/dist/viz/line.d.ts +46 -7
- package/dist/viz/period-selector.d.ts +10 -1
- package/dist/viz/scrubber.d.ts +9 -1
- package/package.json +4 -4
|
@@ -4,21 +4,32 @@ export interface ReferenceLineProps {
|
|
|
4
4
|
dataY?: number;
|
|
5
5
|
/** Vertical line at this x index (event, earnings date). */
|
|
6
6
|
dataX?: number;
|
|
7
|
+
/** For `dataY` with several y axes: which axis the value belongs to. */
|
|
8
|
+
yAxisId?: string;
|
|
7
9
|
label?: string;
|
|
8
10
|
/** Where the label sits along the line. Default 'right' (horizontal) / 'top' (vertical). */
|
|
9
11
|
labelPosition?: 'left' | 'right' | 'center' | 'top' | 'bottom';
|
|
12
|
+
/** Horizontal lines: label above (default), below or centered on the line. */
|
|
13
|
+
labelAlign?: 'above' | 'below' | 'center';
|
|
14
|
+
/** 'text' (default) or 'pill': text on a filled badge in the line color. */
|
|
15
|
+
labelStyle?: 'text' | 'pill';
|
|
16
|
+
/** Nudge the label, px. */
|
|
17
|
+
labelDx?: number;
|
|
18
|
+
labelDy?: number;
|
|
10
19
|
color?: string;
|
|
11
20
|
/** Dash pattern; '' for a solid line. Default '4 4'. */
|
|
12
21
|
dash?: string;
|
|
13
22
|
strokeWidth?: number;
|
|
14
23
|
}
|
|
15
|
-
export declare function ReferenceLine({ dataY, dataX, label, labelPosition, color, dash, strokeWidth }: ReferenceLineProps): import("react").JSX.Element | null;
|
|
24
|
+
export declare function ReferenceLine({ dataY, dataX, yAxisId, label, labelPosition, labelAlign, labelStyle, labelDx, labelDy, color, dash, strokeWidth, }: ReferenceLineProps): import("react").JSX.Element | null;
|
|
16
25
|
export interface PointProps {
|
|
17
26
|
/** X index. */
|
|
18
27
|
dataX: number;
|
|
19
28
|
/** Value. Omit with `seriesId` to sit on that series. */
|
|
20
29
|
dataY?: number;
|
|
21
30
|
seriesId?: string;
|
|
31
|
+
/** For `dataY` without `seriesId` and several y axes: the axis of the value. */
|
|
32
|
+
yAxisId?: string;
|
|
22
33
|
color?: string;
|
|
23
34
|
radius?: number;
|
|
24
35
|
/** Text next to the point (e.g. "매수", "고점 12,400"). */
|
|
@@ -29,6 +40,6 @@ export interface PointProps {
|
|
|
29
40
|
onClick?: () => void;
|
|
30
41
|
}
|
|
31
42
|
/** A marker at a data position: trades on a price line, highs/lows, the latest value. */
|
|
32
|
-
export declare function Point({ dataX, dataY, seriesId, color, radius, label, labelPosition, pulse, onClick }: PointProps): import("react").JSX.Element | null;
|
|
43
|
+
export declare function Point({ dataX, dataY, seriesId, yAxisId, color, radius, label, labelPosition, pulse, onClick }: PointProps): import("react").JSX.Element | null;
|
|
33
44
|
/** Label for a value in the default number format (exported for custom annotations). */
|
|
34
45
|
export declare const formatValue: typeof formatNumber;
|
package/dist/viz/axes.d.ts
CHANGED
|
@@ -23,6 +23,8 @@ export declare namespace XAxis {
|
|
|
23
23
|
export interface YAxisProps {
|
|
24
24
|
/** Right is the trading-chart convention. Default 'right'. */
|
|
25
25
|
position?: 'left' | 'right';
|
|
26
|
+
/** Which y axis to draw when the chart has several (ids from the `yAxis` array). */
|
|
27
|
+
axisId?: string;
|
|
26
28
|
/** Space reserved for labels. Default 48. */
|
|
27
29
|
width?: number;
|
|
28
30
|
/** Explicit tick values. Default: nice numbers, about one per 40px. */
|
|
@@ -34,7 +36,7 @@ export interface YAxisProps {
|
|
|
34
36
|
/** Minimum pixels between ticks when picking automatically. Default 32. */
|
|
35
37
|
minTickSpacing?: number;
|
|
36
38
|
}
|
|
37
|
-
export declare function YAxis({ position, width, ticks, tickLabelFormatter, showGrid, showLine, minTickSpacing, }: YAxisProps): import("react").JSX.Element;
|
|
39
|
+
export declare function YAxis({ position, width, ticks, tickLabelFormatter, axisId, showGrid, showLine, minTickSpacing, }: YAxisProps): import("react").JSX.Element;
|
|
38
40
|
export declare namespace YAxis {
|
|
39
41
|
var axisSpace: (p: YAxisProps) => {
|
|
40
42
|
side: "left" | "right";
|
package/dist/viz/bar.d.ts
CHANGED
|
@@ -3,8 +3,14 @@ export interface BarPlotProps {
|
|
|
3
3
|
seriesIds?: readonly string[];
|
|
4
4
|
/** Corner radius at the bar's far end. Default 3. */
|
|
5
5
|
radius?: number;
|
|
6
|
+
/** Also round the baseline end (pill-shaped bars). Default false. */
|
|
7
|
+
roundBaseline?: boolean;
|
|
6
8
|
/** Gap between grouped bars in one slot, px. Default 2. */
|
|
7
9
|
groupGap?: number;
|
|
10
|
+
/** Gap between stacked segments, px. Default 0. */
|
|
11
|
+
stackGap?: number;
|
|
12
|
+
/** Smallest drawn bar length for non-zero values, px (tiny values stay visible). Default 0. */
|
|
13
|
+
minSize?: number;
|
|
8
14
|
/** Per-bar color (e.g. up/down volume). Return undefined to use the series color. */
|
|
9
15
|
getBarColor?: (value: number, index: number, seriesId: string) => string | undefined;
|
|
10
16
|
/** Dim bars other than the scrubbed one. Default true. */
|
|
@@ -14,4 +20,4 @@ export interface BarPlotProps {
|
|
|
14
20
|
* Bars for every series: side by side (grouped) or on top of each other when the chart
|
|
15
21
|
* is `stacked`. Needs `xAxis.scaleType: 'band'` (BarChart sets it).
|
|
16
22
|
*/
|
|
17
|
-
export declare function BarPlot({ seriesIds, radius, groupGap, getBarColor, highlightScrubbed }: BarPlotProps): import("react").JSX.Element | null;
|
|
23
|
+
export declare function BarPlot({ seriesIds, radius, roundBaseline, groupGap, stackGap, minSize, getBarColor, highlightScrubbed, }: BarPlotProps): import("react").JSX.Element | null;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type CSSProperties, type ReactNode } from 'react';
|
|
2
2
|
import { type ChartSeries } from './context';
|
|
3
|
-
import { type LegendPosition } from './legend';
|
|
3
|
+
import { type LegendPosition, type LegendShape } from './legend';
|
|
4
4
|
export type Inset = number | Partial<Record<'top' | 'right' | 'bottom' | 'left', number>>;
|
|
5
5
|
export interface XAxisConfig {
|
|
6
6
|
/** Labels or timestamps per x position (for axis labels, scrubber and legend). */
|
|
@@ -11,6 +11,8 @@ export interface XAxisConfig {
|
|
|
11
11
|
bandPadding?: number;
|
|
12
12
|
}
|
|
13
13
|
export interface YAxisConfig {
|
|
14
|
+
/** Axis id for `series[].yAxisId` when `yAxis` is an array. */
|
|
15
|
+
id?: string;
|
|
14
16
|
/** Fix either end of the value range; the other end follows the data. */
|
|
15
17
|
domain?: {
|
|
16
18
|
min?: number;
|
|
@@ -20,6 +22,15 @@ export interface YAxisConfig {
|
|
|
20
22
|
includeZero?: boolean;
|
|
21
23
|
/** Round the range outward to nice numbers. Default false (use the data range). */
|
|
22
24
|
nice?: boolean;
|
|
25
|
+
/** 'log' for values spanning orders of magnitude (needs positive values). Default 'linear'. */
|
|
26
|
+
scaleType?: 'linear' | 'log';
|
|
27
|
+
}
|
|
28
|
+
export interface LegendConfig {
|
|
29
|
+
/** Default 'top'. */
|
|
30
|
+
position?: LegendPosition;
|
|
31
|
+
/** Hover an item to emphasize its series, click to hide/show it. Default false. */
|
|
32
|
+
interactive?: boolean;
|
|
33
|
+
shape?: LegendShape;
|
|
23
34
|
}
|
|
24
35
|
export interface CartesianChartProps {
|
|
25
36
|
series: readonly ChartSeries[];
|
|
@@ -30,18 +41,29 @@ export interface CartesianChartProps {
|
|
|
30
41
|
/** Space between the SVG edge and the plot (axes add their own space). Default 8. */
|
|
31
42
|
inset?: Inset;
|
|
32
43
|
xAxis?: XAxisConfig;
|
|
33
|
-
|
|
34
|
-
|
|
44
|
+
/**
|
|
45
|
+
* Value axis options. Pass an array for several y axes (e.g. price on the right, volume
|
|
46
|
+
* on the left) and point series at them with `yAxisId`; render a <YAxis axisId> for each.
|
|
47
|
+
*/
|
|
48
|
+
yAxis?: YAxisConfig | readonly YAxisConfig[];
|
|
49
|
+
/** Stack the series (areas / bars), per y axis. */
|
|
35
50
|
stacked?: boolean;
|
|
36
|
-
/**
|
|
51
|
+
/**
|
|
52
|
+
* Track the pointer and expose the hovered index to <Scrubber>, legends and headers.
|
|
53
|
+
* Also makes the chart focusable: ← → (Shift for 10 steps), Home / End, Esc.
|
|
54
|
+
*/
|
|
37
55
|
enableScrubbing?: boolean;
|
|
38
56
|
onScrubberPositionChange?: (index: number | null) => void;
|
|
57
|
+
/** Screen-reader text for the scrubbed position. Default: the x label and each series value. */
|
|
58
|
+
getScrubberAccessibilityLabel?: (index: number) => string;
|
|
39
59
|
/** Draw-in animation on mount. Default true (off when the user prefers reduced motion). */
|
|
40
60
|
animate?: boolean;
|
|
41
61
|
/** Series legend outside the plot. */
|
|
42
|
-
legend?: boolean | LegendPosition;
|
|
62
|
+
legend?: boolean | LegendPosition | LegendConfig;
|
|
43
63
|
/** Format legend values while scrubbing. */
|
|
44
64
|
legendValueFormatter?: (value: number, seriesId: string) => string;
|
|
65
|
+
/** Shown instead of the plot when no series has a value. */
|
|
66
|
+
emptyState?: ReactNode;
|
|
45
67
|
/** Override the categorical palette. */
|
|
46
68
|
palette?: readonly string[];
|
|
47
69
|
className?: string;
|
|
@@ -60,5 +82,5 @@ export interface AxisSpace {
|
|
|
60
82
|
* themselves as SVG. Compose your own chart from those parts, or use LineChart / AreaChart /
|
|
61
83
|
* BarChart for the common layouts.
|
|
62
84
|
*/
|
|
63
|
-
export declare function CartesianChart({ series, width: fixedWidth, height, inset, xAxis, yAxis, stacked, enableScrubbing, onScrubberPositionChange, animate, legend, legendValueFormatter, palette, className, style, 'aria-label': ariaLabel, children, }: CartesianChartProps): import("react").JSX.Element;
|
|
85
|
+
export declare function CartesianChart({ series, width: fixedWidth, height, inset, xAxis, yAxis, stacked, enableScrubbing, onScrubberPositionChange, getScrubberAccessibilityLabel, animate, legend, legendValueFormatter, emptyState, palette, className, style, 'aria-label': ariaLabel, children, }: CartesianChartProps): import("react").JSX.Element;
|
|
64
86
|
export declare const DEFAULT_CHART_HEIGHT = 240;
|
package/dist/viz/charts.d.ts
CHANGED
|
@@ -3,7 +3,9 @@ import { type CSSProperties, type ReactNode } from 'react';
|
|
|
3
3
|
import { type XAxisProps, type YAxisProps } from './axes';
|
|
4
4
|
import { type BarPlotProps } from './bar';
|
|
5
5
|
import { type CartesianChartProps } from './cartesian-chart';
|
|
6
|
-
import { type
|
|
6
|
+
import { type LineStyle } from './context';
|
|
7
|
+
import { type LegendShape } from './legend';
|
|
8
|
+
import { type AreaFill, type GradientStop, type LineProps, type SplitColors } from './line';
|
|
7
9
|
import { type ScrubberProps } from './scrubber';
|
|
8
10
|
type AxisToggle<P> = boolean | P;
|
|
9
11
|
interface PresetProps extends Omit<CartesianChartProps, 'children'> {
|
|
@@ -17,42 +19,84 @@ interface PresetProps extends Omit<CartesianChartProps, 'children'> {
|
|
|
17
19
|
export interface LineChartProps extends PresetProps {
|
|
18
20
|
curve?: Curve;
|
|
19
21
|
strokeWidth?: number;
|
|
22
|
+
/** 'solid' (default), 'dashed' or 'dotted' for every line (a series' `lineStyle` wins). */
|
|
23
|
+
lineStyle?: LineStyle;
|
|
20
24
|
/** Fill under each line. Default 'none'. */
|
|
21
25
|
area?: AreaFill;
|
|
22
26
|
connectNulls?: boolean;
|
|
27
|
+
/** Dots on the points (see Line `points`). */
|
|
28
|
+
points?: LineProps['points'];
|
|
29
|
+
/** Split line and area colors at this value (e.g. the starting price). */
|
|
30
|
+
baseline?: number;
|
|
31
|
+
/** With `baseline`: colors above / below. Default red / blue (Korean up / down). */
|
|
32
|
+
splitColors?: SplitColors;
|
|
23
33
|
}
|
|
24
34
|
/**
|
|
25
35
|
* Lines for every series. With no axes it is a sparkline:
|
|
26
36
|
* `<LineChart series={[{ id: 'p', data }]} height={40} inset={2} />`.
|
|
27
37
|
*/
|
|
28
|
-
export declare function LineChart({ showXAxis, showYAxis, scrubber, curve, strokeWidth, area, connectNulls, children, ...chart }: LineChartProps): import("react").JSX.Element;
|
|
38
|
+
export declare function LineChart({ showXAxis, showYAxis, scrubber, curve, strokeWidth, lineStyle, area, connectNulls, points, baseline, splitColors, children, ...chart }: LineChartProps): import("react").JSX.Element;
|
|
29
39
|
export interface AreaChartProps extends PresetProps {
|
|
30
40
|
curve?: Curve;
|
|
41
|
+
/** 'gradient' (default), 'solid' or 'dotted'. A series' `areaStyle` wins. */
|
|
31
42
|
fill?: Exclude<AreaFill, 'none'>;
|
|
32
43
|
/** Draw the top edge line. Default true. */
|
|
33
44
|
showLines?: boolean;
|
|
34
45
|
strokeWidth?: number;
|
|
46
|
+
lineStyle?: LineStyle;
|
|
47
|
+
/** Fill toward this value instead of 0 (e.g. the starting price). */
|
|
48
|
+
baseline?: number;
|
|
49
|
+
/** With `baseline`: colors above / below. */
|
|
50
|
+
splitColors?: SplitColors;
|
|
51
|
+
/** Custom gradient stops (offset 0 = line, 1 = baseline). */
|
|
52
|
+
gradientStops?: readonly GradientStop[];
|
|
53
|
+
fillOpacity?: number;
|
|
35
54
|
}
|
|
36
55
|
/** Filled areas; set `stacked` for a composition over time (e.g. portfolio by asset). */
|
|
37
|
-
export declare function AreaChart({ showXAxis, showYAxis, scrubber, curve, fill, showLines, strokeWidth, children, ...chart }: AreaChartProps): import("react").JSX.Element;
|
|
38
|
-
export interface BarChartProps extends PresetProps, Pick<BarPlotProps, 'radius' | 'getBarColor' | 'groupGap'> {
|
|
56
|
+
export declare function AreaChart({ showXAxis, showYAxis, scrubber, curve, fill, showLines, strokeWidth, lineStyle, baseline, splitColors, gradientStops, fillOpacity, children, ...chart }: AreaChartProps): import("react").JSX.Element;
|
|
57
|
+
export interface BarChartProps extends PresetProps, Pick<BarPlotProps, 'radius' | 'getBarColor' | 'groupGap' | 'stackGap' | 'roundBaseline'> {
|
|
58
|
+
/** Smallest drawn bar length for non-zero values, px. */
|
|
59
|
+
barMinSize?: number;
|
|
60
|
+
/**
|
|
61
|
+
* 'vertical' (default) bars grow up from the x axis; 'horizontal' bars run left → right,
|
|
62
|
+
* one row per `xAxis.data` category (rankings, holdings, sector P&L).
|
|
63
|
+
*/
|
|
64
|
+
layout?: 'vertical' | 'horizontal';
|
|
39
65
|
}
|
|
40
66
|
/** Grouped (or `stacked`) bars on a categorical x axis. Hover highlights a bar when `scrubber`. */
|
|
41
|
-
export declare function BarChart({ showXAxis, showYAxis, scrubber, radius, getBarColor, groupGap, xAxis, children, ...chart }: BarChartProps): import("react").JSX.Element;
|
|
67
|
+
export declare function BarChart({ showXAxis, showYAxis, scrubber, radius, getBarColor, groupGap, stackGap, roundBaseline, barMinSize, layout, xAxis, children, ...chart }: BarChartProps): import("react").JSX.Element;
|
|
42
68
|
export interface PercentageBarItem {
|
|
43
69
|
id: string;
|
|
44
70
|
label: string;
|
|
45
71
|
value: number;
|
|
46
72
|
color?: string;
|
|
47
73
|
}
|
|
48
|
-
export interface
|
|
74
|
+
export interface PercentageBarRow {
|
|
75
|
+
id: string;
|
|
76
|
+
/** Shown beside the bar (e.g. account name, date). */
|
|
77
|
+
label?: string;
|
|
49
78
|
data: readonly PercentageBarItem[];
|
|
50
|
-
|
|
79
|
+
}
|
|
80
|
+
export interface PercentageBarChartProps {
|
|
81
|
+
/** One bar. Use `rows` for several bars that share a legend. */
|
|
82
|
+
data?: readonly PercentageBarItem[];
|
|
83
|
+
/** Several bars compared row by row (items are matched by `id`, so colors stay consistent). */
|
|
84
|
+
rows?: readonly PercentageBarRow[];
|
|
85
|
+
/** 'horizontal' (default) or 'vertical' (columns that fill bottom → top). */
|
|
86
|
+
layout?: 'horizontal' | 'vertical';
|
|
87
|
+
/** Bar thickness. Default 10 (horizontal), 28 (vertical). */
|
|
51
88
|
barHeight?: number;
|
|
89
|
+
/** Bar length for `layout: 'vertical'`, px. Default 160. */
|
|
90
|
+
barLength?: number;
|
|
52
91
|
/** Gap between segments, px. Default 2. */
|
|
53
92
|
gap?: number;
|
|
54
|
-
/**
|
|
93
|
+
/** Corner radius of the bar ends. Default barHeight / 2 (fully round) horizontally, 6 vertically. */
|
|
94
|
+
radius?: number;
|
|
95
|
+
/** Labels with percentages. Default true. */
|
|
55
96
|
showLabels?: boolean;
|
|
97
|
+
/** Where the labels go. Default 'bottom' ('right' for vertical). */
|
|
98
|
+
legendPosition?: 'top' | 'bottom' | 'right';
|
|
99
|
+
legendShape?: LegendShape;
|
|
56
100
|
/** Format the label value. Default: "62.5%". */
|
|
57
101
|
formatLabel?: (item: PercentageBarItem, fraction: number) => string;
|
|
58
102
|
palette?: readonly string[];
|
|
@@ -61,8 +105,8 @@ export interface PercentageBarChartProps {
|
|
|
61
105
|
'aria-label'?: string;
|
|
62
106
|
}
|
|
63
107
|
/**
|
|
64
|
-
*
|
|
65
|
-
*
|
|
108
|
+
* A bar split into shares: portfolio weights, buy/sell pressure, long/short ratio.
|
|
109
|
+
* `rows` compares several (accounts, months) with one shared legend; `layout: 'vertical'` stands them up.
|
|
66
110
|
*/
|
|
67
|
-
export declare function PercentageBarChart({ data, barHeight, gap, showLabels, formatLabel, palette, className, style, 'aria-label': ariaLabel, }: PercentageBarChartProps): import("react").JSX.Element;
|
|
111
|
+
export declare function PercentageBarChart({ data, rows, layout, barHeight, barLength, gap, radius, showLabels, legendPosition, legendShape, formatLabel, palette, className, style, 'aria-label': ariaLabel, }: PercentageBarChartProps): import("react").JSX.Element;
|
|
68
112
|
export {};
|
package/dist/viz/context.d.ts
CHANGED
|
@@ -1,16 +1,33 @@
|
|
|
1
|
-
import type { BandScale,
|
|
1
|
+
import type { BandScale, StackedSeries, ValueScale } from '@funnest/charts-viz';
|
|
2
|
+
/** A low–high pair: confidence bands, high/low bars. */
|
|
3
|
+
export type RangeValue = readonly [number, number];
|
|
2
4
|
export interface ChartSeries {
|
|
3
5
|
id: string;
|
|
4
|
-
/** Values per x position; null = gap. */
|
|
5
|
-
data: readonly (number | null)[];
|
|
6
|
+
/** Values per x position; null = gap; `[low, high]` for a range (band / floating bar). */
|
|
7
|
+
data: readonly (number | null | RangeValue)[];
|
|
8
|
+
/** Which y axis this series uses (see `yAxis` as an array). Default: the first axis. */
|
|
9
|
+
yAxisId?: string;
|
|
6
10
|
label?: string;
|
|
7
11
|
/** Any CSS color. Defaults to the palette. */
|
|
8
12
|
color?: string;
|
|
13
|
+
/** Line style for this series (overrides the chart's). */
|
|
14
|
+
lineStyle?: LineStyle;
|
|
15
|
+
/** Area fill for this series in AreaChart / LineChart `area` (overrides the chart's). */
|
|
16
|
+
areaStyle?: 'gradient' | 'solid' | 'dotted' | 'none';
|
|
9
17
|
}
|
|
10
|
-
|
|
11
|
-
|
|
18
|
+
export type LineStyle = 'solid' | 'dashed' | 'dotted';
|
|
19
|
+
/** A series ready to draw: resolved color, its value scale, ranges split into low/high. */
|
|
20
|
+
export interface ResolvedSeries extends Omit<ChartSeries, 'data'> {
|
|
21
|
+
/** Values (the high end for ranges); null = gap. */
|
|
22
|
+
data: readonly (number | null)[];
|
|
23
|
+
/** Low ends when the series has ranges, else null. */
|
|
24
|
+
low: readonly (number | null)[] | null;
|
|
12
25
|
color: string;
|
|
13
26
|
index: number;
|
|
27
|
+
/** Another series is emphasized (legend hover): draw this one faded. */
|
|
28
|
+
dimmed: boolean;
|
|
29
|
+
/** The value scale of this series' y axis. */
|
|
30
|
+
scale: ValueScale;
|
|
14
31
|
}
|
|
15
32
|
export interface PlotRect {
|
|
16
33
|
left: number;
|
|
@@ -34,16 +51,30 @@ export interface CartesianContextValue {
|
|
|
34
51
|
x(i: number): number;
|
|
35
52
|
/** Set when the x axis is categorical (bar charts). */
|
|
36
53
|
band: BandScale | null;
|
|
37
|
-
y
|
|
54
|
+
/** Value scale of the first (default) y axis. */
|
|
55
|
+
y: ValueScale;
|
|
56
|
+
/** Every y axis' scale by id. */
|
|
57
|
+
yScales: Readonly<Record<string, ValueScale>>;
|
|
38
58
|
/** Stacked edges per series id when `stacked`. */
|
|
39
59
|
stacked: Map<string, StackedSeries> | null;
|
|
40
60
|
/** Label for x position `i` (from `xAxis.data`, else the index). */
|
|
41
61
|
xLabel(i: number): string;
|
|
42
62
|
xData: readonly (string | number)[] | undefined;
|
|
43
|
-
/** Index under the pointer, or null. */
|
|
63
|
+
/** Index under the pointer (or chosen with the arrow keys), or null. */
|
|
44
64
|
scrubIndex: number | null;
|
|
65
|
+
/** The chart has keyboard focus (scrubbing with arrow keys). */
|
|
66
|
+
focused: boolean;
|
|
45
67
|
animate: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* `mask` value for series marks while a Scrubber dims the future (right of the pointer);
|
|
70
|
+
* undefined otherwise. Lines and areas apply it, so the fade works on any background.
|
|
71
|
+
*/
|
|
72
|
+
futureMask: string | undefined;
|
|
73
|
+
/** Scrubber turns future dimming on/off. */
|
|
74
|
+
setDimFuture(on: boolean): void;
|
|
46
75
|
}
|
|
76
|
+
/** Hide labels the scrubber line would run through. */
|
|
77
|
+
export declare const nearScrub: (ctx: CartesianContextValue, x: number, within?: number) => boolean;
|
|
47
78
|
export declare const CartesianContext: import("react").Context<CartesianContextValue | null>;
|
|
48
79
|
export declare function useCartesianChart(): CartesianContextValue;
|
|
49
80
|
/**
|
|
@@ -58,8 +89,15 @@ export declare const VAR: {
|
|
|
58
89
|
readonly line: 'var(--fnv-line, color-mix(in srgb, CanvasText 32%, transparent))';
|
|
59
90
|
readonly bg: 'var(--fnv-bg, Canvas)';
|
|
60
91
|
readonly font: 'var(--fnv-font, inherit)';
|
|
92
|
+
readonly accentRing: 'color-mix(in srgb, var(--fnv-accent, #6C4DFF) 55%, transparent)';
|
|
61
93
|
};
|
|
94
|
+
/** Opacity for series faded by legend emphasis. */
|
|
95
|
+
export declare const DIM_OPACITY = 0.22;
|
|
96
|
+
/** Stroke dash pattern for a line style (dotted uses round caps on zero-length dashes). */
|
|
97
|
+
export declare const dashFor: (style: LineStyle | undefined, width: number) => string | undefined;
|
|
62
98
|
/** Default number display: full digits up to 100k, compact (1.2M, 34만) beyond. */
|
|
63
99
|
export declare const formatNumber: (v: number) => string;
|
|
64
100
|
/** Pixel y of series `s` at index `i` (top edge when stacked), or null for a gap. */
|
|
65
101
|
export declare function seriesY(ctx: CartesianContextValue, s: ResolvedSeries, i: number): number | null;
|
|
102
|
+
/** Scale for an axis id (falls back to the first axis). */
|
|
103
|
+
export declare const scaleFor: (ctx: CartesianContextValue, axisId?: string) => ValueScale;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type CSSProperties } from 'react';
|
|
2
|
+
import { type ChartSeries } from './context';
|
|
3
|
+
import { type LegendShape } from './legend';
|
|
4
|
+
export interface HorizontalBarChartProps {
|
|
5
|
+
series: readonly ChartSeries[];
|
|
6
|
+
/** Category labels, one per row (top to bottom). */
|
|
7
|
+
categories?: readonly string[];
|
|
8
|
+
width?: number;
|
|
9
|
+
/** Default: 34px per row plus the axis. */
|
|
10
|
+
height?: number;
|
|
11
|
+
stacked?: boolean;
|
|
12
|
+
/** Corner radius at the bar's far end. Default 3. */
|
|
13
|
+
radius?: number;
|
|
14
|
+
/** Gap between grouped bars in one row, px. Default 2. */
|
|
15
|
+
groupGap?: number;
|
|
16
|
+
/** Gap between stacked segments, px. Default 0. */
|
|
17
|
+
stackGap?: number;
|
|
18
|
+
/** Band padding between rows, 0–0.95. Default 0.3. */
|
|
19
|
+
bandPadding?: number;
|
|
20
|
+
getBarColor?: (value: number, index: number, seriesId: string) => string | undefined;
|
|
21
|
+
/** Value axis along the bottom. Default true. */
|
|
22
|
+
showValueAxis?: boolean;
|
|
23
|
+
/** Category labels on the left. Default true. */
|
|
24
|
+
showCategoryAxis?: boolean;
|
|
25
|
+
valueFormatter?: (value: number) => string;
|
|
26
|
+
/** Highlight the hovered row and show its values. Default true. */
|
|
27
|
+
enableScrubbing?: boolean;
|
|
28
|
+
legend?: boolean | {
|
|
29
|
+
shape?: LegendShape;
|
|
30
|
+
};
|
|
31
|
+
palette?: readonly string[];
|
|
32
|
+
className?: string;
|
|
33
|
+
style?: CSSProperties;
|
|
34
|
+
'aria-label'?: string;
|
|
35
|
+
}
|
|
36
|
+
/** Bars running left → right, one row per category: rankings, holdings, sector P&L. */
|
|
37
|
+
export declare function HorizontalBarChart({ series, categories, width: fixedWidth, height, stacked, radius, groupGap, stackGap, bandPadding, getBarColor, showValueAxis, showCategoryAxis, valueFormatter, enableScrubbing, legend, palette, className, style, 'aria-label': ariaLabel, }: HorizontalBarChartProps): import("react").JSX.Element;
|
package/dist/viz/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
export { CartesianChart, type CartesianChartProps, type XAxisConfig, type YAxisConfig, type Inset } from './cartesian-chart';
|
|
1
|
+
export { CartesianChart, type CartesianChartProps, type XAxisConfig, type YAxisConfig, type LegendConfig, type Inset } from './cartesian-chart';
|
|
2
2
|
export { XAxis, YAxis, type XAxisProps, type YAxisProps } from './axes';
|
|
3
|
-
export { Line, Area, type LineProps, type AreaProps, type AreaFill } from './line';
|
|
3
|
+
export { Line, Area, type LineProps, type AreaProps, type AreaFill, type LinePoint, type SplitColors, type GradientStop } from './line';
|
|
4
4
|
export { BarPlot, type BarPlotProps } from './bar';
|
|
5
|
+
export { HorizontalBarChart, type HorizontalBarChartProps } from './horizontal-bar';
|
|
5
6
|
export { Scrubber, type ScrubberProps } from './scrubber';
|
|
6
7
|
export { ReferenceLine, Point, type ReferenceLineProps, type PointProps } from './annotations';
|
|
7
|
-
export { Legend, type LegendProps, type LegendItem, type LegendPosition } from './legend';
|
|
8
|
-
export { PeriodSelector, DEFAULT_PERIODS, type PeriodSelectorProps, type Period } from './period-selector';
|
|
9
|
-
export { LineChart, AreaChart, BarChart, PercentageBarChart, type LineChartProps, type AreaChartProps, type BarChartProps, type PercentageBarChartProps, type PercentageBarItem, } from './charts';
|
|
10
|
-
export { useCartesianChart, formatNumber, type ChartSeries, type CartesianContextValue, type PlotRect } from './context';
|
|
8
|
+
export { Legend, type LegendProps, type LegendItem, type LegendPosition, type LegendShape } from './legend';
|
|
9
|
+
export { PeriodSelector, LiveTabLabel, DEFAULT_PERIODS, type PeriodSelectorProps, type Period } from './period-selector';
|
|
10
|
+
export { LineChart, AreaChart, BarChart, PercentageBarChart, type LineChartProps, type AreaChartProps, type BarChartProps, type PercentageBarChartProps, type PercentageBarItem, type PercentageBarRow, } from './charts';
|
|
11
|
+
export { useCartesianChart, formatNumber, type ChartSeries, type RangeValue, type LineStyle, type CartesianContextValue, type PlotRect } from './context';
|
package/dist/viz/legend.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { CSSProperties } from 'react';
|
|
2
|
-
export type LegendPosition = 'top' | 'bottom';
|
|
2
|
+
export type LegendPosition = 'top' | 'bottom' | 'left' | 'right';
|
|
3
|
+
export type LegendShape = 'circle' | 'square' | 'squircle' | 'pill' | 'line';
|
|
3
4
|
export interface LegendItem {
|
|
4
5
|
id: string;
|
|
5
6
|
label: string;
|
|
@@ -15,10 +16,14 @@ export interface LegendProps {
|
|
|
15
16
|
onItemClick?: (id: string) => void;
|
|
16
17
|
/** Pointer enters (id) or leaves (null) an item — e.g. to highlight that series. */
|
|
17
18
|
onItemHover?: (id: string | null) => void;
|
|
18
|
-
/** 'circle' (default), 'square' or 'line'
|
|
19
|
-
shape?:
|
|
19
|
+
/** Swatch: 'circle' (default), 'square', 'squircle', 'pill' or 'line'. */
|
|
20
|
+
shape?: LegendShape;
|
|
21
|
+
/** 'row' wraps items across (default); 'column' stacks them (side legends). */
|
|
22
|
+
direction?: 'row' | 'column';
|
|
23
|
+
/** Alignment of the items. Default 'flex-start'. */
|
|
24
|
+
justify?: CSSProperties['justifyContent'];
|
|
20
25
|
className?: string;
|
|
21
26
|
style?: CSSProperties;
|
|
22
27
|
}
|
|
23
28
|
/** Series key, HTML (not SVG) so it wraps and stays readable at any width. */
|
|
24
|
-
export declare function Legend({ items, onItemClick, onItemHover, shape, className, style }: LegendProps): import("react").JSX.Element;
|
|
29
|
+
export declare function Legend({ items, onItemClick, onItemHover, shape, direction, justify, className, style }: LegendProps): import("react").JSX.Element;
|
package/dist/viz/line.d.ts
CHANGED
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
import { type Curve, type XY } from '@funnest/charts-viz';
|
|
2
|
-
import { type CartesianContextValue, type ResolvedSeries } from './context';
|
|
3
|
-
export type AreaFill = 'gradient' | 'solid' | 'none';
|
|
4
|
-
/**
|
|
2
|
+
import { type CartesianContextValue, type LineStyle, type ResolvedSeries } from './context';
|
|
3
|
+
export type AreaFill = 'gradient' | 'solid' | 'dotted' | 'none';
|
|
4
|
+
/** Colors above and below a `baseline` (e.g. red over the starting price, blue under it). */
|
|
5
|
+
export interface SplitColors {
|
|
6
|
+
above: string;
|
|
7
|
+
below: string;
|
|
8
|
+
}
|
|
9
|
+
/** A gradient stop for areas: `offset` 0 at the line, 1 at the baseline. */
|
|
10
|
+
export interface GradientStop {
|
|
11
|
+
offset: number;
|
|
12
|
+
opacity: number;
|
|
13
|
+
color?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Pixel points of a series split at gaps (or joined across them with `connectNulls`).
|
|
17
|
+
* `lower` is the bottom edge for stacked series and for ranges ([low, high] bands).
|
|
18
|
+
*/
|
|
5
19
|
export declare function seriesRuns(ctx: CartesianContextValue, s: ResolvedSeries, connectNulls?: boolean): {
|
|
6
20
|
upper: XY[];
|
|
7
21
|
lower: {
|
|
@@ -12,18 +26,34 @@ export declare function seriesRuns(ctx: CartesianContextValue, s: ResolvedSeries
|
|
|
12
26
|
export interface AreaProps {
|
|
13
27
|
seriesId: string;
|
|
14
28
|
curve?: Curve;
|
|
29
|
+
/** 'gradient' (default), 'solid' or 'dotted' (dot pattern). */
|
|
15
30
|
fill?: Exclude<AreaFill, 'none'>;
|
|
16
|
-
/** Fill opacity at the line (gradient fades to 0). Default 0.24 (solid 0.16). */
|
|
31
|
+
/** Fill opacity at the line (gradient fades to 0). Default 0.24 (solid 0.16, dotted 0.5). */
|
|
17
32
|
opacity?: number;
|
|
18
33
|
connectNulls?: boolean;
|
|
34
|
+
/** Fill toward this value instead of 0 / the plot bottom (e.g. the starting price). */
|
|
35
|
+
baseline?: number;
|
|
36
|
+
/** With `baseline`: color the area above / below it differently. */
|
|
37
|
+
splitColors?: SplitColors;
|
|
38
|
+
/** Custom gradient stops (offset 0 = line, 1 = baseline). */
|
|
39
|
+
gradientStops?: readonly GradientStop[];
|
|
19
40
|
}
|
|
20
41
|
/** Filled area under a series (between stacked edges when the chart is stacked). */
|
|
21
|
-
export declare function Area({ seriesId, curve, fill, opacity, connectNulls }: AreaProps): import("react").JSX.Element | null;
|
|
42
|
+
export declare function Area({ seriesId, curve, fill, opacity, connectNulls, baseline, splitColors, gradientStops }: AreaProps): import("react").JSX.Element | null;
|
|
43
|
+
/** What a single point looks like; return `false`/`null` from `points` to skip one. */
|
|
44
|
+
export interface LinePoint {
|
|
45
|
+
radius?: number;
|
|
46
|
+
color?: string;
|
|
47
|
+
label?: string;
|
|
48
|
+
labelPosition?: 'top' | 'bottom';
|
|
49
|
+
}
|
|
22
50
|
export interface LineProps {
|
|
23
51
|
seriesId: string;
|
|
24
52
|
curve?: Curve;
|
|
25
53
|
strokeWidth?: number;
|
|
26
|
-
/**
|
|
54
|
+
/** 'solid' (default), 'dashed' or 'dotted'. Falls back to the series' `lineStyle`. */
|
|
55
|
+
lineStyle?: LineStyle;
|
|
56
|
+
/** Custom dash pattern, e.g. "4 4" (overrides `lineStyle`). */
|
|
27
57
|
dash?: string;
|
|
28
58
|
/** Draw across null gaps instead of breaking. */
|
|
29
59
|
connectNulls?: boolean;
|
|
@@ -31,5 +61,14 @@ export interface LineProps {
|
|
|
31
61
|
area?: AreaFill;
|
|
32
62
|
areaOpacity?: number;
|
|
33
63
|
opacity?: number;
|
|
64
|
+
/**
|
|
65
|
+
* Dots on the data points: `true` for every point, or a function returning the look of
|
|
66
|
+
* point `index` (or false to skip it) — e.g. label only the high and the low.
|
|
67
|
+
*/
|
|
68
|
+
points?: boolean | ((index: number, value: number) => LinePoint | boolean | null | undefined);
|
|
69
|
+
/** Split the line (and area) color at this value, e.g. the starting price. */
|
|
70
|
+
baseline?: number;
|
|
71
|
+
/** With `baseline`: colors above / below it. */
|
|
72
|
+
splitColors?: SplitColors;
|
|
34
73
|
}
|
|
35
|
-
export declare function Line({ seriesId, curve, strokeWidth, dash, connectNulls, area, areaOpacity, opacity, }: LineProps): import("react").JSX.Element | null;
|
|
74
|
+
export declare function Line({ seriesId, curve, strokeWidth, lineStyle, dash, connectNulls, area, areaOpacity, opacity, points, baseline, splitColors, }: LineProps): import("react").JSX.Element | null;
|
|
@@ -2,7 +2,14 @@ import { type CSSProperties } from 'react';
|
|
|
2
2
|
export interface Period {
|
|
3
3
|
id: string;
|
|
4
4
|
label: string;
|
|
5
|
+
/** A live tab: a pulsing dot next to the label, and the live color when selected. */
|
|
6
|
+
live?: boolean;
|
|
5
7
|
}
|
|
8
|
+
/** A label with a pulsing "live" dot (used by live periods; usable on its own too). */
|
|
9
|
+
export declare function LiveTabLabel({ label, color }: {
|
|
10
|
+
label: string;
|
|
11
|
+
color?: string;
|
|
12
|
+
}): import("react").JSX.Element;
|
|
6
13
|
/** Common ranges for price charts. */
|
|
7
14
|
export declare const DEFAULT_PERIODS: readonly Period[];
|
|
8
15
|
export interface PeriodSelectorProps {
|
|
@@ -11,6 +18,8 @@ export interface PeriodSelectorProps {
|
|
|
11
18
|
onChange: (id: string) => void;
|
|
12
19
|
/** Active pill color. Default Funnest violet (set --fnv-accent to theme). */
|
|
13
20
|
activeColor?: string;
|
|
21
|
+
/** Pill color while a live period is selected. Default red. */
|
|
22
|
+
liveColor?: string;
|
|
14
23
|
/** Stretch the tabs across the full width (mobile). */
|
|
15
24
|
fullWidth?: boolean;
|
|
16
25
|
className?: string;
|
|
@@ -18,4 +27,4 @@ export interface PeriodSelectorProps {
|
|
|
18
27
|
'aria-label'?: string;
|
|
19
28
|
}
|
|
20
29
|
/** Range tabs (1D 1W 1M …) with a sliding pill; arrow keys move between tabs. */
|
|
21
|
-
export declare function PeriodSelector({ periods, value, onChange, activeColor, fullWidth, className, style, 'aria-label': ariaLabel, }: PeriodSelectorProps): import("react").JSX.Element;
|
|
30
|
+
export declare function PeriodSelector({ periods, value, onChange, activeColor, liveColor, fullWidth, className, style, 'aria-label': ariaLabel, }: PeriodSelectorProps): import("react").JSX.Element;
|
package/dist/viz/scrubber.d.ts
CHANGED
|
@@ -5,6 +5,14 @@ export interface ScrubberProps {
|
|
|
5
5
|
seriesIds?: readonly string[];
|
|
6
6
|
/** Dim the part of each line right of the scrubber. Default true. */
|
|
7
7
|
dimFuture?: boolean;
|
|
8
|
+
/** Same as `dimFuture={false}`. */
|
|
9
|
+
hideOverlay?: boolean;
|
|
10
|
+
/** While idle (not scrubbing), pulse a beacon on each series' latest point. */
|
|
11
|
+
idlePulse?: boolean;
|
|
12
|
+
/** Value labels beside each beacon (true, or a formatter). Default false. */
|
|
13
|
+
beaconLabels?: boolean | ((value: number, seriesId: string) => string);
|
|
14
|
+
/** Beacon color per value (e.g. up/down around a baseline). Default: the series color. */
|
|
15
|
+
beaconColor?: (value: number, seriesId: string) => string;
|
|
8
16
|
/** Tooltip with each series' value at the scrubbed index. Default false. */
|
|
9
17
|
showValues?: boolean;
|
|
10
18
|
/** Format tooltip values. */
|
|
@@ -15,4 +23,4 @@ export interface ScrubberProps {
|
|
|
15
23
|
* `enableScrubbing` on the chart. Read the index yourself with `onScrubberPositionChange`
|
|
16
24
|
* to drive a header (price / change at that point).
|
|
17
25
|
*/
|
|
18
|
-
export declare function Scrubber({ label, seriesIds, dimFuture, showValues, valueFormatter }: ScrubberProps): import("react").JSX.Element | null;
|
|
26
|
+
export declare function Scrubber({ label, seriesIds, dimFuture, hideOverlay, idlePulse, beaconLabels, beaconColor, showValues, valueFormatter, }: ScrubberProps): import("react").JSX.Element | null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@funnest/charts-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "React bindings for Funnest Charts: the trading widget plus SVG line, area and bar charts",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -46,9 +46,9 @@
|
|
|
46
46
|
"NOTICE"
|
|
47
47
|
],
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@funnest/charts": "0.
|
|
50
|
-
"@funnest/charts-
|
|
51
|
-
"@funnest/charts-
|
|
49
|
+
"@funnest/charts": "0.2.1",
|
|
50
|
+
"@funnest/charts-viz": "0.2.1",
|
|
51
|
+
"@funnest/charts-ui": "0.2.1"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"react": ">=18",
|