Skip to content

Commit

Permalink
Version 5.4.9
Browse files Browse the repository at this point in the history
  • Loading branch information
martynasma committed Oct 6, 2023
1 parent 39bb139 commit 94fdad7
Show file tree
Hide file tree
Showing 11 changed files with 152 additions and 38 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.8",
"version": "5.4.9",
"author": "amCharts <[email protected]> (https://www.amcharts.com/)",
"description": "amCharts 5",
"homepage": "https://www.amcharts.com/",
Expand Down
12 changes: 12 additions & 0 deletions packages/shared/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@ 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.9] - 2023-10-06

### Added
- `drawingsInteractive(value: bool)` method added to `StockChart`. `false` will make current annotations (drawings) to be fully static (non-editable).

### Fixed
- Zoom out button on `XYChart` was not focusable.
- Pulled out slices of a `PieSeries` could overlap with other slices if some slices were hidden.
- Pinch-zooming was not working properly in `XYChart`.
- Candlesticks on a `StockChart` were being colored based on previous period close value instead of current period open value.


## [5.4.8] - 2023-09-22

### Added
Expand Down
84 changes: 73 additions & 11 deletions src/.internal/charts/stock/StockChart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type { XYSeries, IXYSeriesDataItem, IXYSeriesSettings } from "../xy/serie
import type { DataItem } from "../../core/render/Component";
import type { Indicator } from "./indicators/Indicator";
import type { DrawingSeries } from "./drawing/DrawingSeries";
import type { SimpleLineSeries } from "./drawing/SimpleLineSeries";
import { MultiDisposer } from "../../core/util/Disposer";

import { PanelControls } from "./PanelControls";
Expand Down Expand Up @@ -142,7 +143,7 @@ export interface IStockChartEvents extends IContainerEvents {
drawingsupdated: {};

/**
* Kicks in when drawings change.
* Kicks in when indicators change.
*/
indicatorsupdated: {};
}
Expand Down Expand Up @@ -280,16 +281,62 @@ export class StockChart extends Container {
}
}

/**
* Forces redrawing of all annotations (drfawings).
*/
public markDirtyDrawings() {
this._drawingsChanged = true;
this.markDirty();
}

/**
* Forces redrawing of Indicators.
*/
public markDirtyIndicators() {
this._indicatorsChanged = true;
this.markDirty();
}

/**
* Enables or disables interactivity of annotations (drawings).
*
* @param value Drawings interactive?
* @since 5.4.9
*/
public drawingsInteractive(value: boolean) {
this.panels.each((panel) => {
panel.series.each((series) => {
if (series.isType<DrawingSeries>("DrawingSeries")) {
series.strokes.each((stroke) => {
stroke.set("interactive", value)
});

series.fills.each((fill) => {
fill.set("interactive", value)
});

$array.each(series.dataItems, (dataItem) => {
if (dataItem.bullets) {
const bullet = dataItem.bullets[0];
if (bullet) {
const sprite = bullet.get("sprite");
if (sprite) {
sprite.set("interactive", value);
}
}
}
})

if (series.isType<SimpleLineSeries>("SimpleLineSeries")) {
series.hitLines.each((hitLine) => {
hitLine.set("interactive", value)
})
}
}
})
})
}

public _prepareChildren() {

if (this.isDirty("volumeNegativeColor") || this.isDirty("volumePositiveColor")) {
Expand All @@ -303,7 +350,6 @@ export class StockChart extends Container {

const stockSeries = this.get("stockSeries");


if (this.isDirty("stockSeries")) {
if (stockSeries) {
this.indicators.each((indicator) => {
Expand Down Expand Up @@ -391,8 +437,8 @@ export class StockChart extends Container {
const stockNegativeColor = this.get("stockNegativeColor", this._root.interfaceColors.get("negative"));
const stockPositiveColor = this.get("stockPositiveColor", this._root.interfaceColors.get("positive"));
let previous = stockSeries.dataItems[0];
if(stockPositiveColor && stockPositiveColor){

if (stockPositiveColor && stockPositiveColor) {
$array.each(stockSeries.dataItems, (dataItem) => {
const column = dataItem.get("graphics");
if (column) {
Expand Down Expand Up @@ -421,11 +467,27 @@ export class StockChart extends Container {
}
})

stockSeries.columns.template.states.create("riseFromOpen", { fill: stockPositiveColor, stroke: stockPositiveColor });
stockSeries.columns.template.states.create("riseFromPrevious", { fill: stockPositiveColor, stroke: stockPositiveColor });
const states = stockSeries.columns.template.states;

stockSeries.columns.template.states.create("dropFromOpen", { fill: stockNegativeColor, stroke: stockNegativeColor });
stockSeries.columns.template.states.create("dropFromPrevious", { fill: stockNegativeColor, stroke: stockNegativeColor });
const riseFromOpen = states.lookup("riseFromOpen");
if (riseFromOpen) {
riseFromOpen.setAll({ fill: stockPositiveColor, stroke: stockPositiveColor });
}

const riseFromPrevious = states.lookup("riseFromPrevious");
if (riseFromPrevious) {
riseFromPrevious.setAll({ fill: stockPositiveColor, stroke: stockPositiveColor });
}

const dropFromOpen = states.lookup("dropFromOpen");
if (dropFromOpen) {
dropFromOpen.setAll({ fill: stockNegativeColor, stroke: stockNegativeColor });
}

const dropFromPrevious = states.lookup("dropFromPrevious");
if (dropFromPrevious) {
dropFromPrevious.setAll({ fill: stockNegativeColor, stroke: stockNegativeColor });
}
}

stockSeries.markDirtyValues();
Expand Down Expand Up @@ -453,7 +515,7 @@ export class StockChart extends Container {
const yAxis = stockSeries.get("yAxis") as ValueAxis<AxisRenderer>;
yAxis.set("logarithmic", false);


this._maybePrepAxisDefaults();
if (mainChart) {
const seriesList: XYSeries[] = [];
Expand Down Expand Up @@ -538,7 +600,7 @@ export class StockChart extends Container {
}
}

if (this.get("autoSetPercentScale")) {
if (this.get("autoSetPercentScale")) {
this.setPercentScale(true);
}

Expand Down Expand Up @@ -865,7 +927,7 @@ export class StockChart extends Container {
}


if(negativeColor && positiveColor){
if (negativeColor && positiveColor) {
if (stockSeries && volumeSeries) {
const index = volumeSeries.dataItems.indexOf(dataItem);
if (index > 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/.internal/charts/xy/XYChart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ export class XYChart extends SerialChart {
const plotContainer = this.plotContainer;

if (this.get("pinchZoomX") || this.get("pinchZoomY")) {
const touchEvent = event as any;
const touchEvent = event.originalEvent as any;
const pointerId = touchEvent.pointerId;

if (pointerId) {
Expand Down
4 changes: 3 additions & 1 deletion src/.internal/charts/xy/axes/DateAxis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,11 @@ export class DateAxis<R extends AxisRenderer> extends ValueAxis<R> {
}


if (this.isDirty("groupInterval")) {
if (this.isDirty("groupInterval")) {
let groupInterval = this.get("groupInterval")!;
if (groupInterval) {
this.setRaw("groupIntervals", [groupInterval]);
this._handleRangeChange();
}
}

Expand Down Expand Up @@ -533,6 +534,7 @@ export class DateAxis<R extends AxisRenderer> extends ValueAxis<R> {
series.setDataSet(newId);
}
})

this.markDirtyExtremes();

this._root.events.once("frameended", () => {
Expand Down
2 changes: 1 addition & 1 deletion src/.internal/charts/xy/axes/ValueAxis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1002,9 +1002,9 @@ export class ValueAxis<R extends AxisRenderer> extends Axis<R> {
}

if (selectionMin === selectionMax) {
this._getDelta(selectionMax);
selectionMin -= this._deltaMinMax;
selectionMax += this._deltaMinMax;

let minMaxStep2 = this._adjustMinMax(selectionMin, selectionMax, gridCount, strictMinMax);
selectionMin = minMaxStep2.min;
selectionMax = minMaxStep2.max;
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.8";
readonly version: string = "5.4.9";

/**
* List of applied licenses.
Expand Down
10 changes: 8 additions & 2 deletions src/.internal/core/render/Series.ts
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,10 @@ export abstract class Series extends Component {
const bullets = dataItem.bullets;
if(bullets){
$array.each(bullets, (bullet)=>{
promises.push(bullet.get("sprite").show(duration));
const sprite = bullet.get("sprite");
if(sprite){
promises.push(sprite.show(duration));
}
})
}
await Promise.all(promises);
Expand All @@ -746,7 +749,10 @@ export abstract class Series extends Component {
const bullets = dataItem.bullets;
if(bullets){
$array.each(bullets, (bullet)=>{
promises.push(bullet.get("sprite").hide(duration));
const sprite = bullet.get("sprite");
if(sprite){
promises.push(sprite.hide(duration));
}
})
}
await Promise.all(promises);
Expand Down
6 changes: 2 additions & 4 deletions src/.internal/core/render/Slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export class Slice extends Graphics {
public _beforeChanged() {
super._beforeChanged();

if (this.isDirty("radius") || this.isDirty("arc") || this.isDirty("innerRadius") || this.isDirty("startAngle") || this.isDirty("dRadius") || this.isDirty("dInnerRadius") || this.isDirty("cornerRadius")) {
if (this.isDirty("radius") || this.isDirty("arc") || this.isDirty("innerRadius") || this.isDirty("startAngle") || this.isDirty("dRadius") || this.isDirty("dInnerRadius") || this.isDirty("cornerRadius") || this.isDirty("shiftRadius")) {
this._clear = true;
}
}
Expand Down Expand Up @@ -168,12 +168,10 @@ export class Slice extends Graphics {

this.ix = $math.cos(middleAngle);
this.iy = $math.sin(middleAngle);
}

if (this.isDirty("shiftRadius")) {
const shiftRadius = this.get("shiftRadius", 0);
this.setRaw("dx", this.ix * shiftRadius);
this.setRaw("dy", this.iy * shiftRadius);
this.setRaw("dy", this.iy * shiftRadius);
this.markDirtyPosition();
}
}
Expand Down
15 changes: 15 additions & 0 deletions src/.internal/core/render/Sprite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,18 @@ class SpriteEventDispatcher<Target, E extends Events<Target, ISpriteEvents>> ext
},

"pointerover": function(event) {
/*
const sprite = this._sprite;
let dispatch = true;
if (sprite.get("isMeasured")) {
const bounds = sprite.globalBounds();
if (!$math.inBounds(event.point, bounds)) {
dispatch = false;
sprite._root._renderer.removeHovering(sprite._display);
}
}
*/
if (this.isEnabled("pointerover")) {
this.dispatch("pointerover", this._makePointerEvent("pointerover", event));
}
Expand Down Expand Up @@ -1153,6 +1165,9 @@ export abstract class Sprite extends Entity {

if (this.isDirty("opacity")) {
display.alpha = Math.max(0, this.get("opacity", 1));
if (this.get("focusable")) {
this.markDirtyAccessibility();
}
}

if (this.isDirty("rotation")) {
Expand Down
Loading

0 comments on commit 94fdad7

Please sign in to comment.