@indiminds/chart-types 1.0.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/LICENSE +14 -0
- package/dist/bridge.d.ts +26 -0
- package/dist/bridge.d.ts.map +1 -0
- package/dist/candle.d.ts +9 -0
- package/dist/candle.d.ts.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -0
- package/dist/indicator.d.ts +8 -0
- package/dist/indicator.d.ts.map +1 -0
- package/dist/layout.d.ts +16 -0
- package/dist/layout.d.ts.map +1 -0
- package/dist/node.d.ts +112 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/pane.d.ts +12 -0
- package/dist/pane.d.ts.map +1 -0
- package/dist/price.d.ts +5 -0
- package/dist/price.d.ts.map +1 -0
- package/dist/render.d.ts +148 -0
- package/dist/render.d.ts.map +1 -0
- package/dist/series.d.ts +29 -0
- package/dist/series.d.ts.map +1 -0
- package/dist/viewport.d.ts +5 -0
- package/dist/viewport.d.ts.map +1 -0
- package/package.json +35 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
Copyright (c) 2026 Indiminds Technologies LLP. All rights reserved.
|
|
2
|
+
|
|
3
|
+
This software and its associated documentation files (the "Software") are the intellectual property of Indiminds Technologies LLP.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted to download and view the source code via public registries like npm for evaluation purposes only.
|
|
6
|
+
|
|
7
|
+
STRICTLY PROHIBITED ACTIONS:
|
|
8
|
+
1. Modification: You may not modify, adapt, alter, or create derivative works based on this Software.
|
|
9
|
+
2. Distribution: You may not redistribute, sub-license, rent, lease, or sell this Software, in whole or in part, to any third party.
|
|
10
|
+
3. Production/Commercial Use: You may not use this Software in any production, commercial, or revenue-generating environment without explicit written consent from the copyright holder.
|
|
11
|
+
|
|
12
|
+
Any use of this Software outside of evaluation requires a custom, explicit commercial license agreement. For licensing inquiries, please contact: sonu@indiminds.com.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/dist/bridge.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { CandleData } from "./candle";
|
|
2
|
+
import type { NodeConfig, NodeDescriptor, NodeId, NodeOutput } from "./node";
|
|
3
|
+
export interface IChartEngineBridge {
|
|
4
|
+
initialize(): Promise<void>;
|
|
5
|
+
dispose(): void;
|
|
6
|
+
loadHistory(candles: CandleData[]): Promise<void>;
|
|
7
|
+
onTick(candle: CandleData): Promise<void>;
|
|
8
|
+
addNode(config: NodeConfig): Promise<NodeDescriptor>;
|
|
9
|
+
removeNode(id: NodeId): Promise<void>;
|
|
10
|
+
getOutput(id: NodeId): Promise<NodeOutput>;
|
|
11
|
+
subscribe(id: NodeId, callback: (output: NodeOutput) => void): () => void;
|
|
12
|
+
}
|
|
13
|
+
export declare class EngineInitError extends Error {
|
|
14
|
+
readonly cause?: unknown | undefined;
|
|
15
|
+
constructor(message: string, cause?: unknown | undefined);
|
|
16
|
+
}
|
|
17
|
+
/** Thrown when getOutput() or subscribe() is called with an unknown NodeId */
|
|
18
|
+
export declare class NodeNotFoundError extends Error {
|
|
19
|
+
readonly nodeId: NodeId;
|
|
20
|
+
constructor(nodeId: NodeId);
|
|
21
|
+
}
|
|
22
|
+
/** Thrown when any bridge method is called before initialize() completes */
|
|
23
|
+
export declare class EngineNotInitializedError extends Error {
|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ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"candle.d.ts","sourceRoot":"","sources":["../src/candle.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from "./candle";
|
|
2
|
+
export * from "./indicator";
|
|
3
|
+
export * from "./layout";
|
|
4
|
+
export * from "./pane";
|
|
5
|
+
export * from "./price";
|
|
6
|
+
export * from "./series";
|
|
7
|
+
export * from "./viewport";
|
|
8
|
+
export * from "./bridge";
|
|
9
|
+
export * from "./node";
|
|
10
|
+
export * from "./render";
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var i=class extends Error{constructor(e,n){super(e);this.cause=n;this.name="EngineInitError"}},o=class extends Error{constructor(e){super(`Node not found in DAG: "${e}"`);this.nodeId=e;this.name="NodeNotFoundError"}},t=class extends Error{constructor(){super("Bridge not initialized. Call initialize() and await it first."),this.name="EngineNotInitializedError"}};export{i as EngineInitError,t as EngineNotInitializedError,o as NodeNotFoundError};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indicator.d.ts","sourceRoot":"","sources":["../src/indicator.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC"}
|
package/dist/layout.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface PaneLayout {
|
|
2
|
+
id: string;
|
|
3
|
+
top: number;
|
|
4
|
+
height: number;
|
|
5
|
+
}
|
|
6
|
+
export interface ChartLayout {
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
chartWidth: number;
|
|
10
|
+
chartHeight: number;
|
|
11
|
+
priceScaleWidth: number;
|
|
12
|
+
timeScaleHeight: number;
|
|
13
|
+
panes: PaneLayout[];
|
|
14
|
+
timeAxisTop?: number;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=layout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../src/layout.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;IAExB,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB"}
|
package/dist/node.d.ts
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Globally unique identifier for a DAG node.
|
|
3
|
+
* Opaque string — engine assigns it, consumers just store and pass it back.
|
|
4
|
+
*/
|
|
5
|
+
export type NodeId = string;
|
|
6
|
+
export type SourceNodeKind = "close" | "open" | "high" | "low" | "volume";
|
|
7
|
+
export interface SourceNodeConfig {
|
|
8
|
+
kind: "source";
|
|
9
|
+
source: SourceNodeKind;
|
|
10
|
+
}
|
|
11
|
+
export interface EmaNodeConfig {
|
|
12
|
+
kind: "indicator";
|
|
13
|
+
indicator: "ema";
|
|
14
|
+
sourceId: NodeId;
|
|
15
|
+
period: number;
|
|
16
|
+
}
|
|
17
|
+
export interface SmaNodeConfig {
|
|
18
|
+
kind: "indicator";
|
|
19
|
+
indicator: "sma";
|
|
20
|
+
sourceId: NodeId;
|
|
21
|
+
period: number;
|
|
22
|
+
}
|
|
23
|
+
export interface RsiNodeConfig {
|
|
24
|
+
kind: "indicator";
|
|
25
|
+
indicator: "rsi";
|
|
26
|
+
sourceId: NodeId;
|
|
27
|
+
period: number;
|
|
28
|
+
}
|
|
29
|
+
export interface MacdNodeConfig {
|
|
30
|
+
kind: "indicator";
|
|
31
|
+
indicator: "macd";
|
|
32
|
+
sourceId: NodeId;
|
|
33
|
+
fastPeriod: number;
|
|
34
|
+
slowPeriod: number;
|
|
35
|
+
signalPeriod: number;
|
|
36
|
+
}
|
|
37
|
+
export interface BbNodeConfig {
|
|
38
|
+
kind: "indicator";
|
|
39
|
+
indicator: "bb";
|
|
40
|
+
sourceId: NodeId;
|
|
41
|
+
period: number;
|
|
42
|
+
/** Standard deviation multiplier */
|
|
43
|
+
stdDev: number;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* ATR always reads high/low/close together. `sourceId` is the close leg
|
|
47
|
+
* (chainable like any other indicator's source); high/low are always the
|
|
48
|
+
* fixed OHLC roots, resolved by the bridge rather than user-selectable.
|
|
49
|
+
*/
|
|
50
|
+
export interface AtrNodeConfig {
|
|
51
|
+
kind: "indicator";
|
|
52
|
+
indicator: "atr";
|
|
53
|
+
sourceId: NodeId;
|
|
54
|
+
period: number;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Supertrend always reads high/low/close together, same convention as ATR —
|
|
58
|
+
* `sourceId` is the close leg; high/low are the fixed OHLC roots.
|
|
59
|
+
*/
|
|
60
|
+
export interface SupertrendNodeConfig {
|
|
61
|
+
kind: "indicator";
|
|
62
|
+
indicator: "supertrend";
|
|
63
|
+
sourceId: NodeId;
|
|
64
|
+
period: number;
|
|
65
|
+
multiplier: number;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* All indicator configs as a discriminated union.
|
|
69
|
+
* Engine switches on `indicator` field — type-safe, exhaustive.
|
|
70
|
+
*/
|
|
71
|
+
export type IndicatorNodeConfig = EmaNodeConfig | SmaNodeConfig | RsiNodeConfig | MacdNodeConfig | BbNodeConfig | AtrNodeConfig | SupertrendNodeConfig;
|
|
72
|
+
export type NodeConfig = SourceNodeConfig | IndicatorNodeConfig;
|
|
73
|
+
/**
|
|
74
|
+
* The shape of every kind of series data in the app, generic over the leaf
|
|
75
|
+
* type — single source of truth for the single/band/macd/trend variants and
|
|
76
|
+
* their field names. Instantiated with different T per use: Float64Array for
|
|
77
|
+
* the public NodeOutput contract, GrowableFloat64Array for WasmBridge's tick
|
|
78
|
+
* cache, number for a single tick's delta. Add a new indicator output shape
|
|
79
|
+
* here once, not in every place that needs a T-flavored version of it.
|
|
80
|
+
*/
|
|
81
|
+
export type SeriesShape<T> = {
|
|
82
|
+
kind: "single";
|
|
83
|
+
values: T;
|
|
84
|
+
} | {
|
|
85
|
+
kind: "band";
|
|
86
|
+
upper: T;
|
|
87
|
+
middle: T;
|
|
88
|
+
lower: T;
|
|
89
|
+
} | {
|
|
90
|
+
kind: "macd";
|
|
91
|
+
macd: T;
|
|
92
|
+
signal: T;
|
|
93
|
+
histogram: T;
|
|
94
|
+
} | {
|
|
95
|
+
kind: "trend";
|
|
96
|
+
value: T;
|
|
97
|
+
direction: T;
|
|
98
|
+
};
|
|
99
|
+
/** Discriminated union of all possible node outputs */
|
|
100
|
+
export type NodeOutput = SeriesShape<Float64Array>;
|
|
101
|
+
export interface NodeDescriptor {
|
|
102
|
+
/** Stable id — use this for all future bridge calls */
|
|
103
|
+
id: NodeId;
|
|
104
|
+
/** Original config this node was created with */
|
|
105
|
+
config: NodeConfig;
|
|
106
|
+
/**
|
|
107
|
+
* Output shape kind — renderer uses this to pick draw strategy upfront.
|
|
108
|
+
* Avoids a runtime getOutput() call just to discover the shape.
|
|
109
|
+
*/
|
|
110
|
+
outputKind: NodeOutput["kind"];
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC;AAE5B,MAAM,MAAM,cAAc,GACtB,OAAO,GACP,MAAM,GACN,MAAM,GACN,KAAK,GACL,QAAQ,CAAC;AAEb,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,EAAE,cAAc,CAAC;CACxB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,WAAW,CAAC;IAClB,SAAS,EAAE,KAAK,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,WAAW,CAAC;IAClB,SAAS,EAAE,KAAK,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,WAAW,CAAC;IAClB,SAAS,EAAE,KAAK,CA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,EAAE,CAAC,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,GAC/C;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,CAAC,CAAC;IAAC,MAAM,EAAE,CAAC,CAAC;IAAC,SAAS,EAAE,CAAC,CAAA;CAAE,GAClD;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,CAAC,CAAC;IAAC,SAAS,EAAE,CAAC,CAAA;CAAE,CAAC;AAE9C,uDAAuD;AACvD,MAAM,MAAM,UAAU,GAAG,WAAW,CAAC,YAAY,CAAC,CAAC;AAGnD,MAAM,WAAW,cAAc;IAC7B,uDAAuD;IACvD,EAAE,EAAE,MAAM,CAAC;IACX,iDAAiD;IACjD,MAAM,EAAE,UAAU,CAAC;IACnB;;;OAGG;IACH,UAAU,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;CAChC"}
|
package/dist/pane.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type PaneType = "price" | "indicator";
|
|
2
|
+
export interface Pane {
|
|
3
|
+
id: string;
|
|
4
|
+
type: PaneType;
|
|
5
|
+
title: string;
|
|
6
|
+
visible: boolean;
|
|
7
|
+
height: number;
|
|
8
|
+
minHeight: number;
|
|
9
|
+
resizable: boolean;
|
|
10
|
+
seriesIds: string[];
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=pane.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pane.d.ts","sourceRoot":"","sources":["../src/pane.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,WAAW,CAAC;AAE7C,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,QAAQ,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB"}
|
package/dist/price.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"price.d.ts","sourceRoot":"","sources":["../src/price.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACb"}
|
package/dist/render.d.ts
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The contract between "an indicator" and "a chart that draws it".
|
|
3
|
+
*
|
|
4
|
+
* Indicators are described in terms of what a chart can draw — lines, bands,
|
|
5
|
+
* histograms, panes, reference levels — so the renderer never learns what EMA
|
|
6
|
+
* or MACD means. Which plots a kind produces is declared outside the engine
|
|
7
|
+
* (see packages/ui's indicator-registry).
|
|
8
|
+
*/
|
|
9
|
+
/** Visual treatment of a single plot. Colors are resolved by the caller. */
|
|
10
|
+
export interface PlotStyle {
|
|
11
|
+
color: string;
|
|
12
|
+
lineWidth?: number;
|
|
13
|
+
/** 0-1, applied as globalAlpha so any CSS color format works. */
|
|
14
|
+
opacity?: number;
|
|
15
|
+
/** Canvas dash pattern; omit or [] for solid. */
|
|
16
|
+
dash?: number[];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* "momentum" picks from a 4-color palette by sign and growth-vs-previous.
|
|
20
|
+
* "directional" picks bullStrong/bearStrong by the sign of a companion
|
|
21
|
+
* series (`colorValues`) — e.g. volume bars colored by candle direction
|
|
22
|
+
* rather than by the bar's own value trend.
|
|
23
|
+
*/
|
|
24
|
+
export type HistogramColorMode = "fixed" | "momentum" | "directional";
|
|
25
|
+
export interface MomentumColors {
|
|
26
|
+
bullStrong: string;
|
|
27
|
+
bullWeak: string;
|
|
28
|
+
bearStrong: string;
|
|
29
|
+
bearWeak: string;
|
|
30
|
+
}
|
|
31
|
+
interface BasePlot {
|
|
32
|
+
/** Stable key within its indicator — "values", "upper", "signal", ... */
|
|
33
|
+
key: string;
|
|
34
|
+
/** Row label in the legend. Omit to keep the plot off the legend. */
|
|
35
|
+
label?: string;
|
|
36
|
+
style: PlotStyle;
|
|
37
|
+
/** Show this plot's latest value as a price-scale pill. */
|
|
38
|
+
axisPill?: boolean;
|
|
39
|
+
}
|
|
40
|
+
export interface LinePlot extends BasePlot {
|
|
41
|
+
type: "line";
|
|
42
|
+
values: (number | null)[];
|
|
43
|
+
/** "directional" recolors each segment by the sign of a companion series
|
|
44
|
+
* (`colorValues`) instead of drawing one solid color — e.g. Supertrend's
|
|
45
|
+
* line flips bullStrong/bearStrong with its trend direction. */
|
|
46
|
+
colorMode?: "fixed" | "directional";
|
|
47
|
+
momentumColors?: MomentumColors;
|
|
48
|
+
colorValues?: (number | null)[];
|
|
49
|
+
}
|
|
50
|
+
export interface BandPlot extends BasePlot {
|
|
51
|
+
type: "band";
|
|
52
|
+
upper: (number | null)[];
|
|
53
|
+
lower: (number | null)[];
|
|
54
|
+
/** "directional" fills each contiguous run by the sign of a companion
|
|
55
|
+
* series (`colorValues`) instead of one solid fill — e.g. Supertrend's
|
|
56
|
+
* fill flips bullStrong/bearStrong with its trend direction. */
|
|
57
|
+
colorMode?: "fixed" | "directional";
|
|
58
|
+
momentumColors?: MomentumColors;
|
|
59
|
+
colorValues?: (number | null)[];
|
|
60
|
+
}
|
|
61
|
+
export interface HistogramPlot extends BasePlot {
|
|
62
|
+
type: "histogram";
|
|
63
|
+
values: (number | null)[];
|
|
64
|
+
/** Value the bars grow from. Defaults to 0. */
|
|
65
|
+
baseline?: number;
|
|
66
|
+
colorMode?: HistogramColorMode;
|
|
67
|
+
momentumColors?: MomentumColors;
|
|
68
|
+
/** Sign-only companion series for `colorMode: "directional"`. */
|
|
69
|
+
colorValues?: (number | null)[];
|
|
70
|
+
}
|
|
71
|
+
export type Plot = LinePlot | BandPlot | HistogramPlot;
|
|
72
|
+
/** Fit the data with a proportional cushion. */
|
|
73
|
+
export interface AutoPaneScale {
|
|
74
|
+
mode: "auto";
|
|
75
|
+
cushionRatio: number;
|
|
76
|
+
minCushion?: number;
|
|
77
|
+
}
|
|
78
|
+
/** Bounded axis that always keeps `alwaysInclude` on screen. */
|
|
79
|
+
export interface FixedPaneScale {
|
|
80
|
+
mode: "fixed";
|
|
81
|
+
min: number;
|
|
82
|
+
max: number;
|
|
83
|
+
alwaysInclude?: [number, number];
|
|
84
|
+
cushionRatio: number;
|
|
85
|
+
minCushion?: number;
|
|
86
|
+
}
|
|
87
|
+
/** Share the price pane's extent — for overlays drawn on the candles. */
|
|
88
|
+
export interface PricePaneScale {
|
|
89
|
+
mode: "price";
|
|
90
|
+
}
|
|
91
|
+
export type PaneScale = AutoPaneScale | FixedPaneScale | PricePaneScale;
|
|
92
|
+
export interface ReferenceLineSpec {
|
|
93
|
+
value: number;
|
|
94
|
+
color: string;
|
|
95
|
+
label?: string;
|
|
96
|
+
labelColor?: string;
|
|
97
|
+
dash?: number[];
|
|
98
|
+
lineWidth?: number;
|
|
99
|
+
}
|
|
100
|
+
export interface ZoneSpec {
|
|
101
|
+
from: number;
|
|
102
|
+
to: number;
|
|
103
|
+
color: string;
|
|
104
|
+
}
|
|
105
|
+
/** Indicators declaring the same `id` share one pane. */
|
|
106
|
+
export interface PaneSpec {
|
|
107
|
+
id: string;
|
|
108
|
+
scale: PaneScale;
|
|
109
|
+
/** Preferred height in px; the layout may shrink it to fit. */
|
|
110
|
+
height: number;
|
|
111
|
+
minHeight: number;
|
|
112
|
+
referenceLines?: ReferenceLineSpec[];
|
|
113
|
+
zones?: ZoneSpec[];
|
|
114
|
+
/** Draw nice-step horizontal grid lines with gutter labels. */
|
|
115
|
+
grid?: boolean;
|
|
116
|
+
/** Formats gutter labels and axis pills in this pane. Defaults to 2dp. */
|
|
117
|
+
valuePrecision?: number;
|
|
118
|
+
/** Px kept clear inside the pane's edges. Default 8; pass 0 when the scale
|
|
119
|
+
* already cushions its own extent. */
|
|
120
|
+
padTop?: number;
|
|
121
|
+
padBottom?: number;
|
|
122
|
+
}
|
|
123
|
+
/** Draw on the candles, sharing the price scale. */
|
|
124
|
+
export interface PriceTarget {
|
|
125
|
+
pane: "price";
|
|
126
|
+
}
|
|
127
|
+
/** Draw in a dedicated sub-pane with its own scale. */
|
|
128
|
+
export interface OwnPaneTarget {
|
|
129
|
+
pane: "own";
|
|
130
|
+
spec: PaneSpec;
|
|
131
|
+
}
|
|
132
|
+
export type PaneTarget = PriceTarget | OwnPaneTarget;
|
|
133
|
+
/** The only shape `CandlestickChart.setIndicators()` accepts. */
|
|
134
|
+
export interface RenderableIndicator {
|
|
135
|
+
id: string;
|
|
136
|
+
/** Display name, e.g. "BB(20,2)". */
|
|
137
|
+
label: string;
|
|
138
|
+
visible: boolean;
|
|
139
|
+
target: PaneTarget;
|
|
140
|
+
plots: Plot[];
|
|
141
|
+
/** Draw order against the candles, for price-pane overlays. Default "front". */
|
|
142
|
+
layer?: "behind" | "front";
|
|
143
|
+
/** Widen the price pane's extent to keep these plots in frame — only worth
|
|
144
|
+
* setting for plots that leave the candle range. */
|
|
145
|
+
expandsPriceExtent?: boolean;
|
|
146
|
+
}
|
|
147
|
+
export {};
|
|
148
|
+
//# sourceMappingURL=render.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,4EAA4E;AAC5E,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iEAAiE;IACjE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iDAAiD;IACjD,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB;AAED;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,UAAU,GAAG,aAAa,CAAC;AAEtE,MAAM,WAAW,cAAc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,CAAC;IAClB,cAAc,CAAC,EAAE,iBAAiB,EAAE,CAAC;IACrC,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAC;IACnB,+DAA+D;IAC/D,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,0EAA0E;IAC1E,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;2CACuC;IACvC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,oDAAoD;AACpD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,OAAO,CAAC;CACf;AAED,uDAAuD;AACvD,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,KAAK,CAAC;IACZ,IAAI,EAAE,QAAQ,CAAC;CAChB;AAED,MAAM,MAAM,UAAU,GAAG,WAAW,GAAG,aAAa,CAAC;AAErD,iEAAiE;AACjE,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,qCAAqC;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,UAAU,CAAC;IACnB,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,gFAAgF;IAChF,KAAK,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;IAC3B;yDACqD;IACrD,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B"}
|
package/dist/series.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
type SeriesType = "candlestick" | "line" | "histogram" | "area" | "bar" | "band";
|
|
2
|
+
interface BaseSeries {
|
|
3
|
+
id: string;
|
|
4
|
+
label: string;
|
|
5
|
+
type: SeriesType;
|
|
6
|
+
visible: boolean;
|
|
7
|
+
color?: string;
|
|
8
|
+
}
|
|
9
|
+
interface LineSeries extends BaseSeries {
|
|
10
|
+
type: "line";
|
|
11
|
+
values: (number | null)[];
|
|
12
|
+
}
|
|
13
|
+
interface HistogramSeries extends BaseSeries {
|
|
14
|
+
type: "histogram";
|
|
15
|
+
values: (number | null)[];
|
|
16
|
+
}
|
|
17
|
+
interface AreaSeries extends BaseSeries {
|
|
18
|
+
type: "area";
|
|
19
|
+
values: (number | null)[];
|
|
20
|
+
}
|
|
21
|
+
interface BandSeries extends BaseSeries {
|
|
22
|
+
type: "band";
|
|
23
|
+
upper: (number | null)[];
|
|
24
|
+
middle: (number | null)[];
|
|
25
|
+
lower: (number | null)[];
|
|
26
|
+
}
|
|
27
|
+
type ChartSeries = LineSeries | HistogramSeries | AreaSeries | BandSeries;
|
|
28
|
+
export { SeriesType, BaseSeries, BandSeries, ChartSeries };
|
|
29
|
+
//# sourceMappingURL=series.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"series.d.ts","sourceRoot":"","sources":["../src/series.ts"],"names":[],"mappings":"AAAA,KAAK,UAAU,GACX,aAAa,GACb,MAAM,GACN,WAAW,GACX,MAAM,GACN,KAAK,GACL,MAAM,CAAC;AAEX,UAAU,UAAU;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,UAAU,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,UAAW,SAAQ,UAAU;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;CAC3B;AAED,UAAU,eAAgB,SAAQ,UAAU;IAC1C,IAAI,EAAE,WAAW,CAAC;IAClB,MAAM,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;CAC3B;AAED,UAAU,UAAW,SAAQ,UAAU;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;CAC3B;AAED,UAAU,UAAW,SAAQ,UAAU;IACrC,IAAI,EAAE,MAAM,CAAC;IAEb,KAAK,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;IACzB,MAAM,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;IAC1B,KAAK,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;CAC1B;AAED,KAAK,WAAW,GACZ,UAAU,GACV,eAAe,GACf,UAAU,GACV,UAAU,CAAC;AAEf,OAAO,EAAE,UAAU,EAAE,UAAU,EAAG,UAAU,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viewport.d.ts","sourceRoot":"","sources":["../src/viewport.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,QAAQ;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;CACrB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@indiminds/chart-types",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Shared TypeScript types (candles, indicators, layout, viewport) for @indiminds/charts.",
|
|
5
|
+
"author": "Indiminds <sonu@indiminds.com>",
|
|
6
|
+
"license": "UNLICENSED",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/Indiminds-Trading-Org/Back-Testing-UI.git",
|
|
13
|
+
"directory": "packages/chart-types"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"charts",
|
|
17
|
+
"types",
|
|
18
|
+
"typescript",
|
|
19
|
+
"@indiminds/charts"
|
|
20
|
+
],
|
|
21
|
+
"main": "./dist/index.js",
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"files": [
|
|
24
|
+
"dist"
|
|
25
|
+
],
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"esbuild": "^0.24.0",
|
|
28
|
+
"typescript": "^5.0.0"
|
|
29
|
+
},
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && tsc --emitDeclarationOnly && node build.mjs",
|
|
32
|
+
"typecheck": "tsc --noEmit",
|
|
33
|
+
"clean": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\""
|
|
34
|
+
}
|
|
35
|
+
}
|