Board clear, new id of objects

551 views
Skip to first unread message

Hron

unread,
Mar 25, 2012, 4:11:56 AM3/25/12
to JSXGraph
Hi, im glad your great work. But I have many questions again.
1)How i can clear board (delete all objects what i create).
2)How i can change id of created object.. as example, i have many
objects on board, i need clear them and create new point with my id
from saved XML:
<points>
<point id="jxgBoard1P27" redactorName="1" x="6" y="6.1" xLaw=""
yLaw="" fillColor="#ff0000" strokeColor="#ff0000" size="3" name=""/>
</points>

board.createElement('point',[6,6.1]).id = jxgBoard1P27.. or something
like that?

yikes agent

unread,
Mar 25, 2012, 4:32:07 AM3/25/12
to jsxg...@googlegroups.com

You may use freeBoard(brd),  where brd is the variable for the board.
You can always create an element and assign it to a variable, there you can manipulate it easily.

--
You received this message because you are subscribed to the Google Groups "JSXGraph" group.
To post to this group, send email to jsxg...@googlegroups.com.
To unsubscribe from this group, send email to jsxgraph+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/jsxgraph?hl=en.

Hron

unread,
Mar 25, 2012, 5:55:06 AM3/25/12
to JSXGraph
thx, yikes. Board is clear now.

I dont like to spam vars when i only need to create object with saved
id, but when i use:
______________
function loadPoint(pointID,pX,pY,pN) {
var p = board.createElement('point',
[parseFloat(pX),parseFloat(pY)],{name:''+pN});
JXG.getReference(board, p.id).id = pointID;
//JXG.getReference(board, pointID) - there is no object, i didnt
change anything.
}
______________

So i just want to know, how can i change id of object and then work
with him on board by using this id?
Coz if i cant - i need to refrash my xml file and its "big code"
moment))

Hron

unread,
Mar 25, 2012, 5:58:59 AM3/25/12
to JSXGraph
ofc i will do that on clear board, so i havnt errors with new id, new
id is free always. But what JSXGraph id-system can say about my
manipulations?)

michael

unread,
Mar 25, 2012, 5:59:10 AM3/25/12
to jsxg...@googlegroups.com
Hi,

just add id: 'the id you want to use' in the properties object:

board.create('point', [0, 0], {name: 'A', id: 'Aid'};

And you can use create() instead of createElement. They both do the same, but create() is shorter.

@yikes: When it comes to storing construction in a file you might want to keep track of the ids yourself instead of letting jsxgraph do it to ensure dependencies between the objects are preserved.


michael

Hron

unread,
Mar 25, 2012, 6:25:38 AM3/25/12
to JSXGraph
Your id-system is fine, but i dont want any troubles and started to
use advice of yikes. So easy and practical solve from michel, thanks
too.

yikes

unread,
Mar 25, 2012, 8:00:24 AM3/25/12
to jsxg...@googlegroups.com
Thanx Michael
Reply all
Reply to author
Forward
0 new messages