G6使用记录
1-悬停可操作:自带的悬停,只是悬停展示,无法操作悬停展示的内容,所以需要定位替代自带的悬停-----参考issue地址https://github.com/antvis/G6/issues/2637#issuecomment-781001127
const tooltip = (
<div
className={styles.tooltip}
style={{
opacity: tooltipDisplayStates.opacity,
display: tooltipDisplayStates.display,
left: tooltipStates.x,
top: tooltipStates.y,
}}
>
fdsafsafsafad
<div className={styles.tooltipTitle}>
{tooltipStates.title.replace('\n', '')}
</div>
<div className={styles.tooltipContent}>
<img
className={styles.tooltipImg}
src={tooltipStates.imgSrc}
alt="tooltip"
/>
<div className={styles.tooltipBtnsContainer}>
<p className={styles.demoDescription}>demo</p>
{tooltipStates.buttons}
</div>
</div>
</div>
);
.tooltip {
position: absolute;
width: 218px;
height: 161px;
border: 1px solid #ebedf0;
border-radius: 4px 4px 4px 4px;
background: rgba(255, 255, 255, 1);
box-shadow: 0px 12px 16px rgba(49, 70, 89, 0.12);
transition: all 0.3s;
.tooltipTitle {
width: 100%;
text-align: center;
padding: 10px;
height: auto;
font-size: 14px;
font-weight: 500;
color: #314659;
}
.tooltipContent {
width: 100%;
height: 118px;
text-align: center;
border-top: 1px solid #ebedf0;
.tooltipImg {
width: 214px;
height: 118px;
margin-left: 1px;
border-radius: 0px 0px 3px 3px;
}
.tooltipBtnsContainer {
position: absolute;
width: 99%;
margin-left: 1px;
height: 118px;
padding: auto;
display: flex;
background: #fff;
border-top: 1px solid #ebedf0;
opacity: 0;
bottom: 0;
flex-direction: column;
.demoDescription {
width: 100%;
color: #ced4d9;
position: relative;
top: 30px;
font-size: 12px;
height: fit-content;
}
.buttons {
display: flex;
flex-direction: row;
text-align: center;
margin-top: 30px;
.button {
position: relative;
height: 20px;
text-align: center;
border-right: 1px solid #ebedf0;
a {
color: #2f54eb;
}
&:hover {
color: #597ef7;
}
&:last-child {
border-right: 0px;
}
}
}
&:hover {
opacity: 1;
transition: all 0.3s;
}
}
}
}
2-数据更新不会自动渲染,我这里使用的清空innnerHTML,同X6,也可以使用它的changeData方法强制更新
ref.current.innerHTML = ''; | |||