JXG.JSXGraph.freeBoard(board) freeze browser

306 views
Skip to first unread message

Gabriel Glenn

unread,
Oct 22, 2012, 11:31:52 AM10/22/12
to jsxg...@googlegroups.com
Hello,

First off all, thank you for your great lib : I try to make my way thru Google Chart for days, JSXGraph just rocks !

I have a issue while using JXG.JSXGraph.freeBoard(board).
I made a (very ?) heavy graph : (2 Axes, Ticks, Texts, 1 Polygon of 360 points and 1 Polygon  of 820 points.


The first time the graph is created, it's all good.
But the next time, the browser freeze (I mean it keep working) on JXG.JSXGraph.freeBoard(board).

The code I use looks like :

var b; // global variable that holds the JSXG board

function doTheGraphStuff(){
        if(b != undefined){
JXG.JSXGraph.freeBoard(b);
}

JXG.Options.precision.hasPoint = 0; 
b = JXG.JSXGraph.initBoard('chart_div', {boundingbox: [-10, 90, 380, -10], axis:false, grid:false, showCopyright:false, showNavigation:false});

        /* create axes, ticks, text and polygons */
        [...]
}

It seems to me that the free method has too much to do because of my heavy graph.
The question is : what is the good way to reset or re-create a graph held by the same div ?






Alfred Wassermann

unread,
Oct 22, 2012, 2:53:36 PM10/22/12
to jsxg...@googlegroups.com
Indeed, there seems to be a performance problem during freeBoard() for JSXGraph constructions with many elements. We will try to fix this.
In the mean time, you might consider to use curves of type='plot' instead of polygons:
You can create a filled area with
    b.create('curve', [[array of x coordinates], [array of y coordinates], {fillColor:..., fillOpacity, strokeWidth....});

This is much more lightweight than using points and polygons.

Interactive curves can be created by using your own updateDataArray-Method for the curve,
see http://jsxgraph.uni-bayreuth.de/wiki/index.php/Circle_approximation

Best wishes,
Alfred


Gabriel Glenn

unread,
Oct 23, 2012, 4:56:26 AM10/23/12
to jsxg...@googlegroups.com
Thx, it works great !

-Gabriel
Reply all
Reply to author
Forward
0 new messages