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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:19:55+00:00 2026-06-17T07:19:55+00:00

I have been at this for hours and I have no idea what’s wrong.

  • 0

I have been at this for hours and I have no idea what’s wrong. It displays the correct graph but I can’t hover on any of the points. I’ve read through my var_dump() and all my records are in order. Am I converting the dates wrong at some point?

What my graph looks like (Which is correct): http://screencloud.net/v/qrSS

The error I’m getting: “Highcharts error #15: http://www.highcharts.com/errors/15”

Highcharts expects data to be sorted

This happens when you are trying to create a line series or a stock chart where the data is not sorted in ascending X order. For performance reasons, Highcharts does not sort the data, instead it is required that the implementer pre-sorts the data.

My console: http://screencloud.net/v/qWHo

My highcharts code

        $.post('/card/read_graph_json', inputs, function(data) {
            json = jQuery.parseJSON(data);

            chart = new Highcharts.Chart({
                chart: {
                    renderTo: 'container',
                    type: 'spline'
                },
                global: {
                    useUTC: false
                },
                plotOptions: {
                    series: {
                        animation: false
                    }
                },
                title: {
                    text: '{{ $card->name }}'
                },
                subtitle: {
                    text: null
                },
                xAxis: {
                    type: 'datetime',
                    dateTimeLabelFormats: { // don't display the dummy year
                        month: '%b',
                        year: '%b'
                    }
                },
                yAxis: {
                    title: {
                        text: null
                    },
                },
                tooltip: {
                    formatter: function() {
                        var monthNames = [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ],
                            date = new Date(this.x);

                        return '<strong>'+ this.series.name +'</strong><br/>'+ monthNames[date.getMonth()] + '. ' + date.getDay() + ', ' + date.getFullYear() +': '+ this.y;
                    }
                },
                series: [json]
            });
        });

My php that creates the JSON

public function contact_records($contact_id, $number_past_entries = 6, $reverse = false) 
{
        // Pull 15 records from db and order them by date created "Y-m-d H:i:s" 
        return $this->has_many('Record')
            ->where_deleted(0)
            ->where_contact_id($contact_id)
            ->order_by('created_at', 'desc')
            ->take($number_past_entries)
            ->get();
}

public function post_read_graph_json()
{
    $contact_id = Input::get('contact_id');
    $tracker = Tracker::find(Input::get('tracker_id'));
    $card = Card::find(Input::get('card_id'));
    $serie = array();

    if ($tracker != null && $card != null) {
        Cookie::forever("default_graph_tracker_id", $tracker->id);
        $data = array();

        // This is where my records come from
        $records = $card->contact_records($contact_id, 15);

        // Create the serie
        foreach ($records as $record) {
            $data[] = array(
                strtotime($record->created_at) * 1000,
                floatval($record->read_tracker_value($tracker->id)->value)
            );
        }

        $serie = array(
            'name' => $tracker->name,
            'data' => $data
        );
    }

    return json_encode($serie);
}
  • 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-17T07:19:56+00:00Added an answer on June 17, 2026 at 7:19 am

    I used this function

    function aasort (&$array, $key) {
        $sorter=array();
        $ret=array();
        reset($array);
        foreach ($array as $ii => $va) {
            $sorter[$ii]=$va[$key];
        }
        asort($sorter);
        foreach ($sorter as $ii => $va) {
            $ret[$ii]=$array[$ii];
        }
        $array=$ret;
    }
    

    Updated tis part of my code

            $data = array();
            foreach ($records as $record) {
                $data[] = array(
                    'time' => strtotime($record->created_at) * 1000,
                    'value' => floatval($record->read_tracker_value($tracker->id)->value)
                );
            }
    
            aasort($data, 'time');
    
            $new_data = array();
            foreach ($data as $record) {
                $new_data[] = array(
                    $record['time'],
                    $record['value']
                );
            }
    
            $serie = array(
                'name' => $tracker->name,
                'data' => $new_data
            );
    

    ta da!

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

Sidebar

Related Questions

I have been searching for hours but I can't seem to understand why this
I Have been fiddling with this for hours. I can not get my text
I've been struggling with this for hours and i have no idea why is
I have been trying this for hours without success. http://replicaisland.googlecode.com/svn/trunk/ I have added the
Okay. Now I give up. I have been playing with this for hours. I
I have been working on this for few hours and got stuck, so how
I have been working on this for 24 hours now, trying to optimize it.
I have been researching this for a few hours and I feel that I
I have been rattling this around my head for a few hours now. I
okay i have been trying to understand this for hours i am learning VB

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.