Google Charts with code on body to request

Asked

Viewed 34 times

1

Guys someone has already used goolecharts ? I can only make the plot if it is in the head, how do I make his code stay in the body ? 'Cause I want to plot via a request

1 answer

1


<?php
  // Create some random text-encoded data for a line chart.
  header('content-type: image/png');
  $url = 'https://chart.googleapis.com/chart';
  $chd = 't:';
  for ($i = 0; $i < 150; ++$i) {
    $data = rand(0, 100000);
    $chd .= $data . ',';
  }
  $chd = substr($chd, 0, -1);

  // Add data, chart type, chart size, and scale to params.
  $chart = array(
    'cht' => 'lc',
    'chs' => '600x200',
    'chds' => '0,100000',
    'chd' => $chd);

  // Send the request, and print out the returned bytes.
  $context = stream_context_create(
    array('http' => array(
      'method' => 'POST',
      'content' => http_build_query($chart))));
  fpassthru(fopen($url, 'r', false, $context));
?>
  • <img width='600' height='200' src='chartserver-image.php'> , that’s what you need?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.