PHP: help with formatting google charts (bar)

I am trying to make a horizontal bar chart with data from an array

$values = implode(',', array_values($type));
$labels = implode('|', array_keys($type));
$img = "http://chart.apis.google.com/chart?cht=bhg&chs=600x300&chd=t:{$values}&chxt=x,y&chtt=Ticket+Types&chxl=1:{$labels}&chts=676767,21.5";
echo "<img src='{$img}' alt='Chart'>";

This does not give me what I want to achieve, but it is difficult for me to fix it. The code above gives me a horizontal histogram with y's as the number of rows (i.e., the first label is 1, the second label is 2) and the wrong numbers are x.

I want the labels to display y axis and values ​​along x.

Can someone give me a hand?

Jonesi

+3
source share
2 answers

I tried to do almost the same thing last week. It drove me crazy. Check out this OpenSource project, it's a PHP interface for Google Charts.

http://code.google.com/p/gchartphp/

, ... http://code.google.com/p/gchartphp/wiki/Examples

.

+4
0

Source: https://habr.com/ru/post/1762479/


All Articles