英文:
How to make a relationship diagram between attributes in Angular 8?
问题
我是新手使用Angular 8,需要一些帮助...
我有三个数据库表格,如下所示:
Entities表格
Entity_id Entity_name
1 first_entity
2 second_entity....以此类推
Attributes表格
attribute_id attribute_name
1 first_attr
2 second_attr....以此类推
Entity_attribute Mapping表格
id Entity_id attribute_id
1 1 2
2 1 3
3 1 4
4 2 5
5 2 6
6 2 7等等...
如您所见,一个实体具有多个属性。在前端,我正在列出所有实体在左侧,单击任何实体将显示相关属性。
还有一个来自API的表格数据:
Attributes relations表格
id entity_id attribute_id entity_foreign_key_id attributed_foreign_key_id
1 1 2 3 5
2 1 3 4 7
在上面的表格中,我获取了不同实体的属性之间的关系。我想要在属性之间绘制图像或线条,如下图所示。
当单击任何实体时,我调用此方法:
showAttributes(entityId) {
this.entandApi.getAttributes_by_entity(entityId).subscribe((data: any) => {
let getAttributeResp = data;
})
}
我尝试使用jQuery的以下代码:
var line = $('#line');
var div1 = $('#first-div');
var div2 = $('#second-div');
var x1 = div1.offset().left + (div1.width());
var y1 = div1.offset().top + (div1.height()/2);
var x2 = div2.offset().left;
var y2 = div2.offset().top+ (div1.height()/2);
line.attr('x1',x1).attr('y1',y1).attr('x2',x2).attr('y2',y2);
但不确定如何在Angular 8中实现这一点。
任何帮助将不胜感激。
英文:
I am new to angular 8 and need some help...
I have 3 database tables like below:
**Entities table**
Entity_id Entity_name
1 first_entity
2 second_entity....and so on
**Attributes table**
attribute_id attribute_name
1 first_attr
2 second_attr....and so on
**Enitity_attribute Mapping**
id Entity_id attribute_id
1 1 2
2 1 3
3 1 4
4 2 5
5 2 6
6 2 7 and so on...
As you can see one entity has multiple attributes. In the front end, I am listing down all the entities in the left side and clicking on any entity will show related attribute
one more table data coming from api:
**Attributes relations**
id entity_id attribute_id entity_foreign_key_id attributed_foreign_key_id
1 1 2 3 5
2 1 3 4 7
In above table I am getting the relation between the attributes of different entities. I want draw image or line between the attributes as shown in below picture.
I am calling this method when any entity is clicked:
showAttributes(entityId) {
this.entandApi.getAttributes_by_entity(entityId).subscribe((data: any) => {
let getAttributeResp = data;
})
}
I have tried below code using jquery:
var line = $('#line');
var div1 = $('#first-div');
var div2 = $('#second-div');
var x1 = div1.offset().left + (div1.width());
var y1 = div1.offset().top + (div1.height()/2);
var x2 = div2.offset().left;
var y2 = div2.offset().top+ (div1.height()/2);
line.attr('x1',x1).attr('y1',y1).attr('x2',x2).attr('y2',y2);
But not sure how to achieve this in Angular 8.
Any help would be appreciated.
答案1
得分: 1
我已使用这个库 https://anseki.github.io/leader-line/,并且它按预期工作。以下是我使用的代码:
<div id="start">start</div>
<div id="end">end</div>
new LeaderLine(
document.getElementById('start'),
document.getElementById('end')
);
英文:
I have used this library https://anseki.github.io/leader-line/ and it is working as expected. Below is the code I used
<div id="start">start</div>
<div id="end">end</div>
new LeaderLine(
document.getElementById('start'),
document.getElementById('end')
);
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论