css - 如何将预先存在的 css 类附加到 Cytoscape JS for Angular 中的节点标签

标签 css angular typescript class cytoscape.js

虽然节点的 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 样式。也许您可以设置一个计时器来更改样式,或者始终检查时间并根据时间设置样式。

http://js.cytoscape.org/#cy.style

关于css - 如何将预先存在的 css 类附加到 Cytoscape JS for Angular 中的节点标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55469218/

相关文章:

javascript - 如何让div以100%的宽度和高度填充其容器?

css - 是否可以将 iframe 的元素位置更改为超出 iframe

html - CSS3 过渡向下滑动元素

angular - 在 Angular2 的 CanActivate 中注入(inject)服务

javascript - 如何在 PrimeNG 中使用 RowGroup 对数据进行分组?

javascript - 覆盖子 ngOnInit 方法

html - 如何选择仅使用 CSS 引用的 TH 的 TD?

css - 如何设置 p-tree 的宽度以填充可用空间?

java - 通过 POST 从 Angular 向 Springboot 发送数据

typescript - 如何创建自定义类型保护来检查某个值是否是给定类的实例?