0

I would like to draw a Google chart. In the example, we get the following url to embeded into our HTML code :

https://chart.googleapis.com/chart?cht=lc&chs=250x100&chd=t:60,40

How can I replace the data t:60,40 by an array of data I get from a db ?

Let's say I have the following array, $chartdata :

$chartdata = [1, 2, 3, 4, 5]

Now, I would like to draw the same chart as above, but using my $chartdata.

The following method is not working :

<?php
echo "<img src='https://chart.googleapis.com/chart?cht=lc&amp;chs=250x100&amp;chd=t:" . $chartdata ."'>";
?>

Does someone has an idea ?

Thank you

1 Answer 1

2

Use implode

<?php
echo "<img src='https://chart.googleapis.com/chart?cht=lc&amp;chs=250x100&amp;chd=t:" . implode(",", $chartdata) . "'>";
?>    
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.