Skip to content

Commit

Permalink
fix rotate=90 graph attribute does not set the rotation during transi…
Browse files Browse the repository at this point in the history
…tion

Second and final fix that fixes
#251 originally reported
as https://github.com/magjac/graphviz-visual-editor/issues/214.
  • Loading branch information
magjac committed Oct 10, 2024
1 parent a3fd4fd commit 1bf24ae
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed
* rotate=90 graph attribute does not set the rotation #251

## [5.6.0] – 2024-08-18

### Changed
Expand Down
2 changes: 2 additions & 0 deletions src/element.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ export function extractElementData(element) {
// drawing orientation is portrait
datum.translation = { x: matrix.e, y: matrix.f };
datum.scale = matrix.a;
datum.rotation = 0;
}
else {
// drawing orientation is landscape
datum.translation = { x: matrix.e, y: matrix.f };
datum.scale = matrix.c;
datum.rotation = -90;
}
}
if (tag == 'ellipse') {
Expand Down
1 change: 1 addition & 0 deletions src/graphviz.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ export function Graphviz(selection, options) {
this._images = [];
this._translation = undefined;
this._scale = undefined;
this._rotation = undefined;
this._eventTypes = [
'initEnd',
'start',
Expand Down
5 changes: 3 additions & 2 deletions src/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,9 @@ function _render(callback) {
.tween("attr.transform", function() {
var node = this;
return function (t) {
const fromTransform = zoomTransform(graphvizInstance._zoomSelection.node()).toString();
const toTransform = getTranslatedZoomTransform.call(graphvizInstance, element).toString();
const rotateStr = ` rotate(${data.rotation})`;
const fromTransform = zoomTransform(graphvizInstance._zoomSelection.node()).toString() + rotateStr;
const toTransform = getTranslatedZoomTransform.call(graphvizInstance, element).toString() + rotateStr;
const interpolationFunction = interpolateTransformSvg(fromTransform, toTransform);
node.setAttribute("transform", interpolationFunction(t));
};
Expand Down
1 change: 1 addition & 0 deletions test/dot-data-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ var basic_data = {
"y": 112
},
"scale": 1,
"rotation": 0,
"parent": "[Circular ~]",
"children": [
{
Expand Down

0 comments on commit 1bf24ae

Please sign in to comment.