cytoscape css选择器到嵌套对象

时间:2017-04-11 12:30:07

标签: cytoscape.js

我正在使用一个带有cytoscape.js的项目,它的数据节点有这个对象。

data = {
  id: "some-id-here"
  name: "Area Chart",
  description: "Some cool chart"
  report: {
     type: "areachart",
     data: [{
        label: [...],
        series: [...]
        }
     ]
  }
}

我打算在电路板上的每个图表上添加一个不同的图标。我正在尝试使用上面的cytoscape.stylesheet()函数:

cytoscape.stylesheet()
.selector('node[report\\.type = \'areachart\']')
.css({
    'background-image': 'assets/img/flow/bg-areachart.png'
})

即使我按照Notes & Caveat说明操作,此示例也不起作用。 cytoscape.js是否支持选择嵌套对象属性?如果是这样,我该如何才能使其发挥作用?

1 个答案:

答案 0 :(得分:1)

它不受支持,我认为支持它可能太昂贵了。选择器仅用于简单数据比较。您可以展平对象,也可以使用自定义映射器函数来区分节点类型及其关联的背景图像:http://js.cytoscape.org/#style/mappers