@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)
@@ -2482,6 +2482,22 @@ class SeriesBarColorer {
2482
2482
  // Used to avoid binary search if bars are already known
2483
2483
  return this._private__styleGetter(this._private__findBar, this._private__series._internal_options(), barIndex, precomputedBars);
2484
2484
  }
2485
+ /**
2486
+ * Like `barStyle`, but returns null instead of throwing when the bar is
2487
+ * gone.
2488
+ *
2489
+ * Recolouring walks items that were laid out against the data as it was. A
2490
+ * bar that has since disappeared is not an error there: the view is about
2491
+ * to be rebuilt from the new data anyway. Letting it throw took down
2492
+ * whatever asked for the repaint — including `setData`, which left the
2493
+ * series without its data and the pane empty until the page was reloaded.
2494
+ */
2495
+ _internal_barStyleOrNull(barIndex, precomputedBars) {
2496
+ if (precomputedBars === undefined && this._private__series._internal_bars()._internal_valueAt(barIndex) === null) {
2497
+ return null;
2498
+ }
2499
+ return this._internal_barStyle(barIndex, precomputedBars);
2500
+ }
2485
2501
  }
2486
2502
 
2487
2503
  /**
@@ -11425,10 +11441,14 @@ class SeriesPaneViewBase {
11425
11441
  return this._internal__itemsVisibleRange === null ? null : this._internal__renderer;
11426
11442
  }
11427
11443
  _internal__updateOptions() {
11428
- this._internal__items = this._internal__items.map((item) => ({
11429
- ...item,
11430
- ...this._internal__series._internal_barColorer()._internal_barStyle(item._internal_time),
11431
- }));
11444
+ const colorer = this._internal__series._internal_barColorer();
11445
+ this._internal__items = this._internal__items.map((item) => {
11446
+ // An item whose bar is gone keeps the colour it had. Throwing here
11447
+ // took down whatever asked for the repaint — `setData` among them,
11448
+ // which left the series without its data and the pane empty.
11449
+ const style = colorer._internal_barStyleOrNull(item._internal_time);
11450
+ return style === null ? item : { ...item, ...style };
11451
+ });
11432
11452
  }
11433
11453
  _internal__clearVisibleRange() {
11434
11454
  this._internal__itemsVisibleRange = null;
@@ -11505,7 +11525,7 @@ class SeriesCustomPaneView extends SeriesPaneViewBase {
11505
11525
  return {
11506
11526
  _internal_time: row._internal_index,
11507
11527
  _internal_x: NaN,
11508
- ...colorer._internal_barStyle(row._internal_index),
11528
+ ...colorer._internal_barStyle(row._internal_index, { _internal_value: row }),
11509
11529
  _internal_originalData: row._internal_data,
11510
11530
  };
11511
11531
  });
@@ -12823,7 +12843,9 @@ class LinePaneViewBase extends SeriesPaneViewBase {
12823
12843
  const colorer = this._internal__series._internal_barColorer();
12824
12844
  this._internal__items = this._internal__series._internal_bars()._internal_rows().map((row) => {
12825
12845
  const value = row._internal_value[3 /* PlotRowValueIndex.Close */];
12826
- return this._internal__createRawItem(row._internal_index, value, colorer);
12846
+ // The row travels with the point: without it the colorer looks it up
12847
+ // again by index, and that lookup could fail and take the repaint down.
12848
+ return this._internal__createRawItem(row._internal_index, value, colorer, row);
12827
12849
  });
12828
12850
  }
12829
12851
  }
@@ -12991,10 +13013,10 @@ class SeriesLinePaneView extends LinePaneViewBase {
12991
13013
  super(...arguments);
12992
13014
  this._internal__renderer = new PaneRendererLine();
12993
13015
  }
12994
- _internal__createRawItem(time, price, colorer) {
13016
+ _internal__createRawItem(time, price, colorer, row) {
12995
13017
  return {
12996
13018
  ...this._internal__createRawItemBase(time, price),
12997
- ...colorer._internal_barStyle(time),
13019
+ ...colorer._internal_barStyle(time, { _internal_value: row }),
12998
13020
  };
12999
13021
  }
13000
13022
  _internal__prepareRendererData() {
@@ -13468,10 +13490,10 @@ class SeriesBaselinePaneView extends LinePaneViewBase {
13468
13490
  this._private__baselineLineRenderer = new PaneRendererBaselineLine();
13469
13491
  this._internal__renderer._internal_setRenderers([this._private__baselineAreaRenderer, this._private__baselineLineRenderer]);
13470
13492
  }
13471
- _internal__createRawItem(time, price, colorer) {
13493
+ _internal__createRawItem(time, price, colorer, row) {
13472
13494
  return {
13473
13495
  ...this._internal__createRawItemBase(time, price),
13474
- ...colorer._internal_barStyle(time),
13496
+ ...colorer._internal_barStyle(time, { _internal_value: row }),
13475
13497
  };
13476
13498
  }
13477
13499
  _internal__prepareRendererData() {
@@ -13591,10 +13613,10 @@ class SeriesAreaPaneView extends LinePaneViewBase {
13591
13613
  this._private__lineRenderer = new PaneRendererLine();
13592
13614
  this._internal__renderer._internal_setRenderers([this._private__areaRenderer, this._private__lineRenderer]);
13593
13615
  }
13594
- _internal__createRawItem(time, price, colorer) {
13616
+ _internal__createRawItem(time, price, colorer, row) {
13595
13617
  return {
13596
13618
  ...this._internal__createRawItemBase(time, price),
13597
- ...colorer._internal_barStyle(time),
13619
+ ...colorer._internal_barStyle(time, { _internal_value: row }),
13598
13620
  };
13599
13621
  }
13600
13622
  _internal__prepareRendererData() {
@@ -13787,6 +13809,9 @@ class BarsPaneViewBase extends SeriesPaneViewBase {
13787
13809
  }
13788
13810
  _internal__fillRawPoints() {
13789
13811
  const colorer = this._internal__series._internal_barColorer();
13812
+ // The row goes to the colorer as it is. Asking for the style by index
13813
+ // alone made it look the row up again, and that second lookup could come
13814
+ // back empty and throw, taking the whole repaint down with it.
13790
13815
  this._internal__items = this._internal__series._internal_bars()._internal_rows().map((row) => this._internal__createRawItem(row._internal_index, row, colorer));
13791
13816
  }
13792
13817
  }
@@ -13799,7 +13824,7 @@ class SeriesBarsPaneView extends BarsPaneViewBase {
13799
13824
  _internal__createRawItem(time, bar, colorer) {
13800
13825
  return {
13801
13826
  ...this._internal__createDefaultItem(time, bar, colorer),
13802
- ...colorer._internal_barStyle(time),
13827
+ ...colorer._internal_barStyle(time, { _internal_value: bar }),
13803
13828
  };
13804
13829
  }
13805
13830
  _internal__prepareRendererData() {
@@ -13992,7 +14017,7 @@ class SeriesCandlesticksPaneView extends BarsPaneViewBase {
13992
14017
  _internal__createRawItem(time, bar, colorer) {
13993
14018
  return {
13994
14019
  ...this._internal__createDefaultItem(time, bar, colorer),
13995
- ...colorer._internal_barStyle(time),
14020
+ ...colorer._internal_barStyle(time, { _internal_value: bar }),
13996
14021
  };
13997
14022
  }
13998
14023
  _internal__prepareRendererData() {
@@ -14160,10 +14185,10 @@ class SeriesHistogramPaneView extends LinePaneViewBase {
14160
14185
  super(...arguments);
14161
14186
  this._internal__renderer = new PaneRendererHistogram();
14162
14187
  }
14163
- _internal__createRawItem(time, price, colorer) {
14188
+ _internal__createRawItem(time, price, colorer, row) {
14164
14189
  return {
14165
14190
  ...this._internal__createRawItemBase(time, price),
14166
- ...colorer._internal_barStyle(time),
14191
+ ...colorer._internal_barStyle(time, { _internal_value: row }),
14167
14192
  };
14168
14193
  }
14169
14194
  _internal__prepareRendererData() {
@@ -15857,9 +15882,6 @@ function createUpDownMarkers(series, options = {}) {
15857
15882
  return wrapper;
15858
15883
  }
15859
15884
 
15860
- /**
15861
- * Gestor de marcadores de posiciones de trading
15862
- */
15863
15885
  class PositionMarkersManager {
15864
15886
  constructor(series, options) {
15865
15887
  this._private__markersPlugin = null;
@@ -15879,30 +15901,20 @@ class PositionMarkersManager {
15879
15901
  };
15880
15902
  this._private__markersPlugin = createSeriesMarkers(series);
15881
15903
  }
15882
- /**
15883
- * Agrega una posición al gráfico
15884
- */
15885
15904
  addPosition(position) {
15886
15905
  this._private__positions.push(position);
15887
15906
  this._private__updateMarkers();
15888
15907
  }
15889
- /**
15890
- * Agrega múltiples posiciones al gráfico
15891
- */
15892
15908
  addPositions(positions) {
15893
15909
  this._private__positions.push(...positions);
15894
15910
  this._private__updateMarkers();
15895
15911
  }
15896
- /**
15897
- * Establece las posiciones (reemplaza las existentes)
15898
- */
15912
+ /** Replaces every position currently on the chart. */
15899
15913
  setPositions(positions) {
15900
15914
  this._private__positions = [...positions];
15901
15915
  this._private__updateMarkers();
15902
15916
  }
15903
- /**
15904
- * Cierra una posición abierta agregando el punto de salida
15905
- */
15917
+ /** Closes an open position by giving it an exit point. */
15906
15918
  closePosition(id, exit, exitText) {
15907
15919
  const position = this._private__positions.find(p => p.id === id);
15908
15920
  if (position) {
@@ -15916,29 +15928,17 @@ class PositionMarkersManager {
15916
15928
  this._private__updateMarkers();
15917
15929
  }
15918
15930
  }
15919
- /**
15920
- * Elimina una posición por ID
15921
- */
15922
15931
  removePosition(id) {
15923
15932
  this._private__positions = this._private__positions.filter(p => p.id !== id);
15924
15933
  this._private__updateMarkers();
15925
15934
  }
15926
- /**
15927
- * Limpia todas las posiciones
15928
- */
15929
15935
  clearPositions() {
15930
15936
  this._private__positions = [];
15931
15937
  this._private__updateMarkers();
15932
15938
  }
15933
- /**
15934
- * Obtiene todas las posiciones actuales
15935
- */
15936
15939
  getPositions() {
15937
15940
  return this._private__positions;
15938
15941
  }
15939
- /**
15940
- * Actualiza las opciones del gestor
15941
- */
15942
15942
  applyOptions(options) {
15943
15943
  if (options.longColors) {
15944
15944
  this._private__options.longColors = {
@@ -15963,9 +15963,6 @@ class PositionMarkersManager {
15963
15963
  }
15964
15964
  this._private__updateMarkers();
15965
15965
  }
15966
- /**
15967
- * Convierte las posiciones a marcadores de serie
15968
- */
15969
15966
  _private__positionsToMarkers() {
15970
15967
  const markers = [];
15971
15968
  for (const position of this._private__positions) {
@@ -16012,18 +16009,12 @@ class PositionMarkersManager {
16012
16009
  }
16013
16010
  return markers;
16014
16011
  }
16015
- /**
16016
- * Actualiza los marcadores en el gráfico
16017
- */
16018
16012
  _private__updateMarkers() {
16019
16013
  if (this._private__markersPlugin) {
16020
16014
  const markers = this._private__positionsToMarkers();
16021
16015
  this._private__markersPlugin.setMarkers(markers);
16022
16016
  }
16023
16017
  }
16024
- /**
16025
- * Desconecta el plugin y limpia recursos
16026
- */
16027
16018
  detach() {
16028
16019
  if (this._private__markersPlugin) {
16029
16020
  this._private__markersPlugin.detach();
@@ -16033,47 +16024,18 @@ class PositionMarkersManager {
16033
16024
  }
16034
16025
  }
16035
16026
  /**
16036
- * Crea un gestor de marcadores de posiciones de trading
16037
- *
16038
- * @param series - Serie a la que se adjuntarán los marcadores
16039
- * @param positions - Posiciones iniciales (opcional)
16040
- * @param options - Opciones de configuración (opcional)
16041
- * @returns Instancia del gestor de posiciones
16027
+ * Marks trades on a series with an arrow at the entry and, once closed, at the
16028
+ * exit.
16042
16029
  *
16043
16030
  * @example
16044
16031
  * ```typescript
16045
- * // Crear el gestor
16046
- * const positionMarkers = createPositionMarkers(candleSeries);
16047
- *
16048
- * // Agregar una posición long
16049
- * positionMarkers.addPosition({
16050
- * type: 'long',
16051
- * entry: { time: '2023-01-01', price: 100.50 },
16052
- * exit: { time: '2023-01-05', price: 105.20 },
16053
- * id: 'pos-1'
16054
- * });
16055
- *
16056
- * // Agregar una posición short
16057
- * positionMarkers.addPosition({
16058
- * type: 'short',
16059
- * entry: { time: '2023-01-10', price: 110.00 },
16060
- * exit: { time: '2023-01-15', price: 107.50 },
16061
- * id: 'pos-2'
16062
- * });
16063
- *
16064
- * // Agregar múltiples posiciones
16065
- * positionMarkers.setPositions([
16066
- * {
16032
+ * const markers = createPositionMarkers(candleSeries);
16033
+ * markers.addPosition({
16067
16034
  * type: 'long',
16068
- * entry: { time: '2023-02-01', price: 95.00 },
16069
- * exit: { time: '2023-02-10', price: 98.50 }
16070
- * },
16071
- * {
16072
- * type: 'short',
16073
- * entry: { time: '2023-02-15', price: 102.00 },
16074
- * exit: { time: '2023-02-20', price: 99.00 }
16075
- * }
16076
- * ]);
16035
+ * entry: { time: '2023-01-01', price: 100.50 },
16036
+ * exit: { time: '2023-01-05', price: 105.20 },
16037
+ * id: 'pos-1',
16038
+ * });
16077
16039
  * ```
16078
16040
  */
16079
16041
  function createPositionMarkers(series, positions, options) {
@@ -20324,9 +20286,6 @@ function createTradingLine(series, chart, options) {
20324
20286
  return new DraggablePriceLine(chart, series, lineOptions);
20325
20287
  }
20326
20288
 
20327
- /**
20328
- * Interactive Line Manager - Permite crear líneas haciendo clic en el gráfico
20329
- */
20330
20289
  class InteractiveLineManager {
20331
20290
  constructor(chart, series) {
20332
20291
  this._private__container = null;
@@ -20355,10 +20314,9 @@ class InteractiveLineManager {
20355
20314
  return price === null ? 0 : price;
20356
20315
  }
20357
20316
  /**
20358
- * Activa el modo de creación de líneas por clic
20359
- * @param mode - Tipo de línea a crear
20360
- * @param customOptions - Opciones personalizadas para líneas custom
20361
- * @returns Promesa que se resuelve cuando el usuario hace clic
20317
+ * Arms the chart so the next click drops a line.
20318
+ *
20319
+ * @returns The line, once the user has clicked.
20362
20320
  */
20363
20321
  enableClickToCreate(mode, customOptions) {
20364
20322
  if (!this._private__container) {
@@ -20379,9 +20337,6 @@ class InteractiveLineManager {
20379
20337
  this._private__container.addEventListener('click', this._private__clickHandler);
20380
20338
  });
20381
20339
  }
20382
- /**
20383
- * Desactiva el modo de creación por clic
20384
- */
20385
20340
  disableClickToCreate() {
20386
20341
  if (this._private__container && this._private__clickHandler) {
20387
20342
  this._private__container.removeEventListener('click', this._private__clickHandler);
@@ -20471,31 +20426,21 @@ class InteractiveLineManager {
20471
20426
  }
20472
20427
  return new DraggablePriceLine(this._private__chart, this._private__series, options);
20473
20428
  }
20474
- /**
20475
- * Obtiene el modo actual de creación
20476
- */
20477
20429
  getCreationMode() {
20478
20430
  return this._private__creationMode;
20479
20431
  }
20480
- /**
20481
- * Verifica si está en modo de creación
20482
- */
20483
20432
  isCreating() {
20484
20433
  return this._private__creationMode !== null;
20485
20434
  }
20486
20435
  }
20487
20436
  /**
20488
- * Crea un manager interactivo para añadir líneas con clics
20489
- * @param chart - Chart instance
20490
- * @param series - Series instance
20491
- * @returns InteractiveLineManager
20437
+ * Lets the user place draggable lines by clicking the chart.
20438
+ *
20492
20439
  * @example
20493
20440
  * ```typescript
20494
20441
  * const manager = createInteractiveLineManager(chart, candleSeries);
20495
- *
20496
- * // Activar modo de creación
20497
20442
  * const line = await manager.enableClickToCreate('stop-loss', {
20498
- * onDragEnd: (price) => console.log('SL:', price)
20443
+ * onDragEnd: (price) => console.log('SL:', price),
20499
20444
  * });
20500
20445
  * ```
20501
20446
  */
@@ -24358,9 +24303,6 @@ function createVerticalLineTool(context, options) {
24358
24303
  return new VerticalLineTool(context, options);
24359
24304
  }
24360
24305
 
24361
- /**
24362
- * Fibonacci Calculator - Cálculos de niveles de retroceso de Fibonacci
24363
- */
24364
24306
  /**
24365
24307
  * Standard Fibonacci retracement ratios
24366
24308
  */
@@ -24506,10 +24448,7 @@ class FibonacciPaneView {
24506
24448
  }
24507
24449
  }
24508
24450
 
24509
- /**
24510
- * Fibonacci Retracement Tool - Herramienta para dibujar niveles de Fibonacci
24511
- * Muestra niveles estándar: 0%, 23.6%, 38.2%, 50%, 61.8%, 78.6%, 100%
24512
- */
24451
+ /** Draws 0, 23.6, 38.2, 50, 61.8, 78.6 and 100% unless `levels` says otherwise. */
24513
24452
  /** A ratio and the label it is shown with, derived rather than stored. */
24514
24453
  function toRatio(ratio) {
24515
24454
  return { _internal_ratio: ratio, _internal_label: `${(ratio * 100).toFixed(1)}%` };
@@ -28340,9 +28279,6 @@ function createTextTool(context, options) {
28340
28279
  return new TextTool(context, options);
28341
28280
  }
28342
28281
 
28343
- /**
28344
- * Position Calculator - Cálculos de P&L, pips, R:R para trading
28345
- */
28346
28282
  class PositionCalculator {
28347
28283
  constructor(pipConfig) {
28348
28284
  this._private__pipConfig = pipConfig;
@@ -28494,9 +28430,6 @@ function getPipConfig(symbolOrPrice, price) {
28494
28430
  };
28495
28431
  }
28496
28432
 
28497
- /**
28498
- * Ruler Calculator - Cálculos de distancia, pips, tiempo para mediciones
28499
- */
28500
28433
  class RulerCalculator {
28501
28434
  constructor(pipConfig) {
28502
28435
  this._private__pipConfig = pipConfig;
@@ -28615,10 +28548,7 @@ class RulerPaneView {
28615
28548
  }
28616
28549
  }
28617
28550
 
28618
- /**
28619
- * Measurement Ruler Tool - Herramienta para medir distancia entre dos puntos
28620
- * Muestra pips, porcentaje, tiempo transcurrido y número de barras
28621
- */
28551
+ /** Measures two points: pips, percent, elapsed time and bar count. */
28622
28552
  class RulerTool extends DrawingToolBase {
28623
28553
  constructor(context, options) {
28624
28554
  super(context, 'ruler-tool', options);
@@ -29178,10 +29108,7 @@ class PositionPaneView {
29178
29108
  }
29179
29109
  }
29180
29110
 
29181
- /**
29182
- * Position Tool - Herramienta unificada para marcar posiciones long/short
29183
- * Muestra dos rectángulos ajustables (profit/loss) con línea vertical conectora
29184
- */
29111
+ /** Two adjustable boxes, profit and loss, joined by a vertical connector. */
29185
29112
  class PositionTool extends DrawingToolBase {
29186
29113
  constructor(context, options) {
29187
29114
  super(context, 'position-tool', options);
@@ -31076,7 +31003,7 @@ const customSeriesDefaultOptions = {
31076
31003
  * Returns the current version as a string. For example `'1.0.0'`.
31077
31004
  */
31078
31005
  function version() {
31079
- return "2.3.2";
31006
+ return "2.3.4";
31080
31007
  }
31081
31008
 
31082
31009
  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 };