Speed up development with full-stack environments for every branch.

Learn More

How to use Flot to make a simple Graph with jQuery

Forked from How to use the jQuery UI Slider.

1614 Runs 3378 Views 837 Copies


pg1 45

published 4 years ago

<!doctype html>

    <title>How to use Flot to make a simple Graph with jQuery</title>
            text-align: center;
            font-family: arial;
            height: 400px;

    <div id="graph"></div>

    <!-- add jquery and flot plugin -->
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    <script src="./jquery.flot.js"></script>


        //When DOM loaded we run the flot plugin
        $(document).ready(function() {

            //generate data points for the graph
            //d1 and d2 is js array which stores the data
            var d1 = [];
            for (var i = 0; i < 14; i += 0.1) {
                d1.push([i, Math.sin(i)]);

            var d2 = [];
            for (var i = 0; i < 14; i += 0.1) {
                d2.push([i, Math.cos(i)]);

            //we call the plot function which creates the graph 
            $.plot("#graph", [ d1, d2 ]);


Please login/signup to get access to the terminal.

Your session has timed out.

Dismiss (the page may not function properly).