@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)
@@ -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;
@@ -15857,9 +15877,6 @@ function createUpDownMarkers(series, options = {}) {
15857
15877
  return wrapper;
15858
15878
  }
15859
15879
 
15860
- /**
15861
- * Gestor de marcadores de posiciones de trading
15862
- */
15863
15880
  class PositionMarkersManager {
15864
15881
  constructor(series, options) {
15865
15882
  this._private__markersPlugin = null;
@@ -15879,30 +15896,20 @@ class PositionMarkersManager {
15879
15896
  };
15880
15897
  this._private__markersPlugin = createSeriesMarkers(series);
15881
15898
  }
15882
- /**
15883
- * Agrega una posición al gráfico
15884
- */
15885
15899
  addPosition(position) {
15886
15900
  this._private__positions.push(position);
15887
15901
  this._private__updateMarkers();
15888
15902
  }
15889
- /**
15890
- * Agrega múltiples posiciones al gráfico
15891
- */
15892
15903
  addPositions(positions) {
15893
15904
  this._private__positions.push(...positions);
15894
15905
  this._private__updateMarkers();
15895
15906
  }
15896
- /**
15897
- * Establece las posiciones (reemplaza las existentes)
15898
- */
15907
+ /** Replaces every position currently on the chart. */
15899
15908
  setPositions(positions) {
15900
15909
  this._private__positions = [...positions];
15901
15910
  this._private__updateMarkers();
15902
15911
  }
15903
- /**
15904
- * Cierra una posición abierta agregando el punto de salida
15905
- */
15912
+ /** Closes an open position by giving it an exit point. */
15906
15913
  closePosition(id, exit, exitText) {
15907
15914
  const position = this._private__positions.find(p => p.id === id);
15908
15915
  if (position) {
@@ -15916,29 +15923,17 @@ class PositionMarkersManager {
15916
15923
  this._private__updateMarkers();
15917
15924
  }
15918
15925
  }
15919
- /**
15920
- * Elimina una posición por ID
15921
- */
15922
15926
  removePosition(id) {
15923
15927
  this._private__positions = this._private__positions.filter(p => p.id !== id);
15924
15928
  this._private__updateMarkers();
15925
15929
  }
15926
- /**
15927
- * Limpia todas las posiciones
15928
- */
15929
15930
  clearPositions() {
15930
15931
  this._private__positions = [];
15931
15932
  this._private__updateMarkers();
15932
15933
  }
15933
- /**
15934
- * Obtiene todas las posiciones actuales
15935
- */
15936
15934
  getPositions() {
15937
15935
  return this._private__positions;
15938
15936
  }
15939
- /**
15940
- * Actualiza las opciones del gestor
15941
- */
15942
15937
  applyOptions(options) {
15943
15938
  if (options.longColors) {
15944
15939
  this._private__options.longColors = {
@@ -15963,9 +15958,6 @@ class PositionMarkersManager {
15963
15958
  }
15964
15959
  this._private__updateMarkers();
15965
15960
  }
15966
- /**
15967
- * Convierte las posiciones a marcadores de serie
15968
- */
15969
15961
  _private__positionsToMarkers() {
15970
15962
  const markers = [];
15971
15963
  for (const position of this._private__positions) {
@@ -16012,18 +16004,12 @@ class PositionMarkersManager {
16012
16004
  }
16013
16005
  return markers;
16014
16006
  }
16015
- /**
16016
- * Actualiza los marcadores en el gráfico
16017
- */
16018
16007
  _private__updateMarkers() {
16019
16008
  if (this._private__markersPlugin) {
16020
16009
  const markers = this._private__positionsToMarkers();
16021
16010
  this._private__markersPlugin.setMarkers(markers);
16022
16011
  }
16023
16012
  }
16024
- /**
16025
- * Desconecta el plugin y limpia recursos
16026
- */
16027
16013
  detach() {
16028
16014
  if (this._private__markersPlugin) {
16029
16015
  this._private__markersPlugin.detach();
@@ -16033,47 +16019,18 @@ class PositionMarkersManager {
16033
16019
  }
16034
16020
  }
16035
16021
  /**
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
16022
+ * Marks trades on a series with an arrow at the entry and, once closed, at the
16023
+ * exit.
16042
16024
  *
16043
16025
  * @example
16044
16026
  * ```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
- * {
16027
+ * const markers = createPositionMarkers(candleSeries);
16028
+ * markers.addPosition({
16067
16029
  * 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
- * ]);
16030
+ * entry: { time: '2023-01-01', price: 100.50 },
16031
+ * exit: { time: '2023-01-05', price: 105.20 },
16032
+ * id: 'pos-1',
16033
+ * });
16077
16034
  * ```
16078
16035
  */
16079
16036
  function createPositionMarkers(series, positions, options) {
@@ -20324,9 +20281,6 @@ function createTradingLine(series, chart, options) {
20324
20281
  return new DraggablePriceLine(chart, series, lineOptions);
20325
20282
  }
20326
20283
 
20327
- /**
20328
- * Interactive Line Manager - Permite crear líneas haciendo clic en el gráfico
20329
- */
20330
20284
  class InteractiveLineManager {
20331
20285
  constructor(chart, series) {
20332
20286
  this._private__container = null;
@@ -20355,10 +20309,9 @@ class InteractiveLineManager {
20355
20309
  return price === null ? 0 : price;
20356
20310
  }
20357
20311
  /**
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
20312
+ * Arms the chart so the next click drops a line.
20313
+ *
20314
+ * @returns The line, once the user has clicked.
20362
20315
  */
20363
20316
  enableClickToCreate(mode, customOptions) {
20364
20317
  if (!this._private__container) {
@@ -20379,9 +20332,6 @@ class InteractiveLineManager {
20379
20332
  this._private__container.addEventListener('click', this._private__clickHandler);
20380
20333
  });
20381
20334
  }
20382
- /**
20383
- * Desactiva el modo de creación por clic
20384
- */
20385
20335
  disableClickToCreate() {
20386
20336
  if (this._private__container && this._private__clickHandler) {
20387
20337
  this._private__container.removeEventListener('click', this._private__clickHandler);
@@ -20471,31 +20421,21 @@ class InteractiveLineManager {
20471
20421
  }
20472
20422
  return new DraggablePriceLine(this._private__chart, this._private__series, options);
20473
20423
  }
20474
- /**
20475
- * Obtiene el modo actual de creación
20476
- */
20477
20424
  getCreationMode() {
20478
20425
  return this._private__creationMode;
20479
20426
  }
20480
- /**
20481
- * Verifica si está en modo de creación
20482
- */
20483
20427
  isCreating() {
20484
20428
  return this._private__creationMode !== null;
20485
20429
  }
20486
20430
  }
20487
20431
  /**
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
20432
+ * Lets the user place draggable lines by clicking the chart.
20433
+ *
20492
20434
  * @example
20493
20435
  * ```typescript
20494
20436
  * const manager = createInteractiveLineManager(chart, candleSeries);
20495
- *
20496
- * // Activar modo de creación
20497
20437
  * const line = await manager.enableClickToCreate('stop-loss', {
20498
- * onDragEnd: (price) => console.log('SL:', price)
20438
+ * onDragEnd: (price) => console.log('SL:', price),
20499
20439
  * });
20500
20440
  * ```
20501
20441
  */
@@ -24358,9 +24298,6 @@ function createVerticalLineTool(context, options) {
24358
24298
  return new VerticalLineTool(context, options);
24359
24299
  }
24360
24300
 
24361
- /**
24362
- * Fibonacci Calculator - Cálculos de niveles de retroceso de Fibonacci
24363
- */
24364
24301
  /**
24365
24302
  * Standard Fibonacci retracement ratios
24366
24303
  */
@@ -24506,10 +24443,7 @@ class FibonacciPaneView {
24506
24443
  }
24507
24444
  }
24508
24445
 
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
- */
24446
+ /** Draws 0, 23.6, 38.2, 50, 61.8, 78.6 and 100% unless `levels` says otherwise. */
24513
24447
  /** A ratio and the label it is shown with, derived rather than stored. */
24514
24448
  function toRatio(ratio) {
24515
24449
  return { _internal_ratio: ratio, _internal_label: `${(ratio * 100).toFixed(1)}%` };
@@ -27583,7 +27517,7 @@ class BrushTool extends DrawingToolBase {
27583
27517
  if (this._private__isOverAnotherDrawing()) {
27584
27518
  return;
27585
27519
  }
27586
- const point = this._private__toPanePoint(event);
27520
+ const point = this._private__toPanePoint(event, false);
27587
27521
  if (point === null) {
27588
27522
  return;
27589
27523
  }
@@ -27602,7 +27536,7 @@ class BrushTool extends DrawingToolBase {
27602
27536
  if (!this._private__isDrawing) {
27603
27537
  return;
27604
27538
  }
27605
- const point = this._private__toPanePoint(event);
27539
+ const point = this._private__toPanePoint(event, true);
27606
27540
  if (point === null) {
27607
27541
  return;
27608
27542
  }
@@ -27673,13 +27607,51 @@ class BrushTool extends DrawingToolBase {
27673
27607
  }
27674
27608
  this._private__pointerId = null;
27675
27609
  }
27676
- _private__toPanePoint(event) {
27610
+ /**
27611
+ * Where a press lands relative to the drawing area, or null if it lands
27612
+ * outside it. `clamp` pins the point to the edge instead, for a stroke that
27613
+ * is already under way.
27614
+ */
27615
+ _private__toPanePoint(event, clamp) {
27616
+ const area = this._private__drawArea();
27617
+ if (area === null) {
27618
+ return null;
27619
+ }
27620
+ const x = event.clientX - area._internal_left;
27621
+ const y = event.clientY - area._internal_top;
27622
+ if (clamp) {
27623
+ return {
27624
+ _internal_x: Math.max(0, Math.min(area._internal_width, x)),
27625
+ _internal_y: Math.max(0, Math.min(area._internal_height, y)),
27626
+ };
27627
+ }
27628
+ if (x < 0 || x > area._internal_width || y < 0 || y > area._internal_height) {
27629
+ return null;
27630
+ }
27631
+ return { _internal_x: x, _internal_y: y };
27632
+ }
27633
+ /**
27634
+ * The pane's element is the whole row, price axis cells included, so its
27635
+ * bounds are not the drawing area's. Taking them for it is what let a press
27636
+ * on an axis start a stroke — and be swallowed, leaving the chart unable to
27637
+ * be stretched while the brush was armed.
27638
+ */
27639
+ _private__drawArea() {
27677
27640
  const paneElement = this._private__paneElement();
27678
27641
  if (paneElement === null) {
27679
27642
  return null;
27680
27643
  }
27681
27644
  const rect = paneElement.getBoundingClientRect();
27682
- return { _internal_x: event.clientX - rect.left, _internal_y: event.clientY - rect.top };
27645
+ let left = 0;
27646
+ let width = rect.width;
27647
+ // The time scale measures the drawing area; the left axis, when shown, is
27648
+ // what stands between it and the row's edge.
27649
+ const paneWidth = this._chart.timeScale().width();
27650
+ if (paneWidth > 0) {
27651
+ left = this._chart.priceScale('left').width();
27652
+ width = paneWidth;
27653
+ }
27654
+ return { _internal_left: rect.left + left, _internal_top: rect.top, _internal_width: width, _internal_height: rect.height };
27683
27655
  }
27684
27656
  _private__paneElement() {
27685
27657
  try {
@@ -28302,9 +28274,6 @@ function createTextTool(context, options) {
28302
28274
  return new TextTool(context, options);
28303
28275
  }
28304
28276
 
28305
- /**
28306
- * Position Calculator - Cálculos de P&L, pips, R:R para trading
28307
- */
28308
28277
  class PositionCalculator {
28309
28278
  constructor(pipConfig) {
28310
28279
  this._private__pipConfig = pipConfig;
@@ -28456,9 +28425,6 @@ function getPipConfig(symbolOrPrice, price) {
28456
28425
  };
28457
28426
  }
28458
28427
 
28459
- /**
28460
- * Ruler Calculator - Cálculos de distancia, pips, tiempo para mediciones
28461
- */
28462
28428
  class RulerCalculator {
28463
28429
  constructor(pipConfig) {
28464
28430
  this._private__pipConfig = pipConfig;
@@ -28577,10 +28543,7 @@ class RulerPaneView {
28577
28543
  }
28578
28544
  }
28579
28545
 
28580
- /**
28581
- * Measurement Ruler Tool - Herramienta para medir distancia entre dos puntos
28582
- * Muestra pips, porcentaje, tiempo transcurrido y número de barras
28583
- */
28546
+ /** Measures two points: pips, percent, elapsed time and bar count. */
28584
28547
  class RulerTool extends DrawingToolBase {
28585
28548
  constructor(context, options) {
28586
28549
  super(context, 'ruler-tool', options);
@@ -29140,10 +29103,7 @@ class PositionPaneView {
29140
29103
  }
29141
29104
  }
29142
29105
 
29143
- /**
29144
- * Position Tool - Herramienta unificada para marcar posiciones long/short
29145
- * Muestra dos rectángulos ajustables (profit/loss) con línea vertical conectora
29146
- */
29106
+ /** Two adjustable boxes, profit and loss, joined by a vertical connector. */
29147
29107
  class PositionTool extends DrawingToolBase {
29148
29108
  constructor(context, options) {
29149
29109
  super(context, 'position-tool', options);
@@ -31038,7 +30998,7 @@ const customSeriesDefaultOptions = {
31038
30998
  * Returns the current version as a string. For example `'1.0.0'`.
31039
30999
  */
31040
31000
  function version() {
31041
- return "2.3.1";
31001
+ return "2.3.3";
31042
31002
  }
31043
31003
 
31044
31004
  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 };