Skip to content

Commit

Permalink
Version 5.0.0-beta.18
Browse files Browse the repository at this point in the history
  • Loading branch information
martynasma committed Sep 17, 2021
1 parent 3192aca commit a6d3232
Show file tree
Hide file tree
Showing 890 changed files with 1,176 additions and 2,707 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@amcharts/amcharts5",
"version": "5.0.0-beta.17",
"version": "5.0.0-beta.18",
"author": "amCharts <[email protected]> (https://www.amcharts.com/)",
"description": "amCharts 5",
"homepage": "https://www.amcharts.com/",
Expand Down Expand Up @@ -32,6 +32,7 @@
"docs": "node build/build.js -- docs"
},
"dependencies": {
"@types/geojson": "^7946.0.8",
"d3": "^6.2.0",
"d3-chord": "^2.0.0",
"d3-geo": "^2.0.1",
Expand All @@ -46,7 +47,6 @@
"@types/d3-chord": "^2.0.1",
"@types/d3-sankey": "^0.11.1",
"@types/d3-shape": "^2.0.0",
"@types/geojson": "^7946.0.7",
"@types/polylabel": "^1.0.5",
"ansi-colors": "^4.1.1",
"core-js-builder": "^3.15.1",
Expand Down
1 change: 1 addition & 0 deletions packages/geodata/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ adhere to [Semantic Versioning](http://semver.org/spec/v2.0.0.html) rules.
- Fixed Svalbard map.
- Fixed Nigeria map.
- Fixed US Congressional maps: Alabama, Florida, Maine, Massachusetts, New Jersey, Michigan, Virginia, Washington.
- Fixing type errors with `GeoJSON`.

### Added
- JSON versions of the geodata can now be found in the `json` folder.
Expand Down
5 changes: 4 additions & 1 deletion packages/geodata/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,8 @@
"charts",
"typescript",
"geodata"
]
],
"dependencies": {
"@types/geojson": "^7946.0.8"
}
}
25 changes: 23 additions & 2 deletions packages/shared/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,35 @@ 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.0.0-beta.18] - 2021-09-17

### Added
- `areLinked()` method added to `LinkedHierarchy`.
- `unlinkDataItems()` method added to `LinkedHierarchy`.
- Global function `am5.disposeAllRootElements()` added. Disposes all charts.
- `am5.registry.rootElements` added which holds an array with instances of all active `Root` elements.
- `seriesGraphics` property added to `PictorialStackedSeries`. It's a `Graphics` which shows `svgPath` shape under all slices. Useful when `startLocation`/`endLocation` is used to make slices not occupy whole shape area.

### Changed
- `maxPanOut` of `MapChart` is temporarily disabled until we figure out proper behavior for it.

### Fixed
- Linking nodes with `linkDataItems` of `LinkedHierarchy` was not working if called after the data was set.
- `Micro` theme was not removing padding from charts.
- Adding in `@types/geojson` as a dependency.
- Map could jump to unpredictable position after the chart's container size changed and user zoomed or panned the map.
- In some cases `Label` with `oversizedBehavior = "fit"` could be incorrectly positioned.
- Removing series and axes from a serial chart was not working properly.


## [5.0.0-beta.17] - 2021-09-15

### Changed
- Default for `Treemap` setting `layoutAlgorithm` changed to `"squarify"`.
- Providing value in Hierarchy node's data will override sum of its children (except for `Pack`).
- Providing value in Hierarchy node's data will override sum of its children (except for `Pack`).

### Fixed
- `ForceDirected` nodes were linked to invisible top node even though `topLevel` was set to `1` meaning top node should not be visible. This was causing issues with the layout of such nodes.
- `ForceDirected` nodes were linked to invisible top node even though `topDepth` was set to `1` meaning top node should not be visible. This was causing issues with the layout of such nodes.


## [5.0.0-beta.16] - 2021-09-14
Expand Down
13 changes: 11 additions & 2 deletions src/.internal/charts/funnel/PictorialStackedSeries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ export class PictorialStackedSeries extends PyramidSeries {
*/
public readonly seriesMask: Graphics = Graphics.new(this._root, { position: "absolute", x: p50, y: p50, centerX: p50, centerY: p50 });

public readonly seriesGraphics: Graphics = this.slicesContainer.children.push(Graphics.new(this._root, { themeTags: ["pictorial", "background"], position: "absolute", x: p50, y: p50, centerX: p50, centerY: p50 }));

protected _afterNew() {
super._afterNew();
this.set("topWidth", p100);
Expand All @@ -77,6 +79,7 @@ export class PictorialStackedSeries extends PyramidSeries {
let h = slicesContainer.innerHeight();

let seriesMask = this.seriesMask;
let seriesGraphics = this.seriesGraphics;
let scale = seriesMask.get("scale", 1);

const bounds = seriesMask.localBounds();
Expand All @@ -93,14 +96,20 @@ export class PictorialStackedSeries extends PyramidSeries {
seriesMask.set("scale", scale);
seriesMask.set("x", w / 2);
seriesMask.set("y", h / 2);

seriesGraphics.set("scale", scale);
seriesGraphics.set("x", w / 2);
seriesGraphics.set("y", h / 2);
}
}

public _prepareChildren() {
super._prepareChildren();
if (this.isDirty("svgPath")) {
this.seriesMask.set("svgPath", this.get("svgPath"));
}
const svgPath = this.get("svgPath");
this.seriesMask.set("svgPath", svgPath);
this.seriesGraphics.set("svgPath", svgPath);
}

this._updateScale();
}
Expand Down
19 changes: 18 additions & 1 deletion src/.internal/charts/hierarchy/ForceDirected.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ export class ForceDirected extends LinkedHierarchy {
const index = this._nodes.push(d3ForceNode) - 1;
d3ForceNode.index = index;

this.d3forceSimulation.nodes(this._nodes);

dataItem.set("d3ForceNode", d3ForceNode);
super.processDataItem(dataItem);

Expand Down Expand Up @@ -507,6 +509,21 @@ export class ForceDirected extends LinkedHierarchy {
}

protected _processLink(link: HierarchyLink, source: DataItem<this["_dataItemSettings"]>, target: DataItem<this["_dataItemSettings"]>) {
this._links.push({ link: link, source: source.get("d3ForceNode").index, target: target.get("d3ForceNode").index, sourceDataItem: source, targetDataItem: target });
const d3Link = { link: link, source: source.get("d3ForceNode").index, target: target.get("d3ForceNode").index, sourceDataItem: source, targetDataItem: target };
this._links.push(d3Link);
link.setPrivate("d3Link", d3Link);

this.linkForce = d3Force.forceLink(this._links);
this.d3forceSimulation.force("link", this.linkForce);
this.restartSimulation(0.5);
}

protected _disposeLink(link: HierarchyLink) {
super._disposeLink(link);
$array.remove(this._links, link.getPrivate("d3Link"));
}

protected _handleUnlink() {
this.restartSimulation(0.5);
}
}
15 changes: 8 additions & 7 deletions src/.internal/charts/hierarchy/Hierarchy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,18 +364,17 @@ export abstract class Hierarchy extends Series {

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

if (!dataItem.get("parent")) {
dataItem.setRaw("depth", 0);

if (colors) {
if (colors && topDepth == 0) {
dataItem.setRaw("fill", colors.next());
}
}

let depth = dataItem.get("depth");
const initialDepth = this.get("initialDepth", 1);
const topDepth = this.get("topDepth", 0);

this.makeNode(dataItem);
this._processDataItem(dataItem);
Expand Down Expand Up @@ -440,8 +439,8 @@ export abstract class Hierarchy extends Series {

let dataValue = d3HierarchyNode.data.value;
let value = d3HierarchyNode.value
if(dataValue != null){

if (dataValue != null) {
value = dataValue;
}

Expand Down Expand Up @@ -532,10 +531,12 @@ export abstract class Hierarchy extends Series {
const hiddenState = this.states.create("hidden", {})

if (!$type.isNumber(duration)) {
duration = hiddenState.get("stateAnimationDuration", this.get("stateAnimationDuration", 0));
const stateAnimationDuration = "stateAnimationDuration"
duration = hiddenState.get(stateAnimationDuration, this.get(stateAnimationDuration, 0));
}

const easing = hiddenState.get("stateAnimationEasing", this.get("stateAnimationEasing"));
const stateAnimationEasing = "stateAnimationEasing";
const easing = hiddenState.get(stateAnimationEasing, this.get(stateAnimationEasing));

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

Expand Down
1 change: 1 addition & 0 deletions src/.internal/charts/hierarchy/HierarchyLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export interface IHierarchyLinkSettings extends IGraphicsSettings {
}

export interface IHierarchyLinkPrivate extends IGraphicsPrivate {
d3Link:any;
}

/**
Expand Down
84 changes: 80 additions & 4 deletions src/.internal/charts/hierarchy/LinkedHierarchy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ export abstract class LinkedHierarchy extends Hierarchy {
circle.on("radius", () => {
const d = circle.get("radius", this.width()) * 2;
label.setAll({ maxWidth: d, maxHeight: d })

outerCircle.set("radius", d / 2);

this._handleRadiusChange();
Expand Down Expand Up @@ -290,7 +289,7 @@ export abstract class LinkedHierarchy extends Hierarchy {
}

/**
* Link two data items wit a link element.
* Link two data items with a link element.
*
* @param source Source node data item
* @param target Target node data item
Expand Down Expand Up @@ -344,6 +343,84 @@ export abstract class LinkedHierarchy extends Hierarchy {
return link;
}


/**
* Unlink two data items
*
* @param source Source node data item
* @param target Target node data item
* @param strength Link strength
* @return Link element
*/
public unlinkDataItems(source: DataItem<this["_dataItemSettings"]>, target: DataItem<this["_dataItemSettings"]>) {

let link!: HierarchyLink;

const sourceLinks = source.get("links");

if (sourceLinks) {
$array.each(sourceLinks, (lnk) => {
if (lnk && lnk.get("target") == target) {
link = lnk;
$array.remove(sourceLinks, link);
}
})
}

const targetLinks = target.get("links");

if (targetLinks) {
$array.each(targetLinks, (lnk) => {
if (lnk && lnk.get("target") == source) {
link = lnk;
$array.remove(targetLinks, link);
}
})
}

if (link) {
this._disposeLink(link);
}

this._handleUnlink();
}

protected _handleUnlink() {

}

protected _disposeLink(link: HierarchyLink) {
this.links.removeValue(link);
link.dispose();
}

/**
* Returns `true` if two nodes are linked with each other.
*/
public areLinked(source: DataItem<this["_dataItemSettings"]>, target: DataItem<this["_dataItemSettings"]>): boolean {
const sourceLinks = source.get("links");
let linked = false;
if (sourceLinks) {
$array.each(sourceLinks, (lnk) => {
if (lnk.get("target") == target) {
linked = true;
}
})
}

const targetLinks = target.get("links");

if (targetLinks) {
$array.each(targetLinks, (lnk) => {
if (lnk.get("target") == source) {
linked = true;
}
})
}

return linked;
}

protected _processLink(_link: HierarchyLink, _source: DataItem<this["_dataItemSettings"]>, _target: DataItem<this["_dataItemSettings"]>) {

}
Expand All @@ -356,8 +433,7 @@ export abstract class LinkedHierarchy extends Hierarchy {
const links = dataItem.get("links");
if (links) {
$array.each(links, (link) => {
this.links.removeValue(link);
link.dispose();
this._disposeLink(link)
})
}
}
Expand Down
5 changes: 0 additions & 5 deletions src/.internal/charts/hierarchy/LinkedHierarchyNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@ export class LinkedHierarchyNode extends HierarchyNode {
public static className: string = "LinkedHierarchyNode";
public static classNames: Array<string> = HierarchyNode.classNames.concat([LinkedHierarchyNode.className]);

/*
public readonly circle: Circle = this.children.push(Circle.new(this._root, { themeClasses: ["LinkedHierarchyNodeCircle"] }))
public readonly outerCircle: Circle = this.children.push(Circle.new(this._root, { themeClasses: ["LinkedHierarchyNodeOuterCircle"] }))
public readonly label: Label = this.children.push(Label.new(this._root, { themeClasses: ["LinkedHierarchyNodeLabel"] }));
*/
declare protected _dataItem: DataItem<ILinkedHierarchyDataItem> | undefined;

protected _afterNew() {
Expand Down
Loading

0 comments on commit a6d3232

Please sign in to comment.