katucharts.js 0.2.21 → 0.2.22
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/README.md +18 -3
- package/dist/core/Chart.d.ts +12 -0
- package/dist/core/StackComputer.d.ts +11 -0
- package/dist/katucharts-bio.es.js +1277 -1237
- package/dist/katucharts-bio.umd.js +1 -1
- package/dist/katucharts-finance.es.js +1741 -1512
- package/dist/katucharts-finance.umd.js +1 -1
- package/dist/katucharts.es.js +5416 -4956
- package/dist/katucharts.umd.js +5 -5
- package/dist/layout/LayoutEngine.d.ts +6 -0
- package/dist/series/BaseSeries.d.ts +9 -1
- package/dist/series/cartesian/ColumnChart.d.ts +5 -5
- package/dist/series/financial/AreaRangeChart.d.ts +14 -0
- package/dist/series/hierarchical/TreegraphChart.d.ts +7 -0
- package/dist/series/pictorial/PictorialChart.d.ts +32 -0
- package/dist/series/pie/PieChart.d.ts +31 -0
- package/dist/types/options.d.ts +10 -1
- package/package.json +1 -1
|
@@ -22,6 +22,12 @@ export interface LayoutResult {
|
|
|
22
22
|
width: number;
|
|
23
23
|
height: number;
|
|
24
24
|
};
|
|
25
|
+
captionArea: {
|
|
26
|
+
x: number;
|
|
27
|
+
y: number;
|
|
28
|
+
width: number;
|
|
29
|
+
height: number;
|
|
30
|
+
};
|
|
25
31
|
}
|
|
26
32
|
export declare class LayoutEngine {
|
|
27
33
|
compute(config: InternalConfig, chartWidth: number, chartHeight: number): LayoutResult;
|
|
@@ -20,7 +20,12 @@ export interface SeriesContext {
|
|
|
20
20
|
totalSeriesOfType?: number;
|
|
21
21
|
indexInType?: number;
|
|
22
22
|
animate?: boolean;
|
|
23
|
+
/** Positive-side running stack offset, also aliased as the plain offset for all-positive consumers (area/radar). */
|
|
23
24
|
stackOffsets?: Map<number | string, number>;
|
|
25
|
+
/** Running same-sign stack offset for this series, split so diverging stacks (e.g. pyramids) fill opposite sides of zero. */
|
|
26
|
+
stackOffsetsPos?: Map<number | string, number>;
|
|
27
|
+
stackOffsetsNeg?: Map<number | string, number>;
|
|
28
|
+
/** Absolute stack height per category (positive sum + |negative sum|), used as the percent-stacking denominator. */
|
|
24
29
|
stackTotals?: Map<number | string, number>;
|
|
25
30
|
allSeries?: BaseSeries[];
|
|
26
31
|
inverted?: boolean;
|
|
@@ -179,7 +184,10 @@ export declare abstract class BaseSeries {
|
|
|
179
184
|
/**
|
|
180
185
|
* Render data labels for all visible points based on dataLabels config.
|
|
181
186
|
*/
|
|
182
|
-
protected renderDataLabels(data: PointOptions[], getX: (d: PointOptions, i: number) => number, getY: (d: PointOptions, i: number) => number
|
|
187
|
+
protected renderDataLabels(data: PointOptions[], getX: (d: PointOptions, i: number) => number, getY: (d: PointOptions, i: number) => number, getPlacement?: (d: PointOptions, i: number, textWidth: number) => {
|
|
188
|
+
x: number;
|
|
189
|
+
anchor: 'start' | 'middle' | 'end';
|
|
190
|
+
} | null, defaultDy?: number): void;
|
|
183
191
|
/**
|
|
184
192
|
* Handle point selection toggle when allowPointSelect is enabled.
|
|
185
193
|
*/
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import 'd3-transition';
|
|
7
7
|
import { BaseSeries } from '../BaseSeries';
|
|
8
|
-
import type { InternalSeriesConfig } from '../../types/options';
|
|
8
|
+
import type { InternalSeriesConfig, PointOptions } from '../../types/options';
|
|
9
9
|
export declare class ColumnChart extends BaseSeries {
|
|
10
10
|
protected isHorizontal: boolean;
|
|
11
11
|
constructor(config: InternalSeriesConfig);
|
|
12
|
-
|
|
12
|
+
protected getEntryDuration(): number;
|
|
13
13
|
render(): void;
|
|
14
14
|
private renderVerticalBars;
|
|
15
15
|
private renderHorizontalBars;
|
|
@@ -28,9 +28,9 @@ export declare class ColumnChart extends BaseSeries {
|
|
|
28
28
|
baseline: number;
|
|
29
29
|
groupWidth: number;
|
|
30
30
|
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
protected getPointColor(d: PointOptions, i: number, seriesColor: string, negativeColor?: string, threshold?: number): string;
|
|
32
|
+
protected renderColumnDataLabels(data: PointOptions[], barWidth: number, barOffset: number, baseline: number, getStackedY?: (d: PointOptions) => number, getStackedBase?: (d: PointOptions) => number): void;
|
|
33
|
+
protected attachHoverEffects(bars: any, data: PointOptions[]): void;
|
|
34
34
|
}
|
|
35
35
|
export declare class BarChart extends ColumnChart {
|
|
36
36
|
protected isHorizontal: boolean;
|
|
@@ -6,6 +6,20 @@ export declare class AreaRangeChart extends BaseSeries {
|
|
|
6
6
|
/** Curve used for the band edges. Overridden by areasplinerange for smoothing. */
|
|
7
7
|
protected getCurve(): CurveFactory;
|
|
8
8
|
render(): void;
|
|
9
|
+
/**
|
|
10
|
+
* Picks a solid representative color from a gradient `color` (the first fully
|
|
11
|
+
* opaque stop, else the middle stop) so line/markers match the band instead
|
|
12
|
+
* of falling back to an unrelated palette color. Returns null for non-gradients.
|
|
13
|
+
*/
|
|
14
|
+
private gradientBaseColor;
|
|
15
|
+
private hoverHandlers?;
|
|
16
|
+
/**
|
|
17
|
+
* Shows diamond markers at the band's high and low for the hovered category,
|
|
18
|
+
* so a shared-tooltip hover highlights the range extremes (the line series
|
|
19
|
+
* draws its own marker). Driven by the `point:mouseover` event the hovered
|
|
20
|
+
* series emits, matched by x so it works in shared mode.
|
|
21
|
+
*/
|
|
22
|
+
private setupHoverMarkers;
|
|
9
23
|
/**
|
|
10
24
|
* Computes extents using low/high values for the y-axis range.
|
|
11
25
|
*/
|
|
@@ -19,6 +19,13 @@ export declare function normalizeTreegraphRows(data: TreegraphNodeDatum[]): Tree
|
|
|
19
19
|
export declare class TreegraphChart extends BaseSeries {
|
|
20
20
|
constructor(config: InternalSeriesConfig);
|
|
21
21
|
render(): void;
|
|
22
|
+
/**
|
|
23
|
+
* Assigns a color to each node top-down following the level options: explicit
|
|
24
|
+
* per-point or per-level color, `colorByPoint` cycling the palette across a
|
|
25
|
+
* level, or `colorVariation` brightening the inherited parent color across
|
|
26
|
+
* siblings. Result is stored as `__color` on each node.
|
|
27
|
+
*/
|
|
28
|
+
private assignColors;
|
|
22
29
|
private buildRoot;
|
|
23
30
|
getDataExtents(): {
|
|
24
31
|
xMin: number;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pictorial series — a stacked column whose fill is masked to a custom SVG
|
|
3
|
+
* silhouette. Each category supplies one or more path definitions; the stacked
|
|
4
|
+
* segments fill the silhouette from the baseline upward, so the shape reads as a
|
|
5
|
+
* proportional gauge. Works with `stacking: 'percent'` (fill by share of total)
|
|
6
|
+
* or `stacking: 'normal'` (fill by value against the axis range).
|
|
7
|
+
*/
|
|
8
|
+
import 'd3-transition';
|
|
9
|
+
import { ColumnChart } from '../cartesian/ColumnChart';
|
|
10
|
+
export declare class PictorialChart extends ColumnChart {
|
|
11
|
+
render(): void;
|
|
12
|
+
/**
|
|
13
|
+
* Draws the value labels centered within each stacked segment so they read on
|
|
14
|
+
* top of the filled silhouette instead of piling up at the segment edges.
|
|
15
|
+
*/
|
|
16
|
+
private renderPictorialLabels;
|
|
17
|
+
animateUpdate(): void;
|
|
18
|
+
private getPaths;
|
|
19
|
+
/** The value the silhouette's top edge maps to (100 for percent stacks, else the axis max). */
|
|
20
|
+
private getAxisTopValue;
|
|
21
|
+
/**
|
|
22
|
+
* Places a silhouette inside the column slot preserving its aspect ratio. The
|
|
23
|
+
* path is scaled to fill the full value-axis band height — so a vertical gauge
|
|
24
|
+
* uses all the available height with no top/bottom gap — and centered
|
|
25
|
+
* horizontally within the slot. The natural width that results is not clipped
|
|
26
|
+
* (pictorial opts out of the plot clip), so the shape keeps its proportions.
|
|
27
|
+
* The returned value→pixel mapper is anchored to the band, so a stacked share
|
|
28
|
+
* of X% fills X% of the shape's height.
|
|
29
|
+
*/
|
|
30
|
+
private computeSilhouette;
|
|
31
|
+
private shadowFill;
|
|
32
|
+
}
|
|
@@ -35,7 +35,36 @@ export declare class PieChart extends BaseSeries {
|
|
|
35
35
|
private dataLabelConfigs;
|
|
36
36
|
init(context: SeriesContext): void;
|
|
37
37
|
render(): void;
|
|
38
|
+
/**
|
|
39
|
+
* The colour of slice `index`: an explicit per-point colour wins, then the
|
|
40
|
+
* series palette, then the chart palette — matching the slice fill so labels,
|
|
41
|
+
* connectors and measurement all agree.
|
|
42
|
+
*/
|
|
43
|
+
private resolveSliceColor;
|
|
44
|
+
/**
|
|
45
|
+
* Resolves a point's label to its rendered text (formatter/format/fallback,
|
|
46
|
+
* HTML stripped) plus any inline `color:` declared in the markup. Shared by the
|
|
47
|
+
* sizing pre-pass and the renderer so the measured width can't drift from what
|
|
48
|
+
* is actually drawn.
|
|
49
|
+
*/
|
|
50
|
+
private resolveLabelText;
|
|
51
|
+
/**
|
|
52
|
+
* Plot space to reserve for external labels, measured from real text widths.
|
|
53
|
+
* Horizontal: the widest `distance + textWidth + connectorPadding` over each
|
|
54
|
+
* side, capped at a third of the plot width per side so a single long label
|
|
55
|
+
* can't shrink the pie to nothing. Vertical: the radial `distance + 10`, since
|
|
56
|
+
* side labels stack vertically and don't consume horizontal text room.
|
|
57
|
+
*/
|
|
58
|
+
private measureLabelMargins;
|
|
38
59
|
private renderPieLabels;
|
|
60
|
+
/**
|
|
61
|
+
* Renders a pie label on one line, or word-wraps it onto multiple lines when
|
|
62
|
+
* it exceeds the horizontal space before the plot edge — so long category
|
|
63
|
+
* names break instead of being ellipsis-truncated. Lines are vertically
|
|
64
|
+
* centered on the anchor; an over-long run is capped at three lines and the
|
|
65
|
+
* last is ellipsized.
|
|
66
|
+
*/
|
|
67
|
+
private wrapLabelLines;
|
|
39
68
|
/**
|
|
40
69
|
* Rank-based label distribution. Packs the side's labels into the available
|
|
41
70
|
* vertical span using rank-based priority (higher percentage = higher rank)
|
|
@@ -45,6 +74,8 @@ export declare class PieChart extends BaseSeries {
|
|
|
45
74
|
* regions instead of fanning every label out on a long leader line.
|
|
46
75
|
*/
|
|
47
76
|
private distribute;
|
|
77
|
+
/** Estimated wrapped line count for a label (1-3), from its width vs available space. */
|
|
78
|
+
private estimateLabelLines;
|
|
48
79
|
private distributeBoxes;
|
|
49
80
|
/**
|
|
50
81
|
* Renders pseudo-3D side effect below pie slices using the depth config.
|
package/dist/types/options.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Option types for KatuCharts.
|
|
3
3
|
*/
|
|
4
|
-
export type SeriesType = 'line' | 'spline' | 'area' | 'areaspline' | 'arearange' | 'column' | 'bar' | 'barchartrace' | 'scatter' | 'bubble' | 'pie' | 'donut' | 'heatmap' | 'treemap' | 'sunburst' | 'treegraph' | 'wordcloud' | 'sankey' | 'dependencywheel' | 'networkgraph' | 'gauge' | 'solidgauge' | 'polar' | 'radar' | 'candlestick' | 'ohlc' | 'heikinashi' | 'hollowcandlestick' | 'volume' | 'arearange' | 'baseline' | 'flags' | 'renko' | 'kagi' | 'pointandfigure' | 'linebreak' | 'waterfall' | 'boxplot' | 'funnel' | 'pyramid' | 'timeline' | 'gantt' | 'map' | 'mappoint' | 'flowmap' | 'venn' | 'volcano' | 'manhattan' | 'violin' | 'kaplanmeier' | 'forestplot' | 'sequencelogo' | 'clusteredheatmap' | 'phylotree' | 'circos' | 'circosHeatmap' | 'circosComparative' | 'circosSpiral' | 'item' | 'classroom' | 'pcoa';
|
|
4
|
+
export type SeriesType = 'line' | 'spline' | 'area' | 'areaspline' | 'arearange' | 'column' | 'bar' | 'barchartrace' | 'scatter' | 'bubble' | 'pie' | 'donut' | 'heatmap' | 'treemap' | 'sunburst' | 'treegraph' | 'wordcloud' | 'sankey' | 'dependencywheel' | 'networkgraph' | 'gauge' | 'solidgauge' | 'polar' | 'radar' | 'candlestick' | 'ohlc' | 'heikinashi' | 'hollowcandlestick' | 'volume' | 'arearange' | 'baseline' | 'flags' | 'renko' | 'kagi' | 'pointandfigure' | 'linebreak' | 'waterfall' | 'boxplot' | 'pictorial' | 'funnel' | 'pyramid' | 'timeline' | 'gantt' | 'map' | 'mappoint' | 'flowmap' | 'venn' | 'volcano' | 'manhattan' | 'violin' | 'kaplanmeier' | 'forestplot' | 'sequencelogo' | 'clusteredheatmap' | 'phylotree' | 'circos' | 'circosHeatmap' | 'circosComparative' | 'circosSpiral' | 'item' | 'classroom' | 'pcoa';
|
|
5
5
|
export type CursorType = 'pointer' | 'default' | 'crosshair' | 'move' | 'help' | 'text' | 'not-allowed';
|
|
6
6
|
export type DashStyleType = 'Solid' | 'ShortDash' | 'ShortDot' | 'ShortDashDot' | 'ShortDashDotDot' | 'Dot' | 'Dash' | 'LongDash' | 'DashDot' | 'LongDashDot' | 'LongDashDotDot';
|
|
7
7
|
export type AlignType = 'left' | 'center' | 'right';
|
|
@@ -113,6 +113,9 @@ export interface TitleOptions {
|
|
|
113
113
|
}
|
|
114
114
|
export interface SubtitleOptions extends TitleOptions {
|
|
115
115
|
}
|
|
116
|
+
/** Source/footnote text rendered in a band at the bottom of the chart. */
|
|
117
|
+
export interface CaptionOptions extends TitleOptions {
|
|
118
|
+
}
|
|
116
119
|
export interface AxisLabelOptions {
|
|
117
120
|
enabled?: boolean;
|
|
118
121
|
format?: string;
|
|
@@ -644,6 +647,10 @@ export interface SeriesOptions {
|
|
|
644
647
|
borderWidth?: number;
|
|
645
648
|
borderColor?: string;
|
|
646
649
|
borderRadius?: number | BorderRadiusOptions;
|
|
650
|
+
/** Silhouette path definitions for the pictorial series, indexed (and cycled) by point. */
|
|
651
|
+
paths?: {
|
|
652
|
+
definition: string;
|
|
653
|
+
}[];
|
|
647
654
|
colorByPoint?: boolean;
|
|
648
655
|
colors?: string[];
|
|
649
656
|
innerSize?: string | number;
|
|
@@ -1272,6 +1279,7 @@ export interface KatuChartsOptions {
|
|
|
1272
1279
|
chart?: ChartOptions;
|
|
1273
1280
|
title?: TitleOptions;
|
|
1274
1281
|
subtitle?: SubtitleOptions;
|
|
1282
|
+
caption?: CaptionOptions;
|
|
1275
1283
|
xAxis?: AxisOptions | AxisOptions[];
|
|
1276
1284
|
yAxis?: AxisOptions | AxisOptions[];
|
|
1277
1285
|
colorAxis?: ColorAxisOptions | ColorAxisOptions[];
|
|
@@ -1331,6 +1339,7 @@ export interface InternalConfig {
|
|
|
1331
1339
|
chart: Required<Pick<ChartOptions, 'width' | 'height' | 'backgroundColor' | 'animation' | 'reflow'>> & ChartOptions;
|
|
1332
1340
|
title: TitleOptions;
|
|
1333
1341
|
subtitle: SubtitleOptions;
|
|
1342
|
+
caption?: CaptionOptions;
|
|
1334
1343
|
xAxis: InternalAxisConfig[];
|
|
1335
1344
|
yAxis: InternalAxisConfig[];
|
|
1336
1345
|
colorAxis: ColorAxisOptions[];
|