@pipsend/charts 2.3.1 → 2.3.3

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.
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * @license
3
- * Pipsend Charts v2.3.1
3
+ * Pipsend Charts v2.3.3
4
4
  * Copyright (c) 2026 Pipsend
5
5
  * Licensed under MIT License
6
6
  * Built on TradingView Lightweight Charts™ (Apache 2.0)
@@ -2484,6 +2484,22 @@ class SeriesBarColorer {
2484
2484
  // Used to avoid binary search if bars are already known
2485
2485
  return this._private__styleGetter(this._private__findBar, this._private__series._internal_options(), barIndex, precomputedBars);
2486
2486
  }
2487
+ /**
2488
+ * Like `barStyle`, but returns null instead of throwing when the bar is
2489
+ * gone.
2490
+ *
2491
+ * Recolouring walks items that were laid out against the data as it was. A
2492
+ * bar that has since disappeared is not an error there: the view is about
2493
+ * to be rebuilt from the new data anyway. Letting it throw took down
2494
+ * whatever asked for the repaint — including `setData`, which left the
2495
+ * series without its data and the pane empty until the page was reloaded.
2496
+ */
2497
+ _internal_barStyleOrNull(barIndex, precomputedBars) {
2498
+ if (precomputedBars === undefined && this._private__series._internal_bars()._internal_valueAt(barIndex) === null) {
2499
+ return null;
2500
+ }
2501
+ return this._internal_barStyle(barIndex, precomputedBars);
2502
+ }
2487
2503
  }
2488
2504
 
2489
2505
  /**
@@ -11032,10 +11048,14 @@ class SeriesPaneViewBase {
11032
11048
  return this._internal__itemsVisibleRange === null ? null : this._internal__renderer;
11033
11049
  }
11034
11050
  _internal__updateOptions() {
11035
- this._internal__items = this._internal__items.map((item) => ({
11036
- ...item,
11037
- ...this._internal__series._internal_barColorer()._internal_barStyle(item._internal_time),
11038
- }));
11051
+ const colorer = this._internal__series._internal_barColorer();
11052
+ this._internal__items = this._internal__items.map((item) => {
11053
+ // An item whose bar is gone keeps the colour it had. Throwing here
11054
+ // took down whatever asked for the repaint — `setData` among them,
11055
+ // which left the series without its data and the pane empty.
11056
+ const style = colorer._internal_barStyleOrNull(item._internal_time);
11057
+ return style === null ? item : { ...item, ...style };
11058
+ });
11039
11059
  }
11040
11060
  _internal__clearVisibleRange() {
11041
11061
  this._internal__itemsVisibleRange = null;
@@ -15464,9 +15484,6 @@ function createUpDownMarkers(series, options = {}) {
15464
15484
  return wrapper;
15465
15485
  }
15466
15486
 
15467
- /**
15468
- * Gestor de marcadores de posiciones de trading
15469
- */
15470
15487
  class PositionMarkersManager {
15471
15488
  constructor(series, options) {
15472
15489
  this._private__markersPlugin = null;
@@ -15486,30 +15503,20 @@ class PositionMarkersManager {
15486
15503
  };
15487
15504
  this._private__markersPlugin = createSeriesMarkers(series);
15488
15505
  }
15489
- /**
15490
- * Agrega una posición al gráfico
15491
- */
15492
15506
  addPosition(position) {
15493
15507
  this._private__positions.push(position);
15494
15508
  this._private__updateMarkers();
15495
15509
  }
15496
- /**
15497
- * Agrega múltiples posiciones al gráfico
15498
- */
15499
15510
  addPositions(positions) {
15500
15511
  this._private__positions.push(...positions);
15501
15512
  this._private__updateMarkers();
15502
15513
  }
15503
- /**
15504
- * Establece las posiciones (reemplaza las existentes)
15505
- */
15514
+ /** Replaces every position currently on the chart. */
15506
15515
  setPositions(positions) {
15507
15516
  this._private__positions = [...positions];
15508
15517
  this._private__updateMarkers();
15509
15518
  }
15510
- /**
15511
- * Cierra una posición abierta agregando el punto de salida
15512
- */
15519
+ /** Closes an open position by giving it an exit point. */
15513
15520
  closePosition(id, exit, exitText) {
15514
15521
  const position = this._private__positions.find(p => p.id === id);
15515
15522
  if (position) {
@@ -15523,29 +15530,17 @@ class PositionMarkersManager {
15523
15530
  this._private__updateMarkers();
15524
15531
  }
15525
15532
  }
15526
- /**
15527
- * Elimina una posición por ID
15528
- */
15529
15533
  removePosition(id) {
15530
15534
  this._private__positions = this._private__positions.filter(p => p.id !== id);
15531
15535
  this._private__updateMarkers();
15532
15536
  }
15533
- /**
15534
- * Limpia todas las posiciones
15535
- */
15536
15537
  clearPositions() {
15537
15538
  this._private__positions = [];
15538
15539
  this._private__updateMarkers();
15539
15540
  }
15540
- /**
15541
- * Obtiene todas las posiciones actuales
15542
- */
15543
15541
  getPositions() {
15544
15542
  return this._private__positions;
15545
15543
  }
15546
- /**
15547
- * Actualiza las opciones del gestor
15548
- */
15549
15544
  applyOptions(options) {
15550
15545
  if (options.longColors) {
15551
15546
  this._private__options.longColors = {
@@ -15570,9 +15565,6 @@ class PositionMarkersManager {
15570
15565
  }
15571
15566
  this._private__updateMarkers();
15572
15567
  }
15573
- /**
15574
- * Convierte las posiciones a marcadores de serie
15575
- */
15576
15568
  _private__positionsToMarkers() {
15577
15569
  const markers = [];
15578
15570
  for (const position of this._private__positions) {
@@ -15619,18 +15611,12 @@ class PositionMarkersManager {
15619
15611
  }
15620
15612
  return markers;
15621
15613
  }
15622
- /**
15623
- * Actualiza los marcadores en el gráfico
15624
- */
15625
15614
  _private__updateMarkers() {
15626
15615
  if (this._private__markersPlugin) {
15627
15616
  const markers = this._private__positionsToMarkers();
15628
15617
  this._private__markersPlugin.setMarkers(markers);
15629
15618
  }
15630
15619
  }
15631
- /**
15632
- * Desconecta el plugin y limpia recursos
15633
- */
15634
15620
  detach() {
15635
15621
  if (this._private__markersPlugin) {
15636
15622
  this._private__markersPlugin.detach();
@@ -15640,47 +15626,18 @@ class PositionMarkersManager {
15640
15626
  }
15641
15627
  }
15642
15628
  /**
15643
- * Crea un gestor de marcadores de posiciones de trading
15644
- *
15645
- * @param series - Serie a la que se adjuntarán los marcadores
15646
- * @param positions - Posiciones iniciales (opcional)
15647
- * @param options - Opciones de configuración (opcional)
15648
- * @returns Instancia del gestor de posiciones
15629
+ * Marks trades on a series with an arrow at the entry and, once closed, at the
15630
+ * exit.
15649
15631
  *
15650
15632
  * @example
15651
15633
  * ```typescript
15652
- * // Crear el gestor
15653
- * const positionMarkers = createPositionMarkers(candleSeries);
15654
- *
15655
- * // Agregar una posición long
15656
- * positionMarkers.addPosition({
15657
- * type: 'long',
15658
- * entry: { time: '2023-01-01', price: 100.50 },
15659
- * exit: { time: '2023-01-05', price: 105.20 },
15660
- * id: 'pos-1'
15661
- * });
15662
- *
15663
- * // Agregar una posición short
15664
- * positionMarkers.addPosition({
15665
- * type: 'short',
15666
- * entry: { time: '2023-01-10', price: 110.00 },
15667
- * exit: { time: '2023-01-15', price: 107.50 },
15668
- * id: 'pos-2'
15669
- * });
15670
- *
15671
- * // Agregar múltiples posiciones
15672
- * positionMarkers.setPositions([
15673
- * {
15634
+ * const markers = createPositionMarkers(candleSeries);
15635
+ * markers.addPosition({
15674
15636
  * type: 'long',
15675
- * entry: { time: '2023-02-01', price: 95.00 },
15676
- * exit: { time: '2023-02-10', price: 98.50 }
15677
- * },
15678
- * {
15679
- * type: 'short',
15680
- * entry: { time: '2023-02-15', price: 102.00 },
15681
- * exit: { time: '2023-02-20', price: 99.00 }
15682
- * }
15683
- * ]);
15637
+ * entry: { time: '2023-01-01', price: 100.50 },
15638
+ * exit: { time: '2023-01-05', price: 105.20 },
15639
+ * id: 'pos-1',
15640
+ * });
15684
15641
  * ```
15685
15642
  */
15686
15643
  function createPositionMarkers(series, positions, options) {
@@ -19931,9 +19888,6 @@ function createTradingLine(series, chart, options) {
19931
19888
  return new DraggablePriceLine(chart, series, lineOptions);
19932
19889
  }
19933
19890
 
19934
- /**
19935
- * Interactive Line Manager - Permite crear líneas haciendo clic en el gráfico
19936
- */
19937
19891
  class InteractiveLineManager {
19938
19892
  constructor(chart, series) {
19939
19893
  this._private__container = null;
@@ -19962,10 +19916,9 @@ class InteractiveLineManager {
19962
19916
  return price === null ? 0 : price;
19963
19917
  }
19964
19918
  /**
19965
- * Activa el modo de creación de líneas por clic
19966
- * @param mode - Tipo de línea a crear
19967
- * @param customOptions - Opciones personalizadas para líneas custom
19968
- * @returns Promesa que se resuelve cuando el usuario hace clic
19919
+ * Arms the chart so the next click drops a line.
19920
+ *
19921
+ * @returns The line, once the user has clicked.
19969
19922
  */
19970
19923
  enableClickToCreate(mode, customOptions) {
19971
19924
  if (!this._private__container) {
@@ -19986,9 +19939,6 @@ class InteractiveLineManager {
19986
19939
  this._private__container.addEventListener('click', this._private__clickHandler);
19987
19940
  });
19988
19941
  }
19989
- /**
19990
- * Desactiva el modo de creación por clic
19991
- */
19992
19942
  disableClickToCreate() {
19993
19943
  if (this._private__container && this._private__clickHandler) {
19994
19944
  this._private__container.removeEventListener('click', this._private__clickHandler);
@@ -20078,31 +20028,21 @@ class InteractiveLineManager {
20078
20028
  }
20079
20029
  return new DraggablePriceLine(this._private__chart, this._private__series, options);
20080
20030
  }
20081
- /**
20082
- * Obtiene el modo actual de creación
20083
- */
20084
20031
  getCreationMode() {
20085
20032
  return this._private__creationMode;
20086
20033
  }
20087
- /**
20088
- * Verifica si está en modo de creación
20089
- */
20090
20034
  isCreating() {
20091
20035
  return this._private__creationMode !== null;
20092
20036
  }
20093
20037
  }
20094
20038
  /**
20095
- * Crea un manager interactivo para añadir líneas con clics
20096
- * @param chart - Chart instance
20097
- * @param series - Series instance
20098
- * @returns InteractiveLineManager
20039
+ * Lets the user place draggable lines by clicking the chart.
20040
+ *
20099
20041
  * @example
20100
20042
  * ```typescript
20101
20043
  * const manager = createInteractiveLineManager(chart, candleSeries);
20102
- *
20103
- * // Activar modo de creación
20104
20044
  * const line = await manager.enableClickToCreate('stop-loss', {
20105
- * onDragEnd: (price) => console.log('SL:', price)
20045
+ * onDragEnd: (price) => console.log('SL:', price),
20106
20046
  * });
20107
20047
  * ```
20108
20048
  */
@@ -23965,9 +23905,6 @@ function createVerticalLineTool(context, options) {
23965
23905
  return new VerticalLineTool(context, options);
23966
23906
  }
23967
23907
 
23968
- /**
23969
- * Fibonacci Calculator - Cálculos de niveles de retroceso de Fibonacci
23970
- */
23971
23908
  /**
23972
23909
  * Standard Fibonacci retracement ratios
23973
23910
  */
@@ -24113,10 +24050,7 @@ class FibonacciPaneView {
24113
24050
  }
24114
24051
  }
24115
24052
 
24116
- /**
24117
- * Fibonacci Retracement Tool - Herramienta para dibujar niveles de Fibonacci
24118
- * Muestra niveles estándar: 0%, 23.6%, 38.2%, 50%, 61.8%, 78.6%, 100%
24119
- */
24053
+ /** Draws 0, 23.6, 38.2, 50, 61.8, 78.6 and 100% unless `levels` says otherwise. */
24120
24054
  /** A ratio and the label it is shown with, derived rather than stored. */
24121
24055
  function toRatio(ratio) {
24122
24056
  return { _internal_ratio: ratio, _internal_label: `${(ratio * 100).toFixed(1)}%` };
@@ -27190,7 +27124,7 @@ class BrushTool extends DrawingToolBase {
27190
27124
  if (this._private__isOverAnotherDrawing()) {
27191
27125
  return;
27192
27126
  }
27193
- const point = this._private__toPanePoint(event);
27127
+ const point = this._private__toPanePoint(event, false);
27194
27128
  if (point === null) {
27195
27129
  return;
27196
27130
  }
@@ -27209,7 +27143,7 @@ class BrushTool extends DrawingToolBase {
27209
27143
  if (!this._private__isDrawing) {
27210
27144
  return;
27211
27145
  }
27212
- const point = this._private__toPanePoint(event);
27146
+ const point = this._private__toPanePoint(event, true);
27213
27147
  if (point === null) {
27214
27148
  return;
27215
27149
  }
@@ -27280,13 +27214,51 @@ class BrushTool extends DrawingToolBase {
27280
27214
  }
27281
27215
  this._private__pointerId = null;
27282
27216
  }
27283
- _private__toPanePoint(event) {
27217
+ /**
27218
+ * Where a press lands relative to the drawing area, or null if it lands
27219
+ * outside it. `clamp` pins the point to the edge instead, for a stroke that
27220
+ * is already under way.
27221
+ */
27222
+ _private__toPanePoint(event, clamp) {
27223
+ const area = this._private__drawArea();
27224
+ if (area === null) {
27225
+ return null;
27226
+ }
27227
+ const x = event.clientX - area._internal_left;
27228
+ const y = event.clientY - area._internal_top;
27229
+ if (clamp) {
27230
+ return {
27231
+ _internal_x: Math.max(0, Math.min(area._internal_width, x)),
27232
+ _internal_y: Math.max(0, Math.min(area._internal_height, y)),
27233
+ };
27234
+ }
27235
+ if (x < 0 || x > area._internal_width || y < 0 || y > area._internal_height) {
27236
+ return null;
27237
+ }
27238
+ return { _internal_x: x, _internal_y: y };
27239
+ }
27240
+ /**
27241
+ * The pane's element is the whole row, price axis cells included, so its
27242
+ * bounds are not the drawing area's. Taking them for it is what let a press
27243
+ * on an axis start a stroke — and be swallowed, leaving the chart unable to
27244
+ * be stretched while the brush was armed.
27245
+ */
27246
+ _private__drawArea() {
27284
27247
  const paneElement = this._private__paneElement();
27285
27248
  if (paneElement === null) {
27286
27249
  return null;
27287
27250
  }
27288
27251
  const rect = paneElement.getBoundingClientRect();
27289
- return { _internal_x: event.clientX - rect.left, _internal_y: event.clientY - rect.top };
27252
+ let left = 0;
27253
+ let width = rect.width;
27254
+ // The time scale measures the drawing area; the left axis, when shown, is
27255
+ // what stands between it and the row's edge.
27256
+ const paneWidth = this._chart.timeScale().width();
27257
+ if (paneWidth > 0) {
27258
+ left = this._chart.priceScale('left').width();
27259
+ width = paneWidth;
27260
+ }
27261
+ return { _internal_left: rect.left + left, _internal_top: rect.top, _internal_width: width, _internal_height: rect.height };
27290
27262
  }
27291
27263
  _private__paneElement() {
27292
27264
  try {
@@ -27909,9 +27881,6 @@ function createTextTool(context, options) {
27909
27881
  return new TextTool(context, options);
27910
27882
  }
27911
27883
 
27912
- /**
27913
- * Position Calculator - Cálculos de P&L, pips, R:R para trading
27914
- */
27915
27884
  class PositionCalculator {
27916
27885
  constructor(pipConfig) {
27917
27886
  this._private__pipConfig = pipConfig;
@@ -28063,9 +28032,6 @@ function getPipConfig(symbolOrPrice, price) {
28063
28032
  };
28064
28033
  }
28065
28034
 
28066
- /**
28067
- * Ruler Calculator - Cálculos de distancia, pips, tiempo para mediciones
28068
- */
28069
28035
  class RulerCalculator {
28070
28036
  constructor(pipConfig) {
28071
28037
  this._private__pipConfig = pipConfig;
@@ -28184,10 +28150,7 @@ class RulerPaneView {
28184
28150
  }
28185
28151
  }
28186
28152
 
28187
- /**
28188
- * Measurement Ruler Tool - Herramienta para medir distancia entre dos puntos
28189
- * Muestra pips, porcentaje, tiempo transcurrido y número de barras
28190
- */
28153
+ /** Measures two points: pips, percent, elapsed time and bar count. */
28191
28154
  class RulerTool extends DrawingToolBase {
28192
28155
  constructor(context, options) {
28193
28156
  super(context, 'ruler-tool', options);
@@ -28747,10 +28710,7 @@ class PositionPaneView {
28747
28710
  }
28748
28711
  }
28749
28712
 
28750
- /**
28751
- * Position Tool - Herramienta unificada para marcar posiciones long/short
28752
- * Muestra dos rectángulos ajustables (profit/loss) con línea vertical conectora
28753
- */
28713
+ /** Two adjustable boxes, profit and loss, joined by a vertical connector. */
28754
28714
  class PositionTool extends DrawingToolBase {
28755
28715
  constructor(context, options) {
28756
28716
  super(context, 'position-tool', options);
@@ -30645,7 +30605,7 @@ const customSeriesDefaultOptions = {
30645
30605
  * Returns the current version as a string. For example `'1.0.0'`.
30646
30606
  */
30647
30607
  function version() {
30648
- return "2.3.1";
30608
+ return "2.3.3";
30649
30609
  }
30650
30610
 
30651
30611
  export { areaSeries as AreaSeries, ArrowTool, barSeries as BarSeries, baselineSeries as BaselineSeries, BrushTool, candlestickSeries as CandlestickSeries, CircleTool, ColorType, CrossLineTool, CrosshairMode, DEFAULT_SESSIONS, DraggablePriceLine, DrawingToolsManager, EXTENDED_FIBONACCI_RATIOS, FibonacciCalculator, FibonacciExtensionTool, FibonacciFanTool, FibonacciTool, GanttTool, histogramSeries as HistogramSeries, HorizontalLineTool, InteractiveLineManager, LastPriceAnimationMode, lineSeries as LineSeries, LineStyle, LineType, MismatchDirection, ParallelChannelTool, PitchforkTool, PolygonTool, PositionCalculator, PositionLine, PositionMarkersManager, PositionTool, PriceLineSource, PriceScaleMode, RectangleTool, RulerCalculator, RulerTool, STANDARD_FIBONACCI_RATIOS, TextTool, TickMarkType, TrackingModeExitMode, TradingSessionsIndicator, TrendLineTool, VerticalLineTool, VolumeProfileIndicator, applyADX, applyATR, applyBollingerBands, applyCCI, applyDonchianChannels, applyEMA, applyHeikinAshi, applyIchimoku, applyKeltnerChannels, applyMACD, applyMFI, applyOBV, applyParabolicSAR, applyPivotPoints, applyRSI, applySMA, applyStochastic, applySuperTrend, applyVWAP, applyVolume, applyWMA, applyWilliamsR, calculateHeikinAshi, calculatePipConfig, coordinateFromTime, createArrowTool, createBrushTool, createChart, createChartEx, createCircleTool, createCrossLineTool, createFibonacciExtensionTool, createFibonacciFanTool, createFibonacciTool, createGanttTool, createHorizontalLineTool, createImageWatermark, createInteractiveLineManager, createOptionsChart, createParallelChannelTool, createPitchforkTool, createPolygonTool, createPositionLine, createPositionMarkers, createPositionTool, createRectangleTool, createRulerTool, createSeriesMarkers, createTextTool, createTextWatermark, createTradingLine, createTradingSessionsIndicator, createTrendLineTool, createUpDownMarkers, createVerticalLineTool, createVolumeProfileIndicator, createYieldCurveChart, customSeriesDefaultOptions, defaultHorzScaleBehavior, getPipConfig, hideSeriesPaint, isBusinessDay, isUTCTimestamp, setSeriesVolumes, setVolumeProfileData, timeFromCoordinate, version };