微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

cytoscape 的样式表不生效文字和图表显示不正确

如何解决cytoscape 的样式表不生效文字和图表显示不正确

我正在尝试使用 cytoscape 创建以下图表。

https://pathwaycommons.github.io/cytoscape-sbgn-stylesheet/

我已经安装了 cytoscape-sbgn-stylesheet 和 cytoscape 作为对我的 angular 应用程序的依赖。

这是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
``

但我没有看到图表的实际样式,也没有看到任何标签。我做错了什么?

这是我看到的没有节点样式和标签图片

enter image description here

解决方法

调试时间太长,但错误很小,就用这个:

style: sbgnStylesheet(cytoscape),

代替:

stylesheet: sbgnStylesheet(cytoscape),

这是 cytoscape-sbgn-stylesheet 存储库自述文件中的错误,Usage 段落明确指出使用“样式表”,尽管演示照常使用“样式”。

这是您的stackblitz

的修订版

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。