Cytoscape JS背景色灰色

CytoscapeJS background color grey

我有一个调整了背景颜色的 Cytoscape JS 网站的小例子。但是,要使背景可见,首先必须单击其中一个节点。这是为什么 ?我怎样才能立即看到背景颜色?

<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="https://pagecdn.io/lib/cytoscape/3.10.2/cytoscape.min.js"></script>



<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <title></title>
    <style media="screen">
      #cy {
        width: 100%;
        height: 100%;
      }
    </style>
  </head>
  <body>
    <div id="cy"></div>


  </body>
</html>

<script type="text/javascript">
    $(document).ready(function(){
      var cy = cytoscape({
      container: document.getElementById('cy'),
      elements: {
        nodes: [
          { data: { id: 'n1'}, style: {  'pie-size': '80%',
                                'pie-1-background-color': '#E8747C',
                                'pie-1-background-size': '75%',
                                'pie-2-background-color': '#74CBE8',
                                'pie-2-background-size': '25%'}  },
          { data: { id: 'n2'}, style: {'background-color': '#E8747C'}  }
        ],
        edges: [
          { data: { source: 'n1', target: 'n2' } }
        ]
      }
    });
    })
</script>

通常,您在 cytoscape.js 样式表中指定这些样式(see this section 在文档中):

$(document).ready(function() {
  var cy = cytoscape({
    container: document.getElementById('cy'),
    style: [{
        selector: '.quarter',
        css: {
          'pie-size': '80%',
          'pie-1-background-color': '#E8747C',
          'pie-1-background-size': '75%',
          'pie-2-background-color': '#74CBE8',
          'pie-2-background-size': '25%'
        }
      },
      {
        selector: '.uniform',
        css: {
          'background-color': '#E8747C'
        }
      }
    ],
    elements: {
      nodes: [{
          data: {
            id: 'n1'
          },
          classes: ['quarter']
        },
        {
          data: {
            id: 'n2'
          },
          classes: ['uniform']
        }
      ],
      edges: [{
        data: {
          source: 'n1',
          target: 'n2'
        }
      }]
    }
  });
})
body {
  font: 14px helvetica neue, helvetica, arial, sans-serif;
}

#cy {
  height: 100%;
  width: 100%;
  left: 0;
  top: 0;
  float: left;
  position: absolute;
}
<html>

<head>
  <meta charset=utf-8 />
  <meta name="viewport" content="user-scalable=no, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, minimal-ui">
  <script src="https://unpkg.com/cytoscape@3.3.0/dist/cytoscape.min.js">
  </script>
  <script src="https://unpkg.com/jquery@3.3.1/dist/jquery.js"></script>
</head>

<body>
  <div id="cy"></div>
</body>

</html>