Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP/SWF Charts 1

Status
Not open for further replies.

BiJae

Programmer
Oct 1, 2002
154
US
I am developing a program that incorporates a graph into the application. I have been reading several threads on this and used this thread to choose PHP/SWF charts. I really like the flexibility of the application. I can change the chart types and add special effects. I think this gives the application the flare I'm looking for.

So I read the tutorial and the rest of the documentation. I built a test application using their sample code. Everything worked perfectly. Then it was time to apply the code to my application. I already have a working application that I am adding this to. I took the data that I was getting and compiled it into the format and array that the PHP/SWF application uses. When I did this I got the default graph.

I turned to the application developer for assistance and got this message”

www.maani.us/charts said:
For all inquiries, please e-mail us at info@maani.us.
Technical support is available for registered users only. To receive a reply, please e-mail us from an address with the same domain name the tool was registered for, and include your registration code in the e-mail.

I'm definitely interested in registering this application and buying a license for it. However, I want to make sure it's going to work first. They are not offering any initial support. So I'm turning to you all to see if you've seen something similar. I am not going to be paying just to get an e-mail answered.

To trouble shoot it further I took the dataset that my database was returning and manually put it in the chart application:

Code:
$chart ['chart_data'][0]= array("", "12-08","12-09", "12-10", "12-11", "12-12");

$chart ['chart_data'][1] = array("Events",18,9,19,24,26);

$chart ['chart_data'][2] = array("Dispatches",3,0,3,3,7);

This worked. I got my graph and was able to change the format to the various options available. I then tried to dynamically load the data from the database:
Code:
$Date = array();

$Event = array();

$Disp = array();



$Date[0] = "";

$Event[0] = "Events";

$Disp[0] = "Dispatched";

$x=0;

foreach($graphdata as $k=>$v) {

	$x++;

	$Date[$x] = substr($v[0],5);

	$Event[$x] = $v[1];

	$Disp[$x] = $v[2];

	}

	

$chart['chart_data'][0] = $Date;

$chart['chart_data'][1] = $Event;

$chart['chart_data'][2] = $Disp;

This code gives me the default chart, which according to means that the application does not recognize the array that is being passed. Then I followed their advice and passed the page to the browser to make sure that it did not generate any errors. Sure enough, no errors.

I removed the generate chart code and bounced out the information to the browser. Both the static and dynamically generated array's returned these values:
output said:
stacked column 12-08 12-09 12-10 12-11 12-12 Events 18 9 19 24 26 Dispatched 3 0 3 3 7

Stumped I again generated the report. I looked at the output and received the same HTML source for the manually compiled array and the dynamically compiled array:

html-manual said:
<chart>
<chart_type>stacked column</chart_type>
<axis_category orientation="diagonal_up" />
<chart_transition type="slide_up" delay="1" duration="2" order="series" />
<chart_data>
<row>
<string></string>
<string>12-08</string>
<string>12-09</string>
<string>12-10</string>
<string>12-11</string>
<string>12-12</string>
</row>
<row>
<string>Events</string>
<number>18</number>
<number>9</number>
<number>19</number>
<number>24</number>
<number>26</number>
</row>
<row>
<string>Dispatched</string>
<number>3</number>
<number>0</number>
<number>3</number>
<number>3</number>
<number>7</number>
</row>
</chart_data>
</chart>

html-dynamic said:
<chart>
<chart_type>stacked column</chart_type>
<axis_category orientation="diagonal_up" />
<chart_transition type="slide_up" delay="1" duration="2" order="series" />
<chart_data>
<row>
<string></string>
<string>12-08</string>
<string>12-09</string>
<string>12-10</string>
<string>12-11</string>
<string>12-12</string>
</row>
<row>
<string>Events</string>
<number>18</number>
<number>9</number>
<number>19</number>
<number>24</number>
<number>26</number>
</row>
<row>
<string>Dispatches</string>
<number>3</number>
<number>0</number>
<number>3</number>
<number>3</number>
<number>7</number>
</row>
</chart_data>
</chart>

I'm really stumped by this application. I believe I'm loading the array correctly. From what I'm seeing the array is being loaded and parsed properly. I would love to get this application working in a test environment so I can buy this application, however I'm just about to give up on this application and find another solution, free or not.

Any assistance is greatly appreciated.

Thank you


"If the only prayer you said in
your whole life was, 'thank you,'
that would suffice."
-- Meister Eckhart
 
My bad, I had inadvertently deleted the date line from the copy paste. Not sure how.. I replaced it and yes, it works.


"If the only prayer you said in
your whole life was, 'thank you,'
that would suffice."
-- Meister Eckhart
 
jpadie... you're gonna shoot me..

I think I was following your lead, so I added this code to my script:

Code:
$graphdata = serialize($graphdata);
//echo "graphdata = $graphdata";
$graphdata = unserialize($graphdata);
My thinking was if I can reproduce bit for bit what you gave me in your serialized string, then I should be able to hand that off to the program. I uncommented out the echo line and compared with your string.

a:5:{i:0;a:3:{i:0;s:10:"2007-12-08";i:1;i:18;i:2;i:3;}i:1;a:3:{i:0;s:10:"2007-12-09";i:1;i:9;i:2;i:0;}i:2;a:3:{i:0;s:10:"2007-12-10";i:1;i:19;i:2;i:3;}i:3;a:3:{i:0;s:10:"2007-12-11";i:1;i:24;i:2;i:3;}i:4;a:3:{i:0;s:10:"2007-12-12";i:1;i:26;i:2;i:7;}}
a:5:{i:0;a:3:{i:0;s:10:"2007-12-08";i:1;i:18;i:2;i:3;}i:1;a:3:{i:0;s:10:"2007-12-09";i:1;i:9;i:2;i:0;}i:2;a:3:{i:0;s:10:"2007-12-10";i:1;i:19;i:2;i:3;}i:3;a:3:{i:0;s:10:"2007-12-11";i:1;i:24;i:2;i:3;}i:4;a:3:{i:0;s:10:"2007-12-12";i:1;i:26;i:2;i:7;}}

Identical right? Except one produces a chart with my data and one produces the default chart.

? ? ? ?


"If the only prayer you said in
your whole life was, 'thank you,'
that would suffice."
-- Meister Eckhart
 
Bijae

the serialising piece was just so that i did not have to hard code the array and yet guarantee that i was dealing with the same array shape that you were.

you can safely ignore it and process your $graphdata array from the foreach loop.
 
10-4...

I've been playing with the location of the ob_end_clean() and getting different results. If I put it on the last line of the file I get the load failed message as previously stated. However, if I put it directly in front of:

Code:
SendChartData ( $chartB);
I get a different result. I get both the data labels showing, and a value of 0 - 12 on the Y axis. Then I get a single date of 2005-07-21.

This is a little odd because this is not a date in my returned values, however, it is the MinDate value returned from the MinMax query.


"If the only prayer you said in
your whole life was, 'thank you,'
that would suffice."
-- Meister Eckhart
 
the ob_end_clean() should go just before the sendchartdata().

i can't help you with the faulty values other than to say that you should look at the contents of the $graphdata variable as the first stage of the debug process.
 
jpadie, thank you for all your help! I really do appreciate it! After fighting this for a few days I finally broke down and decided I'm going to rebuild the program. In one hour I've been able to rewrite the code and succesfully build the array from the database. In half the time I've already spent I can rebuild the previous persons whole application.

I'm not sure exactly what the problem was, but I found an effective solution... build it yourself. ;-)

Thank you again for helping me with this problem. I appreciate it!



"If the only prayer you said in
your whole life was, 'thank you,'
that would suffice."
-- Meister Eckhart
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top