Skip to content

Commit

Permalink
Version 5.10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
martynasma committed Jul 22, 2024
1 parent 14a2538 commit 2899773
Show file tree
Hide file tree
Showing 36 changed files with 678 additions and 92 deletions.
5 changes: 4 additions & 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.9.13",
"version": "5.10.0",
"author": "amCharts <contact@amcharts.com> (https://www.amcharts.com/)",
"description": "amCharts 5",
"homepage": "https://www.amcharts.com/",
Expand Down Expand Up @@ -42,6 +42,9 @@
"@types/polylabel": "^1.0.5",
"@types/svg-arc-to-cubic-bezier": "^3.2.0",
"d3": "^7.0.0",
"d3-shape": "^3.0.0",
"d3-force": "^3.0.0",
"d3-hierarchy": "^3.0.0",
"d3-chord": "^3.0.0",
"d3-geo": "^3.0.0",
"d3-sankey": "^0.12.3",
Expand Down
9 changes: 9 additions & 0 deletions packages/geodata/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ 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.

## [UNRELEASED] - ????-??-??


## [5.1.4] - 2024-07-03

### Fixed
- Fixed names/ids in a new map of Algeria.


## [5.1.3] - 2024-06-03

### Added
Expand Down
2 changes: 1 addition & 1 deletion packages/geodata/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@amcharts/amcharts5-geodata",
"version": "5.1.3",
"version": "5.1.4",
"author": "amCharts <contact@amcharts.com> (https://www.amcharts.com/)",
"description": "amCharts 5 Geo Data",
"homepage": "https://www.amcharts.com/",
Expand Down
19 changes: 18 additions & 1 deletion packages/shared/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,29 @@ 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.10.0] - 2024-07-22

### Added
- A second parameter (`dataContext`) added to `Component`'s methods `pushDataItem` and `makeDataItem`, allowing to pass in a data context object related to the data item.
- New class `PatternSet` added. Allows serving patterns similarly to `ColorSet`. [More info](https://www.amcharts.com/docs/v5/concepts/colors-gradients-and-patterns/patterns/#Pattern_sets).
- New setting `patterns` added to `Hierarchy`, `PercentSeries`, `Venn`, `SerialChart`, `FlowNodes`. [More info](https://www.amcharts.com/docs/v5/concepts/colors-gradients-and-patterns/patterns/#Pattern_sets).
- New setting `fillPattern` added to `IFlowNodesDataItem`, `IHierarchyDataItem`, `IPercentSeriesDataItem`, `IVennDataItem`, `ISeriesSettings`.

### Fixed
- `LinkedHierarchy` nodes were not clickable when children were added using `addChildData()` method.
- If there were no nodes at `topLevel` in `Hierarchy` chart, it would show nodes from upper levels.
- Not all event listeners were disposed when disposing a `ChartIndicator`. This could cause a memory leak.
- `Sprite`'s `hover()`/`unhover()` methods now check if the `Sprite` is not disposed. This fixes some potential errors when disposed items are being referenced.
- Adding in explicit d3 dependencies ([Issue 1567](https://github.com/amcharts/amcharts5/issues/1567))
- `DurationFormatter` was not rounding fractional numbers properly in some cases.


## [5.9.13] - 2024-07-03

### Fixed
- If start and end values of a `HeatLegend` were the same, the tooltip was shown in the top/left corner of the chart.
- If a linked hierarchy had bullets on links, they remained visible when nodes and links were hidden.
- Zoom-out button could be visibile initially with some specific setups.
- Zoom-out button could be visible initially with some specific setups.
- `ZoomableContainer` would not react to pans in some of its sections if its contents was panned outside the its bounds.


Expand Down
2 changes: 2 additions & 0 deletions src/.internal/charts/flow/ArcDiagramNodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export class ArcDiagramNodes extends FlowNodes {
const circle = node.children.insertIndex(0, this.circles.make());
dataItem.set("circle", circle);
circle._setSoft("fill", dataItem.get("fill"));
circle._setSoft("fillPattern", dataItem.get("fillPattern"));

const label = this.labels.make();
this.labels.push(label);
Expand Down Expand Up @@ -107,6 +108,7 @@ export class ArcDiagramNodes extends FlowNodes {
const circle = dataItem.get("circle");
if (circle) {
circle.set("fill", dataItem.get("fill"));
circle.set("fillPattern", dataItem.get("fillPattern"));
}
}
}
2 changes: 2 additions & 0 deletions src/.internal/charts/flow/ChordNodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export class ChordNodes extends FlowNodes {
const slice = node.children.insertIndex(0, this.slices.make());
dataItem.set("slice", slice);
slice._setSoft("fill", dataItem.get("fill"));
slice._setSoft("fillPattern", dataItem.get("fillPattern"));

const label = this.labels.make();
this.labels.push(label);
Expand Down Expand Up @@ -148,6 +149,7 @@ export class ChordNodes extends FlowNodes {
const slice = dataItem.get("slice");
if(slice){
slice.set("fill", dataItem.get("fill"));
slice.set("fillPattern", dataItem.get("fillPattern"));
}
}

Expand Down
40 changes: 38 additions & 2 deletions src/.internal/charts/flow/FlowNodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@ import type { DataItem } from "../../core/render/Component";
import type { Color } from "../../core/util/Color";
import type { Time } from "../../core/util/Animation";
import type { Flow, IFlowDataItem } from "./Flow";
import type { ColorSet } from "../../core/util/ColorSet";
import type { PatternSet } from "../../core/util/PatternSet";
import type { Pattern } from "../../core/render/patterns/Pattern";

import type * as d3sankey from "d3-sankey";

import { Label } from "../../core/render/Label";
import { Series, ISeriesSettings, ISeriesDataItem, ISeriesPrivate, ISeriesEvents } from "../../core/render/Series";
import { Template } from "../../core/util/Template";
import { ListTemplate } from "../../core/util/List";
import { FlowNode } from "./FlowNode";
import type { ColorSet } from "../../core/util/ColorSet";

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

Expand All @@ -35,6 +38,14 @@ export interface IFlowNodesDataItem extends ISeriesDataItem {
*/
fill: Color;

/**
* Node pattern.
*
* @see {@link https://www.amcharts.com/docs/v5/concepts/colors-gradients-and-patterns/patterns/} for more info
* @since 5.10.0
*/
fillPattern: Pattern;

/**
* Indicates "unknown" node.
*/
Expand Down Expand Up @@ -128,6 +139,14 @@ export interface IFlowNodesSettings extends ISeriesSettings {
*/
colors?: ColorSet;

/**
* A [[PatternSet]] that series will use to apply to its nodes.
*
* @see {@link https://www.amcharts.com/docs/v5/concepts/colors-gradients-and-patterns/patterns/#Pattern_sets} for more info
* @since 5.10.0
*/
patterns?: PatternSet;

/**
* Animation duration in ms.
*/
Expand Down Expand Up @@ -204,6 +223,11 @@ export abstract class FlowNodes extends Series {
colors.reset();
}

const patterns = this.get("patterns");
if (patterns) {
patterns.reset();
}

this._userDataSet = true;
}

Expand All @@ -218,6 +242,13 @@ export abstract class FlowNodes extends Series {
}
}

if (dataItem.get("fillPattern") == null) {
let patterns = this.get("patterns");
if (patterns) {
dataItem.setRaw("fillPattern", patterns.next());
}
}

const node = this.makeNode(dataItem);
dataItem.setRaw("node", node);

Expand Down Expand Up @@ -275,11 +306,16 @@ export abstract class FlowNodes extends Series {
this._updateNodeColor(dataItem);
})

dataItem.on("fillPattern", () => {
this._updateNodeColor(dataItem);
})


dataItem.set("node", node);
return node;
}

public _updateNodeColor(_dataItem: DataItem<this["_dataItemSettings"]>){
public _updateNodeColor(_dataItem: DataItem<this["_dataItemSettings"]>) {

}

Expand Down
3 changes: 3 additions & 0 deletions src/.internal/charts/flow/SankeyNodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ export class SankeyNodes extends FlowNodes {
const rectangle = node.children.insertIndex(0, this.rectangles.make());
this.rectangles.push(rectangle);
rectangle._setSoft("fill", dataItem.get("fill"));
rectangle._setSoft("fillPattern", dataItem.get("fillPattern"));

dataItem.set("rectangle", rectangle);

node.events.on("dragged", () => {
Expand Down Expand Up @@ -129,6 +131,7 @@ export class SankeyNodes extends FlowNodes {
const rectangle = dataItem.get("rectangle");
if(rectangle){
rectangle.set("fill", dataItem.get("fill"));
rectangle.set("fillPattern", dataItem.get("fillPattern"));
}
}
}
2 changes: 2 additions & 0 deletions src/.internal/charts/funnel/FunnelSeries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,11 @@ export class FunnelSeries extends PercentSeries {
const label = dataItem.get("label");
const link = dataItem.get("link");
const color = dataItem.get("fill");
const fillPattern = dataItem.get("fillPattern");

slice._setDefault("fill", color);
slice._setDefault("stroke", color);
slice._setDefault("fillPattern", fillPattern);
link._setDefault("fill", color);
link._setDefault("stroke", color);

Expand Down
58 changes: 51 additions & 7 deletions src/.internal/charts/hierarchy/Hierarchy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import type { ColorSet } from "../../core/util/ColorSet";
import type { Bullet } from "../../core/render/Bullet";
import type { Root } from "../../core/Root";
import type { Easing } from "../../core/util/Ease";
import type { PatternSet } from "../../core/util/PatternSet";
import type { Pattern } from "../../core/render/patterns/Pattern";

import { HierarchyDefaultTheme } from "./HierarchyDefaultTheme";
import { Series, ISeriesSettings, ISeriesDataItem, ISeriesPrivate, ISeriesEvents } from "../../core/render/Series";
Expand Down Expand Up @@ -98,6 +100,14 @@ export interface IHierarchyDataItem extends ISeriesDataItem {
*/
fill: Color;

/**
* Node's auto-assigned pattern.
*
* @see {@link https://www.amcharts.com/docs/v5/concepts/colors-gradients-and-patterns/patterns/} for more info
* @since 5.10.0
*/
fillPattern: Pattern;

/**
* Indicates if node is currently disabled.
*/
Expand Down Expand Up @@ -153,6 +163,14 @@ export interface IHierarchySettings extends ISeriesSettings {
*/
colors?: ColorSet;

/**
* A [[PatternSet]] to use when asigning patterns for nodes.
*
* @see {@link https://www.amcharts.com/docs/v5/concepts/colors-gradients-and-patterns/patterns/#Pattern_sets} for more info
* @since 5.10.0
*/
patterns?: PatternSet;

/**
* Number of child levels to open when clicking on a node.
*
Expand Down Expand Up @@ -454,19 +472,29 @@ export abstract class Hierarchy extends Series {
if (colors) {
colors.reset();
}

const patterns = this.get("patterns");
if (patterns) {
patterns.reset();
}
}

protected processDataItem(dataItem: DataItem<this["_dataItemSettings"]>) {
super.processDataItem(dataItem);

const childData = dataItem.get("childData");
const colors = this.get("colors");
const patterns = this.get("patterns");
const topDepth = this.get("topDepth", 0);

if (!dataItem.get("parent")) {
dataItem.setRaw("depth", 0);
if (colors && topDepth == 0 && dataItem.get("fill") == null) {
dataItem.setRaw("fill", colors.next());

if (patterns) {
dataItem.setRaw("fillPattern", patterns.next());
}
}
}

Expand All @@ -492,11 +520,17 @@ export abstract class Hierarchy extends Series {
if (colors && childDataItem.get("fill") == null) {
childDataItem.setRaw("fill", colors.next());
}
if (patterns && childDataItem.get("fillPattern") == null) {
childDataItem.setRaw("fillPattern", patterns.next());
}
}
else {
if (childDataItem.get("fill") == null) {
childDataItem.setRaw("fill", dataItem.get("fill"));
}
if (childDataItem.get("fillPattern") == null) {
childDataItem.setRaw("fillPattern", dataItem.get("fillPattern"));
}
}

this.processDataItem(childDataItem);
Expand Down Expand Up @@ -541,6 +575,12 @@ export abstract class Hierarchy extends Series {
dataItem.set("children", children);
}

const node = dataItem.get("node");

if (node) {
node.set("toggleKey", "disabled");
}

let depth = dataItem.get("depth");

$array.each(childData, (child) => {
Expand Down Expand Up @@ -588,7 +628,7 @@ export abstract class Hierarchy extends Series {

this._index++;

this.root.events.once("frameended", ()=>{
this.root.events.once("frameended", () => {
dataItem.get("node").set("disabled", dataItem.get("disabled"));
})

Expand All @@ -612,11 +652,13 @@ export abstract class Hierarchy extends Series {
dataItem.get("label").text.markDirtyText();
dataItem.setRaw("valuePercent", valuePercent);

if (this.getPrivate("valueLow") > value) {
const valueLow = this.getPrivate("valueLow");
if (valueLow != undefined && valueLow > value) {
this.setPrivateRaw("valueLow", value);
}

if (this.getPrivate("valueHigh") < value) {
const valueHigh = this.getPrivate("valueHigh");
if (valueHigh != undefined && valueHigh < value) {
this.setPrivateRaw("valueHigh", value);
}
}
Expand Down Expand Up @@ -777,6 +819,8 @@ export abstract class Hierarchy extends Series {
dataItem.get("node").show(duration);
}



const topDepth = this.get("topDepth", 0);
if (dataItem.get("depth") < topDepth) {
dataItem.get("node").hide(0);
Expand All @@ -798,7 +842,7 @@ export abstract class Hierarchy extends Series {

let children = dataItem.get("children");
if (children) {
if (depth < maxDepth - 1) {
if (depth < maxDepth - 1) {
$array.each(children, (child) => {
const disabledField = this.get("disabledField");
if (disabledField) {
Expand Down Expand Up @@ -860,15 +904,15 @@ export abstract class Hierarchy extends Series {
downDepth = Math.min(this.get("downDepth", 1), maxDepth - dataItem.get("depth"));
}

const hierarchyNode = dataItem.get("d3HierarchyNode");
let currentDepth = hierarchyNode.depth;
if (!this.inited) {
downDepth = Math.min(this.get("initialDepth", 1), maxDepth - topDepth);
downDepth = Math.max(0, downDepth);
}

this._currentDownDepth = downDepth;

const hierarchyNode = dataItem.get("d3HierarchyNode");
let currentDepth = hierarchyNode.depth;

if (currentDepth + downDepth > maxDepth) {
downDepth = maxDepth - currentDepth;
}
Expand Down
Loading

0 comments on commit 2899773

Please sign in to comment.