css - 如何将预先存在的 css 类附加到 Cytoscape JS for Angular 中的节点标签
问题描述
尽管节点的 CSS 不符合要求,但我在整个项目中都有一个统一的 CSS 主题。我需要根据日间模式和夜间模式更改 css 标签颜色,我是如何实现的?
this.cy = cytoscape({
container: document.getElementById(this.pageId),
boxSelectionEnabled: false,
autounselectify: true,
zoomingEnabled: true,
panningEnabled: true,
autoungrabify: false,
elements: this.nodes,
style: [{
selector: 'node',
style: {
'width':'data(cpu)',
'height': 'data(cpu)',
//'shape': 'circle',
'background-image': 'data(HealthImage)',
'background-fit': 'contain contain',
'background-color': '#f5f7fa',
'label': 'data(' + this.nodeName + ')',
'cssClass': 'form-group', //tried this didn't work
"text-valign": "bottom",
"text-halign": "center",
"font-size": "12px",
"text-margin-y": "8px"
}
}]
});
解决方案
您可以使用 javascript 代码设置 cytoscape js 样式。也许您可以设置一个计时器来更改样式或始终检查时间并根据时间设置样式。
推荐阅读
- python - 在 python 控制台中自动突出显示一个字母/单词
- python - 条件减日期
- c++ - 返回类型重载运算符
- c# - 全局模型不存在添加方法
- javascript - 如何更改 Semantic-UI React 的选项卡标题宽度(垂直选项卡)
- angular - 部署在 Intranet IIS 10 上的 Angular 6 客户端应用程序始终返回错误 0
- javascript - 将 ActiveDirectory Javascript 代码集成到 React
- python - 乘以继承自 QWidget 和另一个基类?
- node.js - Lambda 函数未返回对 Alexa 技能的响应
- r - 文件上传后更新 checkboxGroupInput() 选项