javascript - "Loading Data" Stuck on AMChart -


hello,

i using amcharts framework make charts data in mysql database. stuck "loading data" instead of actual chart. (http://gyazo.com/b72693484ab39e2635c0a0ab21c889a5)

and no, it's not loading data. went launch , came hour later , it's yet loaded. when used data amcharts website provided, worked fine, own data, no such luck.

also, have checked this link , isn't answering question. question shouldn't duplicate.

the data :

for data, using section of starbucks stock close prices 100 dates in 2007. it's test data before start real part of project. things rolling. started 2100 rows, when first got "loading data" message, cut down data simple 100 rows. still, no such luck.

if you'd data used, way got it, here r code used.

require('quantmod') getsymbols("sbux") starbucks <- data.frame(sbux) starbucks[,7] <- row.names(starbucks) starbucks <- data.frame(starbucks[,c(7,6)]) row.names(starbucks) <- null colnames(starbucks) <- c("dates","values") starbucks <- data.frame(starbucks[1:100,]) write.table(starbucks, file="path\\to\\file\\starbucks.csv", sep=",") 

upload:

i created new database called "charts" , under made table named "starbucks". there 2 columns under starbucks named "dates" (set date) , "values" (set float) each given length of 10.

i went import , uploaded csv table , imported well.

php

this code used php side of things.

<?php // connect mysql $link = mysql_connect( 'localhost', 'root', '' ); if ( !$link ) {   die( 'could not connect: ' . mysql_error() ); }  // select data base $db = mysql_select_db( 'charts', $link ); if ( !$db ) {   die ( 'error selecting database \'test\' : ' . mysql_error() ); }  // fetch data $query = "   select *   starbucks"; $result = mysql_query( $query );  // good? if ( !$result ) {   // nope   $message  = 'invalid query: ' . mysql_error() . "\n";   $message .= 'whole query: ' . $query;   die( $message ); }  // print out rows  $data = array(); while ( $row = mysql_fetch_assoc( $result ) ) {   $data[] = $row; } echo json_encode( $data ); // close connection mysql_close($link);  ?> 

javascript

then there javascript side of things.

var chart = amcharts.makechart( "chartdiv", { "type": "serial", "dataloader": { "url": "../scripts/data.php" }, "pathtoimages": "http://www.amcharts.com/lib/images/", "categoryfield": "category", "datadateformat": "yyyy-mm-dd", "startduration": 1, "rotate": false, "animationduration": 0, "minselectedtime": 100, "categoryaxis": { "parsedates": true }, "graphs": [ { "valuefield": "value1", "bullet": "square", "bulletbordercolor": "#ffffff", "bulletborderthickness": 2, "linethickness ": 2, "linealpha": 0.5 } ]  } ); 

html

theres of course, html.

<div id="chartdiv" style="width:100%; height:400px;"></div> 

so problem

after copy/pasting code, actual question of post. why getting "loading data" instead of actual chart?

if there else needed, let me know. i've done best not vague in question.

i'm having similar issue. if save json output, remove preceding square braces, , use input, works:

json doesn't work:

[     [],     {"key1":"val1","key2":"val1"},     {"key1":"val2","key2":"val2"},     ... ] 

json works:

[     {"key1":"val1","key2":"val1"},     {"key1":"val2","key2":"val2"},     ... ] 

modify amchart.makechart bit test json:

"dataloader": {       "url": "test.json",       "format": "json"     }, 

..but don't know how remove preceding braces in php code.. step closer resolution...


Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -