Jump to content
JChartFX Community
  • 0

Dynamic resize of the plot div


flapane

Question

6 answers to this question

Recommended Posts

  • 0

As far as I know there is no event on an element when it is resized but you can attach to the window resize event. e.g.

 

$(window).resize(function() {

    if (chart1 != null)
        chart1.doUpdate(true);
});
 
Note that if the browser sends this event while the window is being resized, and your page have lots of content, performance might not be ideal, you could start/reset a time in the resize function so that you delay the chart repainting until the window stops resizing.
 
var timerResize = null;
$(window).resize(function() {
    if (chart1 != null) {
        if (timerResize != null)
            clearTimeout(timerResize);
        timerResize = setTimeout(function() {
            chart1.doUpdate(true);
        }, 250);
    }
});
 
JuanC
Link to comment
Share on other sites

  • 0

Thanks, it work great.

My plots are enclosed in a

function loadChart(){}
window.onload

function in order to avoid adding the onload attribute in the <body> tag, which is something I can't do it.

Now I've moved the variables right before the loadChart() function.

 

I didn't pay attention to the fact that the variable was inside a function, I'm not by any means a js expert.

 

Thanks

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...