6

I'm trying to build tiles using Cytoscape. Basically, each rectangle (tile) has a title and I want it to be written within the limits of that rectangle.

My code is:

var cy = cytoscape({
  container: document.getElementById('cy'),

  style: [
    {
      selector: 'node',
      css: {
        'shape': 'rectangle',
        'width': '200',
        'height': '150',
        'content': 'data(name)',
        'text-wrap': 'wrap',
        'text-valign': 'center',
        'text-halign': 'center',
        'text-transform': 'uppercase'
      }
    }, ///

And:

elements: {
    nodes: [
      { data: { id: 'F1', name: 'This is my very long text long text long text long text long text long text long text'} },
      { data: { id: 'F2' } },
      { data: { id: 'c', parent: 'b' } },
      { data: { id: 'd' } },
      { data: { id: 'e' } },
      { data: { id: 'f', parent: 'e' } }
    ],///

But it seems the text-wrap value isn't being read. I get:

Can anyone help with this?

Thanks in advance!

Page

4

1 回答 1

5

您已设置text-wrap: wrap为启用文本换行。您还没有为您希望如何包装文本指定任何规则。选项:

(1) 使用手动换行符(即'\n'

(2)text-max-width根据需要设置为最大行长度

于 2015-07-29T18:40:20.140 回答