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 6101253
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:28:44+00:00 2026-05-23T13:28:44+00:00

I am having problem with flot library to plot a graph using its line

  • 0

I am having problem with flot library to plot a graph using its line graph. What I want is to generate a java based sql query which would give me a values which I would put inside my json string variable and pass it to the data variable of javascript. I have attempted to do something, but its not updating it. Here’s my code:

     <script>
 $(function(){
     var options = {
                lines: { show: true },
                points: { show: true },
                xaxis: { show:false,tickDecimals: 0, tickSize: 20 }
            };

            var data = [];
            var placeholder = $("#myplace");

            $.plot(placeholder, data, options);

            function update() {
                // we get all the data in one go, if we only got partial
                // data, we could merge it with what we already got
            <%
    String jsonString = "{\"label\": \"Europe (EU28)\",\"data\": [[1, 20], [20, 10], [40, 3.9], [100, 40]]}";
    out.flush();
    %>    
                data = [<%=jsonString%>];

              // console.log(series[0][1]);
                $.plot($("#myplace"), data, options);
                setTimeout(update,1000);
            }

           update();

 });
 </script>

Can anyone guide me how should I proceed with this? thanks

  • 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-23T13:28:44+00:00Added an answer on May 23, 2026 at 1:28 pm

    Your Java code will produce a string that is not assigned to a JavaScript variable. I removed useless things like out.flush. This is how your update function should look:

    function update() {
            // we get all the data in one go, if we only got partial
            // data, we could merge it with what we already got
            data = <% "{\"label\": \"Europe (EU28)\",\"data\": [[1, 20], [20, 10], [40, 3.9], [100, 40]]}";%>;   
            $.plot($("#myplace"), data, options);
    }
    

    I also removed the setTimeout since it will produce the same data every time. If you want your graphs to update repeatedly from the server, you should look into ajax requests (e.g. $.get in jQuery).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having problem in the following line: rd.PrintOptions.PaperSize = PaperSize.PaperFanfoldStdGerman; it throws an exception
I'm having a problem writing Norwegian characters into an XML file using C#. I
I am having problem with Monodevelop 2.4 on windows 7 x64. When using Control-Tab
Hi I'm having problem with initialization in java, following code give me compile error
hi I'm having problem with my database. I'm using access as my database and
I am having problem transforming xml to xml using xsl. I found out where
We're having problem with a huge number of legacy stored procedures at work. Do
Having a problem getting a TreeView control to display node images. The code below
Having a problem trying to create a function, as part of a BizTalk helper
Im having a problem with a final part of my assignment. We get in

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.