Skip to content

Commit

Permalink
Version 5.7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
martynasma committed Dec 18, 2023
1 parent c22e96e commit 0d98433
Show file tree
Hide file tree
Showing 7 changed files with 319 additions and 270 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.7.0",
"version": "5.7.1",
"author": "amCharts <[email protected]> (https://www.amcharts.com/)",
"description": "amCharts 5",
"homepage": "https://www.amcharts.com/",
Expand Down
10 changes: 10 additions & 0 deletions packages/shared/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ 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.7.1] - 2023-12-18

### Fixed
- `DataSaveControl` was always clearing manually-saved drawings/indicators unless auto-save was enabled.
- Drawing tools eraser and clear would not always clear drawings loeaded by a `DataSaveControl`.
- `VolumeProfileIndicator` was not working if added via API.
- `VolumeProfileIndicator` was drawn detached from the Y-axis in some cases.
- Fixed `VWAP` indicator with data that contained zero-volume items.


## [5.7.0] - 2023-12-17

### Added
Expand Down
41 changes: 22 additions & 19 deletions src/.internal/charts/stock/indicators/VWAP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,31 +87,34 @@ export class VWAP extends Indicator {
let i = 0;
let totalVolume = 0;
let totalVW = 0;

$array.each(data, (dataItem) => {
const volumeDI = volumeSeries.dataItems[i];
if (volumeDI) {
const volume = volumeDI.get("valueY", 0);
const vw = dataItem.value_y * volume;

dataItem.vw = vw;
dataItem.volume = volume;

totalVW += vw;
totalVolume += volume;

if (i >= period) {
let volumeToRemove = data[i - period].volume;
let vwToRemove = data[i - period].vw;
if (volumeToRemove != null) {
totalVolume -= volumeToRemove;
if (volume > 0) {
const vw = dataItem.value_y * volume;

dataItem.vw = vw;
dataItem.volume = volume;

totalVW += vw;
totalVolume += volume;

if (i >= period) {
let volumeToRemove = data[i - period].volume;
let vwToRemove = data[i - period].vw;
if (volumeToRemove != null) {
totalVolume -= volumeToRemove;
}
if (vwToRemove != null) {
totalVW -= vwToRemove;
}
}
if (vwToRemove != null) {
totalVW -= vwToRemove;
}
}

dataItem.totalVW = totalVW;
dataItem.vwap = totalVW / totalVolume;
dataItem.totalVW = totalVW;
dataItem.vwap = totalVW / totalVolume;
}
}

i++;
Expand Down
Loading

0 comments on commit 0d98433

Please sign in to comment.