@pipsend/charts 2.1.0 → 2.2.0

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.
package/README.md CHANGED
@@ -260,10 +260,15 @@ const ha = applyHeikinAshi(series, chart);
260
260
  ha.remove();
261
261
  ```
262
262
 
263
- The source series keeps its real prices and is only hidden, so indicators bound
264
- to it keep computing on the true OHLC, and `remove()` restores the chart exactly
265
- as it was — which makes this usable as a chart-type toggle. New bars pushed to
266
- the source are transformed automatically.
263
+ The source series keeps its real prices and is only painted transparent, not
264
+ hidden: indicators bound to it keep computing on the true OHLC, its price lines
265
+ and primitives (positions, alerts, drawings) stay on screen, and `remove()`
266
+ restores the chart exactly as it was — which makes this usable as a chart-type
267
+ toggle. New bars pushed to the source are transformed automatically.
268
+
269
+ The same trick is exported as `hideSeriesPaint(series)` for drawing any other
270
+ view over a series: it blanks the paint, leaves the series visible to the engine,
271
+ and returns a function that puts the paint back.
267
272
 
268
273
  Colors can be changed on a running transform, and are the candlestick ones:
269
274
 
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * @license
3
- * Pipsend Charts v2.1.0
3
+ * Pipsend Charts v2.2.0
4
4
  * Copyright (c) 2026 Pipsend
5
5
  * Licensed under MIT License
6
6
  * Built on TradingView Lightweight Charts™ (Apache 2.0)
@@ -15520,6 +15520,85 @@ function hasSeriesVolumes(series) {
15520
15520
  return volumes !== undefined && volumes.size > 0;
15521
15521
  }
15522
15522
 
15523
+ const TRANSPARENT = 'rgba(0, 0, 0, 0)';
15524
+ /**
15525
+ * Take a series off the screen without hiding it.
15526
+ *
15527
+ * `visible: false` takes down everything hung off the series as well: its
15528
+ * price lines, primitives and price-axis label stop rendering. A transform
15529
+ * that only wants the bars themselves out of the way — Heikin Ashi drawing
15530
+ * over its source — needs the series to stay visible to the engine, so its
15531
+ * paint is made transparent instead and the last-value label and price line
15532
+ * are switched off. Custom series have no known colours; those fall back to
15533
+ * `visible: false`.
15534
+ *
15535
+ * @param series - Series to blank out.
15536
+ * @returns Puts back the options the series had when it was blanked.
15537
+ */
15538
+ function hideSeriesPaint(series) {
15539
+ switch (series.seriesType()) {
15540
+ case 'Candlestick':
15541
+ return blank(series, {
15542
+ upColor: TRANSPARENT,
15543
+ downColor: TRANSPARENT,
15544
+ borderVisible: false,
15545
+ wickVisible: false,
15546
+ });
15547
+ case 'Bar':
15548
+ return blank(series, {
15549
+ upColor: TRANSPARENT,
15550
+ downColor: TRANSPARENT,
15551
+ });
15552
+ case 'Line':
15553
+ return blank(series, {
15554
+ color: TRANSPARENT,
15555
+ crosshairMarkerVisible: false,
15556
+ pointMarkersVisible: false,
15557
+ });
15558
+ case 'Area':
15559
+ return blank(series, {
15560
+ lineColor: TRANSPARENT,
15561
+ topColor: TRANSPARENT,
15562
+ bottomColor: TRANSPARENT,
15563
+ crosshairMarkerVisible: false,
15564
+ pointMarkersVisible: false,
15565
+ });
15566
+ case 'Baseline':
15567
+ return blank(series, {
15568
+ topLineColor: TRANSPARENT,
15569
+ topFillColor1: TRANSPARENT,
15570
+ topFillColor2: TRANSPARENT,
15571
+ bottomLineColor: TRANSPARENT,
15572
+ bottomFillColor1: TRANSPARENT,
15573
+ bottomFillColor2: TRANSPARENT,
15574
+ crosshairMarkerVisible: false,
15575
+ pointMarkersVisible: false,
15576
+ });
15577
+ case 'Histogram':
15578
+ return blank(series, {
15579
+ color: TRANSPARENT,
15580
+ });
15581
+ default:
15582
+ return blank(series, { visible: false });
15583
+ }
15584
+ }
15585
+ function blank(series, paint) {
15586
+ const patch = {
15587
+ ...paint,
15588
+ lastValueVisible: false,
15589
+ priceLineVisible: false,
15590
+ };
15591
+ const before = series.options();
15592
+ const snapshot = {};
15593
+ for (const key of Object.keys(patch)) {
15594
+ snapshot[key] = before[key];
15595
+ }
15596
+ series.applyOptions(patch);
15597
+ return () => {
15598
+ series.applyOptions(snapshot);
15599
+ };
15600
+ }
15601
+
15523
15602
  /**
15524
15603
  * Pins a bounded indicator (RSI, Stochastic…) to a fixed price range.
15525
15604
  *
@@ -17216,9 +17295,9 @@ function calculateHeikinAshi(bars) {
17216
17295
  * Draw a source series as Heikin Ashi candles.
17217
17296
  *
17218
17297
  * The source series is left in place holding its real prices — it is only
17219
- * hidden — so indicators bound to it keep computing on the true OHLC, and
17220
- * `remove()` puts the chart back exactly as it was. That makes this usable as a
17221
- * chart-type toggle:
17298
+ * painted transparent — so indicators bound to it keep computing on the true
17299
+ * OHLC, its price lines and primitives stay on screen, and `remove()` puts the
17300
+ * chart back exactly as it was. That makes this usable as a chart-type toggle:
17222
17301
  *
17223
17302
  * ```js
17224
17303
  * const ha = applyHeikinAshi(candleSeries, chart);
@@ -17260,10 +17339,16 @@ function applyHeikinAshi(series, chart, options = {}) {
17260
17339
  priceScaleId: sourceOptions.priceScaleId,
17261
17340
  priceFormat: sourceOptions.priceFormat,
17262
17341
  }, resolved.paneIndex);
17263
- const sourceWasVisible = sourceOptions.visible;
17264
- if (resolved.hideSource === true) {
17265
- series.applyOptions({ visible: false });
17266
- }
17342
+ let restoreSourcePaint = null;
17343
+ const blankSource = (blank) => {
17344
+ if (blank && restoreSourcePaint === null) {
17345
+ restoreSourcePaint = hideSeriesPaint(series);
17346
+ }
17347
+ else if (!blank && restoreSourcePaint !== null) {
17348
+ restoreSourcePaint();
17349
+ restoreSourcePaint = null;
17350
+ }
17351
+ };
17267
17352
  const runtime = bindIndicator({
17268
17353
  _internal_source: series,
17269
17354
  _internal_chart: chart,
@@ -17287,9 +17372,7 @@ function applyHeikinAshi(series, chart, options = {}) {
17287
17372
  wickUpColor: current.wickUpColor,
17288
17373
  wickDownColor: current.wickDownColor,
17289
17374
  });
17290
- series.applyOptions({
17291
- visible: current.hideSource === true ? false : sourceWasVisible,
17292
- });
17375
+ blankSource(current.hideSource === true);
17293
17376
  },
17294
17377
  });
17295
17378
  const handle = {
@@ -17299,10 +17382,10 @@ function applyHeikinAshi(series, chart, options = {}) {
17299
17382
  recalculate: runtime.recalculate,
17300
17383
  remove: () => {
17301
17384
  runtime.remove();
17302
- // The source outlives the indicator, so its visibility is ours to put
17385
+ // The source outlives the indicator, so its paint is ours to put
17303
17386
  // back — otherwise removing a Heikin Ashi overlay leaves a blank chart.
17304
17387
  try {
17305
- series.applyOptions({ visible: sourceWasVisible });
17388
+ blankSource(false);
17306
17389
  }
17307
17390
  catch (error) {
17308
17391
  // The series may already be gone if the chart was disposed
@@ -29370,7 +29453,7 @@ const customSeriesDefaultOptions = {
29370
29453
  * Returns the current version as a string. For example `'1.0.0'`.
29371
29454
  */
29372
29455
  function version() {
29373
- return "2.1.0";
29456
+ return "2.2.0";
29374
29457
  }
29375
29458
 
29376
- 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, 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, createPositionMarkers, createPositionTool, createRectangleTool, createRulerTool, createSeriesMarkers, createTextTool, createTextWatermark, createTradingLine, createTradingSessionsIndicator, createTrendLineTool, createUpDownMarkers, createVerticalLineTool, createVolumeProfileIndicator, createYieldCurveChart, customSeriesDefaultOptions, defaultHorzScaleBehavior, getPipConfig, isBusinessDay, isUTCTimestamp, setSeriesVolumes, setVolumeProfileData, timeFromCoordinate, version };
29459
+ 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, 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, createPositionMarkers, createPositionTool, createRectangleTool, createRulerTool, createSeriesMarkers, createTextTool, createTextWatermark, createTradingLine, createTradingSessionsIndicator, createTrendLineTool, createUpDownMarkers, createVerticalLineTool, createVolumeProfileIndicator, createYieldCurveChart, customSeriesDefaultOptions, defaultHorzScaleBehavior, getPipConfig, hideSeriesPaint, isBusinessDay, isUTCTimestamp, setSeriesVolumes, setVolumeProfileData, timeFromCoordinate, version };