phpcakephphighchartscakephp-2.3

Highchart not displaying in cakephp


I'm working on one of the cakephp website, where I'm using HighchartPHP libraries. But high-chart is not displaying. This issue is only when I use dynamic data from database, but if I use static array to pass then it will working fine with same code.

Below are array which I get from dynamic code I have used:

stdClass Object
(
    [series] => Array
        (
            [0] => Array
                (
                    [name] => Forwarding Facility 1
                    [data] => Array
                        (
                            [0] => 28.5
                            [1] => 410.68
                            [2] => 0
                            [3] => 0
                        )

                )

            [1] => Array
                (
                    [name] => Forwarding Facility 2
                    [data] => Array
                        (
                            [0] => 0
                            [1] => 0
                            [2] => 99.05000000000001
                            [3] => 0
                        )

                )

            [2] => Array
                (
                    [name] => Forwarding Facility 3
                    [data] => Array
                        (
                            [0] => 0
                            [1] => 15.7
                            [2] => 0
                            [3] => 0
                        )

                )

            [3] => Array
                (
                    [name] => Hampshire Turf
                    [data] => Array
                        (
                            [0] => 0
                            [1] => 540
                            [2] => 0
                            [3] => 0
                        )

                )

        )

)

Below are static data array i used from one of the example from demo :

    stdClass Object
(
    [series] => Array
        (
            [0] => Array
                (
                    [name] => John
                    [data] => Array
                        (
                            [0] => 5
                            [1] => 3
                            [2] => 4
                            [3] => 7
                            [4] => 2
                        )

                )

            [1] => Array
                (
                    [name] => Jane
                    [data] => Array
                        (
                            [0] => 2
                            [1] => 2
                            [2] => 3
                            [3] => 2
                            [4] => 1
                        )

                )

            [2] => Array
                (
                    [name] => Joe
                    [data] => Array
                        (
                            [0] => 3
                            [1] => 4
                            [2] => 4
                            [3] => 2
                            [4] => 5
                        )

                )

        )

)

I can't find any solution for the same.


Solution

  • I have tried with lots of different ways, but found very simple solution. CASTING. Yes, somehow its required to TYPE CASTE array value when passing to the highcharts. so i use floatval() function to convert data into the float value. and finally its working like a charm!

    Thank you all for your response and support!