O'Reilly logo

jQuery for Designers : Beginner's Guide - Second Edition by Natalie MacLees

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – calculating the ideal size for charts and graphs

We'll keep working with the files we created in the previous section. Perform the following steps to dynamically set the width and height of our charts and graphs according to the width of the browser window:

  1. Open your scripts.js file. We'll want to add a few quick calculations. First up, let's set a preferred width for our graphs and charts, as follows:
    $(document).ready(function(){
      var preferredWidth = 450;
    
    
      $('#menu').visualize({
        ...
      });
    
      $('#eaten').addClass('accessHide').visualize({
        ...
      }).appendTo('#pie-container').trigger('visualizeRefresh');
    
    });

    We created a variable named preferredWidth. Recall that a variable is just a container—in this case, the variable contains the size ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required