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

  • Home
  • SEARCH
  • 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 8884137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:59:30+00:00 2026-06-14T20:59:30+00:00

I’m using Flot Graph Api to display bar chart, line chart in my clien

  • 0

I’m using Flot Graph Api to display bar chart, line chart in my clien side php. I try to pass Json to plot graph as they have mentioned in their examples.

I pack the Json like this,

 [{"label":"63f9311f-5d33-66ad-dcc1-353054485572","bars":{"show":true},"data":        [[-170.44530493708,270.44530493708]]},{"label":"8f6dcf4a-b20c-8059-1410-353054486037","bars":{"show":true},"data":[[-791.50048402711,891.50048402711]]},{"label":"c2b4cf75-3e0b-f9ff-722e-353054485803","bars":{"show":true},"data":[[-1280.0484027106,1380.0484027106]]},{"label":"eb963e23-75cd-6131-867a-353054485894","bars":{"show":true},"data":[[-1487.2604065828,1587.2604065828]]},{"label":"ef413106-d5be-593b-1cda-353054485719","bars":{"show":true},"data":[[-1940.9583736689,2040.9583736689]]}]

But the graph is not ploting.

     $.ajax({                                      
  url: '../c/By_Machine_Controller.php',                  //the script to call to get data          
  data: "",                        //you can insert url argumnets here to pass to api.php
                                   //for example "id=5&parent=6"
  dataType: 'json',                //data format      
  success: function(data)          //on recieve of reply
  {
    var Up = [];
    var Down = [];
    Up = data[0];              //get Up
    Down = data[1];           //get Down
    //alert(Up);
    $.plot($("#placeholder"), [ Up , Down ]);
  } 
});

Is it anything to do with Json or My JS is wrong. Since, i am new to flot i don’t have any clue. Can anyone help me out.

The Answer i have entered works fine, but in this case, i’m writing the JSON into a temp file and accessing it, but my requirement is,

I calculate the values for the flot in MODEL Folder in my localhost and passing it as associative array and encoding it as a JSON in CONTROLLER Folder. Now i need to access the JSON in VIEW Folder in my localhost.

CONTROLLER CODE:

    $json = json_encode($allData);
    $myFile = "ReasonByTime.txt";
    $fh = fopen($myFile, 'w') or die("can't open file");
    $stringData = "Bobby Bopper\n";
    fwrite($fh, $json);

    fclose($fh);

But when i access the $json of the CONTROLLER in the VIEW through JS like the following, its not working. I googled it but i was not able to fix it. Can you help me out with this?

VIEW JS CODE TO ACCESS JSON From CONTROLLER.

      $(document).ready(function () {

    //var dataurl = '../c/By_Machine_Controller.php';

    function onDataReceived(data) {

        $.plot(placeholder, data, options);
    }
    $.ajax({
        type: "GET",
        url: '../c/By_Machine_Controller.php',
        data: 'data',
        dataType: 'json', 
        success: function(data) { 
            alert(data);
        }
    });
});
  • 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-06-14T20:59:31+00:00Added an answer on June 14, 2026 at 8:59 pm

    This works for me.

     <script language="javascript" type="text/javascript">  
    $(document).ready(function(){
    $.getJSON('ReasonByTime.txt', function(json) {
        $.plot($("#placeholder"),json, {bars: { show: true, barWidth:0.2},xaxis: {ticks: json.ticks}});
    });
    

    });

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm making a simple page using Google Maps API 3. My first. One marker
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am reading a book about Javascript and jQuery and using one of the
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
this is what i have right now Drawing an RSS feed into the php,

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.