Skip to content

Commit 1a7228e

Browse files
committed
yFiles for HTML 3.0-final demos
1 parent 7ba4d8b commit 1a7228e

File tree

7 files changed

+54
-11
lines changed

7 files changed

+54
-11
lines changed

demos/layout-features/hierarchical-incremental/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Click the button in the toolbar to run the layout and see the effect.
2929

3030
### Code Snippet
3131

32-
You can copy the code snippet to configure the layout from [GitHub](https://github.com/yWorks/yfiles-for-html-demos/blob/master/demos/layout-features/hierarchical-incremental/HierarchicIncremental.ts).
32+
You can copy the code snippet to configure the layout from [GitHub](https://github.com/yWorks/yfiles-for-html-demos/blob/master/demos/layout-features/hierarchical-incremental/HierarchicalIncremental.ts).
3333

3434
### Demos
3535

demos/layout-features/hierarchical-incremental/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ <h3>Code Snippet</h3>
112112
<p>
113113
You can copy the code snippet to configure the layout from
114114
<a
115-
href="https://github.com/yWorks/yfiles-for-html-demos/blob/master/demos/layout-features/hierarchical-incremental/HierarchicIncremental.ts"
115+
href="https://github.com/yWorks/yfiles-for-html-demos/blob/master/demos/layout-features/hierarchical-incremental/HierarchicalIncremental.ts"
116116
target="_blank"
117117
>GitHub</a
118118
>.

demos/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020
"@yfiles/yfiles": "^30.0.0+dev",
2121
"codemirror": "5.65.16",
2222
"d3": "~7.8.5",
23-
"jspdf": "2.5.1",
23+
"jspdf": "~3.0.0",
2424
"leaflet": "~1.9.4",
2525
"markdown-it": "13.0.2",
2626
"neo4j-driver": "5.14.0",
2727
"quill": "^2.0.0-rc.5",
2828
"react": "18.2.0",
2929
"react-dom": "18.2.0",
30-
"svg2pdf.js": "2.2.2"
30+
"svg2pdf.js": "~2.4.0"
3131
},
3232
"devDependencies": {
3333
"@types/babel__standalone": "7.1.7",

demos/showcase/decisiontree/decision-tree-component/DecisionTree.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ import {
3737
LayoutExecutor,
3838
PlaceNodesAtBarycenterStage,
3939
PlaceNodesAtBarycenterStageData,
40-
PolylineEdgeStyle
40+
PolylineEdgeStyle,
41+
Rect
4142
} from '@yfiles/yfiles'
4243
import {
4344
colorSets,
@@ -192,6 +193,24 @@ export default class DecisionTree {
192193
this.updateNodeStyles()
193194
this.beforeLayoutCallback?.(true, this.graphComponent)
194195
await this.runLayout(newNodes, animateScroll)
196+
// calculate the bounding box of all new nodes
197+
let nodeArea = Rect.EMPTY
198+
for (const node of newNodes) {
199+
nodeArea = Rect.add(nodeArea, node.layout.toRect())
200+
}
201+
// if there are new nodes, ensure all of them are visible
202+
if (!nodeArea.isEmpty) {
203+
nodeArea = nodeArea.getEnlarged(10)
204+
let zoom = targetZoom
205+
if (nodeArea.width * targetZoom > this.graphComponent.size.width) {
206+
zoom = this.graphComponent.size.width / nodeArea.width
207+
}
208+
if (animateScroll) {
209+
await this.graphComponent.zoomToAnimated(zoom, nodeArea.center)
210+
} else {
211+
this.graphComponent.zoomTo(zoom, nodeArea.center)
212+
}
213+
}
195214
this.afterLayoutCallback?.(false, this.graphComponent)
196215
}
197216
/**
@@ -451,7 +470,8 @@ export default class DecisionTree {
451470
graphComponent: this.graphComponent,
452471
layout,
453472
layoutData,
454-
animationDuration: animated ? '0.2s' : '0s'
473+
animationDuration: animated ? '0.2s' : '0s',
474+
animateViewport: false
455475
})
456476
try {
457477
await layoutExecutor.start()

demos/showcase/decisiontree/decision-tree-component/DecisionTree.ts

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ import {
3939
LayoutExecutor,
4040
PlaceNodesAtBarycenterStage,
4141
PlaceNodesAtBarycenterStageData,
42-
PolylineEdgeStyle
42+
PolylineEdgeStyle,
43+
Rect
4344
} from '@yfiles/yfiles'
4445

4546
import {
@@ -213,7 +214,26 @@ export default class DecisionTree {
213214
this.beforeLayoutCallback?.(true, this.graphComponent)
214215

215216
await this.runLayout(newNodes, animateScroll)
217+
// calculate the bounding box of all new nodes
218+
let nodeArea = Rect.EMPTY
219+
for (const node of newNodes) {
220+
nodeArea = Rect.add(nodeArea, node.layout.toRect())
221+
}
222+
223+
// if there are new nodes, ensure all of them are visible
224+
if (!nodeArea.isEmpty) {
225+
nodeArea = nodeArea.getEnlarged(10)
216226

227+
let zoom = targetZoom
228+
if (nodeArea.width * targetZoom > this.graphComponent.size.width) {
229+
zoom = this.graphComponent.size.width / nodeArea.width
230+
}
231+
if (animateScroll) {
232+
await this.graphComponent.zoomToAnimated(zoom, nodeArea.center)
233+
} else {
234+
this.graphComponent.zoomTo(zoom, nodeArea.center)
235+
}
236+
}
217237
this.afterLayoutCallback?.(false, this.graphComponent)
218238
}
219239

@@ -493,7 +513,8 @@ export default class DecisionTree {
493513
graphComponent: this.graphComponent,
494514
layout,
495515
layoutData,
496-
animationDuration: animated ? '0.2s' : '0s'
516+
animationDuration: animated ? '0.2s' : '0s',
517+
animateViewport: false
497518
})
498519
try {
499520
await layoutExecutor.start()

demos/toolkit/vue/src/composables/useContextMenu.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import {
3131
Command,
3232
GraphComponent,
3333
GraphEditorInputMode,
34+
type GraphInputMode,
3435
GraphViewerInputMode,
3536
IEdge,
3637
IModelItem,
@@ -67,7 +68,7 @@ export function useContextMenu(getGraphComponent: () => GraphComponent) {
6768
/**
6869
* Registers the context menu on the current input mode.
6970
*/
70-
function register(inputMode: GraphEditorInputMode | GraphViewerInputMode): void {
71+
function register(inputMode: GraphInputMode): void {
7172
inputMode.addEventListener(
7273
'populate-item-context-menu',
7374
(evt: PopulateItemContextMenuEventArgs<IModelItem>) => {

demos/toolkit/vue/src/composables/useTooltips.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,14 @@ import { createApp, defineComponent, onMounted } from 'vue'
3030
import {
3131
GraphComponent,
3232
GraphEditorInputMode,
33+
type GraphInputMode,
3334
GraphItemTypes,
3435
GraphViewerInputMode,
3536
IEdge,
3637
IModelItem,
3738
INode,
38-
QueryItemToolTipEventArgs,
3939
Point,
40+
QueryItemToolTipEventArgs,
4041
TimeSpan
4142
} from '@yfiles/yfiles'
4243
import Tooltip from '@/components/Tooltip.vue'
@@ -57,7 +58,7 @@ export function useTooltips(getGraphComponent: () => GraphComponent) {
5758
* {@link QueryItemToolTipEventArgs.queryLocation} property contains the mouse position for the query in world coordinates.
5859
* The {@link QueryItemToolTipEventArgs.toolTip} is set by setting the ToolTip property.
5960
*/
60-
function register(inputMode: GraphEditorInputMode | GraphViewerInputMode): void {
61+
function register(inputMode: GraphInputMode): void {
6162
// show tooltips only for nodes and edges
6263
inputMode.toolTipItems = GraphItemTypes.NODE | GraphItemTypes.EDGE
6364

0 commit comments

Comments
 (0)