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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:57:11+00:00 2026-06-13T11:57:11+00:00

I need to create chart using Flot chart library, using PHP JSON functions (ie.

  • 0

I need to create chart using Flot chart library, using PHP JSON functions (ie. json_encode).

Problem is that I don’t understand structure of PHP array that have to be encoded to create proper JS array for generating Flot charts.

Chart needs to have several lines, with different colors.

Can somebody help me with some example of proper PHP array for this kind.

I have tried (without success) to implement next example:

FLOT data from MySQL via PHP?

Problem with it is that I’m getting Object that I don’t know how to implement in my script:

    $.ajax({
        type:'post', 
        dataType: "json", 
        url:'/stocks/index/',
        success: function(r) {
            $.plot($("#placeholder"), [
                {data:(r)}
            ] )
        }
    });

Thank you in advance!

UPDATE: php code used to generate JSON array looks like this:

$dataSet1 = array();
$dataSet1['label'] = 'Customer 1';
$dataSet1['data'] = array(array(1,1),array(2,2)); // an array of arrays of point pairs

$dataSet2 = array();
$dataSet2['label'] = 'Customer 2';
$dataSet2['data'] = array(array(3,3),array(4,5)); // an array of arrays of point pairs

$flots = array($dataSet1, $dataSet2);
return json_encode($flots);
  • 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-13T11:57:12+00:00Added an answer on June 13, 2026 at 11:57 am
    $dataSet1 = array();
    $dataSet1['label'] = 'Customer 1';
    $dataSet1['data'] = array(array(1,1),array(2,2)); // an array of arrays of point pairs
    
    $dataSet2 = array();
    $dataSet2['label'] = 'Customer 2';
    $dataSet2['data'] = array(array(3,3),array(4,5)); // an array of arrays of point pairs
    
    $flots = array($dataSet1, $dataSet2);
    echo json_encode($flots);
    

    php file..

    and

    $.ajax({
            type:'post', 
            dataType: "json", 
            url:'/stocks/index/',
            success: function(data) {
                $.plot($("#placeholder"),  data );
            }
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to create a basic column chart using highcharts. Here's my PHP code:
I need to create a structure that holds a variable number of 'char[2]'s, i.e.
I bumped into this problem when I created a chart that need a axis
I need some help. I want to create a dynamic line chart using Google's
I'm using iReport to try to create a chart for bug tracking. I need
I have a bar chart created using flot jsFiddle Code Now i need to
I am trying to create a using jfree chart library line chart and i
I am using flot to create bar charts like I need to specify a
Using the DataVisualization.Charting.Chart control, I need to create a bar chart (maybe stacked bar
I'm trying to create a chart using the Google Visualization API, with 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.