How to draw a chart in PHP or Javascript or JQuery from Yahoo Finance CSV api result?

I want to draw a chart from the following url in either PHP or Javascript or JQuery

I can display the results in html using PHP code:

    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "");
    curl_setopt($curl, CURLOPT_HEADER, 0);
    $data = ob_get_clean();

    $rows = explode("\n", $data);
    echo "<table border='1'>";
    foreach($rows as $row) {
      echo "<tr>";
      $cols = explode(',', $row);
      foreach($cols as $col)
        echo "<td>$col</td>";
      echo "</tr>";
    echo "</table>";


You can draw a chart using the service Google Charts.

Once you download the document, the script must generate URL for service from Google.

I'd suggest JavaScript as being a great tool for this type of job. There are a number of great libraries you could use. Yahoo's yui charts or jqPlot if you prefer jQuery.

Personally I'd recommend Scott Murray's "Interactive Data Visualization for the Web" as a good place to start, you can buy it in print or view it online free. It is a guided walkthrough, building up to some very complex examples, of the d3.js. To quote from Murray:

  • Loading data into the browser’s memory
  • Binding data to elements within the document, creating new elements as needed
  • Transforming those elements by interpreting each element’s bound datum and setting its visual properties accordingly
  • Transitioning elements between states in response to user input

If you want to get further I recommend, D3's creator, Bostock's tutorials on github.

You could use JpGraph for doing this with PHP only. You can find a simple complete implementation example in

In your case Date could be X (you need to map dates to numerical values) and you would graph Open, High, Low, Close, Volume, Adj Close as Y values each in different lines on the same graph.

Need Your Help

Convert GeoDataFrame polygons to kml file

python-2.7 kml polygons geopandas

I have a geopandas GeoDataFrame with various polygons and colors that I'm using to plot meteorological data (another question I asked here):