javascript - Building path between nodes with possible scenarios
问题描述
I am trying to create link between two nodes with some possible scenarios as you can see in below image. The target will always be on right side in a row and target can be in the same row, next row or next to next row depend on number of shapes.
Single row contains 5 shapes including target shape. if we have 20 shapes and 1 target shape then there will be 5 rows, last will be target shape.
Below is the data model for the source and target which will be used to create nodes and paths between.
[
{
"shapeName": "rect1",
"shapeId": "1.1",
"coordinateData": {
"height": 125,
"width": 100,
"xCoordinate": 300,
"yCoordinate": 100
},
"ticks": [
{
"tickId": "1.1.1",
"sourceTarget": [
{
"sourceTick": "1.1.1",
"targetTick": "1.4.11"
}
]
}
]
},
{
"shapeName": "rect2",
"shapeId": "1.2",
"coordinateData": {
"height": 125,
"width": 100,
"xCoordinate": 850,
"yCoordinate": 100
},
"ticks": [
{
"tickId": "1.2.1",
"sourceTarget": [
{
"sourceTick": "1.2.1",
"targetTick": "1.4.12"
}
]
}
]
},
{
"shapeName": "rect3",
"shapeId": "1.3",
"coordinateData": {
"height": 125,
"width": 100,
"xCoordinate": 1400,
"yCoordinate": 100
},
"ticks": [
{
"tickId": "1.3.1",
"sourceTarget": [
{
"sourceTick": "1.3.1",
"targetTick": "1.4.13"
}
]
}
]
},
{
"shapeName": "rect4",
"shapeId": "1.4",
"coordinateData": {
"height": 375,
"width": 100,
"xCoordinate": 1750,
"yCoordinate": 100
},
"ticks": [
{
"tickId": "1.4.11",
"sourceTarget": null
},
{
"tickId": "1.4.12",
"sourceTarget": null
},
{
"tickId": "1.4.13",
"sourceTarget": null
}
]
}
]
Thanks
解决方案
推荐阅读
- mysql - PDOException: SQLSTATE [42000]
- python - Python - 根据单元格元素(对象)选择行
- node.js - 为什么 res.header() 不能在 express 中工作?
- istio - Istio-Service 到服务的通信没有按预期进行
- javascript - 如何将此代码从 Jquery 转换为 Vanilla Javascript?
- java - 如何减少 Docker 中的 Spring Boot 应用程序内存使用量?
- c# - 使用 nhibernate 将两个表映射到一个对象
- asp.net-mvc - 身份无法连接到远程数据库,继续连接到本地数据库
- pyspark - 计算日期在每个 ID 的日期范围内的行数
- javascript - 如何隐藏未选中的表单的输入字段并仅显示已选中的输入字段