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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:10:29+00:00 2026-05-26T13:10:29+00:00

I was dealing today with Flot and when I try to get the data

  • 0

I was dealing today with Flot and when I try to get the data from PHP (with json_encode()) I can’t get it work properly.

I could display labels but no chart is created.

PHP

    $newData = array();

    $newData[0] = array();
    $newData[1] = array();
    $newData[2] = array();

    $newData[0]['label'] = 'Slice 1';
    $newData[1]['label'] = 'Slice 2';
    $newData[2]['label'] = 'Slice 3';

    $newData[0]['color'] = '#122b45';
    $newData[1]['color'] = '#064792';
    $newData[2]['color'] = '#9e253b';

    $newData[0]['data'] = array();
    $newData[0]['data'][0] = 1;
    $newData[0]['data'][1] = 1000;
    $newData[1]['data'] = array();
    $newData[1]['data'][0] = 1;
    $newData[1]['data'][1] = 500;
    $newData[2]['data'] = array();
    $newData[2]['data'][0] = 1;
    $newData[2]['data'][1] = 100;

    echo json_encode($newData);

jQuery

$.ajax({
            url: "get-stats.php",
            type: "POST", 
            async: false,
            dataType : 'JSON',
            data: {section:  section, endDate: endDate, startDate: startDate},
            success: function(data){
                $.plot($("#flot"), data,{
                series: {
                    pie: {
                        show: true
                    },
                    grid: {
                        hoverable: true,
                        clickable: true
                    }
                }
            }
        });

Can anyone tell me where I’m doing wrong?
Labels and colors are ok but it seems I can’t get the data.

Thank you for your time and concern in advance.

  • 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-26T13:10:30+00:00Added an answer on May 26, 2026 at 1:10 pm

    I found the problem and solution. I had to do following for the data;

    $newData[0]['data'] = array(array(1,100));
    

    This saved my day.

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

Sidebar

Related Questions

I frequently have problems dealing with DataRows returned from SqlDataAdapters . When I try
When dealing with a single file, I'm used to: /blah do some work n
I have a read a number of excellent questions and answers today about dealing
I was dealing with refactoring of my small web app. all night. Today when
My day to day work flow is something like this: acquire raw data (~50GB)
Dealing with go's funcs I discovered that one can't force the compiler to control
When dealing with something like a List<string> you can write the following: list.ForEach(x =>
I had an interesting request from a client today and I'm not exactly sure
I need to get the newest files/directory on my FTP server (updated today), I've
The problem I have today is about dealing with HTML in an included JSP,

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.