@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/barchart.chart.d.ts +2 -0
- chart-lib/barchart.chart.js +1 -1
- chart-lib/index.js +14 -4
- chart-lib/package.json +1 -1
- chart-lib/schemas/chart.schema.json +1861 -0
- chart-lib/schemas/fields.schema.json +60 -0
- chart-lib/schemas/studies.schema.json +103 -0
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
|
|
222
|
-
const
|
|
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
|
|
262
|
-
cfosc = (100 * (
|
|
271
|
+
const src = this.baseVal(this.source, pos);
|
|
272
|
+
cfosc = (100 * (src - mlr)) / src;
|
|
263
273
|
}
|
|
264
274
|
}
|
|
265
275
|
return {
|