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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:04:28+00:00 2026-05-26T03:04:28+00:00

I need help for generate the series data part into json var chart =

  • 0

I need help for generate the series data part into json

var chart = new Highcharts.Chart({
    chart: {
        renderTo: 'container'
    },
    xAxis: {
        type: 'datetime'
    },
    series: [{
        data: [
            [Date.UTC(2010, 0, 1), 29.9],
            [Date.UTC(2010, 0, 2), 71.5],
            [Date.UTC(2010, 0, 3), 106.4],
            [Date.UTC(2010, 0, 6), 129.2],
            [Date.UTC(2010, 0, 7), 144.0],
            [Date.UTC(2010, 0, 8), 176.0]
         ]
    }]
});

My php part

foreach ($behaviour as $value) {
    $chart['xAxis']['categories'][]= time($value['date']);
}

Json output

[1318354710,1318354710,1318354710,1318354710]

I don’t know what I need to do with my php code to do this part with a valid json.

part where I need help

series: [{
    data: [
        [Date.UTC(2010, 0, 1), 29.9],
        [Date.UTC(2010, 0, 2), 71.5],
        [Date.UTC(2010, 0, 3), 106.4],
        [Date.UTC(2010, 0, 6), 129.2],
        [Date.UTC(2010, 0, 7), 144.0],
        [Date.UTC(2010, 0, 8), 176.0]
     ]
}]

How can I solve this?

  • 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-26T03:04:28+00:00Added an answer on May 26, 2026 at 3:04 am

    Date.UTC returns the number of milliseconds in a date string since midnight of January 1, 1970. This is the same as a UNIX timestamp. So [Date.UTC(2010, 0, 1), 29.9] translates to [1262304000, 29.9].

    There are a number of ways to get this timestamp in PHP. One simple (and object oriented) way is to use the DateTime class:

    $time = new DateTime($value['date'], new DateTimezone('UTC'));
    $chart['xAxis']['categories'][] = $time->getTimestamp();
    

    Update

    Without knowing the ins and outs of your code, the best I can do is offer some sample code:

    <?php
    // sample data
    $behaviour = array(
        array(
            'date' => '2010-01-01',
            'datum' => 29.9
        ),
        array(
            'date' => '2010-01-02',
            'datum' => 71.5
        ),
        array(
            'date' => '2010-01-03',
            'datum' => 106.4
        ),
        array(
            'date' => '2010-01-06',
            'datum' => 129.2
        ),
        array(
            'date' => '2010-01-07',
            'datum' => 144
        ),
        array(
            'date' => '2010-01-08',
            'datum' => 176
        )
    );
    
    // creates the container information
    $output = array(
        'chart' => array(
            'renderTo' => 'container'
        ),
    
        'xAxis' => array(
            'type' => 'datetime'
        ),
    
        'series' => array()
    );
    
    // adds the sample data
    foreach ($behaviour as $value) {
        $time = new DateTime($value['date'], new DateTimezone('UTC'));
        $output['series'][0]['data'][] = array(
            $time->getTimestamp(), $value['datum']
        );
    }
    
    // output as JSON
    header('Content-type: application/json');
    echo json_encode($output); 
    ?>
    

    Feel free to adapt it to your actual code.

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

Sidebar

Related Questions

Need help with following situation: Users can generate their own data structures which are
I need help writing a T-SQL query that will generate 52 rows of data
Need help writing a script downloads data from google insight using c# this is
I need help with this route map routes.MapRoute(Blog_Archive, Blog/Archive/{year}/{month}/{day}, new { controller = Blog,
I need help to replace all \n (new line) caracters for in a String,
I need to help to generate column name from excel automatically. I think that:
I need help to generate a tree of categories from a CSV file. I
Need help with SQL - I want to generate and update a column in
need help to create regular expression matching string www.*.abc.*/somestring Here * is wild card
I need help on this following aspx code aspx Code: <asp:Label ID =lblName runat

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.