Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 323343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:01:20+00:00 2026-05-12T09:01:20+00:00

Greetings I am a jquery newbie and trying to fix an issue which uses

  • 0

Greetings
I am a jquery newbie and trying to fix an issue which uses a version of “turning-series.html” from the official flot examples,
1- I am wondering how can I swith it from display selected to display all from my datasets.
2- How to change my options so when mouse over the point, it displays the value of the Y axis ?

//My data instance:
var datasets = {
        "1st input": {
            label: "1st input",
            data: [
            [1.250208e+12, 1339],   
            [1.2502944e+12, 1316],      
            [1.2503808e+12, 1379],
            [1.2504672e+12, 1223],
             ]
        },
        "2nd input": {
            label: "2nd input",
            data: [
            [1.2503808e+12, 1324],

            ]
        },
    };


//old one, instead of displaying the selected ones from choiceContainer, I want to display all.
    function showWhole() {
        var data = [];
        choiceContainer.find("option:selected").each(function () {
            var key = $(this).attr("name");
            if (key && datasets[key])
                data.push(datasets[key]);
        });

        if (data.length > 0)
            $.plot($("#placeholder"), data, {
                yaxis: {},
                xaxis: { mode: "time",minTickSize: [1, "day"],timeformat: "%d/%m/%y"},"lines": {"show": "true"},"points": {"show": "true"},clickable:true,hoverable: true
            });
    }

Regards

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T09:01:21+00:00Added an answer on May 12, 2026 at 9:01 am

    I took the example turning-series.html from FLOT website and made some changes. Copy and paste the following into a new HTML file and run it – works in Firefox, not tested in IE.

    <html>
     <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>Flot Examples</title>
        <link href="http://people.iola.dk/olau/flot/examples/layout.css" rel="stylesheet" type="text/css"></link>
        <!--[if IE]><script language="javascript" type="text/javascript" src="http://people.iola.dk/olau/flot/excanvas.pack.js"></script><![endif]-->
        <script language="javascript" type="text/javascript" src="http://people.iola.dk/olau/flot/jquery.js"></script>
        <script language="javascript" type="text/javascript" src="http://people.iola.dk/olau/flot/jquery.flot.js"></script>
        <style> #tooltip { font-size:8pt; } </style>
     </head>
        <body>
        <h1>Flot Examples</h1>
    
        <div id="placeholder" style="width:600px;height:300px;"></div>
    
        <p>Here is an example with real data: military budgets for
            various countries in constant (2005) million US dollars (source: <a href="http://www.sipri.org/">SIPRI</a>).</p>
    
    
    <script id="source" language="javascript" type="text/javascript">
    $(function () {
        var datasets = {
            "usa": {
                label: "USA",
                data: [[1988, 483994], [1989, 479060], [1990, 457648], [1991, 401949], [1992, 424705], [1993, 402375], [1994, 377867], [1995, 357382], [1996, 337946], [1997, 336185], [1998, 328611], [1999, 329421], [2000, 342172], [2001, 344932], [2002, 387303], [2003, 440813], [2004, 480451], [2005, 504638], [2006, 528692]]
            },        
            "russia": {
                label: "Russia",
                data: [[1988, 218000], [1989, 203000], [1990, 171000], [1992, 42500], [1993, 37600], [1994, 36600], [1995, 21700], [1996, 19200], [1997, 21300], [1998, 13600], [1999, 14000], [2000, 19100], [2001, 21300], [2002, 23600], [2003, 25100], [2004, 26100], [2005, 31100], [2006, 34700]]
            },
            "uk": {
                label: "UK",
                data: [[1988, 62982], [1989, 62027], [1990, 60696], [1991, 62348], [1992, 58560], [1993, 56393], [1994, 54579], [1995, 50818], [1996, 50554], [1997, 48276], [1998, 47691], [1999, 47529], [2000, 47778], [2001, 48760], [2002, 50949], [2003, 57452], [2004, 60234], [2005, 60076], [2006, 59213]]
            },
            "germany": {
                label: "Germany",
                data: [[1988, 55627], [1989, 55475], [1990, 58464], [1991, 55134], [1992, 52436], [1993, 47139], [1994, 43962], [1995, 43238], [1996, 42395], [1997, 40854], [1998, 40993], [1999, 41822], [2000, 41147], [2001, 40474], [2002, 40604], [2003, 40044], [2004, 38816], [2005, 38060], [2006, 36984]]
            },
        };
    
    
        // define an empty array
        var data = [];
    
        // use this existing loop...
        var i = 0;
        $.each(datasets, function(key, val) {
           val.color = i;
           ++i;
    
           // ... and add this line - so the data array is populated (row by row)
            data.push(datasets[key]);
        });
    
        // plot the graph with the newly populated data array
        $.plot($("#placeholder"), data, {
                    yaxis: { min: 0 },
                    xaxis: { tickDecimals: 0 },
                    grid: { hoverable: true, clickable: true },
                    points: { show: true },
                    lines: { show: true },
                });
    
    
        // add some hovering logic to each point...
         var previousPoint = null;
        $("#placeholder").bind("plothover", function (event, pos, item) {
            $("#x").text(pos.x.toFixed(2));
            $("#y").text(pos.y.toFixed(2));
    
                if (item) {
                    if (previousPoint != item.datapoint) {
                        previousPoint = item.datapoint;
                        $("#tooltip").remove();
                        var x = item.datapoint[0].toFixed(2), y = item.datapoint[1].toFixed(2);
                        showTooltip(item.pageX, item.pageY, item.series.label + " of " + x + " = " + y);
                    }
                }
                else {
                    $("#tooltip").remove();
                    previousPoint = null;            
                }
    
        });
    
        // show the tooltip
        function showTooltip(x, y, contents) {
            $('<div id="tooltip">' + contents + '</div>').css( {
                position: 'absolute',
                display: 'none',
                top: y - 35,
                left: x + 5,
                border: '1px solid #fdd',
                padding: '2px',
                'background-color': '#fee',
                opacity: 0.80
            }).appendTo("body").fadeIn(200);
        }
    
    });
    </script>
    
    </body>
    </html>
    
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Greetings from some noob trying to learn JQuery, I am attempting to make it
Greetings! I'm trying to have a UIWebView controlled from generated events. Is there a
Greetings, I am using the official Autocomplete jquery widget and am having troubles dynamically
Greetings all, I have a simple JQuery function which is bound to an ASP:Button
Greetings, how to get the selectedindex of check box from checkboxlist control using jquery?
Greetings, I'm trying to select item from asp.net list box then assign it to
I'm trying to make a jQuery mobile app read data from a server I'm
Greetings, I'm using https://github.com/blueimp/jQuery-File-Upload (downloaded the version as of 5/21/2011) along with ASP.NET MVC3.
Greetings. I'm having a weird problem with jQuery on my website. I'm trying to
Greetings, So I am trying to manually apply the jQuery CSS classes to my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.