@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)
@@ -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;
@@ -11112,7 +11132,7 @@ class SeriesCustomPaneView extends SeriesPaneViewBase {
11112
11132
  return {
11113
11133
  _internal_time: row._internal_index,
11114
11134
  _internal_x: NaN,
11115
- ...colorer._internal_barStyle(row._internal_index),
11135
+ ...colorer._internal_barStyle(row._internal_index, { _internal_value: row }),
11116
11136
  _internal_originalData: row._internal_data,
11117
11137
  };
11118
11138
  });
@@ -12430,7 +12450,9 @@ class LinePaneViewBase extends SeriesPaneViewBase {
12430
12450
  const colorer = this._internal__series._internal_barColorer();
12431
12451
  this._internal__items = this._internal__series._internal_bars()._internal_rows().map((row) => {
12432
12452
  const value = row._internal_value[3 /* PlotRowValueIndex.Close */];
12433
- return this._internal__createRawItem(row._internal_index, value, colorer);
12453
+ // The row travels with the point: without it the colorer looks it up
12454
+ // again by index, and that lookup could fail and take the repaint down.
12455
+ return this._internal__createRawItem(row._internal_index, value, colorer, row);
12434
12456
  });
12435
12457
  }
12436
12458
  }
@@ -12598,10 +12620,10 @@ class SeriesLinePaneView extends LinePaneViewBase {
12598
12620
  super(...arguments);
12599
12621
  this._internal__renderer = new PaneRendererLine();
12600
12622
  }
12601
- _internal__createRawItem(time, price, colorer) {
12623
+ _internal__createRawItem(time, price, colorer, row) {
12602
12624
  return {
12603
12625
  ...this._internal__createRawItemBase(time, price),
12604
- ...colorer._internal_barStyle(time),
12626
+ ...colorer._internal_barStyle(time, { _internal_value: row }),
12605
12627
  };
12606
12628
  }
12607
12629
  _internal__prepareRendererData() {
@@ -13075,10 +13097,10 @@ class SeriesBaselinePaneView extends LinePaneViewBase {
13075
13097
  this._private__baselineLineRenderer = new PaneRendererBaselineLine();
13076
13098
  this._internal__renderer._internal_setRenderers([this._private__baselineAreaRenderer, this._private__baselineLineRenderer]);
13077
13099
  }
13078
- _internal__createRawItem(time, price, colorer) {
13100
+ _internal__createRawItem(time, price, colorer, row) {
13079
13101
  return {
13080
13102
  ...this._internal__createRawItemBase(time, price),
13081
- ...colorer._internal_barStyle(time),
13103
+ ...colorer._internal_barStyle(time, { _internal_value: row }),
13082
13104
  };
13083
13105
  }
13084
13106
  _internal__prepareRendererData() {
@@ -13198,10 +13220,10 @@ class SeriesAreaPaneView extends LinePaneViewBase {
13198
13220
  this._private__lineRenderer = new PaneRendererLine();
13199
13221
  this._internal__renderer._internal_setRenderers([this._private__areaRenderer, this._private__lineRenderer]);
13200
13222
  }
13201
- _internal__createRawItem(time, price, colorer) {
13223
+ _internal__createRawItem(time, price, colorer, row) {
13202
13224
  return {
13203
13225
  ...this._internal__createRawItemBase(time, price),
13204
- ...colorer._internal_barStyle(time),
13226
+ ...colorer._internal_barStyle(time, { _internal_value: row }),
13205
13227
  };
13206
13228
  }
13207
13229
  _internal__prepareRendererData() {
@@ -13394,6 +13416,9 @@ class BarsPaneViewBase extends SeriesPaneViewBase {
13394
13416
  }
13395
13417
  _internal__fillRawPoints() {
13396
13418
  const colorer = this._internal__series._internal_barColorer();
13419
+ // The row goes to the colorer as it is. Asking for the style by index
13420
+ // alone made it look the row up again, and that second lookup could come
13421
+ // back empty and throw, taking the whole repaint down with it.
13397
13422
  this._internal__items = this._internal__series._internal_bars()._internal_rows().map((row) => this._internal__createRawItem(row._internal_index, row, colorer));
13398
13423
  }
13399
13424
  }
@@ -13406,7 +13431,7 @@ class SeriesBarsPaneView extends BarsPaneViewBase {
13406
13431
  _internal__createRawItem(time, bar, colorer) {
13407
13432
  return {
13408
13433
  ...this._internal__createDefaultItem(time, bar, colorer),
13409
- ...colorer._internal_barStyle(time),
13434
+ ...colorer._internal_barStyle(time, { _internal_value: bar }),
13410
13435
  };
13411
13436
  }
13412
13437
  _internal__prepareRendererData() {
@@ -13599,7 +13624,7 @@ class SeriesCandlesticksPaneView extends BarsPaneViewBase {
13599
13624
  _internal__createRawItem(time, bar, colorer) {
13600
13625
  return {
13601
13626
  ...this._internal__createDefaultItem(time, bar, colorer),
13602
- ...colorer._internal_barStyle(time),
13627
+ ...colorer._internal_barStyle(time, { _internal_value: bar }),
13603
13628
  };
13604
13629
  }
13605
13630
  _internal__prepareRendererData() {
@@ -13767,10 +13792,10 @@ class SeriesHistogramPaneView extends LinePaneViewBase {
13767
13792
  super(...arguments);
13768
13793
  this._internal__renderer = new PaneRendererHistogram();
13769
13794
  }
13770
- _internal__createRawItem(time, price, colorer) {
13795
+ _internal__createRawItem(time, price, colorer, row) {
13771
13796
  return {
13772
13797
  ...this._internal__createRawItemBase(time, price),
13773
- ...colorer._internal_barStyle(time),
13798
+ ...colorer._internal_barStyle(time, { _internal_value: row }),
13774
13799
  };
13775
13800
  }
13776
13801
  _internal__prepareRendererData() {
@@ -15464,9 +15489,6 @@ function createUpDownMarkers(series, options = {}) {
15464
15489
  return wrapper;
15465
15490
  }
15466
15491
 
15467
- /**
15468
- * Gestor de marcadores de posiciones de trading
15469
- */
15470
15492
  class PositionMarkersManager {
15471
15493
  constructor(series, options) {
15472
15494
  this._private__markersPlugin = null;
@@ -15486,30 +15508,20 @@ class PositionMarkersManager {
15486
15508
  };
15487
15509
  this._private__markersPlugin = createSeriesMarkers(series);
15488
15510
  }
15489
- /**
15490
- * Agrega una posición al gráfico
15491
- */
15492
15511
  addPosition(position) {
15493
15512
  this._private__positions.push(position);
15494
15513
  this._private__updateMarkers();
15495
15514
  }
15496
- /**
15497
- * Agrega múltiples posiciones al gráfico
15498
- */
15499
15515
  addPositions(positions) {
15500
15516
  this._private__positions.push(...positions);
15501
15517
  this._private__updateMarkers();
15502
15518
  }
15503
- /**
15504
- * Establece las posiciones (reemplaza las existentes)
15505
- */
15519
+ /** Replaces every position currently on the chart. */
15506
15520
  setPositions(positions) {
15507
15521
  this._private__positions = [...positions];
15508
15522
  this._private__updateMarkers();
15509
15523
  }
15510
- /**
15511
- * Cierra una posición abierta agregando el punto de salida
15512
- */
15524
+ /** Closes an open position by giving it an exit point. */
15513
15525
  closePosition(id, exit, exitText) {
15514
15526
  const position = this._private__positions.find(p => p.id === id);
15515
15527
  if (position) {
@@ -15523,29 +15535,17 @@ class PositionMarkersManager {
15523
15535
  this._private__updateMarkers();
15524
15536
  }
15525
15537
  }
15526
- /**
15527
- * Elimina una posición por ID
15528
- */
15529
15538
  removePosition(id) {
15530
15539
  this._private__positions = this._private__positions.filter(p => p.id !== id);
15531
15540
  this._private__updateMarkers();
15532
15541
  }
15533
- /**
15534
- * Limpia todas las posiciones
15535
- */
15536
15542
  clearPositions() {
15537
15543
  this._private__positions = [];
15538
15544
  this._private__updateMarkers();
15539
15545
  }
15540
- /**
15541
- * Obtiene todas las posiciones actuales
15542
- */
15543
15546
  getPositions() {
15544
15547
  return this._private__positions;
15545
15548
  }
15546
- /**
15547
- * Actualiza las opciones del gestor
15548
- */
15549
15549
  applyOptions(options) {
15550
15550
  if (options.longColors) {
15551
15551
  this._private__options.longColors = {
@@ -15570,9 +15570,6 @@ class PositionMarkersManager {
15570
15570
  }
15571
15571
  this._private__updateMarkers();
15572
15572
  }
15573
- /**
15574
- * Convierte las posiciones a marcadores de serie
15575
- */
15576
15573
  _private__positionsToMarkers() {
15577
15574
  const markers = [];
15578
15575
  for (const position of this._private__positions) {
@@ -15619,18 +15616,12 @@ class PositionMarkersManager {
15619
15616
  }
15620
15617
  return markers;
15621
15618
  }
15622
- /**
15623
- * Actualiza los marcadores en el gráfico
15624
- */
15625
15619
  _private__updateMarkers() {
15626
15620
  if (this._private__markersPlugin) {
15627
15621
  const markers = this._private__positionsToMarkers();
15628
15622
  this._private__markersPlugin.setMarkers(markers);
15629
15623
  }
15630
15624
  }
15631
- /**
15632
- * Desconecta el plugin y limpia recursos
15633
- */
15634
15625
  detach() {
15635
15626
  if (this._private__markersPlugin) {
15636
15627
  this._private__markersPlugin.detach();
@@ -15640,47 +15631,18 @@ class PositionMarkersManager {
15640
15631
  }
15641
15632
  }
15642
15633
  /**
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
15634
+ * Marks trades on a series with an arrow at the entry and, once closed, at the
15635
+ * exit.
15649
15636
  *
15650
15637
  * @example
15651
15638
  * ```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
- * {
15639
+ * const markers = createPositionMarkers(candleSeries);
15640
+ * markers.addPosition({
15674
15641
  * 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
- * ]);
15642
+ * entry: { time: '2023-01-01', price: 100.50 },
15643
+ * exit: { time: '2023-01-05', price: 105.20 },
15644
+ * id: 'pos-1',
15645
+ * });
15684
15646
  * ```
15685
15647
  */
15686
15648
  function createPositionMarkers(series, positions, options) {
@@ -19931,9 +19893,6 @@ function createTradingLine(series, chart, options) {
19931
19893
  return new DraggablePriceLine(chart, series, lineOptions);
19932
19894
  }
19933
19895
 
19934
- /**
19935
- * Interactive Line Manager - Permite crear líneas haciendo clic en el gráfico
19936
- */
19937
19896
  class InteractiveLineManager {
19938
19897
  constructor(chart, series) {
19939
19898
  this._private__container = null;
@@ -19962,10 +19921,9 @@ class InteractiveLineManager {
19962
19921
  return price === null ? 0 : price;
19963
19922
  }
19964
19923
  /**
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
19924
+ * Arms the chart so the next click drops a line.
19925
+ *
19926
+ * @returns The line, once the user has clicked.
19969
19927
  */
19970
19928
  enableClickToCreate(mode, customOptions) {
19971
19929
  if (!this._private__container) {
@@ -19986,9 +19944,6 @@ class InteractiveLineManager {
19986
19944
  this._private__container.addEventListener('click', this._private__clickHandler);
19987
19945
  });
19988
19946
  }
19989
- /**
19990
- * Desactiva el modo de creación por clic
19991
- */
19992
19947
  disableClickToCreate() {
19993
19948
  if (this._private__container && this._private__clickHandler) {
19994
19949
  this._private__container.removeEventListener('click', this._private__clickHandler);
@@ -20078,31 +20033,21 @@ class InteractiveLineManager {
20078
20033
  }
20079
20034
  return new DraggablePriceLine(this._private__chart, this._private__series, options);
20080
20035
  }
20081
- /**
20082
- * Obtiene el modo actual de creación
20083
- */
20084
20036
  getCreationMode() {
20085
20037
  return this._private__creationMode;
20086
20038
  }
20087
- /**
20088
- * Verifica si está en modo de creación
20089
- */
20090
20039
  isCreating() {
20091
20040
  return this._private__creationMode !== null;
20092
20041
  }
20093
20042
  }
20094
20043
  /**
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
20044
+ * Lets the user place draggable lines by clicking the chart.
20045
+ *
20099
20046
  * @example
20100
20047
  * ```typescript
20101
20048
  * const manager = createInteractiveLineManager(chart, candleSeries);
20102
- *
20103
- * // Activar modo de creación
20104
20049
  * const line = await manager.enableClickToCreate('stop-loss', {
20105
- * onDragEnd: (price) => console.log('SL:', price)
20050
+ * onDragEnd: (price) => console.log('SL:', price),
20106
20051
  * });
20107
20052
  * ```
20108
20053
  */
@@ -23965,9 +23910,6 @@ function createVerticalLineTool(context, options) {
23965
23910
  return new VerticalLineTool(context, options);
23966
23911
  }
23967
23912
 
23968
- /**
23969
- * Fibonacci Calculator - Cálculos de niveles de retroceso de Fibonacci
23970
- */
23971
23913
  /**
23972
23914
  * Standard Fibonacci retracement ratios
23973
23915
  */
@@ -24113,10 +24055,7 @@ class FibonacciPaneView {
24113
24055
  }
24114
24056
  }
24115
24057
 
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
- */
24058
+ /** Draws 0, 23.6, 38.2, 50, 61.8, 78.6 and 100% unless `levels` says otherwise. */
24120
24059
  /** A ratio and the label it is shown with, derived rather than stored. */
24121
24060
  function toRatio(ratio) {
24122
24061
  return { _internal_ratio: ratio, _internal_label: `${(ratio * 100).toFixed(1)}%` };
@@ -27947,9 +27886,6 @@ function createTextTool(context, options) {
27947
27886
  return new TextTool(context, options);
27948
27887
  }
27949
27888
 
27950
- /**
27951
- * Position Calculator - Cálculos de P&L, pips, R:R para trading
27952
- */
27953
27889
  class PositionCalculator {
27954
27890
  constructor(pipConfig) {
27955
27891
  this._private__pipConfig = pipConfig;
@@ -28101,9 +28037,6 @@ function getPipConfig(symbolOrPrice, price) {
28101
28037
  };
28102
28038
  }
28103
28039
 
28104
- /**
28105
- * Ruler Calculator - Cálculos de distancia, pips, tiempo para mediciones
28106
- */
28107
28040
  class RulerCalculator {
28108
28041
  constructor(pipConfig) {
28109
28042
  this._private__pipConfig = pipConfig;
@@ -28222,10 +28155,7 @@ class RulerPaneView {
28222
28155
  }
28223
28156
  }
28224
28157
 
28225
- /**
28226
- * Measurement Ruler Tool - Herramienta para medir distancia entre dos puntos
28227
- * Muestra pips, porcentaje, tiempo transcurrido y número de barras
28228
- */
28158
+ /** Measures two points: pips, percent, elapsed time and bar count. */
28229
28159
  class RulerTool extends DrawingToolBase {
28230
28160
  constructor(context, options) {
28231
28161
  super(context, 'ruler-tool', options);
@@ -28785,10 +28715,7 @@ class PositionPaneView {
28785
28715
  }
28786
28716
  }
28787
28717
 
28788
- /**
28789
- * Position Tool - Herramienta unificada para marcar posiciones long/short
28790
- * Muestra dos rectángulos ajustables (profit/loss) con línea vertical conectora
28791
- */
28718
+ /** Two adjustable boxes, profit and loss, joined by a vertical connector. */
28792
28719
  class PositionTool extends DrawingToolBase {
28793
28720
  constructor(context, options) {
28794
28721
  super(context, 'position-tool', options);
@@ -30683,7 +30610,7 @@ const customSeriesDefaultOptions = {
30683
30610
  * Returns the current version as a string. For example `'1.0.0'`.
30684
30611
  */
30685
30612
  function version() {
30686
- return "2.3.2";
30613
+ return "2.3.4";
30687
30614
  }
30688
30615
 
30689
30616
  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 };