Skip to content

Commit

Permalink
Version 5.6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
martynasma committed Nov 27, 2023
1 parent 0be0f51 commit 62447ae
Show file tree
Hide file tree
Showing 8 changed files with 129 additions and 49 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.6.0",
"version": "5.6.1",
"author": "amCharts <contact@amcharts.com> (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.6.1] - 2023-11-27

### Changed
- New default rule added to `ResponsiveTheme` that will hide minor axis labels below `XXL` (1000px) breakpoint.
- `IndicatorControl` will not list Indicators that rely on volume if chart's `volumeSeries` is not set.

### Fixed
- Fixed stacking of bullets with varying `centerY`.
- `role` setting for `Root` element was being ignored.
- Setting `name` for a Series would not right away update labels of its related legend item.


## [5.6.0] - 2023-11-26

### Added
Expand Down
67 changes: 46 additions & 21 deletions src/.internal/charts/stock/toolbar/IndicatorControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ export class IndicatorControl extends DropdownListControl {
button.className = button.className + " am5stock-control-dropdown";

this._initList();

// Re-nit list if volume series is added or removed so that we can show/hide
// volume-dependent indicators
this.get("stockChart").on("volumeSeries", () => this._initList());
}

protected _initList(): void {
Expand All @@ -129,21 +133,37 @@ export class IndicatorControl extends DropdownListControl {
const items: IDropdownListItem[] = [];
$array.each(indicators, (indicator: Indicators | IIndicator) => {
if ($type.isObject(indicator)) {
items.push({
id: indicator.id,
label: indicator.name
});
if (this.supportsIndicator(indicator.id as Indicators)) {
items.push({
id: indicator.id,
label: indicator.name
});
}
}
else {
items.push({
id: indicator,
label: this._root.language.translateAny(indicator)
});
if (this.supportsIndicator(indicator as Indicators)) {
items.push({
id: indicator,
label: this._root.language.translateAny(indicator)
});
}
}
})
list.set("items", items);
}

/**
* Returns `true` if the indicator is supported in current chart setup.
*
* @param indicatorId Indicator ID
* @return Supported?
*/
public supportsIndicator(indicatorId: Indicators): boolean {
const stockChart = this.get("stockChart");
const volumeIndicators = ["Chaikin Money Flow", "Chaikin Oscillator", "On Balance Volume", "Volume", "VWAP"];
return (stockChart.get("volumeSeries") || volumeIndicators.indexOf(indicatorId) === -1) ? true : false;
}

protected _getDefaultIcon(): SVGElement {
return StockIcons.getIcon("Indicator");
}
Expand All @@ -162,6 +182,11 @@ export class IndicatorControl extends DropdownListControl {
* @return Indicator instance
*/
public addIndicator(indicatorId: Indicators): Indicator | undefined {

if (!this.supportsIndicator(indicatorId)) {
return;
}

const stockChart = this.get("stockChart");
let indicator: Indicator | undefined;
const stockSeries = stockChart.get("stockSeries")!;
Expand Down Expand Up @@ -240,6 +265,19 @@ export class IndicatorControl extends DropdownListControl {
legend: legend
});
break;
case "Median Price":
indicator = MedianPrice.new(this.root, {
stockChart: stockChart,
stockSeries: stockSeries,
legend: legend
});
break;
case "Momentum":
indicator = Momentum.new(this.root, {
stockChart: stockChart,
stockSeries: stockSeries
});
break;
case "Moving Average":
indicator = MovingAverage.new(this.root, {
stockChart: stockChart,
Expand Down Expand Up @@ -282,19 +320,6 @@ export class IndicatorControl extends DropdownListControl {
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,
stockSeries: stockSeries,
legend: legend
});
break;
case "On Balance Volume":
indicator = OnBalanceVolume.new(this.root, {
stockChart: stockChart,
Expand Down
66 changes: 42 additions & 24 deletions src/.internal/charts/xy/series/XYSeries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1814,39 +1814,57 @@ export abstract class XYSeries extends Series {
const chart = this.chart;
if (baseAxis == xAxis) {
let previousBullet = this._bullets[positionX + "_" + positionY];
let d = -1;
if (stacked == "down") {
d = 1;
}
else if (stacked == "auto") {
if (chart) {
if (y < chart.plotContainer.height() / 2) {
d = 1;
if (previousBullet) {
let previousBounds = previousBullet.bounds();
let bounds = sprite.localBounds();
let yo = y;
y = previousBounds.top;

if (stacked == "down") {
y = previousBounds.bottom - bounds.top;
}
else if (stacked == "auto") {
if (chart) {
if (yo < chart.plotContainer.height() / 2) {
y = previousBounds.bottom - bounds.top;
}
else {
y += bounds.bottom;
}
}
}
}

if (previousBullet) {
y = previousBullet.y() + previousBullet.height() * d;
else {
y += bounds.bottom;
}
}
this._bullets[positionX + "_" + positionY] = sprite;
}
else {
let previousBullet = this._bullets[positionX + "_" + positionY];
let d = -1;
if (stacked == "down") {
d = 1;
}
else if (stacked == "auto") {
if (chart) {
if (x < chart.plotContainer.width() / 2) {
d = 1;
if (previousBullet) {
let previousBounds = previousBullet.bounds();
let bounds = sprite.localBounds();
let xo = x;
x = previousBounds.right;

if (stacked == "down") {
x = previousBounds.left - bounds.right;
}
else if (stacked == "auto") {
if (chart) {
if (xo < chart.plotContainer.width() / 2) {
x = previousBounds.left - bounds.right;
}
else {
x -= bounds.left;
}
}
}
else {
x -= bounds.left;
}
}
if (previousBullet) {
x = previousBullet.x() + previousBullet.width() * d;
}

this._bullets[positionX + "_" + positionY] = sprite;
}
}
Expand Down Expand Up @@ -2161,7 +2179,7 @@ export abstract class XYSeries extends Series {
/**
* @ignore
*/
public updateLegendValue(dataItem: DataItem<this["_dataItemSettings"]> | undefined) {
public updateLegendValue(dataItem?: DataItem<this["_dataItemSettings"]> | undefined) {
const legendDataItem = this.get("legendDataItem");

if (legendDataItem) {
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.6.0";
readonly version: string = "5.6.1";

/**
* List of applied licenses.
Expand Down
6 changes: 5 additions & 1 deletion src/.internal/core/Root.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export interface IRootSettings {
ariaLabel?: string;

/**
* Allows setting a "role" for the innert `<div>`.
* Allows setting a "role" for the inner `<div>`.
*
* @since 5.3.17
* @see {@link https://www.amcharts.com/docs/v5/concepts/accessibility/#Accessibility_of_Root_element} for more info
Expand Down Expand Up @@ -572,6 +572,10 @@ export class Root implements IDisposer {
if (settings.ariaLabel) {
this._inner.setAttribute("aria-label", settings.ariaLabel);
}

if (settings.role) {
this._inner.setAttribute("role", settings.role);
}
}

const renderer = this._renderer;
Expand Down
5 changes: 4 additions & 1 deletion src/.internal/core/render/Series.ts
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,9 @@ export abstract class Series extends Component {
let startIndex = this.startIndex();
let endIndex = this.endIndex();

if(this.isDirty("name")){
this.updateLegendValue();
}

if(this.isDirty("heatRules")){
this._valuesDirty = true;
Expand Down Expand Up @@ -861,7 +864,7 @@ export abstract class Series extends Component {
/**
* @ignore
*/
public updateLegendValue(dataItem: DataItem<this["_dataItemSettings"]>) {
public updateLegendValue(dataItem?: DataItem<this["_dataItemSettings"]>) {
if(dataItem){
const legendDataItem = dataItem.get("legendDataItem" as any) as DataItem<ILegendDataItem>;

Expand Down
18 changes: 18 additions & 0 deletions src/.internal/themes/ResponsiveTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,15 @@ export class ResponsiveTheme extends Theme {
}
});

addRule({
name: "AxisLabel",
tags: ["x", "minor"],
relevant: ResponsiveTheme.widthXXL,
settings: {
forceHidden: true
}
});

addRule({
name: "AxisLabel",
tags: ["y"],
Expand All @@ -458,6 +467,15 @@ export class ResponsiveTheme extends Theme {
}
});

addRule({
name: "AxisLabel",
tags: ["y", "minor"],
relevant: ResponsiveTheme.heightXXL,
settings: {
forceHidden: true
}
});

addRule({
name: "AxisTick",
tags: ["x"],
Expand Down

0 comments on commit 62447ae

Please sign in to comment.