Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8413035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:49:55+00:00 2026-06-10T00:49:55+00:00

I’m having some problems with importing a csv in order to get the highstock

  • 0

I’m having some problems with importing a csv in order to get the highstock graph.
I’m using the same code as the ohlc example (which works fine locally) but with another CSV which is created on my localhost by php.

PHP to get the CSV

<?PHP

// Declare the new variable as an array
$arrCSV = array();

// Open the CSV file
if (($handle = fopen("http://ichart.finance.yahoo.com/table.csv?s=AAPL&d=7&e=7&f=2012&g=d&a=8&b=7&c=1984&ignore=.csv", "r")) !==FALSE)
{

// Set the parent array key to 0
$key = 0;
// While there is data available loop through unlimited times (0) using separator (,)
while (($data = fgetcsv($handle, 0, ",")) !==FALSE) {

    // Count the total keys in each row
    $c = count($data);
    //print  $c . "<BR>"; // <------ 7 o numero de colunas

    //Populate the array
    If ($key != 0) {
        $arrCSV[$key-1][0] = strtotime($data[0])*1000; //Time
        $arrCSV[$key-1][1] = $data[1];            //Open
        $arrCSV[$key-1][2] = $data[2];            //High
        $arrCSV[$key-1][3] = $data[3];            //Low
        $arrCSV[$key-1][4] = $data[6];            //Adj Close
        $arrCSV[$key-1][5] = $data[5];            //Volume
    }

    $key++;
} // end while

$keymax = $key;

// Close the CSV file
fclose($handle);
} // end if

print "?(/* AAPL historical OHLC data from the Google Finance API */<BR>";
echo json_encode($arrCSV,JSON_NUMERIC_CHECK);
print ");";

?>

Code to import and create the graph:

<!DOCTYPE HTML>
<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <title>Highstock Example</title>

          <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
      <script type="text/javascript">
$(function() {
   $.getJSON('http://localhost/teste03.php', function(data) {
      console.log("1");
      // create the chart
      chart = new Highcharts.StockChart({
         chart : {
            renderTo : 'container'
         },

         rangeSelector : {
            selected : 2
         },

         title : {
            text : 'AAPL Stock Price'
         },

         series : [{
            type : 'ohlc',
            name : 'AAPL Stock Price',
            data : data,
            dataGrouping : {
               units : [[
                  'week', // unit name
                  [1] // allowed multiples
               ], [
                  'month', 
                  [1, 2, 3, 4, 6]
               ]]
            }
         }]
      });
   });
});

      </script>
   </head>
   <body>
<script src="js/highstock.js"></script>
<script src="js/modules/exporting.js"></script>

<div id="container" style="height: 500px; min-width: 500px"></div>
   </body>
</html>

In the end it just get me a blank page…
On the chrome console I’m not able to get the console log that is inside the getjson and it reports as if everything is ok:

[23:39:29.980] GET http://localhost/TraderMananger/Highstock/ohlc4.htm [HTTP/1.1 304 Not Modified 1ms]
[23:39:30.036] GET http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js [HTTP/1.1 304 Not Modified 87ms]
[23:39:30.055] GET http://localhost/TraderMananger/Highstock/js/highstock.js [HTTP/1.1 304 Not Modified 1ms]
[23:39:30.073] GET http://localhost/TraderMananger/Highstock/js/modules/exporting.js [HTTP/1.1 304 Not Modified 1ms]
[23:39:30.219] GET http://localhost/TraderMananger/Highstock/teste04.php [HTTP/1.1 200 OK 2056ms]

Help?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T00:49:57+00:00Added an answer on June 10, 2026 at 12:49 am

    It is solved now, the issue was in the chos added before and after the json_encode, there is no need to add them

    print "?(/* AAPL historical OHLC data from the Google Finance API */<BR>";
    echo json_encode($arrCSV,JSON_NUMERIC_CHECK);
    print ");";
    

    So, removing them it solved the issue.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
We're building an app, our first using Rails 3, and we're having to build
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.