Skip to content

Commit

Permalink
Version 5.4.8
Browse files Browse the repository at this point in the history
  • Loading branch information
martynasma committed Sep 22, 2023
1 parent 25951de commit 39bb139
Show file tree
Hide file tree
Showing 16 changed files with 226 additions and 52 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@amcharts/amcharts5",
"version": "5.4.7",
"version": "5.4.8",
"author": "amCharts <[email protected]> (https://www.amcharts.com/)",
"description": "amCharts 5",
"homepage": "https://www.amcharts.com/",
Expand Down
14 changes: 14 additions & 0 deletions packages/shared/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
Please note, that this project, while following numbering syntax, it DOES NOT
adhere to [Semantic Versioning](http://semver.org/spec/v2.0.0.html) rules.

## [5.4.8] - 2023-09-22

### Added
- Momentum indicator added to `StockChart`.

### Fixed
- `"z"` date formatting codes were not respecting the `Root.timezone` setting.
- If a new data was loaded and `groupData` of `DateAxis` was changed from `true` to `false`, the chart was not displaying the newly-loaded data properly.
- Accessibility: togglable elements like legend items were not being toggled by ENTER and SPACE keys with some screen reaaders (JAWS, Narrator) active.
- RST indicator of `StockChart` was always using "close" value even if a different value was selected in the settings.
- In some case chart could freeze when selecting with an `XYCursor` and releasing outside plot area.
- If a new animation of the same setting was created right after previous animation finished (on `Animation`'s `"stopped"` event) the animation would not play.


## [5.4.7] - 2023-09-18

### Added
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ This amCharts software is provided under linkware license, conditions of which a

### If the following conditions are met

* You do not disable, hide or alter the branding link which is displayed on all the content generated by amCharts software unless you provide some other adequately prominent attribution to amCharts.
* You do not disable, hide or alter the branding link which is displayed on all the content generated by amCharts software.
* You include this original LICENSE file together with original (or modified) files from amCharts software.
* Your own personal license does not supersede or in any way negate the effect of this LICENSE, or make the impression of doing so.

### You can't

* Remove or alter this LICENSE file.
* Remove any of the amCharts copyright notices from any of the files of amCharts software.
* Use amCharts software without any kind of prominent attribution (bundled or custom). Please see note about commercial amCharts licenses below.
* Use amCharts software without built-in attribution (logo). Please see note about commercial amCharts licenses below.
* Sell or receive any compensation for amCharts software.
* Distribute amCharts software on its own, not as part of other application.

Expand Down
15 changes: 14 additions & 1 deletion src/.internal/charts/stock/StockChartDefaultTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,11 @@ export class StockChartDefaultTheme extends Theme {
legendLabelText: "{shortName} ({period.formatNumber('#.')},{field})"
})

r("LineSeries", ["momentum"]).setAll({
legendValueText: "[{seriesColor} bold]{valueY.formatNumber('#.000a')}[/]",
legendLabelText: "{shortName} ({period.formatNumber('#.')},{field})"
})

r("LineSeries", ["williamsr"]).setAll({
legendValueText: "[{seriesColor} bold]{valueY.formatNumber('#.000a')}[/]",
legendLabelText: "{shortName} ({period.formatNumber('#.')})"
Expand Down Expand Up @@ -1059,6 +1064,14 @@ export class StockChartDefaultTheme extends Theme {
seriesColor: color(0xab82da)
})

r("Momentum").setAll({
name: "Momentum",
shortName: "Mom",
period: 14,
field: "close",
seriesColor: color(0xab82da)
})

r("WilliamsR").setAll({
name: "Williams %R",
shortName: "Williams %R",
Expand Down Expand Up @@ -1154,7 +1167,7 @@ export class StockChartDefaultTheme extends Theme {

r("IndicatorControl").setAll({
name: l.translateAny("Indicators"),
indicators: ["Aroon", "Accumulation Distribution", "Accumulative Swing Index", "Awesome Oscillator", "Bollinger Bands", "Chaikin Money Flow", "Chaikin Oscillator", "Commodity Channel Index", "Disparity Index", "MACD", "Median Price", "Moving Average", "Moving Average Deviation", "Moving Average Envelope", "On Balance Volume", "Relative Strength Index", "Standard Deviation", "Stochastic Oscillator", "Trix", "Typical Price", "Volume", "VWAP", "Williams R", "ZigZag"]
indicators: ["Aroon", "Accumulation Distribution", "Accumulative Swing Index", "Awesome Oscillator", "Bollinger Bands", "Chaikin Money Flow", "Chaikin Oscillator", "Commodity Channel Index", "Disparity Index", "MACD", "Median Price", "Momentum", "Moving Average", "Moving Average Deviation", "Moving Average Envelope", "On Balance Volume", "Relative Strength Index", "Standard Deviation", "Stochastic Oscillator", "Trix", "Typical Price", "Volume", "VWAP", "Williams R", "ZigZag"]
});

r("ComparisonControl").setAll({
Expand Down
98 changes: 98 additions & 0 deletions src/.internal/charts/stock/indicators/Momentum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import type { IIndicatorEditableSetting } from "./Indicator";

import { ChartIndicator, IChartIndicatorSettings, IChartIndicatorPrivate, IChartIndicatorEvents } from "./ChartIndicator";
import { LineSeries } from "../../xy/series/LineSeries";

import * as $array from "../../../core/util/Array";

export interface IMomentumSettings extends IChartIndicatorSettings {
}

export interface IMomentumPrivate extends IChartIndicatorPrivate {
}

export interface IMomentumEvents extends IChartIndicatorEvents {
}


/**
* An implementation of a [[StockChart]] indicator.
*
* @see {@link https://www.amcharts.com/docs/v5/charts/stock/indicators/} for more info
* @since 5.4.8
*/
export class Momentum extends ChartIndicator {
public static className: string = "Momentum";
public static classNames: Array<string> = ChartIndicator.classNames.concat([Momentum.className]);

declare public _settings: IMomentumSettings;
declare public _privateSettings: IMomentumPrivate;
declare public _events: IMomentumEvents;

/**
* Indicator series.
*/
declare public series: LineSeries;

public _editableSettings: IIndicatorEditableSetting[] = [
{
key: "period",
name: this.root.language.translateAny("Period"),
type: "number"
}, {
key: "field",
name: this.root.language.translateAny("Field"),
type: "dropdown",
options: ["open", "close", "low", "high", "hl/2", "hlc/3", "hlcc/4", "ohlc/4"]
}, {
key: "seriesColor",
name: this.root.language.translateAny("Color"),
type: "color"
}
];

protected _themeTag: string = "momentum";

public _createSeries(): LineSeries {
return this.panel.series.push(LineSeries.new(this._root, {
themeTags: ["indicator"],
xAxis: this.xAxis,
yAxis: this.yAxis,
valueXField: "valueX",
valueYField: "valueY",
stroke: this.get("seriesColor"),
fill: undefined
}))
}

/**
* @ignore
*/
public prepareData() {
if (this.series) {
const dataItems = this.get("stockSeries").dataItems;
const period = this.get("period", 14);
const data: Array<any> = [];

let i = 0;

$array.each(dataItems, (dataItem) => {
if (i > period) {
let value = this._getValue(dataItem);
let prevValue = this._getValue(dataItems[i - period]);

if (value != undefined && prevValue != undefined) {
data.push({ valueX: dataItem.get("valueX"), valueY: value - prevValue });
}
}
else {
data.push({ valueX: dataItem.get("valueX") });
}
i++;
})


this.series.data.setAll(data);
}
}
}
51 changes: 27 additions & 24 deletions src/.internal/charts/stock/indicators/RelativeStrengthIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,40 +246,43 @@ export class RelativeStrengthIndex extends ChartIndicator {

if (i == period + 1) {
for (let j = 1; j <= period; j++) {
let value = dataItems[j].get("valueY", 0)
let prevValue = dataItems[j - 1].get("valueY", 0);
let change = value - prevValue;

if (change > 0) {
averageGain += change / period;
}
else {
averageLoss += Math.abs(change) / period;
let value = this._getValue(dataItems[j]);
let prevValue = this._getValue(dataItems[j - 1]);
if (value != undefined && prevValue != undefined) {
let change = value - prevValue;

if (change > 0) {
averageGain += change / period;
}
else {
averageLoss += Math.abs(change) / period;
}
}
}

rsi = 100 - (100 / (1 + averageGain / averageLoss));
}
else if (i > period) {
let value = dataItem.get("valueY", 0);
let prevValue = dataItems[i - 2].get("valueY", 0);

let change = value - prevValue;
let value = this._getValue(dataItem);
let prevValue = this._getValue(dataItems[i - 2]);
if (value != null && prevValue != null) {
let change = value - prevValue;

let gain = 0;
let loss = 0;
let gain = 0;
let loss = 0;

if (change > 0) {
gain = change;
}
else {
loss = -change;
}
if (change > 0) {
gain = change;
}
else {
loss = -change;
}

averageGain = (prevAverageGain * (period - 1) + gain) / period;
averageLoss = (prevAverageLoss * (period - 1) + loss) / period;
averageGain = (prevAverageGain * (period - 1) + gain) / period;
averageLoss = (prevAverageLoss * (period - 1) + loss) / period;

rsi = 100 - (100 / (1 + averageGain / averageLoss));
rsi = 100 - (100 / (1 + averageGain / averageLoss));
}
}

data.push({ valueX: dataItem.get("valueX"), valueY: rsi });
Expand Down
9 changes: 8 additions & 1 deletion src/.internal/charts/stock/toolbar/IndicatorControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { StandardDeviation } from "../indicators/StandardDeviation";
import { TypicalPrice } from "../indicators/TypicalPrice";
import { MedianPrice } from "../indicators/MedianPrice";
import { OnBalanceVolume } from "../indicators/OnBalanceVolume";
import { Momentum } from "../indicators/Momentum";
import { RelativeStrengthIndex } from "../indicators/RelativeStrengthIndex";
import { StochasticOscillator } from "../indicators/StochasticOscillator";
import { WilliamsR } from "../indicators/WilliamsR";
Expand All @@ -38,7 +39,7 @@ import { StockIcons } from "./StockIcons";
import * as $array from "../../../core/util/Array";
import * as $type from "../../../core/util/Type";

export type Indicators = "Accumulation Distribution" | "Accumulative Swing Index" | "Aroon" | "Awesome Oscillator" | "Bollinger Bands" | "Chaikin Money Flow" | "Chaikin Oscillator" | "Commodity Channel Index" | "Disparity Index" | "MACD" | "Moving Average" | "Moving Average Deviation" | "Moving Average Envelope" | "On Balance Volume" | "Relative Strength Index" | "Standard Deviation" | "Stochastic Oscillator" | "Trix" | "Typical Price" | "Volume" | "VWAP" | "Williams R" | "Median Price" | "ZigZag";
export type Indicators = "Accumulation Distribution" | "Accumulative Swing Index" | "Aroon" | "Awesome Oscillator" | "Bollinger Bands" | "Chaikin Money Flow" | "Chaikin Oscillator" | "Commodity Channel Index" | "Disparity Index" | "MACD" | "Momentum" | "Moving Average" | "Moving Average Deviation" | "Moving Average Envelope" | "On Balance Volume" | "Relative Strength Index" | "Standard Deviation" | "Stochastic Oscillator" | "Trix" | "Typical Price" | "Volume" | "VWAP" | "Williams R" | "Median Price" | "ZigZag";

export interface IIndicator {
id: string;
Expand Down Expand Up @@ -262,6 +263,12 @@ export class IndicatorControl extends StockControl {
legend: legend
});
break;
case "Momentum":
indicator = Momentum.new(this.root, {
stockChart: stockChart,
stockSeries: stockSeries
});
break;
case "Median Price":
indicator = MedianPrice.new(this.root, {
stockChart: stockChart,
Expand Down
5 changes: 2 additions & 3 deletions src/.internal/charts/xy/XYChart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1291,9 +1291,8 @@ export class XYChart extends SerialChart {
const downPositionX = cursor.getPrivate("downPositionX", 0);
const downPositionY = cursor.getPrivate("downPositionY", 0);

const positionX = cursor.getPrivate("positionX", 0.5);
const positionY = cursor.getPrivate("positionY", 0.5);

const positionX = Math.min(1, Math.max(0, cursor.getPrivate("positionX", 0.5)));
const positionY = Math.min(1, Math.max(0, cursor.getPrivate("positionY", 0.5)));

this.xAxes.each((axis) => {
if (behavior === "zoomX" || behavior === "zoomXY") {
Expand Down
1 change: 1 addition & 0 deletions src/.internal/charts/xy/axes/DateAxis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ export class DateAxis<R extends AxisRenderer> extends ValueAxis<R> {
let mainDataSetId: string = baseInterval.timeUnit + baseInterval.count;
$array.each(this.series, (series) => {
series.setDataSet(mainDataSetId);
series.resetGrouping();
})

this._setBaseInterval(baseInterval);
Expand Down
22 changes: 18 additions & 4 deletions src/.internal/charts/xy/series/XYSeries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -915,8 +915,8 @@ export abstract class XYSeries extends Series {
protected _tooltipFieldX?: string;
protected _tooltipFieldY?: string;

public _posXDp?:IDisposer;
public _posYDp?:IDisposer;
public _posXDp?: IDisposer;
public _posYDp?: IDisposer;

protected _afterNew() {
this.fields.push("categoryX", "categoryY", "openCategoryX", "openCategoryY");
Expand Down Expand Up @@ -1221,7 +1221,7 @@ export abstract class XYSeries extends Series {
this._valuesDirty = true;
}

if(this.isDirty("xAxis") || this.isDirty("yAxis")){
if (this.isDirty("xAxis") || this.isDirty("yAxis")) {
this._valuesDirty = true;
}

Expand Down Expand Up @@ -1359,7 +1359,6 @@ export abstract class XYSeries extends Series {
}

if (this._valuesDirty || this.isPrivateDirty("startIndex") || this.isPrivateDirty("endIndex") || this.isDirty("vcx") || this.isDirty("vcy") || this._stackDirty) {

let startIndex = this.startIndex();
let endIndex = this.endIndex();
let minBulletDistance = this.get("minBulletDistance", 0);
Expand Down Expand Up @@ -1786,6 +1785,21 @@ export abstract class XYSeries extends Series {
}
}

/**
* @ignore
*/
public resetGrouping() {
$object.each(this._dataSets, (_key, dataSet) => {
if (dataSet != this._mainDataItems) {
$array.each(dataSet, (dataItem) => {
this.disposeDataItem(dataItem);
})
}
})
this._dataSets = {};
this._dataItems = this.mainDataItems;
}

protected _handleDataSetChange() {
if (this.bullets.length > 0) {
$array.each(this._dataItems, (dataItem) => {
Expand Down
2 changes: 2 additions & 0 deletions src/.internal/core/Classes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ import type { MapPolygonSeries } from "./../charts/map/MapPolygonSeries.js";
import type { MapSeries } from "./../charts/map/MapSeries.js";
import type { MedianPrice } from "./../charts/stock/indicators/MedianPrice.js";
import type { Modal } from "./util/Modal.js";
import type { Momentum } from "./../charts/stock/indicators/Momentum.js";
import type { MovingAverage } from "./../charts/stock/indicators/MovingAverage.js";
import type { MovingAverageDeviation } from "./../charts/stock/indicators/MovingAverageDeviation.js";
import type { MovingAverageEnvelope } from "./../charts/stock/indicators/MovingAverageEnvelope.js";
Expand Down Expand Up @@ -326,6 +327,7 @@ export interface IClasses {
"MapSeries": MapSeries;
"MedianPrice": MedianPrice;
"Modal": Modal;
"Momentum": Momentum;
"MovingAverage": MovingAverage;
"MovingAverageDeviation": MovingAverageDeviation;
"MovingAverageEnvelope": MovingAverageEnvelope;
Expand Down
2 changes: 1 addition & 1 deletion src/.internal/core/Registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export class Registry {
/**
* Currently running version of amCharts.
*/
readonly version: string = "5.4.7";
readonly version: string = "5.4.8";

/**
* List of applied licenses.
Expand Down
Loading

0 comments on commit 39bb139

Please sign in to comment.