Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Pie Chart is not showing any slices but others

I'm working with google visualization charts and I've got the following problem.

I've got a page were the charts are displayed. It's possible to switch between different charts. Every chart option works, except for the piechart.

The PieChart is visible but it just is a grey circle showing 100%.

The data i've got in the DataTable is:

{"cols": [{
            "id": "New jobs",
            "label": "New jobs",
            "pattern": "",
            "type": "string"
        },
        {
            "id": "Date",
            "label": "Date",
            "pattern": "",
            "type": "number"
        }
    ],
    "rows": [{"c": [{
                    "v": "01-11-2012",
                    "f": null
                },{
                    "v": "5",
                    "f": null
                }
            ]
        },{"c": [{
                    "v": "02-11-2012",
                    "f": null
                },{
                    "v": "3",
                    "f": null
                }
            ]
        },{"c": [{
                    "v": "03-11-2012",
                    "f": null
                },{
                    "v": "8",
                    "f": null
                }]
        },{"c": [{
                    "v": "04-11-2012",
                    "f": null
                },
                {
                    "v": "2",
                    "f": null
                }
            ]
        },{"c": [{
                    "v": "05-11-2012",
                    "f": null
                },
                {
                    "v": "6",
                    "f": null
                }
            ]
        },{"c": [{
                    "v": "06-11-2012",
                    "f": null
                },
                {
                    "v": "7",
                    "f": null
                }
            ]
        }
    ]
}

Maybe there is something wrong with the JSON format.

Please let me know if you want more information or if you have an possible answer.

like image 621
MmynameStackflow Avatar asked Jan 24 '26 00:01

MmynameStackflow


1 Answers

The problem has been solved.

The value was a string and it had to be a number so in PHP just cast the value to an int and then put it into the array.

{"cols": [{
            "id": "New jobs",
            "label": "New jobs",
            "pattern": "",
            "type": "string"
        },
        {
            "id": "Date",
            "label": "Date",
            "pattern": "",
            "type": "number"
        }
    ],
    "rows": [{"c": [{
                    "v": "01-11-2012",
                    "f": null
                },{
                    "v": 5,
                    "f": null
                }
            ]
        },{"c": [{
                    "v": "02-11-2012",
                    "f": null
                },{
                    "v": 3,
                    "f": null
                }
            ]
        },{"c": [{
                    "v": "03-11-2012",
                    "f": null
                },{
                    "v": 8,
                    "f": null
                }]
        },{"c": [{
                    "v": "04-11-2012",
                    "f": null
                },
                {
                    "v": 2,
                    "f": null
                }
            ]
        },{"c": [{
                    "v": "05-11-2012",
                    "f": null
                },
                {
                    "v": 6,
                    "f": null
                }
            ]
        },{"c": [{
                    "v": "06-11-2012",
                    "f": null
                },
                {
                    "v": 7,
                    "f": null
                }
            ]
        }
    ]
}
like image 138
MmynameStackflow Avatar answered Jan 26 '26 15:01

MmynameStackflow