@barchart/chart-lib 2.201.1 → 2.201.2

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.
chart-lib/index.js CHANGED
@@ -12,6 +12,9 @@ import {
12
12
  SeriesKind,
13
13
  OHLCDataPointBuilder,
14
14
  StudySeries,
15
+ linReg,
16
+ convertSeries,
17
+ mapSeries,
15
18
  } from "./barchart.chart.js";
16
19
 
17
20
  const ohlcFields = [
@@ -218,8 +221,15 @@ class ChandeForecastOscillatorSeries1 extends StudySeries {
218
221
  constructor(options, innerSeries) {
219
222
  super(options, innerSeries);
220
223
  const linRegSeries = linReg(innerSeries, this.period, this.source);
221
- const oscFunc = (_pos, close, linReg) => (null === close ? null : (100 * (close - linReg)) / close);
222
- const oscSeries = mapSeries(this.target, oscFunc, innerSeries, linRegSeries);
224
+ const that = this; // chart replaces `this` inside `convertSeries` with its return value
225
+ const pluckField = function (pos) {
226
+ return {
227
+ [that.source.id]: this.baseVal(that.source, pos),
228
+ };
229
+ };
230
+ const sourceSeries = convertSeries(this.source, pluckField, innerSeries);
231
+ const oscFunc = (_pos, src, linReg) => (null === src ? null : (100 * (src - linReg)) / src);
232
+ const oscSeries = mapSeries(this.target, oscFunc, sourceSeries, linRegSeries);
223
233
  this.addInner(oscSeries);
224
234
  }
225
235
  // no need for `calculateAt`, just need to expose the computed value from inner series
@@ -258,8 +268,8 @@ class ChandeForecastOscillatorSeries2 extends StudySeries {
258
268
  const intercept = (ySum - slope * this.xSum) / per;
259
269
  const mlr = intercept + slope * per;
260
270
  // y = a + b * x; a = intercept, b = slope; y = price, x = date (of bar) index
261
- const close = this.baseVal(this.source, pos);
262
- cfosc = (100 * (close - mlr)) / close;
271
+ const src = this.baseVal(this.source, pos);
272
+ cfosc = (100 * (src - mlr)) / src;
263
273
  }
264
274
  }
265
275
  return {
chart-lib/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barchart/chart-lib",
3
- "version": "2.201.1",
3
+ "version": "2.201.2",
4
4
  "description": "Barchart HTML5 Streaming Chart",
5
5
  "main": "barchart.chart.js",
6
6
  "types": "barchart.chart.d.ts",