Skip to content

Commit

Permalink
Version 5.5.5
Browse files Browse the repository at this point in the history
  • Loading branch information
martynasma committed Nov 6, 2023
1 parent b34df70 commit 0aff2d1
Show file tree
Hide file tree
Showing 25 changed files with 470 additions and 105 deletions.
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@amcharts/amcharts5",
"version": "5.5.4",
"version": "5.5.5",
"author": "amCharts <contact@amcharts.com> (https://www.amcharts.com/)",
"description": "amCharts 5",
"homepage": "https://www.amcharts.com/",
Expand Down Expand Up @@ -52,13 +52,11 @@
"markerjs2": "^2.29.4",
"pdfmake": "^0.2.2",
"polylabel": "^1.1.0",
"regression": "^2.0.1",
"seedrandom": "^3.0.5",
"svg-arc-to-cubic-bezier": "^3.2.0",
"tslib": "^2.2.0"
},
"devDependencies": {
"@types/regression": "^2.0.2",
"@types/seedrandom": "^3.0.5",
"ansi-colors": "^4.1.1",
"core-js-builder": "^3.15.1",
Expand Down
17 changes: 16 additions & 1 deletion packages/shared/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@ 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.5.5] - 2023-11-06

### Added
- SMA line added to Relative Strength Index indicator in `StockChart`.
- A possibility to draw a Parallel Channel added to `StockChart`.

### Changed
- Removed dependency on the `regression` npm package.

### Fixed
- Change of `minGridDistance` setting on `AxisRenderer` was not being applied until next redraw.
- Snapping of `StockChart` drawings sometimes worked incorrectly.
- Average line was drawn incorectly on a `StockChart` (since `5.5.2`).


## [5.5.4] - 2023-11-01

### Fixed
Expand Down Expand Up @@ -75,7 +90,7 @@ adhere to [Semantic Versioning](http://semver.org/spec/v2.0.0.html) rules.
- New private setting `trustBounds` added to `Sprite`. If set to `true`, the Sprite will check if a mouse pointer is within bounds of a Sprite before dispatching its pointer events. This helps to solve ghost tooltips problem which sometimes appears while moving the pointer over interactive objects. It is set to `true` by default on `Rectangle` and `Circle`.

### Changed
- Previously elements only supported one fill at a time - either `fill` or `fillGradient` or `fillPattern`. Now `fill` or `fillGradient` will be drawn even if `fillPattern` is set. This allows combining
- Previously elements only supported one fill at a time - either `fill` or `fillGradient` or `fillPattern`. Now `fill` or `fillGradient` will be drawn even if `fillPattern` is set. This allows combining
patterns with gradient fills.
- Gradients no longer inherit parent object's `fill`.
- It is now possible to draw annotations on a `StockChart` outside X-axis' min/max using axis overzoom.
Expand Down
10 changes: 6 additions & 4 deletions src/.internal/charts/stock/StockChartDefaultTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -817,8 +817,8 @@ export class StockChartDefaultTheme extends Theme {


r("LineSeries", ["rsi"]).setAll({
legendValueText: "[{seriesColor} bold]{valueY.formatNumber('#.00')}[/]",
legendLabelText: "{shortName} ({period.formatNumber('#.')},{field})"
legendValueText: "[{seriesColor} bold]{valueY.formatNumber('#.00')}[/] [{smaColor} bold]{sma.formatNumber('#.00')}[/]",
legendLabelText: "{shortName} ({period.formatNumber('#.')},{smaPeriod.formatNumber('#.')},{field})"
})

r("LineSeries", ["standarddeviation"]).setAll({
Expand Down Expand Up @@ -1058,12 +1058,14 @@ export class StockChartDefaultTheme extends Theme {
name: "Relative Strength Index",
shortName: "RSI",
period: 14,
smaPeriod: 3,
field: "close",
overSold: 20,
overBought: 80,
overSoldColor: color(0xe40000),
overBoughtColor: color(0x67b7dc),
seriesColor: color(0xab82da)
seriesColor: color(0xab82da),
smaColor: color(0xff903f)
})

r("Momentum").setAll({
Expand Down Expand Up @@ -1309,7 +1311,7 @@ export class StockChartDefaultTheme extends Theme {
r("DrawingControl").setAll({
name: l.translateAny("Draw"),
tool: "Line",
tools: ["Arrows &amp; Icons", "Average", "Callout", "Doodle", "Ellipse", "Fibonacci", "Fibonacci Timezone", "Horizontal Line", "Horizontal Ray", "Label", "Line", "Measure", "Polyline", "Quadrant Line", "Rectangle", "Regression", "Trend Line", "Vertical Line"],
tools: ["Arrows &amp; Icons", "Average", "Callout", "Doodle", "Ellipse", "Fibonacci", "Fibonacci Timezone", "Horizontal Line", "Horizontal Ray", "Label", "Line", "Measure", "Parallel Channel", "Polyline", "Quadrant Line", "Rectangle", "Regression", "Trend Line", "Vertical Line"],
togglable: true,
strokeColor: color(0x882dff),
strokeWidth: 2,
Expand Down
39 changes: 23 additions & 16 deletions src/.internal/charts/stock/drawing/DrawingSeries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -459,8 +459,8 @@ export class DrawingSeries extends LineSeries {
const point = chart.plotContainer.toLocal(event.point);

this._dragStartPX = xAxis.coordinateToPosition(point.x);
const valueX = this._getXValue(xAxis.positionToValue(this._dragStartPX));
this._dragStartY = this._getYValue(yAxis.positionToValue(yAxis.coordinateToPosition(point.y)), valueX);
const valueXns = xAxis.positionToValue(this._dragStartPX);
this._dragStartY = this._getYValue(yAxis.positionToValue(yAxis.coordinateToPosition(point.y)), valueXns);

const dataItems = this._di[index];
if (dataItems) {
Expand All @@ -481,28 +481,32 @@ export class DrawingSeries extends LineSeries {
const yAxis = this.get("yAxis");

const posX = xAxis.coordinateToPosition(point.x);
const valueX = this._getXValue(xAxis.positionToValue(xAxis.coordinateToPosition(point.x)));
const valueY = this._getYValue(yAxis.positionToValue(yAxis.coordinateToPosition(point.y)), valueX);
const valueXns = xAxis.positionToValue(xAxis.coordinateToPosition(point.x));
const valueY = this._getYValue(yAxis.positionToValue(yAxis.coordinateToPosition(point.y)), valueXns);

const dpx = posX - this._dragStartPX;
const dy = valueY - this._dragStartY;

event.target.setAll({
x: 0, y: 0
})

const dataItems = this._di[index];

if (dataItems) {
$object.each(dataItems, (key, dataItem) => {
const dvpx = this._dvpX[key];
const dvy = this._dvY[key];
if ($type.isNumber(dvpx) && $type.isNumber(dvy)) {

const vpx = dvpx + dpx;
let vy = dvy + dy;
const vxns = xAxis.positionToValue(vpx);
const vx = this._getXValue(vxns);

let vy = dvy + dy;
const yAxis = this.get("yAxis");
const roundTo = yAxis.getPrivate("stepDecimalPlaces", 0) + 1;
vy = $math.round(vy, roundTo);

const vx = this._getXValue(xAxis.positionToValue(vpx))
vy = this._getYValue(vy, vxns);

this._setContext(dataItem, "valueX", vx)
this._setContext(dataItem, "valueY", vy, true);
Expand Down Expand Up @@ -663,12 +667,13 @@ export class DrawingSeries extends LineSeries {
const xAxis = this.get("xAxis");
const yAxis = this.get("yAxis");

const vx = this._getXValue(xAxis.positionToValue(xAxis.coordinateToPosition(point.x)));
const vy = this._getYValue(yAxis.positionToValue(yAxis.coordinateToPosition(point.y)), vx);
const valueXns = xAxis.positionToValue(xAxis.coordinateToPosition(point.x));
const valueX = this._getXValue(valueXns);
const valueY = this._getYValue(yAxis.positionToValue(yAxis.coordinateToPosition(point.y)), valueXns);

this._setContext(dataItem, "valueX", vx);
this._setContext(dataItem, "valueY", vy, true);
this._setXLocation(dataItem, vx);
this._setContext(dataItem, "valueX", valueX);
this._setContext(dataItem, "valueY", valueY, true);
this._setXLocation(dataItem, valueX);

this._positionBullets(dataItem);
}
Expand Down Expand Up @@ -789,6 +794,9 @@ export class DrawingSeries extends LineSeries {
if (!this.get("snapToData")) {
this._setXLocationReal(dataItem, value);
}
else {
dataItem.set("locationX", undefined);
}
}

protected _setXLocationReal(dataItem: DataItem<this["_dataItemSettings"]>, value: number) {
Expand Down Expand Up @@ -856,7 +864,7 @@ export class DrawingSeries extends LineSeries {
const max = xAxis.getPrivate("max", 1) - 1;

value = $math.fitToRange(value, min, max);
value = this._snap(value, value, "valueX", series);
value = this._snap(value, value, "valueX", series) + 1; // important!
return value
}
else {
Expand All @@ -879,8 +887,7 @@ export class DrawingSeries extends LineSeries {

protected _snap(value: number, realValue: number, key: string, series: XYSeries): number {
const xAxis = this.get("xAxis");
const dataItem = xAxis.getSeriesItem(series, Math.max(0, xAxis.valueToPosition(value)));

const dataItem = xAxis.getSeriesItem(series, Math.max(0, xAxis.valueToPosition(value)), 0.5, true);
if (dataItem) {
return dataItem.get(key as any)!;
}
Expand Down
13 changes: 9 additions & 4 deletions src/.internal/charts/stock/drawing/HorizontalRaySeries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,19 @@ export class HorizontalRaySeries extends SimpleLineSeries {

const series = this.get("series");
if (series && diP1 && diP2) {
const valueX = this._getXValue(diP2.get("valueX" as any));
const valueY = this._getYValue(valueX, valueX);
const valueXns = diP2.get("valueX" as any);
let valueY = diP2.get("valueY" as any)
const valueX = this._getXValue(valueXns);
valueY = this._getYValue(valueY, valueXns);

this._setContext(diP1, "valueY", valueY, true);
this._setContext(diP2, "valueY", valueY, true);

this._setContext(diP1, "valueX", valueX);
this._setContext(diP2, "valueX", valueX + 0.01);
this._setContext(diP2, "valueX", valueX);
this._setContext(diP1, "valueX", valueX + 1);

this._setXLocation(diP2, valueX);
this._setXLocation(diP1, valueX + 1);

this._positionBullets(diP1);
this._positionBullets(diP2);
Expand Down
Loading

0 comments on commit 0aff2d1

Please sign in to comment.