Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP open flash chart 2 error(get rid of it)
    primarykey
    data
    text
    <p>I am new to this forum and to Open Flash Chart 2. I just installed a chart in one of my website, which works fine. I am getting the chart points dynamically through a URL using file_get_contents in PHP. Everything works fine, but some URLs doesn't has points data so the chart is returning me the JSON error</p> <pre><code>Open Flash Chart JSON Parse Error [Syntax Error] Error at character 0, line 1: 0: &lt;br /&gt; </code></pre> <p>I know why the error is punched, but I want to get rid of this, instead it should show "Not enough data to map the chart".</p> <p>Is there any solution for this?</p> <p>Thank you in advance :D</p> <p>EDIT: MY CODE:</p> <pre><code>&lt;?php include 'oc/php-ofc-library/open-flash-chart.php'; $url = 'http://*****.api3.nextbigsound.com/metrics/artist/'.$_REQUEST['artistId'].'.json'; $file = file_get_contents($url); $data = json_decode($file); foreach($data as $Idx =&gt; $key){ if($key-&gt;Service-&gt;name === 'MySpace'){ foreach($key-&gt;Metric as $Index =&gt; $Item){ $ctr = 1; if($Index == "views"){ foreach($Item as $a =&gt; $b){ $record[] = $b; } } } } } $year = array(); $price = array(); $year[] = 'Sun, 12 Feb 2012'; $price[] = 36.7; $year[] = 'Sun, 13 Feb 2012'; $price[] = 38.7; $year[] = 'Sun, 14 Feb 2012'; $price[] = 42.8; $year[] = 'Sun, 15 Feb 2012'; $price[] = 38.2; $year[] = 'Sun, 16 Feb 2012'; $price[] = 37.8; $year[] = 'Sun, 17 Feb 2012'; $price[] = 34.7; $year[] = 'Sun, 18 Feb 2012'; $price[] = 38.4; $chart = new open_flash_chart(); $chart-&gt;set_bg_colour( '#FFFFFF' ); $title = new title( 'MySpace Views' ); $title-&gt;set_style( "{font-size: 20px; background:#fff; color: #A2ACBA; text-align: center; width: 300px; border-radius:50px;}" ); $chart-&gt;set_title( $title ); $area = new area(); $area-&gt;set_colour( '#5B56B6' ); $area-&gt;set_values( $record ); $area-&gt;set_key( 'Views', 7 ); $chart-&gt;add_element( $area ); $x_labels = new x_axis_labels(); $x_labels-&gt;set_steps( 1 ); //$x_labels-&gt;set_vertical(); $x_labels-&gt;set_colour( '#A2ACBA' ); $x_labels-&gt;set_labels( $year ); $x = new x_axis(); $x-&gt;set_colour( '#A2ACBA' ); $x-&gt;set_grid_colour( '#D7E4A3' ); $x-&gt;set_offset( false ); $x-&gt;set_steps(1); $x-&gt;set_range('0','6'); // Add the X Axis Labels to the X Axis $x-&gt;set_labels( $x_labels ); $chart-&gt;set_x_axis( $x ); // // LOOK: // $x_legend = new x_legend( '2012' ); $x_legend-&gt;set_style( '{font-size: 20px; color: #778877}' ); $chart-&gt;set_x_legend( $x_legend ); // // remove this when the Y Axis is smarter // $y = new y_axis(); $min = min($record); $max = max($record); $len = strlen($max); if($len == '9'){ $diff = '10000'; }elseif($len == '8'){ $diff = '1000'; }elseif($len == '7'){ $diff = '1000'; }elseif($len == '6'){ $diff = '1000'; }elseif($len == '5'){ $diff = '1000'; } $y-&gt;set_range( $min, $max, $diff ); $chart-&gt;add_y_axis( $y ); echo $chart-&gt;toPrettyString(); </code></pre> <p>Here is the <code>print_r($data)</code></p> <pre><code>Array ( [0] =&gt; stdClass Object ( [Service] =&gt; stdClass Object ( [name] =&gt; MySpace [id] =&gt; 1 ) [Profile] =&gt; stdClass Object ( [url] =&gt; http://www.myspace.com/adamgreen1 [id] =&gt; 384 ) [Metric] =&gt; Array ( ) ) [1] =&gt; stdClass Object ( [Service] =&gt; stdClass Object ( [name] =&gt; Last.fm [id] =&gt; 2 ) [Profile] =&gt; stdClass Object ( [url] =&gt; http://www.last.fm/music/adam+green [id] =&gt; 174985 ) [Metric] =&gt; stdClass Object ( [plays] =&gt; stdClass Object ( [15383] =&gt; 10165386 [15384] =&gt; 10165386 [15385] =&gt; 10165375 [15386] =&gt; 10168408 [15387] =&gt; 10171611 [15388] =&gt; 10174725 [15389] =&gt; 10177797 ) [fans] =&gt; stdClass Object ( [15383] =&gt; 242392 [15384] =&gt; 242392 [15385] =&gt; 242535 [15386] =&gt; 242580 [15387] =&gt; 242641 [15388] =&gt; 242709 [15389] =&gt; 242775 ) [comments] =&gt; stdClass Object ( [15383] =&gt; 916 [15384] =&gt; 916 [15385] =&gt; 918 [15386] =&gt; 918 [15387] =&gt; 918 [15388] =&gt; 918 [15389] =&gt; 918 ) ) ) [2] =&gt; stdClass Object ( [Service] =&gt; stdClass Object ( [name] =&gt; Wikipedia [id] =&gt; 17 ) [Profile] =&gt; stdClass Object ( [url] =&gt; http://en.wikipedia.org/wiki/Adam_Green_(musician) [id] =&gt; 918802 ) [Metric] =&gt; Array ( ) ) ) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload