@tranding-custom-chart/react 0.0.0-stage → 2.1.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.
Files changed (116) hide show
  1. package/README.md +351 -2
  2. package/dist/AccessibleChartTable.d.ts +12 -0
  3. package/dist/AccessibleChartTable.d.ts.map +1 -0
  4. package/dist/AccessibleChartTable.js +19 -0
  5. package/dist/BaselineSeries.d.ts +13 -0
  6. package/dist/BaselineSeries.d.ts.map +1 -0
  7. package/dist/BaselineSeries.js +32 -0
  8. package/dist/BoxPlotSeries.d.ts +11 -0
  9. package/dist/BoxPlotSeries.d.ts.map +1 -0
  10. package/dist/BoxPlotSeries.js +37 -0
  11. package/dist/BubbleSeries.d.ts +11 -0
  12. package/dist/BubbleSeries.d.ts.map +1 -0
  13. package/dist/BubbleSeries.js +37 -0
  14. package/dist/CandlestickSeries.d.ts +13 -0
  15. package/dist/CandlestickSeries.d.ts.map +1 -0
  16. package/dist/CandlestickSeries.js +54 -0
  17. package/dist/ChartContainer.d.ts +73 -0
  18. package/dist/ChartContainer.d.ts.map +1 -0
  19. package/dist/ChartContainer.js +631 -0
  20. package/dist/ChartContext.d.ts +36 -0
  21. package/dist/ChartContext.d.ts.map +1 -0
  22. package/dist/ChartContext.js +13 -0
  23. package/dist/ChartSyncGroup.d.ts +14 -0
  24. package/dist/ChartSyncGroup.d.ts.map +1 -0
  25. package/dist/ChartSyncGroup.js +18 -0
  26. package/dist/ColumnsSeries.d.ts +13 -0
  27. package/dist/ColumnsSeries.d.ts.map +1 -0
  28. package/dist/ColumnsSeries.js +54 -0
  29. package/dist/CrosshairOverlay.d.ts +10 -0
  30. package/dist/CrosshairOverlay.d.ts.map +1 -0
  31. package/dist/CrosshairOverlay.js +65 -0
  32. package/dist/DrawingOverlay.d.ts +16 -0
  33. package/dist/DrawingOverlay.d.ts.map +1 -0
  34. package/dist/DrawingOverlay.js +50 -0
  35. package/dist/GridAxes.d.ts +19 -0
  36. package/dist/GridAxes.d.ts.map +1 -0
  37. package/dist/GridAxes.js +50 -0
  38. package/dist/HeatmapSeries.d.ts +11 -0
  39. package/dist/HeatmapSeries.d.ts.map +1 -0
  40. package/dist/HeatmapSeries.js +74 -0
  41. package/dist/HighLowSeries.d.ts +12 -0
  42. package/dist/HighLowSeries.d.ts.map +1 -0
  43. package/dist/HighLowSeries.js +29 -0
  44. package/dist/HlcAreaSeries.d.ts +13 -0
  45. package/dist/HlcAreaSeries.d.ts.map +1 -0
  46. package/dist/HlcAreaSeries.js +28 -0
  47. package/dist/HollowCandlestickSeries.d.ts +13 -0
  48. package/dist/HollowCandlestickSeries.d.ts.map +1 -0
  49. package/dist/HollowCandlestickSeries.js +30 -0
  50. package/dist/HorizontalBarSeries.d.ts +15 -0
  51. package/dist/HorizontalBarSeries.d.ts.map +1 -0
  52. package/dist/HorizontalBarSeries.js +42 -0
  53. package/dist/InteractiveLegend.d.ts +19 -0
  54. package/dist/InteractiveLegend.d.ts.map +1 -0
  55. package/dist/InteractiveLegend.js +39 -0
  56. package/dist/LastPriceLine.d.ts +11 -0
  57. package/dist/LastPriceLine.d.ts.map +1 -0
  58. package/dist/LastPriceLine.js +29 -0
  59. package/dist/LineSeries.d.ts +20 -0
  60. package/dist/LineSeries.d.ts.map +1 -0
  61. package/dist/LineSeries.js +74 -0
  62. package/dist/LineWithMarkersSeries.d.ts +13 -0
  63. package/dist/LineWithMarkersSeries.d.ts.map +1 -0
  64. package/dist/LineWithMarkersSeries.js +30 -0
  65. package/dist/MixedChartSeries.d.ts +14 -0
  66. package/dist/MixedChartSeries.d.ts.map +1 -0
  67. package/dist/MixedChartSeries.js +30 -0
  68. package/dist/OhlcBarSeries.d.ts +14 -0
  69. package/dist/OhlcBarSeries.d.ts.map +1 -0
  70. package/dist/OhlcBarSeries.js +31 -0
  71. package/dist/PieSeries.d.ts +18 -0
  72. package/dist/PieSeries.d.ts.map +1 -0
  73. package/dist/PieSeries.js +85 -0
  74. package/dist/PluginLayer.d.ts +11 -0
  75. package/dist/PluginLayer.d.ts.map +1 -0
  76. package/dist/PluginLayer.js +14 -0
  77. package/dist/PolarAreaSeries.d.ts +11 -0
  78. package/dist/PolarAreaSeries.d.ts.map +1 -0
  79. package/dist/PolarAreaSeries.js +35 -0
  80. package/dist/RadarSeries.d.ts +16 -0
  81. package/dist/RadarSeries.d.ts.map +1 -0
  82. package/dist/RadarSeries.js +47 -0
  83. package/dist/ScatterSeries.d.ts +11 -0
  84. package/dist/ScatterSeries.d.ts.map +1 -0
  85. package/dist/ScatterSeries.js +60 -0
  86. package/dist/SeriesMarkersOverlay.d.ts +10 -0
  87. package/dist/SeriesMarkersOverlay.d.ts.map +1 -0
  88. package/dist/SeriesMarkersOverlay.js +28 -0
  89. package/dist/StackedBarSeries.d.ts +13 -0
  90. package/dist/StackedBarSeries.d.ts.map +1 -0
  91. package/dist/StackedBarSeries.js +26 -0
  92. package/dist/StepLineSeries.d.ts +15 -0
  93. package/dist/StepLineSeries.d.ts.map +1 -0
  94. package/dist/StepLineSeries.js +28 -0
  95. package/dist/SupertrendSeries.d.ts +16 -0
  96. package/dist/SupertrendSeries.d.ts.map +1 -0
  97. package/dist/SupertrendSeries.js +40 -0
  98. package/dist/UniversalSeries.d.ts +21 -0
  99. package/dist/UniversalSeries.d.ts.map +1 -0
  100. package/dist/UniversalSeries.js +222 -0
  101. package/dist/VolumeProfileSeries.d.ts +21 -0
  102. package/dist/VolumeProfileSeries.d.ts.map +1 -0
  103. package/dist/VolumeProfileSeries.js +57 -0
  104. package/dist/VolumeSeries.d.ts +14 -0
  105. package/dist/VolumeSeries.d.ts.map +1 -0
  106. package/dist/VolumeSeries.js +33 -0
  107. package/dist/WatermarkOverlay.d.ts +11 -0
  108. package/dist/WatermarkOverlay.d.ts.map +1 -0
  109. package/dist/WatermarkOverlay.js +27 -0
  110. package/dist/index.d.ts +42 -0
  111. package/dist/index.d.ts.map +1 -0
  112. package/dist/index.js +41 -0
  113. package/dist/useChart.d.ts +16 -0
  114. package/dist/useChart.d.ts.map +1 -0
  115. package/dist/useChart.js +34 -0
  116. package/package.json +93 -4
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @file packages/chart-react/src/InteractiveLegend.tsx
3
+ * Interactive Legend component supporting dataset visibility toggling.
4
+ */
5
+ import React from 'react';
6
+ export interface LegendItem {
7
+ readonly id: string;
8
+ readonly label: string;
9
+ readonly color: string;
10
+ readonly type?: 'line' | 'rect' | 'circle' | undefined;
11
+ }
12
+ export interface InteractiveLegendProps {
13
+ readonly items: readonly LegendItem[];
14
+ readonly activeIds: ReadonlySet<string>;
15
+ readonly onToggle: (id: string) => void;
16
+ readonly className?: string | undefined;
17
+ }
18
+ export declare function InteractiveLegend({ items, activeIds, onToggle, className, }: InteractiveLegendProps): React.JSX.Element;
19
+ //# sourceMappingURL=InteractiveLegend.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InteractiveLegend.d.ts","sourceRoot":"","sources":["../src/InteractiveLegend.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAC;CACxD;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,KAAK,EAAE,SAAS,UAAU,EAAE,CAAC;IACtC,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACxC,QAAQ,CAAC,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACzC;AAED,wBAAgB,iBAAiB,CAAC,EAChC,KAAK,EACL,SAAS,EACT,QAAQ,EACR,SAAc,GACf,EAAE,sBAAsB,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAuD5C"}
@@ -0,0 +1,39 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /**
3
+ * @file packages/chart-react/src/InteractiveLegend.tsx
4
+ * Interactive Legend component supporting dataset visibility toggling.
5
+ */
6
+ import React from 'react';
7
+ export function InteractiveLegend({ items, activeIds, onToggle, className = '', }) {
8
+ return (_jsx("div", { role: "toolbar", "aria-label": "Chart dataset toggles", className: `interactive-legend ${className}`, style: {
9
+ display: 'flex',
10
+ flexWrap: 'wrap',
11
+ gap: '0.75rem',
12
+ alignItems: 'center',
13
+ padding: '0.4rem 0',
14
+ }, children: items.map((item) => {
15
+ const isActive = activeIds.has(item.id);
16
+ return (_jsxs("button", { type: "button", role: "checkbox", "aria-checked": isActive, onClick: () => onToggle(item.id), style: {
17
+ display: 'inline-flex',
18
+ alignItems: 'center',
19
+ gap: '0.5rem',
20
+ padding: '0.25rem 0.6rem',
21
+ background: isActive ? 'rgba(255, 255, 255, 0.06)' : 'transparent',
22
+ border: `1px solid ${isActive ? item.color : 'rgba(255, 255, 255, 0.15)'}`,
23
+ borderRadius: '9999px',
24
+ color: isActive ? '#e8ebe6' : '#858e89',
25
+ fontSize: '0.8rem',
26
+ fontWeight: 500,
27
+ cursor: 'pointer',
28
+ transition: 'all 0.15s ease',
29
+ textDecoration: isActive ? 'none' : 'line-through',
30
+ opacity: isActive ? 1 : 0.6,
31
+ }, children: [_jsx("span", { style: {
32
+ display: 'inline-block',
33
+ width: '10px',
34
+ height: '10px',
35
+ borderRadius: item.type === 'line' ? '1px' : '50%',
36
+ background: isActive ? item.color : '#858e89',
37
+ } }), item.label] }, item.id));
38
+ }) }));
39
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @file packages/chart-react/src/LastPriceLine.tsx
3
+ * Declarative real-time last price line and dynamic Y-axis badge component.
4
+ */
5
+ export interface LastPriceLineProps {
6
+ readonly price: number;
7
+ readonly color?: string | undefined;
8
+ readonly formatter?: ((price: number) => string) | undefined;
9
+ }
10
+ export declare function LastPriceLine({ price, color, formatter, }: LastPriceLineProps): null;
11
+ //# sourceMappingURL=LastPriceLine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LastPriceLine.d.ts","sourceRoot":"","sources":["../src/LastPriceLine.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC,GAAG,SAAS,CAAC;CAC9D;AAED,wBAAgB,aAAa,CAAC,EAC5B,KAAK,EACL,KAAK,EACL,SAAS,GACV,EAAE,kBAAkB,GAAG,IAAI,CAwB3B"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * @file packages/chart-react/src/LastPriceLine.tsx
3
+ * Declarative real-time last price line and dynamic Y-axis badge component.
4
+ */
5
+ import React, { useEffect, useId } from 'react';
6
+ import { renderLastPriceLine } from '@tranding-custom-chart/renderer-canvas';
7
+ import { useChartContext } from './ChartContext.js';
8
+ export function LastPriceLine({ price, color, formatter, }) {
9
+ const { registerOverlayLayer, yScale, bounds, padding } = useChartContext();
10
+ const id = useId();
11
+ useEffect(() => {
12
+ if (!yScale || !Number.isFinite(price))
13
+ return;
14
+ const unregister = registerOverlayLayer(id, (ctx, _bounds, _padding, dpr) => {
15
+ renderLastPriceLine({
16
+ ctx,
17
+ lastPrice: price,
18
+ yScale,
19
+ bounds,
20
+ padding,
21
+ dpr,
22
+ color,
23
+ formatter,
24
+ });
25
+ });
26
+ return unregister;
27
+ }, [registerOverlayLayer, id, price, yScale, bounds, padding, color, formatter]);
28
+ return null;
29
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * @file packages/chart-react/src/LineSeries.tsx
3
+ * Declarative Line and Area series component.
4
+ */
5
+ import type { CurveInterpolation } from '@tranding-custom-chart/core';
6
+ export interface LineSeriesProps {
7
+ readonly data: readonly (number | null | undefined)[];
8
+ readonly color?: string | undefined;
9
+ readonly strokeWidth?: number | undefined;
10
+ readonly lineDash?: readonly number[] | undefined;
11
+ readonly curve?: CurveInterpolation | undefined;
12
+ readonly tension?: number | undefined;
13
+ readonly areaFill?: {
14
+ readonly gradientTopColor: string;
15
+ readonly gradientBottomColor: string;
16
+ readonly baselineY: number;
17
+ } | undefined;
18
+ }
19
+ export declare function LineSeries({ data, color, strokeWidth, lineDash, curve, tension, areaFill, }: LineSeriesProps): null;
20
+ //# sourceMappingURL=LineSeries.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LineSeries.d.ts","sourceRoot":"","sources":["../src/LineSeries.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,kBAAkB,EAAS,MAAM,6BAA6B,CAAC;AAG7E,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,CAAC;IACtD,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1C,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;IAClD,QAAQ,CAAC,KAAK,CAAC,EAAE,kBAAkB,GAAG,SAAS,CAAC;IAChD,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,QAAQ,CAAC,QAAQ,CAAC,EAAE;QAClB,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;QAClC,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC;QACrC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;KAC5B,GAAG,SAAS,CAAC;CACf;AAED,wBAAgB,UAAU,CAAC,EACzB,IAAI,EACJ,KAAiB,EACjB,WAAe,EACf,QAAQ,EACR,KAAgB,EAChB,OAAa,EACb,QAAQ,GACT,EAAE,eAAe,GAAG,IAAI,CAsExB"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * @file packages/chart-react/src/LineSeries.tsx
3
+ * Declarative Line and Area series component.
4
+ */
5
+ import React, { useEffect, useId } from 'react';
6
+ import { renderLineSeries, renderCurvedLine } from '@tranding-custom-chart/renderer-canvas';
7
+ import { useChartContext } from './ChartContext.js';
8
+ export function LineSeries({ data, color = '#155c45', strokeWidth = 2, lineDash, curve = 'linear', tension = 0.8, areaFill, }) {
9
+ const { registerDataLayer, registerHitTest, xScale, yScale } = useChartContext();
10
+ const id = useId();
11
+ useEffect(() => {
12
+ if (!xScale || !yScale || data.length === 0)
13
+ return;
14
+ const unregisterHit = registerHitTest(id, (x, y) => {
15
+ const idx = Math.round(xScale.invert(x));
16
+ if (idx >= 0 && idx < data.length) {
17
+ const val = data[idx];
18
+ if (val !== null && val !== undefined && Number.isFinite(val)) {
19
+ const px = xScale.scale(idx);
20
+ const py = yScale.scale(val);
21
+ if (Math.abs(x - px) <= 15 && Math.abs(y - py) <= 30) {
22
+ return {
23
+ elementType: 'dataPoint',
24
+ seriesId: id,
25
+ dataIndex: idx,
26
+ pointId: idx,
27
+ label: String(val),
28
+ };
29
+ }
30
+ }
31
+ }
32
+ return null;
33
+ });
34
+ return unregisterHit;
35
+ }, [registerHitTest, id, data, xScale, yScale]);
36
+ useEffect(() => {
37
+ if (!xScale || !yScale || data.length === 0)
38
+ return;
39
+ const unregister = registerDataLayer(id, (ctx) => {
40
+ if (curve === 'bezier') {
41
+ const validPoints = [];
42
+ for (let i = 0; i < data.length; i++) {
43
+ const val = data[i];
44
+ if (val !== null && val !== undefined && Number.isFinite(val)) {
45
+ validPoints.push({
46
+ x: xScale.scale(i),
47
+ y: yScale.scale(val),
48
+ });
49
+ }
50
+ }
51
+ renderCurvedLine(ctx, validPoints, {
52
+ strokeColor: color,
53
+ strokeWidth,
54
+ tension,
55
+ areaFill,
56
+ });
57
+ }
58
+ else {
59
+ renderLineSeries({
60
+ ctx,
61
+ points: data,
62
+ xScale,
63
+ yScale,
64
+ color,
65
+ strokeWidth,
66
+ lineDash,
67
+ areaFill,
68
+ });
69
+ }
70
+ });
71
+ return unregister;
72
+ }, [registerDataLayer, id, data, xScale, yScale, color, strokeWidth, lineDash, curve, tension, areaFill]);
73
+ return null;
74
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @file packages/chart-react/src/LineWithMarkersSeries.tsx
3
+ * Declarative Line with Markers series component.
4
+ */
5
+ export interface LineWithMarkersSeriesProps {
6
+ readonly data: readonly number[];
7
+ readonly color?: string | undefined;
8
+ readonly strokeWidth?: number | undefined;
9
+ readonly markerRadius?: number | undefined;
10
+ readonly markerFillColor?: string | undefined;
11
+ }
12
+ export declare function LineWithMarkersSeries({ data, color, strokeWidth, markerRadius, markerFillColor, }: LineWithMarkersSeriesProps): null;
13
+ //# sourceMappingURL=LineWithMarkersSeries.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LineWithMarkersSeries.d.ts","sourceRoot":"","sources":["../src/LineWithMarkersSeries.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1C,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3C,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/C;AAED,wBAAgB,qBAAqB,CAAC,EACpC,IAAI,EACJ,KAAiB,EACjB,WAAe,EACf,YAAgB,EAChB,eAA2B,GAC5B,EAAE,0BAA0B,GAAG,IAAI,CAyBnC"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @file packages/chart-react/src/LineWithMarkersSeries.tsx
3
+ * Declarative Line with Markers series component.
4
+ */
5
+ import React, { useEffect, useId } from 'react';
6
+ import { renderLineWithMarkers } from '@tranding-custom-chart/renderer-canvas';
7
+ import { useChartContext } from './ChartContext.js';
8
+ export function LineWithMarkersSeries({ data, color = '#2563eb', strokeWidth = 2, markerRadius = 3, markerFillColor = '#ffffff', }) {
9
+ const { registerDataLayer, xScale, yScale } = useChartContext();
10
+ const id = useId();
11
+ useEffect(() => {
12
+ if (!xScale || !yScale || data.length === 0)
13
+ return;
14
+ const unregister = registerDataLayer(id, (ctx) => {
15
+ renderLineWithMarkers({
16
+ ctx,
17
+ points: data,
18
+ xScale,
19
+ yScale,
20
+ color,
21
+ strokeWidth,
22
+ markerRadius,
23
+ markerFillColor,
24
+ markerStrokeColor: color,
25
+ });
26
+ });
27
+ return unregister;
28
+ }, [registerDataLayer, id, data, xScale, yScale, color, strokeWidth, markerRadius, markerFillColor]);
29
+ return null;
30
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @file packages/chart-react/src/MixedChartSeries.tsx
3
+ * Declarative component for heterogeneous mixed datasets (Bar + Line + Spline + Area).
4
+ * Coordinated multi-dataset rendering with dual-axis scale synchronization.
5
+ */
6
+ import type { MixedDataset, Scale } from '@tranding-custom-chart/core';
7
+ export interface MixedChartSeriesProps {
8
+ /** Array of heterogeneous datasets (bars, lines, splines, areas, scatter) */
9
+ readonly datasets: readonly MixedDataset[];
10
+ /** Optional secondary Y-Scale for datasets assigned to yAxisPosition="right" */
11
+ readonly secondaryYScale?: Scale<number> | undefined;
12
+ }
13
+ export declare function MixedChartSeries({ datasets, secondaryYScale, }: MixedChartSeriesProps): null;
14
+ //# sourceMappingURL=MixedChartSeries.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MixedChartSeries.d.ts","sourceRoot":"","sources":["../src/MixedChartSeries.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAIvE,MAAM,WAAW,qBAAqB;IACpC,6EAA6E;IAC7E,QAAQ,CAAC,QAAQ,EAAE,SAAS,YAAY,EAAE,CAAC;IAC3C,gFAAgF;IAChF,QAAQ,CAAC,eAAe,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;CACtD;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,QAAQ,EACR,eAAe,GAChB,EAAE,qBAAqB,GAAG,IAAI,CAwB9B"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @file packages/chart-react/src/MixedChartSeries.tsx
3
+ * Declarative component for heterogeneous mixed datasets (Bar + Line + Spline + Area).
4
+ * Coordinated multi-dataset rendering with dual-axis scale synchronization.
5
+ */
6
+ import React, { useEffect, useId } from 'react';
7
+ import { renderMixedDatasets } from '@tranding-custom-chart/renderer-canvas';
8
+ import { useChartContext } from './ChartContext.js';
9
+ export function MixedChartSeries({ datasets, secondaryYScale, }) {
10
+ const { registerDataLayer, xScale, yScale } = useChartContext();
11
+ const id = useId();
12
+ useEffect(() => {
13
+ if (!xScale || !yScale)
14
+ return;
15
+ const unregister = registerDataLayer(id, (ctx, bounds, padding, dpr) => {
16
+ renderMixedDatasets({
17
+ ctx,
18
+ bounds,
19
+ padding,
20
+ xScale,
21
+ yScale,
22
+ secondaryYScale,
23
+ datasets,
24
+ dpr,
25
+ });
26
+ });
27
+ return unregister;
28
+ }, [registerDataLayer, id, xScale, yScale, secondaryYScale, datasets]);
29
+ return null;
30
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @file packages/chart-react/src/OhlcBarSeries.tsx
3
+ * Declarative American OHLC Bar series component.
4
+ */
5
+ import type { OHLCVBar } from '@tranding-custom-chart/core';
6
+ export interface OhlcBarSeriesProps {
7
+ readonly data: readonly OHLCVBar[];
8
+ readonly upColor?: string | undefined;
9
+ readonly downColor?: string | undefined;
10
+ readonly tickWidthRatio?: number | undefined;
11
+ readonly lineWidth?: number | undefined;
12
+ }
13
+ export declare function OhlcBarSeries({ data, upColor, downColor, tickWidthRatio, lineWidth, }: OhlcBarSeriesProps): null;
14
+ //# sourceMappingURL=OhlcBarSeries.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OhlcBarSeries.d.ts","sourceRoot":"","sources":["../src/OhlcBarSeries.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAI5D,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,IAAI,EAAE,SAAS,QAAQ,EAAE,CAAC;IACnC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7C,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACzC;AAED,wBAAgB,aAAa,CAAC,EAC5B,IAAI,EACJ,OAAO,EACP,SAAS,EACT,cAAqB,EACrB,SAAe,GAChB,EAAE,kBAAkB,GAAG,IAAI,CA0B3B"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @file packages/chart-react/src/OhlcBarSeries.tsx
3
+ * Declarative American OHLC Bar series component.
4
+ */
5
+ import React, { useEffect, useId } from 'react';
6
+ import { renderOhlcBars } from '@tranding-custom-chart/renderer-canvas';
7
+ import { useChartContext } from './ChartContext.js';
8
+ export function OhlcBarSeries({ data, upColor, downColor, tickWidthRatio = 0.35, lineWidth = 1.2, }) {
9
+ const { registerDataLayer, xScale, yScale, theme } = useChartContext();
10
+ const id = useId();
11
+ useEffect(() => {
12
+ if (!xScale || !yScale || data.length === 0)
13
+ return;
14
+ const unregister = registerDataLayer(id, (ctx, bounds, padding, dpr) => {
15
+ renderOhlcBars({
16
+ ctx,
17
+ bars: data,
18
+ xScale,
19
+ yScale,
20
+ theme,
21
+ dpr,
22
+ tickWidthRatio,
23
+ customUpColor: upColor,
24
+ customDownColor: downColor,
25
+ lineWidth,
26
+ });
27
+ });
28
+ return unregister;
29
+ }, [registerDataLayer, id, data, xScale, yScale, theme, upColor, downColor, tickWidthRatio, lineWidth]);
30
+ return null;
31
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @file packages/chart-react/src/PieSeries.tsx
3
+ * Declarative Pie and Doughnut series component.
4
+ */
5
+ import type { PieSlice } from '@tranding-custom-chart/core';
6
+ import { type PieCenterText } from '@tranding-custom-chart/renderer-canvas';
7
+ export interface PieSeriesProps {
8
+ readonly slices: readonly PieSlice[];
9
+ readonly radius?: number | undefined;
10
+ readonly innerRadius?: number | undefined;
11
+ readonly hoverIndex?: number | null | undefined;
12
+ readonly hoverExplodeDistance?: number | undefined;
13
+ readonly borderColor?: string | undefined;
14
+ readonly borderWidth?: number | undefined;
15
+ readonly centerText?: PieCenterText | undefined;
16
+ }
17
+ export declare function PieSeries({ slices, radius, innerRadius, hoverIndex, hoverExplodeDistance, borderColor, borderWidth, centerText, }: PieSeriesProps): null;
18
+ //# sourceMappingURL=PieSeries.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PieSeries.d.ts","sourceRoot":"","sources":["../src/PieSeries.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAa,KAAK,aAAa,EAAE,MAAM,wCAAwC,CAAC;AAGvF,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,MAAM,EAAE,SAAS,QAAQ,EAAE,CAAC;IACrC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1C,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAChD,QAAQ,CAAC,oBAAoB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACnD,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1C,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1C,QAAQ,CAAC,UAAU,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;CACjD;AAED,wBAAgB,SAAS,CAAC,EACxB,MAAM,EACN,MAAM,EACN,WAAe,EACf,UAAiB,EACjB,oBAAwB,EACxB,WAAW,EACX,WAAe,EACf,UAAU,GACX,EAAE,cAAc,GAAG,IAAI,CAqFvB"}
@@ -0,0 +1,85 @@
1
+ /**
2
+ * @file packages/chart-react/src/PieSeries.tsx
3
+ * Declarative Pie and Doughnut series component.
4
+ */
5
+ import React, { useEffect, useId } from 'react';
6
+ import { renderPie } from '@tranding-custom-chart/renderer-canvas';
7
+ import { useChartContext } from './ChartContext.js';
8
+ export function PieSeries({ slices, radius, innerRadius = 0, hoverIndex = null, hoverExplodeDistance = 6, borderColor, borderWidth = 2, centerText, }) {
9
+ const { registerDataLayer, registerHitTest, bounds } = useChartContext();
10
+ const id = useId();
11
+ useEffect(() => {
12
+ if (slices.length === 0)
13
+ return;
14
+ const unregisterHit = registerHitTest(id, (x, y) => {
15
+ const cx = bounds.width / 2;
16
+ const cy = bounds.height / 2;
17
+ const maxRadius = Math.min(cx, cy) - 20;
18
+ const actualRadius = radius ?? Math.max(10, maxRadius);
19
+ const dx = x - cx;
20
+ const dy = y - cy;
21
+ const dist = Math.hypot(dx, dy);
22
+ if (dist >= innerRadius && dist <= actualRadius) {
23
+ let angle = Math.atan2(dy, dx);
24
+ if (angle < 0)
25
+ angle += 2 * Math.PI;
26
+ const total = slices.reduce((acc, s) => acc + s.value, 0);
27
+ if (total <= 0)
28
+ return null;
29
+ let currentAngle = 0;
30
+ for (let i = 0; i < slices.length; i++) {
31
+ const slice = slices[i];
32
+ const sliceAngle = (slice.value / total) * 2 * Math.PI;
33
+ if (angle >= currentAngle && angle <= currentAngle + sliceAngle) {
34
+ return {
35
+ elementType: 'slice',
36
+ seriesId: id,
37
+ elementId: slice.id,
38
+ dataIndex: i,
39
+ label: slice.label,
40
+ };
41
+ }
42
+ currentAngle += sliceAngle;
43
+ }
44
+ }
45
+ return null;
46
+ });
47
+ return unregisterHit;
48
+ }, [registerHitTest, id, slices, bounds, radius, innerRadius]);
49
+ useEffect(() => {
50
+ if (slices.length === 0)
51
+ return;
52
+ const unregister = registerDataLayer(id, (ctx) => {
53
+ const cx = bounds.width / 2;
54
+ const cy = bounds.height / 2;
55
+ const maxRadius = Math.min(cx, cy) - 20;
56
+ const actualRadius = radius ?? Math.max(10, maxRadius);
57
+ renderPie(ctx, slices, {
58
+ cx,
59
+ cy,
60
+ radius: actualRadius,
61
+ innerRadius,
62
+ hoverIndex,
63
+ hoverExplodeDistance,
64
+ borderColor: borderColor ?? ctx.canvas?.style?.backgroundColor ?? '#181b19',
65
+ borderWidth,
66
+ centerText,
67
+ });
68
+ });
69
+ return unregister;
70
+ }, [
71
+ registerDataLayer,
72
+ id,
73
+ slices,
74
+ bounds.width,
75
+ bounds.height,
76
+ radius,
77
+ innerRadius,
78
+ hoverIndex,
79
+ hoverExplodeDistance,
80
+ borderColor,
81
+ borderWidth,
82
+ centerText,
83
+ ]);
84
+ return null;
85
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @file packages/chart-react/src/PluginLayer.tsx
3
+ * Declarative component for registering a custom ChartPlugin inside <ChartContainer>.
4
+ */
5
+ import type { ChartPlugin } from '@tranding-custom-chart/core';
6
+ export interface PluginLayerProps<O = Record<string, unknown>> {
7
+ readonly plugin: ChartPlugin<O>;
8
+ readonly options?: O | undefined;
9
+ }
10
+ export declare function PluginLayer<O>({ plugin, options }: PluginLayerProps<O>): null;
11
+ //# sourceMappingURL=PluginLayer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PluginLayer.d.ts","sourceRoot":"","sources":["../src/PluginLayer.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAG/D,MAAM,WAAW,gBAAgB,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC3D,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;IAChC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC;CAClC;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,IAAI,CAS7E"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @file packages/chart-react/src/PluginLayer.tsx
3
+ * Declarative component for registering a custom ChartPlugin inside <ChartContainer>.
4
+ */
5
+ import React, { useEffect } from 'react';
6
+ import { useChartContext } from './ChartContext.js';
7
+ export function PluginLayer({ plugin, options }) {
8
+ const { registerPlugin } = useChartContext();
9
+ useEffect(() => {
10
+ const unregister = registerPlugin(plugin, options);
11
+ return unregister;
12
+ }, [registerPlugin, plugin, options]);
13
+ return null;
14
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @file packages/chart-react/src/PolarAreaSeries.tsx
3
+ * Declarative Polar Area Chart series component.
4
+ */
5
+ import type { PolarAreaDatum } from '@tranding-custom-chart/core';
6
+ import { type PolarAreaRenderOptions } from '@tranding-custom-chart/renderer-canvas';
7
+ export interface PolarAreaSeriesProps extends PolarAreaRenderOptions {
8
+ readonly data: readonly PolarAreaDatum[];
9
+ }
10
+ export declare function PolarAreaSeries({ data, startAngle, strokeColor, strokeWidth, showLabels, }: PolarAreaSeriesProps): null;
11
+ //# sourceMappingURL=PolarAreaSeries.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PolarAreaSeries.d.ts","sourceRoot":"","sources":["../src/PolarAreaSeries.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAmB,KAAK,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;AAGtG,MAAM,WAAW,oBAAqB,SAAQ,sBAAsB;IAClE,QAAQ,CAAC,IAAI,EAAE,SAAS,cAAc,EAAE,CAAC;CAC1C;AAED,wBAAgB,eAAe,CAAC,EAC9B,IAAI,EACJ,UAAyB,EACzB,WAAwC,EACxC,WAAe,EACf,UAAiB,GAClB,EAAE,oBAAoB,GAAG,IAAI,CA8B7B"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * @file packages/chart-react/src/PolarAreaSeries.tsx
3
+ * Declarative Polar Area Chart series component.
4
+ */
5
+ import React, { useEffect, useId } from 'react';
6
+ import { renderPolarArea } from '@tranding-custom-chart/renderer-canvas';
7
+ import { useChartContext } from './ChartContext.js';
8
+ export function PolarAreaSeries({ data, startAngle = -Math.PI / 2, strokeColor = 'rgba(255, 255, 255, 0.4)', strokeWidth = 1, showLabels = true, }) {
9
+ const { registerDataLayer, bounds, padding } = useChartContext();
10
+ const id = useId();
11
+ useEffect(() => {
12
+ if (!data || data.length === 0)
13
+ return;
14
+ const unregister = registerDataLayer(id, (ctx) => {
15
+ renderPolarArea(ctx, data, bounds, padding, {
16
+ startAngle,
17
+ strokeColor,
18
+ strokeWidth,
19
+ showLabels,
20
+ });
21
+ });
22
+ return unregister;
23
+ }, [
24
+ registerDataLayer,
25
+ id,
26
+ data,
27
+ bounds,
28
+ padding,
29
+ startAngle,
30
+ strokeColor,
31
+ strokeWidth,
32
+ showLabels,
33
+ ]);
34
+ return null;
35
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @file packages/chart-react/src/RadarSeries.tsx
3
+ * Declarative Radar / Spider series component.
4
+ */
5
+ import type { RadarAxis, RadarDataset } from '@tranding-custom-chart/core';
6
+ export interface RadarSeriesProps {
7
+ readonly axes: readonly RadarAxis[];
8
+ readonly datasets: readonly RadarDataset[];
9
+ readonly radius?: number | undefined;
10
+ readonly rings?: number | undefined;
11
+ readonly gridColor?: string | undefined;
12
+ readonly axisColor?: string | undefined;
13
+ readonly labelColor?: string | undefined;
14
+ }
15
+ export declare function RadarSeries({ axes, datasets, radius, rings, gridColor, axisColor, labelColor, }: RadarSeriesProps): null;
16
+ //# sourceMappingURL=RadarSeries.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RadarSeries.d.ts","sourceRoot":"","sources":["../src/RadarSeries.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAI3E,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,SAAS,SAAS,EAAE,CAAC;IACpC,QAAQ,CAAC,QAAQ,EAAE,SAAS,YAAY,EAAE,CAAC;IAC3C,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1C;AAED,wBAAgB,WAAW,CAAC,EAC1B,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,KAAS,EACT,SAAS,EACT,SAAS,EACT,UAAU,GACX,EAAE,gBAAgB,GAAG,IAAI,CA2CzB"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * @file packages/chart-react/src/RadarSeries.tsx
3
+ * Declarative Radar / Spider series component.
4
+ */
5
+ import React, { useEffect, useId } from 'react';
6
+ import { renderRadar } from '@tranding-custom-chart/renderer-canvas';
7
+ import { useChartContext } from './ChartContext.js';
8
+ export function RadarSeries({ axes, datasets, radius, rings = 4, gridColor, axisColor, labelColor, }) {
9
+ const { registerDataLayer, bounds, theme } = useChartContext();
10
+ const id = useId();
11
+ useEffect(() => {
12
+ if (axes.length < 3)
13
+ return;
14
+ const unregister = registerDataLayer(id, (ctx) => {
15
+ const cx = bounds.width / 2;
16
+ const cy = bounds.height / 2;
17
+ const maxRadius = Math.min(cx, cy) - 40;
18
+ const actualRadius = radius ?? Math.max(20, maxRadius);
19
+ renderRadar(ctx, axes, datasets, {
20
+ cx,
21
+ cy,
22
+ radius: actualRadius,
23
+ rings,
24
+ gridColor: gridColor ?? theme.gridLine,
25
+ axisColor: axisColor ?? theme.axisLine,
26
+ labelColor: labelColor ?? theme.textSecondary,
27
+ });
28
+ });
29
+ return unregister;
30
+ }, [
31
+ registerDataLayer,
32
+ id,
33
+ axes,
34
+ datasets,
35
+ bounds.width,
36
+ bounds.height,
37
+ radius,
38
+ rings,
39
+ gridColor,
40
+ axisColor,
41
+ labelColor,
42
+ theme.gridLine,
43
+ theme.axisLine,
44
+ theme.textSecondary,
45
+ ]);
46
+ return null;
47
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @file packages/chart-react/src/ScatterSeries.tsx
3
+ * Declarative Scatter Plot series component.
4
+ */
5
+ import type { ScatterDatum } from '@tranding-custom-chart/core';
6
+ import { type ScatterRenderOptions } from '@tranding-custom-chart/renderer-canvas';
7
+ export interface ScatterSeriesProps extends ScatterRenderOptions {
8
+ readonly data: readonly ScatterDatum[];
9
+ }
10
+ export declare function ScatterSeries({ data, defaultRadius, defaultColor, strokeColor, strokeWidth, shape, }: ScatterSeriesProps): null;
11
+ //# sourceMappingURL=ScatterSeries.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScatterSeries.d.ts","sourceRoot":"","sources":["../src/ScatterSeries.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAiB,KAAK,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AAGlG,MAAM,WAAW,kBAAmB,SAAQ,oBAAoB;IAC9D,QAAQ,CAAC,IAAI,EAAE,SAAS,YAAY,EAAE,CAAC;CACxC;AAED,wBAAgB,aAAa,CAAC,EAC5B,IAAI,EACJ,aAAiB,EACjB,YAAwB,EACxB,WAAuB,EACvB,WAAiB,EACjB,KAAgB,GACjB,EAAE,kBAAkB,GAAG,IAAI,CAyD3B"}