cytoscape.js - cytoscape 的样式表不生效。文字和图表显示不正确
问题描述
我正在尝试使用 cytoscape 创建下图。
https://pathwaycommons.github.io/cytoscape-sbgn-stylesheet/
我已经安装了 cytoscape-sbgn-stylesheet 和 cytoscape 作为我的 Angular 应用程序的依赖项。
这是角度应用程序的代码
import { AfterViewInit, Component, ElementRef, ViewChild } from '@angular/core';
import * as cytoscape from 'cytoscape';
import sbgnStylesheet from 'cytoscape-sbgn-stylesheet';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
})
export class AppComponent implements AfterViewInit {
@ViewChild('cy') el: ElementRef;
ngAfterViewInit() {
var cy = cytoscape({
container: document.getElementById('cy'), // container to render in
stylesheet: sbgnStylesheet(cytoscape),
elements :[] //copied from https://github.com/PathwayCommons/cytoscape-sbgn-stylesheet/blob/master/demo.json
layout: {
name: 'preset',
},
});
}
}
Html File
```
但我没有看到图表的实际样式,也没有看到任何标签。我究竟做错了什么?
这是我看到的没有节点样式和标签的图片
解决方案
调试时间太长,但错误很小,就用这个:
style: sbgnStylesheet(cytoscape),
代替:
stylesheet: sbgnStylesheet(cytoscape),
这是cytoscape-sbgn-stylesheet存储库 README 中的一个错误,用法段落明确指出使用“样式表”,尽管演示照常使用“样式”。
这是您的stackblitz的修订版
推荐阅读
- wordpress - 删除重复帖子的循环未发布正确数量的帖子
- c - Pointer is being being masked when calling a C function from Fortran
- node.js - 如何设置 socket.io 以实时获取数据
- jquery - 将外部事件拖入日历(或从日历返回到“外部事件”列表)的溢出剪辑问题
- django - 尽管字段具有“空白=真”,但 Django EmbeddedModelField 在执行 PUT 请求时说“此字段可能不是空白”
- vulkan - VkDebugUtilsMessengerEXT 使用的最小 Vulkan 示例不输出任何内容?
- android-instant-apps - libwebsockets 无法在 android 即时应用程序中建立 Web 套接字连接
- javascript - 当父宽度减小时移动内部元素
- mysql - mysql查询回调返回值到变量
- graphviz - 在 Graphviz 中写在边缘箭头上的边缘标签