Hi,

\n

I need the label font size to grow or shrink according to the cell geometry. Is this possible in mxGraph ?
\n

asked 31 Jan '12, 21:41

Raanan's gravatar image

Raanan
1124
accept rate: 0%


Here is an example:

\n
// Updates the cell after implicit style changes\ngraph.processChange = function(change)\n{\n  if (change instanceof mxGeometryChange)\n  {\n    this.view.removeState(change.cell);\n  }\n\n  mxGraph.prototype.processChange.apply(this, arguments);\n};\n\n// Returns dynamic fontsize based on geometry\ngraph.model.getStyle = function(cell)\n{\n  var geometry = this.getGeometry(cell);\n  var fs = mxConstants.DEFAULT_FONTSIZE;\n\n  if (geometry != null)\n  {\n    fs = Math.max(fs, geometry.height);\n  }\n\n  return mxGraphModel.prototype.getStyle.apply(this, arguments) + ';fontSize=' + fs;  \n};\n
link

answered 01 Feb '12, 00:35

Gaudenz's gravatar image

Gaudenz
80.1k1310
accept rate: 39%

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: 31 Jan '12, 21:41

Seen: 2,923 times

Last updated: 01 Feb '12, 00:35