Get the latest news, exclusives, sport, celebrities, showbiz, politics, business and lifestyle from The VeryTime,Stay informed and read the latest news today from The VeryTime, the definitive source.

How to Graph With jQuery

8
    • 1). Download the plug-in from its host site. Decompress the plug-in in a directory that can be accessed by the JavaScript program that will use it.

    • 2). Create a new HTML 5 file using an HTML editor or Notepad. Add the "<head>" tag, specify a window title using the "<title>" tag and add the jQuery and charting plug-in libraries using the "<script>" tag:

      <html>
      <head>
      <title>jQuery Graphs</title>
      <script src="https://ajax.googleapis.com/ajax/l;ibs/jquery/1.6.4/jquery.min.js"></script>
      <script src="lib/flot/jquery.flot.min.js"></script>
      </head>

    • 3). Add a "<body>" tag and an empty "<div>" tag with an "id" where you want the graph to display. Select the "<div>" tag using jQuery with "$('#id')." Insert the JavaScript code to display a chart or graph:

      <body>
      <div id="mychart" style="width:600px;height:300px"></div>
      <script>
      $(document).ready(function() {
      var dataPoints = [[1,27964], [2,33435], [3,43165], [4,50359], [5,54861], [6,82197], [7,99516], [8,166065], [9,129773]];
      $.plot($("#mychart"), [{data:dataPoints, bars:{show:true}}])});
      </script>
      </body>
      </html>

    • 4). Save the HTML file. Open it in a Web browser to verify that the graph displays properly.

Source...
Subscribe to our newsletter
Sign up here to get the latest news, updates and special offers delivered directly to your inbox.
You can unsubscribe at any time

Leave A Reply

Your email address will not be published.