I have set the htmlLabels attribute to true on the mxGraph and now all my text labels are aligning to the bottom of the cells even though the style has mxConstants.STYLE_VERTICAL_LABEL_POSITION set to 'ALIGN_TOP' in the code. Is there an issue with top-aligning HTML labels in a cell? The actual text return by mxGraph.convertValueToString is not HTML but a plaintext string. The setting of htmlLabels was done to get wrapping to work.

asked 04 May '11, 12:41

cgidwhite's gravatar image

cgidwhite
194829
accept rate: 66%


Use mxConstants.VERTICAL_ALIGN instead.

link

answered 05 May '11, 05:32

Gaudenz's gravatar image

Gaudenz
80.1k1310
accept rate: 39%

That is also set to 'ALIGN_TOP'. Can both of them be set at the same time or are they mutually exclusive? As more history, before I set the mxGraph.htmlLabels property to true, the text correctly aligned to the top. After setting that property to true, the labels stopped properly aligning. Is there another way to get text to wrap within a cell without having mxGraph.htmlLabels set to true? Based on the documentation, there isn't.

(05 May '11, 07:54) cgidwhite

I wrapped the text in a

tag set and there was no change in behavior. The text is still aligned at the bottom of the cell even with the VERTICAL_ALIGN and VERTICAL_LABEL_POSITION set to ALIGN_TOP.

(10 May '11, 09:19) cgidwhite

This is my mistake. I had the string value set to "ALIGN_TOP" instead of "top".

(19 May '11, 08:11) cgidwhite

If you are working with the tree and nodes,this should work.

\n

var label11 = graph.insertVertex(v1, null, 'Label1');

\n

this worked for me to align the label at top.

link

answered 10 May '11, 09:41

kbp's gravatar image

kbp
0110
accept rate: 0%

This works for me: graph.insertVertex(graph.getDefaultParent(), null, '<b>Bold</b>', 20, 20, 80, 30, 'verticalAlign=top'); with graph.setHtmlLabels(true) and the default stylesheet.

link

answered 11 May '11, 03:14

Gaudenz's gravatar image

Gaudenz
80.1k1310
accept rate: 39%

The special twist on this is that I'm using an XML attribute to store the label and using the mxGraph.convertValueToString function to return the string. Is there anything special that needs to be done to get text from that mechanism to appear top-aligned?

(16 May '11, 05:34) cgidwhite
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×228
×29

Asked: 04 May '11, 12:41

Seen: 5,892 times

Last updated: 19 May '11, 08:11