@pipsend/charts 2.3.2 → 2.3.4

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.2
3
+ * Pipsend Charts v2.3.4
4
4
  * Copyright (c) 2026 Pipsend
5
5
  * Licensed under MIT License
6
6
  * Built on TradingView Lightweight Charts™ (Apache 2.0)
@@ -2485,6 +2485,22 @@
2485
2485
  // Used to avoid binary search if bars are already known
2486
2486
  return this._private__styleGetter(this._private__findBar, this._private__series._internal_options(), barIndex, precomputedBars);
2487
2487
  }
2488
+ /**
2489
+ * Like `barStyle`, but returns null instead of throwing when the bar is
2490
+ * gone.
2491
+ *
2492
+ * Recolouring walks items that were laid out against the data as it was. A
2493
+ * bar that has since disappeared is not an error there: the view is about
2494
+ * to be rebuilt from the new data anyway. Letting it throw took down
2495
+ * whatever asked for the repaint — including `setData`, which left the
2496
+ * series without its data and the pane empty until the page was reloaded.
2497
+ */
2498
+ _internal_barStyleOrNull(barIndex, precomputedBars) {
2499
+ if (precomputedBars === undefined && this._private__series._internal_bars()._internal_valueAt(barIndex) === null) {
2500
+ return null;
2501
+ }
2502
+ return this._internal_barStyle(barIndex, precomputedBars);
2503
+ }
2488
2504
  }
2489
2505
 
2490
2506
  /**
@@ -11428,10 +11444,14 @@
11428
11444
  return this._internal__itemsVisibleRange === null ? null : this._internal__renderer;
11429
11445
  }
11430
11446
  _internal__updateOptions() {
11431
- this._internal__items = this._internal__items.map((item) => ({
11432
- ...item,
11433
- ...this._internal__series._internal_barColorer()._internal_barStyle(item._internal_time),
11434
- }));
11447
+ const colorer = this._internal__series._internal_barColorer();
11448
+ this._internal__items = this._internal__items.map((item) => {
11449
+ // An item whose bar is gone keeps the colour it had. Throwing here
11450
+ // took down whatever asked for the repaint — `setData` among them,
11451
+ // which left the series without its data and the pane empty.
11452
+ const style = colorer._internal_barStyleOrNull(item._internal_time);
11453
+ return style === null ? item : { ...item, ...style };
11454
+ });
11435
11455
  }
11436
11456
  _internal__clearVisibleRange() {
11437
11457
  this._internal__itemsVisibleRange = null;
@@ -11508,7 +11528,7 @@
11508
11528
  return {
11509
11529
  _internal_time: row._internal_index,
11510
11530
  _internal_x: NaN,
11511
- ...colorer._internal_barStyle(row._internal_index),
11531
+ ...colorer._internal_barStyle(row._internal_index, { _internal_value: row }),
11512
11532
  _internal_originalData: row._internal_data,
11513
11533
  };
11514
11534
  });
@@ -12826,7 +12846,9 @@
12826
12846
  const colorer = this._internal__series._internal_barColorer();
12827
12847
  this._internal__items = this._internal__series._internal_bars()._internal_rows().map((row) => {
12828
12848
  const value = row._internal_value[3 /* PlotRowValueIndex.Close */];
12829
- return this._internal__createRawItem(row._internal_index, value, colorer);
12849
+ // The row travels with the point: without it the colorer looks it up
12850
+ // again by index, and that lookup could fail and take the repaint down.
12851
+ return this._internal__createRawItem(row._internal_index, value, colorer, row);
12830
12852
  });
12831
12853
  }
12832
12854
  }
@@ -12994,10 +13016,10 @@
12994
13016
  super(...arguments);
12995
13017
  this._internal__renderer = new PaneRendererLine();
12996
13018
  }
12997
- _internal__createRawItem(time, price, colorer) {
13019
+ _internal__createRawItem(time, price, colorer, row) {
12998
13020
  return {
12999
13021
  ...this._internal__createRawItemBase(time, price),
13000
- ...colorer._internal_barStyle(time),
13022
+ ...colorer._internal_barStyle(time, { _internal_value: row }),
13001
13023
  };
13002
13024
  }
13003
13025
  _internal__prepareRendererData() {
@@ -13471,10 +13493,10 @@
13471
13493
  this._private__baselineLineRenderer = new PaneRendererBaselineLine();
13472
13494
  this._internal__renderer._internal_setRenderers([this._private__baselineAreaRenderer, this._private__baselineLineRenderer]);
13473
13495
  }
13474
- _internal__createRawItem(time, price, colorer) {
13496
+ _internal__createRawItem(time, price, colorer, row) {
13475
13497
  return {
13476
13498
  ...this._internal__createRawItemBase(time, price),
13477
- ...colorer._internal_barStyle(time),
13499
+ ...colorer._internal_barStyle(time, { _internal_value: row }),
13478
13500
  };
13479
13501
  }
13480
13502
  _internal__prepareRendererData() {
@@ -13594,10 +13616,10 @@
13594
13616
  this._private__lineRenderer = new PaneRendererLine();
13595
13617
  this._internal__renderer._internal_setRenderers([this._private__areaRenderer, this._private__lineRenderer]);
13596
13618
  }
13597
- _internal__createRawItem(time, price, colorer) {
13619
+ _internal__createRawItem(time, price, colorer, row) {
13598
13620
  return {
13599
13621
  ...this._internal__createRawItemBase(time, price),
13600
- ...colorer._internal_barStyle(time),
13622
+ ...colorer._internal_barStyle(time, { _internal_value: row }),
13601
13623
  };
13602
13624
  }
13603
13625
  _internal__prepareRendererData() {
@@ -13790,6 +13812,9 @@
13790
13812
  }
13791
13813
  _internal__fillRawPoints() {
13792
13814
  const colorer = this._internal__series._internal_barColorer();
13815
+ // The row goes to the colorer as it is. Asking for the style by index
13816
+ // alone made it look the row up again, and that second lookup could come
13817
+ // back empty and throw, taking the whole repaint down with it.
13793
13818
  this._internal__items = this._internal__series._internal_bars()._internal_rows().map((row) => this._internal__createRawItem(row._internal_index, row, colorer));
13794
13819
  }
13795
13820
  }
@@ -13802,7 +13827,7 @@
13802
13827
  _internal__createRawItem(time, bar, colorer) {
13803
13828
  return {
13804
13829
  ...this._internal__createDefaultItem(time, bar, colorer),
13805
- ...colorer._internal_barStyle(time),
13830
+ ...colorer._internal_barStyle(time, { _internal_value: bar }),
13806
13831
  };
13807
13832
  }
13808
13833
  _internal__prepareRendererData() {
@@ -13995,7 +14020,7 @@
13995
14020
  _internal__createRawItem(time, bar, colorer) {
13996
14021
  return {
13997
14022
  ...this._internal__createDefaultItem(time, bar, colorer),
13998
- ...colorer._internal_barStyle(time),
14023
+ ...colorer._internal_barStyle(time, { _internal_value: bar }),
13999
14024
  };
14000
14025
  }
14001
14026
  _internal__prepareRendererData() {
@@ -14163,10 +14188,10 @@
14163
14188
  super(...arguments);
14164
14189
  this._internal__renderer = new PaneRendererHistogram();
14165
14190
  }
14166
- _internal__createRawItem(time, price, colorer) {
14191
+ _internal__createRawItem(time, price, colorer, row) {
14167
14192
  return {
14168
14193
  ...this._internal__createRawItemBase(time, price),
14169
- ...colorer._internal_barStyle(time),
14194
+ ...colorer._internal_barStyle(time, { _internal_value: row }),
14170
14195
  };
14171
14196
  }
14172
14197
  _internal__prepareRendererData() {
@@ -15860,9 +15885,6 @@
15860
15885
  return wrapper;
15861
15886
  }
15862
15887
 
15863
- /**
15864
- * Gestor de marcadores de posiciones de trading
15865
- */
15866
15888
  class PositionMarkersManager {
15867
15889
  constructor(series, options) {
15868
15890
  this._private__markersPlugin = null;
@@ -15882,30 +15904,20 @@
15882
15904
  };
15883
15905
  this._private__markersPlugin = createSeriesMarkers(series);
15884
15906
  }
15885
- /**
15886
- * Agrega una posición al gráfico
15887
- */
15888
15907
  addPosition(position) {
15889
15908
  this._private__positions.push(position);
15890
15909
  this._private__updateMarkers();
15891
15910
  }
15892
- /**
15893
- * Agrega múltiples posiciones al gráfico
15894
- */
15895
15911
  addPositions(positions) {
15896
15912
  this._private__positions.push(...positions);
15897
15913
  this._private__updateMarkers();
15898
15914
  }
15899
- /**
15900
- * Establece las posiciones (reemplaza las existentes)
15901
- */
15915
+ /** Replaces every position currently on the chart. */
15902
15916
  setPositions(positions) {
15903
15917
  this._private__positions = [...positions];
15904
15918
  this._private__updateMarkers();
15905
15919
  }
15906
- /**
15907
- * Cierra una posición abierta agregando el punto de salida
15908
- */
15920
+ /** Closes an open position by giving it an exit point. */
15909
15921
  closePosition(id, exit, exitText) {
15910
15922
  const position = this._private__positions.find(p => p.id === id);
15911
15923
  if (position) {
@@ -15919,29 +15931,17 @@
15919
15931
  this._private__updateMarkers();
15920
15932
  }
15921
15933
  }
15922
- /**
15923
- * Elimina una posición por ID
15924
- */
15925
15934
  removePosition(id) {
15926
15935
  this._private__positions = this._private__positions.filter(p => p.id !== id);
15927
15936
  this._private__updateMarkers();
15928
15937
  }
15929
- /**
15930
- * Limpia todas las posiciones
15931
- */
15932
15938
  clearPositions() {
15933
15939
  this._private__positions = [];
15934
15940
  this._private__updateMarkers();
15935
15941
  }
15936
- /**
15937
- * Obtiene todas las posiciones actuales
15938
- */
15939
15942
  getPositions() {
15940
15943
  return this._private__positions;
15941
15944
  }
15942
- /**
15943
- * Actualiza las opciones del gestor
15944
- */
15945
15945
  applyOptions(options) {
15946
15946
  if (options.longColors) {
15947
15947
  this._private__options.longColors = {
@@ -15966,9 +15966,6 @@
15966
15966
  }
15967
15967
  this._private__updateMarkers();
15968
15968
  }
15969
- /**
15970
- * Convierte las posiciones a marcadores de serie
15971
- */
15972
15969
  _private__positionsToMarkers() {
15973
15970
  const markers = [];
15974
15971
  for (const position of this._private__positions) {
@@ -16015,18 +16012,12 @@
16015
16012
  }
16016
16013
  return markers;
16017
16014
  }
16018
- /**
16019
- * Actualiza los marcadores en el gráfico
16020
- */
16021
16015
  _private__updateMarkers() {
16022
16016
  if (this._private__markersPlugin) {
16023
16017
  const markers = this._private__positionsToMarkers();
16024
16018
  this._private__markersPlugin.setMarkers(markers);
16025
16019
  }
16026
16020
  }
16027
- /**
16028
- * Desconecta el plugin y limpia recursos
16029
- */
16030
16021
  detach() {
16031
16022
  if (this._private__markersPlugin) {
16032
16023
  this._private__markersPlugin.detach();
@@ -16036,47 +16027,18 @@
16036
16027
  }
16037
16028
  }
16038
16029
  /**
16039
- * Crea un gestor de marcadores de posiciones de trading
16040
- *
16041
- * @param series - Serie a la que se adjuntarán los marcadores
16042
- * @param positions - Posiciones iniciales (opcional)
16043
- * @param options - Opciones de configuración (opcional)
16044
- * @returns Instancia del gestor de posiciones
16030
+ * Marks trades on a series with an arrow at the entry and, once closed, at the
16031
+ * exit.
16045
16032
  *
16046
16033
  * @example
16047
16034
  * ```typescript
16048
- * // Crear el gestor
16049
- * const positionMarkers = createPositionMarkers(candleSeries);
16050
- *
16051
- * // Agregar una posición long
16052
- * positionMarkers.addPosition({
16053
- * type: 'long',
16054
- * entry: { time: '2023-01-01', price: 100.50 },
16055
- * exit: { time: '2023-01-05', price: 105.20 },
16056
- * id: 'pos-1'
16057
- * });
16058
- *
16059
- * // Agregar una posición short
16060
- * positionMarkers.addPosition({
16061
- * type: 'short',
16062
- * entry: { time: '2023-01-10', price: 110.00 },
16063
- * exit: { time: '2023-01-15', price: 107.50 },
16064
- * id: 'pos-2'
16065
- * });
16066
- *
16067
- * // Agregar múltiples posiciones
16068
- * positionMarkers.setPositions([
16069
- * {
16035
+ * const markers = createPositionMarkers(candleSeries);
16036
+ * markers.addPosition({
16070
16037
  * type: 'long',
16071
- * entry: { time: '2023-02-01', price: 95.00 },
16072
- * exit: { time: '2023-02-10', price: 98.50 }
16073
- * },
16074
- * {
16075
- * type: 'short',
16076
- * entry: { time: '2023-02-15', price: 102.00 },
16077
- * exit: { time: '2023-02-20', price: 99.00 }
16078
- * }
16079
- * ]);
16038
+ * entry: { time: '2023-01-01', price: 100.50 },
16039
+ * exit: { time: '2023-01-05', price: 105.20 },
16040
+ * id: 'pos-1',
16041
+ * });
16080
16042
  * ```
16081
16043
  */
16082
16044
  function createPositionMarkers(series, positions, options) {
@@ -20327,9 +20289,6 @@
20327
20289
  return new DraggablePriceLine(chart, series, lineOptions);
20328
20290
  }
20329
20291
 
20330
- /**
20331
- * Interactive Line Manager - Permite crear líneas haciendo clic en el gráfico
20332
- */
20333
20292
  class InteractiveLineManager {
20334
20293
  constructor(chart, series) {
20335
20294
  this._private__container = null;
@@ -20358,10 +20317,9 @@
20358
20317
  return price === null ? 0 : price;
20359
20318
  }
20360
20319
  /**
20361
- * Activa el modo de creación de líneas por clic
20362
- * @param mode - Tipo de línea a crear
20363
- * @param customOptions - Opciones personalizadas para líneas custom
20364
- * @returns Promesa que se resuelve cuando el usuario hace clic
20320
+ * Arms the chart so the next click drops a line.
20321
+ *
20322
+ * @returns The line, once the user has clicked.
20365
20323
  */
20366
20324
  enableClickToCreate(mode, customOptions) {
20367
20325
  if (!this._private__container) {
@@ -20382,9 +20340,6 @@
20382
20340
  this._private__container.addEventListener('click', this._private__clickHandler);
20383
20341
  });
20384
20342
  }
20385
- /**
20386
- * Desactiva el modo de creación por clic
20387
- */
20388
20343
  disableClickToCreate() {
20389
20344
  if (this._private__container && this._private__clickHandler) {
20390
20345
  this._private__container.removeEventListener('click', this._private__clickHandler);
@@ -20474,31 +20429,21 @@
20474
20429
  }
20475
20430
  return new DraggablePriceLine(this._private__chart, this._private__series, options);
20476
20431
  }
20477
- /**
20478
- * Obtiene el modo actual de creación
20479
- */
20480
20432
  getCreationMode() {
20481
20433
  return this._private__creationMode;
20482
20434
  }
20483
- /**
20484
- * Verifica si está en modo de creación
20485
- */
20486
20435
  isCreating() {
20487
20436
  return this._private__creationMode !== null;
20488
20437
  }
20489
20438
  }
20490
20439
  /**
20491
- * Crea un manager interactivo para añadir líneas con clics
20492
- * @param chart - Chart instance
20493
- * @param series - Series instance
20494
- * @returns InteractiveLineManager
20440
+ * Lets the user place draggable lines by clicking the chart.
20441
+ *
20495
20442
  * @example
20496
20443
  * ```typescript
20497
20444
  * const manager = createInteractiveLineManager(chart, candleSeries);
20498
- *
20499
- * // Activar modo de creación
20500
20445
  * const line = await manager.enableClickToCreate('stop-loss', {
20501
- * onDragEnd: (price) => console.log('SL:', price)
20446
+ * onDragEnd: (price) => console.log('SL:', price),
20502
20447
  * });
20503
20448
  * ```
20504
20449
  */
@@ -24361,9 +24306,6 @@
24361
24306
  return new VerticalLineTool(context, options);
24362
24307
  }
24363
24308
 
24364
- /**
24365
- * Fibonacci Calculator - Cálculos de niveles de retroceso de Fibonacci
24366
- */
24367
24309
  /**
24368
24310
  * Standard Fibonacci retracement ratios
24369
24311
  */
@@ -24509,10 +24451,7 @@
24509
24451
  }
24510
24452
  }
24511
24453
 
24512
- /**
24513
- * Fibonacci Retracement Tool - Herramienta para dibujar niveles de Fibonacci
24514
- * Muestra niveles estándar: 0%, 23.6%, 38.2%, 50%, 61.8%, 78.6%, 100%
24515
- */
24454
+ /** Draws 0, 23.6, 38.2, 50, 61.8, 78.6 and 100% unless `levels` says otherwise. */
24516
24455
  /** A ratio and the label it is shown with, derived rather than stored. */
24517
24456
  function toRatio(ratio) {
24518
24457
  return { _internal_ratio: ratio, _internal_label: `${(ratio * 100).toFixed(1)}%` };
@@ -28343,9 +28282,6 @@
28343
28282
  return new TextTool(context, options);
28344
28283
  }
28345
28284
 
28346
- /**
28347
- * Position Calculator - Cálculos de P&L, pips, R:R para trading
28348
- */
28349
28285
  class PositionCalculator {
28350
28286
  constructor(pipConfig) {
28351
28287
  this._private__pipConfig = pipConfig;
@@ -28497,9 +28433,6 @@
28497
28433
  };
28498
28434
  }
28499
28435
 
28500
- /**
28501
- * Ruler Calculator - Cálculos de distancia, pips, tiempo para mediciones
28502
- */
28503
28436
  class RulerCalculator {
28504
28437
  constructor(pipConfig) {
28505
28438
  this._private__pipConfig = pipConfig;
@@ -28618,10 +28551,7 @@
28618
28551
  }
28619
28552
  }
28620
28553
 
28621
- /**
28622
- * Measurement Ruler Tool - Herramienta para medir distancia entre dos puntos
28623
- * Muestra pips, porcentaje, tiempo transcurrido y número de barras
28624
- */
28554
+ /** Measures two points: pips, percent, elapsed time and bar count. */
28625
28555
  class RulerTool extends DrawingToolBase {
28626
28556
  constructor(context, options) {
28627
28557
  super(context, 'ruler-tool', options);
@@ -29181,10 +29111,7 @@
29181
29111
  }
29182
29112
  }
29183
29113
 
29184
- /**
29185
- * Position Tool - Herramienta unificada para marcar posiciones long/short
29186
- * Muestra dos rectángulos ajustables (profit/loss) con línea vertical conectora
29187
- */
29114
+ /** Two adjustable boxes, profit and loss, joined by a vertical connector. */
29188
29115
  class PositionTool extends DrawingToolBase {
29189
29116
  constructor(context, options) {
29190
29117
  super(context, 'position-tool', options);
@@ -31079,7 +31006,7 @@
31079
31006
  * Returns the current version as a string. For example `'1.0.0'`.
31080
31007
  */
31081
31008
  function version() {
31082
- return "2.3.2";
31009
+ return "2.3.4";
31083
31010
  }
31084
31011
 
31085
31012
  var PipsendChartsModule = /*#__PURE__*/Object.freeze({