I've created a chart with labels which depend on the value of a slider. What's the preferred method to update a label when a condition (the slider value) changes?

\n

Currently I change the toString() value of the user object of my vertex and call graph.refresh() to show the new label values in the vertices, but the performance isn't good.

\n

Is there a better solution?

\n

Thanks for your answer!

\n

edit: just tried

\n

\n for( Object cell: cellList) {\n String text = getNewText( cell);\n mxCellState state = graph.getView().getState( cell);\n state.setLabel( text);\n }\n }\n graph.repaint();\n
\n

\n

which performs faster, but is still not performing good.

asked 09 Oct '11, 00:55

Lofi's gravatar image

Lofi
1.0k1221
accept rate: 37%

edited 09 Oct '11, 01:32

Is performance any better if you just repaint what really needs to be repainted, by calling graph.repaint( state.getBoundingBox()); inside the loop instead of the call following the loop?

(11 Oct '11, 05:50) rknowles9

thanks, but calling only one graph.repaint() outside the loop is faster.

(11 Oct '11, 08:52) Lofi

Did you also try mxIGraphModel.setValue (between a begin-/endUpdate)?

(12 Oct '11, 23:25) Gaudenz

Now i did :-) Thank you very much, Gaudenz! I found a good solution by combination of setting the label in my user object (needed when things change later) and setting the state:

\n

\ngraph.getModel().beginUpdate();\ntry {\n...loop begin...\nmyUserObject.setString("xxx");\nmxCellState state = graph.getView().getState( cell);\nstate.setLabel( "xxx");\n...loop end...\n} finally {\ngraph.getModel().endUpdate();\n}\ngraph.repaint();\n

\n

using setValue within the try...finally would have also been fast, but it was a bit slower than my current solution. my main problem was that repaint() didn't work. it works now using the try...finally block

\n

:-)

link

answered 13 Oct '11, 06:26

Lofi's gravatar image

Lofi
1.0k1221
accept rate: 37%

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:

×29
×6

Asked: 09 Oct '11, 00:55

Seen: 1,924 times

Last updated: 13 Oct '11, 06:26