Jump to content

Open Flash charts 4 on same page


budimir

Recommended Posts

Guys,

 

I'm trying to display 4 chart of same type on same page. Chart I'm using is from Open Flash charts (http://teethgrinder.co.uk/open-flash-chart-2/). I have managed to get 2 working but of different type. If I try to use 2 of the same type it's not working. I tried to follow the instructions from the webpage above, but with no success. Can you tell me what I'm doing wrong. My code is bellow:

 

Javascript part

<script type="text/javascript" src="../js/json/json2.js"></script>
<script type="text/javascript" src="js/swfobject.js"></script>
<script type="text/javascript">
swfobject.embedSWF("open-flash-chart.swf", "my_chart", "1200", "400", "9.0.0", "expressInstall.swf", {"data-file":"gallery/cijena_eur.php"} );


swfobject.embedSWF("open-flash-chart.swf", "my_chart1", "1200", "400", "9.0.0", "expressInstall.swf", {"data-file":"gallery/cijena_nc.php", "id":"data_1"} );


swfobject.embedSWF("open-flash-chart.swf", "my_chart2", "1200", "400", "9.0.0", "expressInstall.swf", {"data-file":"gallery/cijena_vpc.php", "id":"data_2"} );
</script>

 

Php part

<?php
include ("../../admin/servis/include/session.php");


//Dohvačanje ID-eva
$id_redka = $_SESSION['id_redka'];
$id_kalkulacije = $_SESSION['id_kalkulacije'];
$kataloski_broj = $_SESSION['kataloski_broj'];
$id_cjenika = $_SESSION['id_cjenika'];
$godina_danas = date("Y");


$upit4 = "SELECT vpc, kataloski_broj, godina_pov FROM kalkulacija_import_povijest_stavke WHERE kataloski_broj = '$kataloski_broj' ORDER BY godina_pov ASC";
$rezultat4 = mysql_query($upit4) or die(mysql_error());
$godina = array();
$data = array();
while($row = mysql_fetch_array($rezultat4)){
  $kataloski_vpc = $row["kataloski_broj"];
  $vpc = round(($row["vpc"]),2);
  $godina_vpc = $row["godina_pov"];

  $data[] = $vpc;
  $godina[] = $godina_vpc;
}


if ($godina_danas < $godina_pov){
  $upit2 = "SELECT neto_VPC,kataloski_broj,datum FROM kalkulacija_stavke WHERE kataloski_broj = '$kataloski_broj' ORDER BY vrijeme ASC";
  $rezultat2 = mysql_query($upit2) or die (mysql_error());
  $row = mysql_fetch_array($rezultat2);
   $kataloski_vpc = $row["kataloski_broj"];
   $vpc = round(($row["neto_VPC"]),2);
   $godina_vpc = date('Y', strtotime($row["datum"])); 
 }


   $data[] = $vpc;
   $godina[] = $godina_vpc;

$maks = max($data) + 100;
$min = min($data);
$korak = round($maks / 5);



include '../open-flash/php-ofc-library/open-flash-chart.php';


$chart2 = new open_flash_chart();
$chart2->set_title( new title( 'VPC za artikal '.$kataloski_vpc.'' ) );


//
// Make our area chart:
//
$area2 = new area();
// set the circle line width:
$area2->set_width( 2 );
$area2->set_default_dot_style( new hollow_dot() );
$area2->set_colour( '#838A96' );
$area2->set_fill_colour( '#E01B49' );
$area2->set_fill_alpha( 0.4 );
$area2->set_values( $data );


// add the area object to the chart:
$chart2->add_element( $area2 );


$y_axis2 = new y_axis();
$y_axis2->set_range( $min, $maks, $korak );
$y_axis2->labels = null;
$y_axis2->set_offset( false );



$x_axis2 = new x_axis();
$x_axis2->labels = $godina;
$x_axis2->set_steps( 2 );


$x_labels2 = new x_axis_labels();
$x_labels2->set_steps( 1 );
$x_labels2->set_vertical();
$x_labels2->labels = $godina;
// Add the X Axis Labels to the X Axis
$x_axis2->set_labels( $x_labels2 );




$chart2->add_y_axis( $y_axis2 );
$chart2->x_axis = $x_axis2;


echo $chart2->toPrettyString();
?>

 

HTML part

<div id="my_chart"></div>
<div id="my_chart1"></div>
<div id="my_chart2"></div>

 

Error message I'm getting is:

"Open Flash Chart

 

JSON Parse Error [syntax Error]

Error at character 0, line 1:

 

0: <br />"

 

What am I doing wrong?

 

Thanks in advance!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.