tslab-widgets 0.1.0 → 1.0.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 (43) hide show
  1. package/LICENSE +170 -197
  2. package/dist/chart/chart.d.ts +10 -9
  3. package/dist/chart/chart.d.ts.map +1 -0
  4. package/dist/chart/chart.js +219 -79
  5. package/dist/chart/chart.js.map +1 -0
  6. package/dist/chart/plugins/tooltip.d.ts +32 -17
  7. package/dist/chart/plugins/tooltip.d.ts.map +1 -0
  8. package/dist/chart/plugins/tooltip.js +235 -64
  9. package/dist/chart/plugins/tooltip.js.map +1 -0
  10. package/dist/chart/plugins/trendLine.d.ts +5 -4
  11. package/dist/chart/plugins/trendLine.d.ts.map +1 -0
  12. package/dist/chart/plugins/trendLine.js +10 -4
  13. package/dist/chart/plugins/trendLine.js.map +1 -0
  14. package/dist/chart/plugins/verticalLine.d.ts +5 -4
  15. package/dist/chart/plugins/verticalLine.d.ts.map +1 -0
  16. package/dist/chart/plugins/verticalLine.js +43 -13
  17. package/dist/chart/plugins/verticalLine.js.map +1 -0
  18. package/dist/chart/plugins/volumeProfile.d.ts +31 -11
  19. package/dist/chart/plugins/volumeProfile.d.ts.map +1 -0
  20. package/dist/chart/plugins/volumeProfile.js +162 -24
  21. package/dist/chart/plugins/volumeProfile.js.map +1 -0
  22. package/dist/config/versions.d.ts +37 -0
  23. package/dist/config/versions.d.ts.map +1 -0
  24. package/dist/config/versions.js +43 -0
  25. package/dist/config/versions.js.map +1 -0
  26. package/dist/csv/csv.d.ts +1 -0
  27. package/dist/csv/csv.d.ts.map +1 -0
  28. package/dist/csv/csv.js +8 -6
  29. package/dist/csv/csv.js.map +1 -0
  30. package/dist/gauge/gauge.d.ts +1 -0
  31. package/dist/gauge/gauge.d.ts.map +1 -0
  32. package/dist/gauge/gauge.js +7 -5
  33. package/dist/gauge/gauge.js.map +1 -0
  34. package/dist/index.d.ts +8 -7
  35. package/dist/index.d.ts.map +1 -0
  36. package/dist/index.js +1 -0
  37. package/dist/index.js.map +1 -0
  38. package/dist/json/json.d.ts +1 -0
  39. package/dist/json/json.d.ts.map +1 -0
  40. package/dist/json/json.js +5 -3
  41. package/dist/json/json.js.map +1 -0
  42. package/package.json +46 -31
  43. package/readme.md +54 -6
@@ -7,14 +7,17 @@ class VertLinePaneRenderer {
7
7
  this._options = _options;
8
8
  }
9
9
  draw(target) {
10
- target.useBitmapCoordinateSpace(scope => {
10
+ target.useBitmapCoordinateSpace((scope) => {
11
11
  if (this._x === null)
12
12
  return;
13
13
  const ctx = scope.context;
14
14
  const scaledPosition = Math.round(scope.horizontalPixelRatio * this._x);
15
15
  const lineBitmapWidth = Math.round(this._options.width * scope.horizontalPixelRatio);
16
16
  const offset = Math.floor(lineBitmapWidth * 0.5);
17
- const position = { length: lineBitmapWidth, position: scaledPosition - offset };
17
+ const position = {
18
+ length: lineBitmapWidth,
19
+ position: scaledPosition - offset,
20
+ };
18
21
  ctx.fillStyle = this._options.color;
19
22
  ctx.fillRect(position.position, 0, position.length, scope.bitmapSize.height);
20
23
  });
@@ -42,22 +45,40 @@ class VertLineTimeAxisView {
42
45
  this._options = _options;
43
46
  this._x = null;
44
47
  }
45
- backColor() { return this._options.labelBackgroundColor; }
46
- coordinate() { var _a; return (_a = this._x) !== null && _a !== void 0 ? _a : 0; }
47
- text() { return this._options.labelText; }
48
- textColor() { return this._options.labelTextColor; }
49
- tickVisible() { return this._options.showLabel; }
48
+ backColor() {
49
+ return this._options.labelBackgroundColor;
50
+ }
51
+ coordinate() {
52
+ var _a;
53
+ return (_a = this._x) !== null && _a !== void 0 ? _a : 0;
54
+ }
55
+ text() {
56
+ return this._options.labelText;
57
+ }
58
+ textColor() {
59
+ return this._options.labelTextColor;
60
+ }
61
+ tickVisible() {
62
+ return this._options.showLabel;
63
+ }
50
64
  update() {
51
65
  const timeScale = this._source._chart.timeScale();
52
66
  this._x = timeScale.timeToCoordinate(this._source._time);
53
67
  }
54
- visible() { return this._options.showLabel; }
68
+ visible() {
69
+ return this._options.showLabel;
70
+ }
55
71
  }
56
72
  exports.VertLineTimeAxisView = VertLineTimeAxisView;
57
73
  class VertLine {
58
74
  constructor(chart, series, time, options) {
59
75
  const defaultOptions = {
60
- color: 'green', labelBackgroundColor: 'green', labelText: '', labelTextColor: 'white', showLabel: false, width: 2,
76
+ color: "green",
77
+ labelBackgroundColor: "green",
78
+ labelText: "",
79
+ labelTextColor: "white",
80
+ showLabel: false,
81
+ width: 2,
61
82
  };
62
83
  const vertLineOptions = Object.assign(Object.assign({}, defaultOptions), options);
63
84
  this._chart = chart;
@@ -66,11 +87,20 @@ class VertLine {
66
87
  this._paneViews = [new VertLinePaneView(this, vertLineOptions)];
67
88
  this._timeAxisViews = [new VertLineTimeAxisView(this, vertLineOptions)];
68
89
  }
69
- paneViews() { return this._paneViews; }
70
- timeAxisViews() { return this._timeAxisViews; }
90
+ paneViews() {
91
+ return this._paneViews;
92
+ }
93
+ timeAxisViews() {
94
+ return this._timeAxisViews;
95
+ }
71
96
  updateAllViews() {
72
- this._paneViews.forEach(pw => { pw.update(); });
73
- this._timeAxisViews.forEach(tw => { tw.update(); });
97
+ this._paneViews.forEach((pw) => {
98
+ pw.update();
99
+ });
100
+ this._timeAxisViews.forEach((tw) => {
101
+ tw.update();
102
+ });
74
103
  }
75
104
  }
76
105
  exports.VertLine = VertLine;
106
+ //# sourceMappingURL=verticalLine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verticalLine.js","sourceRoot":"","sources":["../../../src/chart/plugins/verticalLine.ts"],"names":[],"mappings":";;;AAsBA,MAAa,oBAAoB;IAChC,YACS,EAAqB,EACrB,QAA0B;QAD1B,OAAE,GAAF,EAAE,CAAmB;QACrB,aAAQ,GAAR,QAAQ,CAAkB;IAChC,CAAC;IACJ,IAAI,CAAC,MAAqD;QACzD,MAAM,CAAC,wBAAwB,CAAC,CAAC,KAAK,EAAE,EAAE;YACzC,IAAI,IAAI,CAAC,EAAE,KAAK,IA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IAAI,CAAC;QAClB,IAAI,CAAC,UAAU,GAAG,CAAC,IAAI,gBAAgB,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC,CAAC;QAChE,IAAI,CAAC,cAAc,GAAG,CAAC,IAAI,oBAAoB,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC,CAAC;IACzE,CAAC;IACD,SAAS;QACR,OAAO,IAAI,CAAC,UAAU,CAAC;IACxB,CAAC;IACD,aAAa;QACZ,OAAO,IAAI,CAAC,cAAc,CAAC;IAC5B,CAAC;IACD,cAAc;QACb,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE;YAC9B,EAAE,CAAC,MAAM,EAAE,CAAC;QACb,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE;YAClC,EAAE,CAAC,MAAM,EAAE,CAAC;QACb,CAAC,CAAC,CAAC;IACJ,CAAC;CACD;AA1CD,4BA0CC"}
@@ -1,4 +1,4 @@
1
- import type { Coordinate, IChartApi, ISeriesApi, ISeriesPrimitive, ISeriesPrimitivePaneRenderer, ISeriesPrimitivePaneView, SeriesType, Time } from 'lightweight-charts';
1
+ import type { CandlestickData, Coordinate, IChartApi, IPrimitivePaneRenderer, IPrimitivePaneView, ISeriesApi, ISeriesPrimitive, SeriesType, Time } from "lightweight-charts";
2
2
  type IVolumeProfileDataPoint = {
3
3
  negativeVolume: number;
4
4
  positiveVolume: number;
@@ -6,31 +6,31 @@ type IVolumeProfileDataPoint = {
6
6
  };
7
7
  export type IVolumeProfileData = {
8
8
  fromTime: Time;
9
- position: 'left' | 'right';
9
+ toTime?: Time;
10
+ position: "left" | "right";
10
11
  profile: IVolumeProfileDataPoint[];
11
12
  };
12
13
  type IVolumeProfileItem = {
13
14
  widthNegative: number;
14
15
  widthPositive: number;
15
16
  y: Coordinate | null;
17
+ height: number;
16
18
  };
17
19
  type IVolumeProfileRendererData = {
18
- columnHeight: number;
19
20
  items: IVolumeProfileItem[];
20
- position: 'left' | 'right';
21
+ position: "left" | "right";
21
22
  top: Coordinate | null;
22
23
  widthNegative: number;
23
24
  widthPositive: number;
24
25
  };
25
- export declare class VolumeProfileRenderer implements ISeriesPrimitivePaneRenderer {
26
+ export declare class VolumeProfileRenderer implements IPrimitivePaneRenderer {
26
27
  private _data;
27
28
  constructor(_data: IVolumeProfileRendererData);
28
29
  private positionsBox;
29
- draw(target: Parameters<ISeriesPrimitivePaneRenderer['draw']>[0]): void;
30
+ draw(target: Parameters<IPrimitivePaneRenderer["draw"]>[0]): void;
30
31
  }
31
- export declare class VolumeProfilePaneView implements ISeriesPrimitivePaneView {
32
+ export declare class VolumeProfilePaneView implements IPrimitivePaneView {
32
33
  private _source;
33
- private _columnHeight;
34
34
  private _items;
35
35
  private _top;
36
36
  private _widthNegative;
@@ -45,16 +45,36 @@ export declare class VolumeProfilePaneView implements ISeriesPrimitivePaneView {
45
45
  export declare class VolumeProfileSeries implements ISeriesPrimitive {
46
46
  private _chart;
47
47
  private _series;
48
- private _vpData;
49
48
  private _paneViews;
49
+ private _vpData;
50
50
  _vpIndex: null | number;
51
- constructor(_chart: IChartApi, _series: ISeriesApi<SeriesType>, _vpData: IVolumeProfileData);
51
+ constructor(_chart: IChartApi, _series: ISeriesApi<SeriesType>, _vpSettings: VolumeProfileConfig, ohlcv: (CandlestickData & {
52
+ volume: number;
53
+ })[]);
52
54
  getContext(): {
53
55
  chart: IChartApi;
54
- series: ISeriesApi<keyof import("lightweight-charts").SeriesOptionsMap, Time, import("lightweight-charts").BarData<Time> | import("lightweight-charts").WhitespaceData<Time> | import("lightweight-charts").CandlestickData<Time> | import("lightweight-charts").AreaData<Time> | import("lightweight-charts").BaselineData<Time> | import("lightweight-charts").LineData<Time> | import("lightweight-charts").HistogramData<Time> | import("lightweight-charts").CustomData<Time> | import("lightweight-charts").CustomSeriesWhitespaceData<Time>, import("lightweight-charts").BarSeriesOptions | import("lightweight-charts").CandlestickSeriesOptions | import("lightweight-charts").AreaSeriesOptions | import("lightweight-charts").BaselineSeriesOptions | import("lightweight-charts").LineSeriesOptions | import("lightweight-charts").HistogramSeriesOptions | import("lightweight-charts").CustomSeriesOptions, import("lightweight-charts").DeepPartial<import("lightweight-charts").AreaStyleOptions & import("lightweight-charts").SeriesOptionsCommon> | import("lightweight-charts").DeepPartial<import("lightweight-charts").BaselineStyleOptions & import("lightweight-charts").SeriesOptionsCommon> | import("lightweight-charts").DeepPartial<import("lightweight-charts").BarStyleOptions & import("lightweight-charts").SeriesOptionsCommon> | import("lightweight-charts").DeepPartial<import("lightweight-charts").CandlestickStyleOptions & import("lightweight-charts").SeriesOptionsCommon> | import("lightweight-charts").DeepPartial<import("lightweight-charts").HistogramStyleOptions & import("lightweight-charts").SeriesOptionsCommon> | import("lightweight-charts").DeepPartial<import("lightweight-charts").LineStyleOptions & import("lightweight-charts").SeriesOptionsCommon> | import("lightweight-charts").DeepPartial<import("lightweight-charts").CustomStyleOptions & import("lightweight-charts").SeriesOptionsCommon>>;
56
+ series: ISeriesApi<keyof import("lightweight-charts").SeriesOptionsMap, Time, import("lightweight-charts").WhitespaceData<Time> | import("lightweight-charts").LineData<Time> | CandlestickData<Time> | import("lightweight-charts").BarData<Time> | import("lightweight-charts").AreaData<Time> | import("lightweight-charts").BaselineData<Time> | import("lightweight-charts").HistogramData<Time> | import("lightweight-charts").CustomData<Time> | import("lightweight-charts").CustomSeriesWhitespaceData<Time>, import("lightweight-charts").BarSeriesOptions | import("lightweight-charts").CandlestickSeriesOptions | import("lightweight-charts").AreaSeriesOptions | import("lightweight-charts").BaselineSeriesOptions | import("lightweight-charts").LineSeriesOptions | import("lightweight-charts").HistogramSeriesOptions | import("lightweight-charts").CustomSeriesOptions, import("lightweight-charts").DeepPartial<import("lightweight-charts").BarStyleOptions & import("lightweight-charts").SeriesOptionsCommon> | import("lightweight-charts").DeepPartial<import("lightweight-charts").CandlestickStyleOptions & import("lightweight-charts").SeriesOptionsCommon> | import("lightweight-charts").DeepPartial<import("lightweight-charts").AreaStyleOptions & import("lightweight-charts").SeriesOptionsCommon> | import("lightweight-charts").DeepPartial<import("lightweight-charts").BaselineStyleOptions & import("lightweight-charts").SeriesOptionsCommon> | import("lightweight-charts").DeepPartial<import("lightweight-charts").LineStyleOptions & import("lightweight-charts").SeriesOptionsCommon> | import("lightweight-charts").DeepPartial<import("lightweight-charts").HistogramStyleOptions & import("lightweight-charts").SeriesOptionsCommon> | import("lightweight-charts").DeepPartial<import("lightweight-charts").CustomStyleOptions & import("lightweight-charts").SeriesOptionsCommon>>;
55
57
  vpData: IVolumeProfileData;
56
58
  };
57
59
  paneViews(): VolumeProfilePaneView[];
58
60
  updateAllViews(): void;
61
+ createVolumeProfileFromOHLCV(ohlcvData: OHLCVDataPoint[], config?: VolumeProfileConfig): IVolumeProfileData;
59
62
  }
63
+ type OHLCVDataPoint = {
64
+ time: Time;
65
+ open: number;
66
+ high: number;
67
+ low: number;
68
+ close: number;
69
+ volume: number;
70
+ };
71
+ export type VolumeProfileConfig = {
72
+ priceBins?: number;
73
+ usePercentageBins?: boolean;
74
+ priceStep?: number;
75
+ fromTime?: Time;
76
+ toTime?: Time;
77
+ position?: "left" | "right";
78
+ };
60
79
  export {};
80
+ //# sourceMappingURL=volumeProfile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"volumeProfile.d.ts","sourceRoot":"","sources":["../../../src/chart/plugins/volumeProfile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,eAAe,EACf,UAAU,EACV,SAAS,EACT,sBAAsB,EACtB,kBAAkB,EAClB,UAAU,EACV,gBAAgB,EAChB,UAAU,EACV,IAAI,EACJ,MAAM,oBAAoB,CAAC;AAE5B,KAAK,uBAAuB,GAAG;IAC9B,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;CACd,CAAC;AACF,MAAM,MAAM,kBAAkB,GAAG;IAChC,QAA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AAO,EAAE,UAAU,CAAC,UAAU,CAAC,EACvC,WAAW,EAAE,mBAAmB,EAChC,KAAK,EAAE,CAAC,eAAe,GAAG;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,EAAE;IAOhD,UAAU;;;;;IAIV,SAAS;IAGT,cAAc;IAMd,4BAA4B,CAC3B,SAAS,EAAE,cAAc,EAAE,EAC3B,MAAM,GAAE,mBAAwB,GAC9B,kBAAkB;CAmHrB;AAKD,KAAK,cAAc,GAAG;IACrB,IAAI,EAAE,IAAI,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,IAAI,CAAC;IAChB,MAAM,CAAC,EAAE,IAAI,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B,CAAC"}
@@ -14,19 +14,26 @@ class VolumeProfileRenderer {
14
14
  };
15
15
  }
16
16
  draw(target) {
17
- target.useBitmapCoordinateSpace(scope => {
17
+ target.useBitmapCoordinateSpace((scope) => {
18
18
  if (this._data.top === null)
19
19
  return;
20
- this._data.items.forEach(row => {
20
+ this._data.items.forEach((row) => {
21
21
  if (row.y === null)
22
22
  return;
23
- const itemVerticalPos = this.positionsBox(row.y, row.y - this._data.columnHeight, scope.verticalPixelRatio);
24
- scope.context.fillStyle = 'rgba(40, 98, 255, 0.55)';
25
- const itemHorizontalPosP = this.positionsBox(this._data.position === 'left' ? 0 : scope.mediaSize.width, this._data.position === 'left' ? row.widthPositive : (scope.mediaSize.width - row.widthPositive), scope.horizontalPixelRatio);
26
- scope.context.fillRect(itemHorizontalPosP.position, itemVerticalPos.position, itemHorizontalPosP.length, itemVerticalPos.length - 2);
27
- scope.context.fillStyle = 'rgba(251, 191, 44, 0.55)';
28
- const itemHorizontalPosN = this.positionsBox(this._data.position === 'left' ? row.widthPositive : (scope.mediaSize.width - row.widthPositive), this._data.position === 'left' ? (row.widthNegative + row.widthPositive) : (scope.mediaSize.width - (row.widthNegative + row.widthPositive)), scope.horizontalPixelRatio);
29
- scope.context.fillRect(itemHorizontalPosN.position, itemVerticalPos.position, itemHorizontalPosN.length, itemVerticalPos.length - 2);
23
+ const itemVerticalPos = this.positionsBox(row.y, row.y - row.height, // Use individual bar height
24
+ scope.verticalPixelRatio);
25
+ scope.context.fillStyle = "rgba(40, 98, 255, 0.55)";
26
+ const itemHorizontalPosP = this.positionsBox(this._data.position === "left" ? 0 : scope.mediaSize.width, this._data.position === "left"
27
+ ? row.widthPositive
28
+ : scope.mediaSize.width - row.widthPositive, scope.horizontalPixelRatio);
29
+ scope.context.fillRect(itemHorizontalPosP.position, itemVerticalPos.position, itemHorizontalPosP.length, itemVerticalPos.length);
30
+ scope.context.fillStyle = "rgba(251, 191, 44, 0.55)";
31
+ const itemHorizontalPosN = this.positionsBox(this._data.position === "left"
32
+ ? row.widthPositive
33
+ : scope.mediaSize.width - row.widthPositive, this._data.position === "left"
34
+ ? row.widthNegative + row.widthPositive
35
+ : scope.mediaSize.width - (row.widthNegative + row.widthPositive), scope.horizontalPixelRatio);
36
+ scope.context.fillRect(itemHorizontalPosN.position, itemVerticalPos.position, itemHorizontalPosN.length, itemVerticalPos.length);
30
37
  });
31
38
  });
32
39
  }
@@ -35,7 +42,6 @@ exports.VolumeProfileRenderer = VolumeProfileRenderer;
35
42
  class VolumeProfilePaneView {
36
43
  constructor(_source) {
37
44
  this._source = _source;
38
- this._columnHeight = 0;
39
45
  this._items = [];
40
46
  this._top = null;
41
47
  this._widthNegative = 0;
@@ -43,7 +49,6 @@ class VolumeProfilePaneView {
43
49
  }
44
50
  renderer() {
45
51
  return new VolumeProfileRenderer({
46
- columnHeight: this._columnHeight,
47
52
  items: this._items,
48
53
  position: this._source.getContext().vpData.position,
49
54
  top: this._top,
@@ -52,42 +57,175 @@ class VolumeProfilePaneView {
52
57
  });
53
58
  }
54
59
  update() {
55
- var _a, _b;
56
60
  const ctx = this._source.getContext();
57
61
  const data = ctx.vpData;
58
62
  const series = ctx.series;
59
63
  const timeScale = ctx.chart.timeScale();
60
64
  const vr = timeScale.getVisibleRange();
61
- if (!vr || data.fromTime > vr.to) { // hide visible range when context initial time is after chart visible time
65
+ if (!vr || data.fromTime > vr.to) {
66
+ // hide visible range when context initial time is after chart visible time
62
67
  this._items = [];
63
68
  return { widthNegative: 0, widthPositive: 0 };
64
69
  }
65
70
  const _width = timeScale.width() * 0.33;
66
- const y1 = (_a = series.priceToCoordinate(data.profile[0].price)) !== null && _a !== void 0 ? _a : 0;
67
- const y2 = (_b = series.priceToCoordinate(data.profile[1].price)) !== null && _b !== void 0 ? _b : timeScale.height();
68
- this._columnHeight = Math.max(1, y1 - y2);
71
+ // Get all y-coordinates for the price levels
72
+ const yCoordinates = data.profile.map((row) => series.priceToCoordinate(row.price));
73
+ // Calculate the maximum volume for scaling
69
74
  const maxVolume = data.profile.reduce((acc, item) => Math.max(acc, item.positiveVolume + item.negativeVolume), 0);
70
- this._top = y1;
71
- this._items = data.profile.map(row => {
75
+ // Set the top coordinate (highest price)
76
+ this._top = yCoordinates[0];
77
+ // Create items with proper height calculation
78
+ this._items = data.profile.map((row, index) => {
79
+ let height = 1; // Minimum height
80
+ // Calculate height based on the distance to the next price level
81
+ if (index < data.profile.length - 1) {
82
+ const currentY = yCoordinates[index];
83
+ const nextY = yCoordinates[index + 1];
84
+ if (currentY !== null && nextY !== null) {
85
+ // Calculate the gap to the next bar
86
+ height = Math.abs(currentY - nextY);
87
+ // Adjust for the last bar - make it a bit shorter
88
+ if (index === data.profile.length - 2) {
89
+ height = Math.max(1, height * 0.8);
90
+ }
91
+ }
92
+ }
93
+ else {
94
+ // For the last bar, use the same height as the previous bar
95
+ const prevY = yCoordinates[index - 1];
96
+ const currentY = yCoordinates[index];
97
+ if (prevY !== null && currentY !== null) {
98
+ height = Math.max(1, Math.abs(prevY - currentY) * 0.8);
99
+ }
100
+ }
101
+ // Ensure minimum height
102
+ height = Math.max(1, height);
72
103
  return {
73
104
  widthNegative: (_width * row.positiveVolume) / maxVolume,
74
105
  widthPositive: (_width * row.negativeVolume) / maxVolume,
75
- y: series.priceToCoordinate(row.price),
106
+ y: yCoordinates[index],
107
+ height: height, // Add calculated height to each item
76
108
  };
77
109
  });
78
110
  }
79
111
  }
80
112
  exports.VolumeProfilePaneView = VolumeProfilePaneView;
81
113
  class VolumeProfileSeries {
82
- constructor(_chart, _series, _vpData) {
114
+ constructor(_chart, _series, _vpSettings, ohlcv) {
83
115
  this._chart = _chart;
84
116
  this._series = _series;
85
- this._vpData = _vpData;
86
117
  this._vpIndex = null;
118
+ this._vpData = this.createVolumeProfileFromOHLCV(ohlcv, _vpSettings);
119
+ // window.alert(JSON.stringify(this._vpData));
87
120
  this._paneViews = [new VolumeProfilePaneView(this)];
88
121
  }
89
- getContext() { return { chart: this._chart, series: this._series, vpData: this._vpData }; }
90
- paneViews() { return this._paneViews; }
91
- updateAllViews() { this._paneViews.forEach(pw => { pw.update(); }); }
122
+ getContext() {
123
+ // window.alert(JSON.stringify(this._vpData));
124
+ return { chart: this._chart, series: this._series, vpData: this._vpData };
125
+ }
126
+ paneViews() {
127
+ return this._paneViews;
128
+ }
129
+ updateAllViews() {
130
+ this._paneViews.forEach((pw) => {
131
+ pw.update();
132
+ });
133
+ }
134
+ createVolumeProfileFromOHLCV(ohlcvData, config = {}) {
135
+ var _a, _b;
136
+ const { priceBins = 20, usePercentageBins = true, priceStep, fromTime = (_a = ohlcvData[0]) === null || _a === void 0 ? void 0 : _a.time, toTime = (_b = ohlcvData[ohlcvData.length - 1]) === null || _b === void 0 ? void 0 : _b.time, position = "right", } = config;
137
+ // Filter data within the time range
138
+ const filteredData = ohlcvData.filter((point) => {
139
+ const isAfterFrom = !fromTime || point.time >= fromTime;
140
+ const isBeforeTo = !toTime || point.time <= toTime;
141
+ return isAfterFrom && isBeforeTo;
142
+ });
143
+ if (filteredData.length === 0) {
144
+ throw new Error("No data in the specified time range");
145
+ }
146
+ // Find min and max prices in the filtered data
147
+ const minPrice = Math.min(...filteredData.map((d) => d.low));
148
+ const maxPrice = Math.max(...filteredData.map((d) => d.high));
149
+ // Calculate price bins
150
+ let priceLevels;
151
+ if (usePercentageBins) {
152
+ // Create price levels based on percentage distribution
153
+ const priceRange = maxPrice - minPrice;
154
+ priceLevels = Array.from({ length: priceBins + 1 }, (_, i) => {
155
+ return minPrice + (priceRange * i) / priceBins;
156
+ });
157
+ }
158
+ else if (priceStep) {
159
+ // Create price levels with fixed step
160
+ const numBins = Math.ceil((maxPrice - minPrice) / priceStep);
161
+ priceLevels = Array.from({ length: numBins + 1 }, (_, i) => {
162
+ return minPrice + priceStep * i;
163
+ });
164
+ }
165
+ else {
166
+ // Default to percentage bins if no step specified
167
+ const priceRange = maxPrice - minPrice;
168
+ priceLevels = Array.from({ length: priceBins + 1 }, (_, i) => {
169
+ return minPrice + (priceRange * i) / priceBins;
170
+ });
171
+ }
172
+ // Initialize volume profile with zero volumes
173
+ const profile = priceLevels.map((price) => ({
174
+ price,
175
+ positiveVolume: 0,
176
+ negativeVolume: 0,
177
+ }));
178
+ // Distribute volume to price bins
179
+ filteredData.forEach((dataPoint) => {
180
+ const { open, close, volume } = dataPoint;
181
+ const isUpBar = close >= open;
182
+ // Find the appropriate price bin for this data point
183
+ // For simplicity, we can distribute volume to the price level closest to the VWAP
184
+ // or you can distribute based on the high-low range
185
+ // Method 1: Simple - distribute to price levels within high-low range
186
+ const relevantLevels = priceLevels.filter((price) => price >= dataPoint.low && price <= dataPoint.high);
187
+ if (relevantLevels.length > 0) {
188
+ const volumePerLevel = volume / relevantLevels.length;
189
+ relevantLevels.forEach((price) => {
190
+ const index = profile.findIndex((p) => p.price === price);
191
+ if (index !== -1) {
192
+ if (isUpBar) {
193
+ profile[index].positiveVolume += volumePerLevel;
194
+ }
195
+ else {
196
+ profile[index].negativeVolume += volumePerLevel;
197
+ }
198
+ }
199
+ });
200
+ }
201
+ else {
202
+ // Fallback: find the closest price level
203
+ const closestPrice = priceLevels.reduce((prev, curr) => {
204
+ const prevDiff = Math.abs(prev - dataPoint.close);
205
+ const currDiff = Math.abs(curr - dataPoint.close);
206
+ return currDiff < prevDiff ? curr : prev;
207
+ });
208
+ const index = profile.findIndex((p) => p.price === closestPrice);
209
+ if (index !== -1) {
210
+ if (isUpBar) {
211
+ profile[index].positiveVolume += volume;
212
+ }
213
+ else {
214
+ profile[index].negativeVolume += volume;
215
+ }
216
+ }
217
+ }
218
+ });
219
+ // Filter out bins with zero volume (optional)
220
+ const filteredProfile = profile.filter((item) => item.positiveVolume > 0 || item.negativeVolume > 0);
221
+ // Sort by price descending (highest price first)
222
+ filteredProfile.sort((a, b) => b.price - a.price);
223
+ return {
224
+ fromTime: fromTime || filteredData[0].time,
225
+ position,
226
+ profile: filteredProfile,
227
+ };
228
+ }
92
229
  }
93
230
  exports.VolumeProfileSeries = VolumeProfileSeries;
231
+ //# sourceMappingURL=volumeProfile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"volumeProfile.js","sourceRoot":"","sources":["../../../src/chart/plugins/volumeProfile.ts"],"names":[],"mappings":";;;AAsCA,MAAa,qBAAqB;IACjC,YAAoB,KAAiC;QAAjC,UAAK,GAAL,KAAK,CAA4B;IAAG,CAAC;IAEjD,YAAY,CACnB,cAAsB,EACtB,cAAsB,EACtB,UAAkB;QAElB,MAAM,eAAe,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,cAAc,CAAC,CAAC;QAChE,MAAM,eAAe,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,cAAc,CAAC,CAAC;QAChE,OAAO;YACN,MAAM,E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CAAC;QAEF,iDAAiD;QACjD,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;QAElD,OAAO;YACN,QAAQ,EAAE,QAAQ,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI;YAC1C,QAAQ;YACR,OAAO,EAAE,eAAe;SACxB,CAAC;IACH,CAAC;CACD;AAlJD,kDAkJC"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Centralized CDN version management for tslab-widgets
3
+ *
4
+ * All CDN dependency versions are managed here to ensure consistency
5
+ * between package.json devDependencies and runtime CDN imports.
6
+ *
7
+ * When updating versions:
8
+ * 1. Update the version in CDN_VERSIONS
9
+ * 2. Update corresponding package.json devDependencies
10
+ * 3. Run `npm run validate` to verify consistency
11
+ */
12
+ export declare const CDN_VERSIONS: {
13
+ readonly react: "18.3.1";
14
+ readonly reactDom: "18.3.1";
15
+ readonly lightweightCharts: "5.1.0";
16
+ readonly reactCsvToTable: "0.0.4";
17
+ readonly reactJsonTree: "0.15.0";
18
+ readonly reactGaugeChart: "0.5.1";
19
+ };
20
+ export declare const CDN_PROVIDER = "https://esm.sh";
21
+ /**
22
+ * Constructs a CDN URL for a given package and version
23
+ */
24
+ export declare function getCdnUrl(pkg: string, version: string): string;
25
+ /**
26
+ * Pre-built CDN URLs for all dependencies
27
+ * Use these constants in widget HTML generation
28
+ */
29
+ export declare const CDN_URLS: {
30
+ readonly react: string;
31
+ readonly reactDom: string;
32
+ readonly lightweightCharts: string;
33
+ readonly reactCsvToTable: string;
34
+ readonly reactJsonTree: string;
35
+ readonly reactGaugeChart: string;
36
+ };
37
+ //# sourceMappingURL=versions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"versions.d.ts","sourceRoot":"","sources":["../../src/config/versions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,eAAO,MAAM,YAAY;;;;;;;CAOf,CAAC;AAEX,eAAO,MAAM,YAAY,mBAAmB,CAAC;AAE7C;;GAEG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAE9D;AAED;;;GAGG;AACH,eAAO,MAAM,QAAQ;;;;;;;CAaX,CAAC"}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ /**
3
+ * Centralized CDN version management for tslab-widgets
4
+ *
5
+ * All CDN dependency versions are managed here to ensure consistency
6
+ * between package.json devDependencies and runtime CDN imports.
7
+ *
8
+ * When updating versions:
9
+ * 1. Update the version in CDN_VERSIONS
10
+ * 2. Update corresponding package.json devDependencies
11
+ * 3. Run `npm run validate` to verify consistency
12
+ */
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.CDN_URLS = exports.getCdnUrl = exports.CDN_PROVIDER = exports.CDN_VERSIONS = void 0;
15
+ exports.CDN_VERSIONS = {
16
+ react: "18.3.1",
17
+ reactDom: "18.3.1",
18
+ lightweightCharts: "5.1.0",
19
+ reactCsvToTable: "0.0.4",
20
+ reactJsonTree: "0.15.0",
21
+ reactGaugeChart: "0.5.1",
22
+ };
23
+ exports.CDN_PROVIDER = "https://esm.sh";
24
+ /**
25
+ * Constructs a CDN URL for a given package and version
26
+ */
27
+ function getCdnUrl(pkg, version) {
28
+ return `${exports.CDN_PROVIDER}/${pkg}@${version}`;
29
+ }
30
+ exports.getCdnUrl = getCdnUrl;
31
+ /**
32
+ * Pre-built CDN URLs for all dependencies
33
+ * Use these constants in widget HTML generation
34
+ */
35
+ exports.CDN_URLS = {
36
+ react: getCdnUrl("react", exports.CDN_VERSIONS.react),
37
+ reactDom: getCdnUrl("react-dom", exports.CDN_VERSIONS.reactDom),
38
+ lightweightCharts: getCdnUrl("lightweight-charts", exports.CDN_VERSIONS.lightweightCharts),
39
+ reactCsvToTable: getCdnUrl("react-csv-to-table", exports.CDN_VERSIONS.reactCsvToTable),
40
+ reactJsonTree: getCdnUrl("react-json-tree", exports.CDN_VERSIONS.reactJsonTree),
41
+ reactGaugeChart: getCdnUrl("react-gauge-chart", exports.CDN_VERSIONS.reactGaugeChart),
42
+ };
43
+ //# sourceMappingURL=versions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"versions.js","sourceRoot":"","sources":["../../src/config/versions.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AAEU,QAAA,YAAY,GAAG;IAC3B,KAAK,EAAE,QAAQ;IACf,QAAQ,EAAE,QAAQ;IAClB,iBAAiB,EAAE,OAAO;IAC1B,eAAe,EAAE,OAAO;IACxB,aAAa,EAAE,QAAQ;IACvB,eAAe,EAAE,OAAO;CACf,CAAC;AAEE,QAAA,YAAY,GAAG,gBAAgB,CAAC;AAE7C;;GAEG;AACH,SAAgB,SAAS,CAAC,GAAW,EAAE,OAAe;IACrD,OAAO,GAAG,oBAAY,IAAI,GAAG,IAAI,OAAO,EAAE,CAAC;AAC5C,CAAC;AAFD,8BAEC;AAED;;;GAGG;AACU,QAAA,QAAQ,GAAG;IACvB,KAAK,EAAE,SAAS,CAAC,OAAO,EAAE,oBAAY,CAAC,KAAK,CAAC;IAC7C,QAAQ,EAAE,SAAS,CAAC,WAAW,EAAE,oBAAY,CAAC,QAAQ,CAAC;IACvD,iBAAiB,EAAE,SAAS,CAC3B,oBAAoB,EACpB,oBAAY,CAAC,iBAAiB,CAC9B;IACD,eAAe,EAAE,SAAS,CACzB,oBAAoB,EACpB,oBAAY,CAAC,eAAe,CAC5B;IACD,aAAa,EAAE,SAAS,CAAC,iBAAiB,EAAE,oBAAY,CAAC,aAAa,CAAC;IACvE,eAAe,EAAE,SAAS,CAAC,mBAAmB,EAAE,oBAAY,CAAC,eAAe,CAAC;CACpE,CAAC"}
package/dist/csv/csv.d.ts CHANGED
@@ -3,3 +3,4 @@ declare function csv(data: string[], options?: {
3
3
  maxHeight?: number;
4
4
  }): void;
5
5
  export { csv };
6
+ //# sourceMappingURL=csv.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"csv.d.ts","sourceRoot":"","sources":["../../src/csv/csv.ts"],"names":[],"mappings":"AAKA,iBAAS,GAAG,CACX,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,CAAC,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,QA4EpD;AAED,OAAO,EAAE,GAAG,EAAE,CAAC"}
package/dist/csv/csv.js CHANGED
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.csv = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const tslab = tslib_1.__importStar(require("tslab"));
6
+ const versions_1 = require("../config/versions");
6
7
  // https://github.com/marudhupandiyang/react-csv-to-table
7
8
  function csv(data, options) {
8
9
  const reactComponentId = `_csv_widget${Math.random().toString(36).substring(2, 9)}`;
@@ -23,19 +24,19 @@ function csv(data, options) {
23
24
  }
24
25
  }
25
26
  }
26
- ${(options === null || options === void 0 ? void 0 : options.customCss) || ''}
27
+ ${(options === null || options === void 0 ? void 0 : options.customCss) || ""}
27
28
  </style>
28
29
  <div id="${reactComponentId}" style="margin:auto;" />
29
30
  <script type="module">
30
- import React from "https://esm.sh/react@18.3.1";
31
- import ReactDOM from "https://esm.sh/react-dom@18.3.1";
32
- import { CsvToHtmlTable } from "https://esm.sh/react-csv-to-table@0.0.4";
31
+ import React from "${versions_1.CDN_URLS.react}";
32
+ import ReactDOM from "${versions_1.CDN_URLS.reactDom}";
33
+ import { CsvToHtmlTable } from "${versions_1.CDN_URLS.reactCsvToTable}";
33
34
  const h = React.createElement;
34
35
 
35
36
  const reactJupyterLabComponentId = "${reactComponentId}";
36
37
  const jupyterLabReactComponentContainer = document.getElementById("${reactComponentId}");
37
38
 
38
- const data = [${data.map((d) => JSON.stringify(d)).join(',')}];
39
+ const data = [${data.map((d) => JSON.stringify(d)).join(",")}];
39
40
  const csvWidgets = groupArrayIntoPairs(data);
40
41
  const rows = csvWidgets.map((rowDataPair, idx) => {
41
42
  const cid1 = reactJupyterLabComponentId + '-0';
@@ -44,7 +45,7 @@ function csv(data, options) {
44
45
  display: 'flex',
45
46
  flexDirection: 'column',
46
47
  alignSelf: 'baseline',
47
- ${(options === null || options === void 0 ? void 0 : options.maxHeight) ? `maxHeight:${options.maxHeight},overflowY: "scroll"` : ''}
48
+ ${(options === null || options === void 0 ? void 0 : options.maxHeight) ? `maxHeight:${options.maxHeight},overflowY: "scroll"` : ""}
48
49
  };
49
50
  const key = 'row-' + idx;
50
51
  return (
@@ -81,3 +82,4 @@ function csv(data, options) {
81
82
  tslab.display.html(html);
82
83
  }
83
84
  exports.csv = csv;
85
+ //# sourceMappingURL=csv.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"csv.js","sourceRoot":"","sources":["../../src/csv/csv.ts"],"names":[],"mappings":";;;;AAAA,qDAA+B;AAE/B,iDAA8C;AAE9C,yDAAyD;AACzD,SAAS,GAAG,CACX,IAAc,EACd,OAAoD;IAEpD,MAAM,gBAAgB,GAAG,cAAc,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;IACpF,MAAM,IAAI,GAAG;;;;;;;;;;;;;;;;;QAiBN,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,KAAI,EAAE;;eAEjB,gBAAgB;;2BAEJ,mBAAQ,CAAC,KAAK;8BACX,mBAAQ,CAAC,QAAQ;wCACP,mBAAQ,CAAC,eAAe;;;4CAGpB,gBAAgB;2EACe,gBAAgB;;sBAErE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;;;;;;;;;YAStD,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,EAAC,CAAC,CAAC,aAAa,OAAO,CAAC,SAAS,sBAAsB,CAAC,CAAC,CAAC,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCvF,CAAC;IACH,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAEQ,kBAAG"}
@@ -7,3 +7,4 @@ declare function gauge(width: number | undefined, props: {
7
7
  title?: string;
8
8
  }): void;
9
9
  export { gauge };
10
+ //# sourceMappingURL=gauge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gauge.d.ts","sourceRoot":"","sources":["../../src/gauge/gauge.ts"],"names":[],"mappings":"AAKA,iBAAS,KAAK,CACb,KAAK,oBAAM,EACX,KAAK,EAAE;IACN,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CACf,QAmDD;AAED,OAAO,EAAE,KAAK,EAAE,CAAC"}