Skip to content
Advertisement

Google chart not showing population of Girls via PHP

Am trying to build a Google ColumnChart that will show population of boys and girls in each locality.

The column chart for boys will be in red and that of girls in blue. I created MySQL database and inserted contents as follows:

JavaScript

Here is my issue: when I run the code below. It only display the column chart for boys alone.

If I try to add database rows to display that of girls as well as per this line of code

JavaScript

it will throw error below

JavaScript

Below is a working code that display columnchart for boys. How do I show Column chart of Girls also?

JavaScript

Advertisement

Answer

The first item in the array must define the columns:

JavaScript

Then the API should be able to handle the output of this:

JavaScript

See https://developers.google.com/chart/interactive/docs/gallery/columnchart

Such a chart can also be constructed differently: https://jsfiddle.net/api/post/library/pure

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement