FusionCharts Forum: Multi-Series with MySQL Database :: URGENT! - FusionCharts Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Multi-Series with MySQL Database :: URGENT!

#1 User is offline   karenn1 

  • Forum Newbie
  • Group: Members
  • Posts: 3
  • Joined: 04-April 08

Posted 04 April 2008 - 05:28 AM

Can anyone urgently help me please? I want to use the multi-series option of FusionCharts and connect it to my database. This is what my table looks like:

months		    units   stationName

January14,629 Station 1
February19,161 Station 1
March13,388 Station 1
April10,522 Station 1
May15,941  Station 1
June10,650 Station 1
July11,005 Station 1
August19,141 Station 1
September13,228 Station 1
October22,452 Station 1
November15,757 Station 1
December20,464 Station 1
January   15,654  Station 2
February16,718 Station 2
March14,839 Station 2
April12,791 Station 2
May12,838 Station 2
June14,229 Station 2
July15,616 Station 2
August14,633 Station 2
September19,544 Station 2
October16,592 Station 2
November14,746 Station 2
December15,425 Station 2
January233,796 Station 3
February82,309 Station 3
March198,876 Station 3
April34,959 Station 3
May367,101 Station 3
June430,691 Station 3
July220,664 Station 3
August318,963 Station 3
September106,403 Station 3
October248,531 Station 3
November339,486 Station 3
December174,552 Station 3
January190,048 Station 4
February38,460 Station 4
March178,998 Station 4
April49,516 Station 4
May256,988 Station 4
June307,099 Station 4
July201,678 Station 4
August215,608 Station 4
September108,847 Station 4
October222,191 Station 4
November235,785 Station 4
December103,880 Station 4

I'm struggling to get the info from the table. Here's PHP the code I used:

# Months     $strQuery = "SELECT distinct months FROM stations_new";   $result = mysql_query($strQuery);     # Add category names   $FC->addCategoryFromDatabase($result, "months");

    # Stations     # Create a new dataset

  $strQuery = "select units, months, stationName from stations_new GROUP BY stationName";   $result = mysql_query($strQuery);   $FC->addDatasetsFromDatabase($result, "stationName", "units");

    # Add chart values for the above dataset       $strQuery = "select months, units, stationName from stations_new";   $result = mysql_query($strQuery);   $FC->addDataFromDatabase($result, "units");

This code is not working at all. What am I doing wrong? Is there anyway to simplify the table structure? The table above is very cumbersome. Eventually I would need it to be by week and days of the year. To do that the table would be 365 x 4 rows long. Is there a better way to do this?

Thanks!

Karen

0

Other Replies To This Topic

#2 User is offline   Sudipto Choudhury 

  • Supreme Being
  • Group: Administrators
  • Posts: 1886
  • Joined: 19-March 07

Posted 07 April 2008 - 12:15 AM

Hi,

Could you please try changin the SQL :

$strQuery = "select units, months, stationName from stations_new ORDER BY stationName";

Regards,

Sudipto Choudhury
FusionCharts Team

Follow us on Twitter

I code, therefore I am.

0

Other Replies To This Topic

#3 User is offline   karenn1 

  • Forum Newbie
  • Group: Members
  • Posts: 3
  • Joined: 04-April 08

Posted 07 April 2008 - 12:48 AM

Hi,

Thanks for your reply. I've changed the code as you requested and this is what I get:

At least it's picking up on all four stations per month but it's not recognizing the units. Any insight why this could be?

Thanks!
Karen

0

Other Replies To This Topic

#4 User is offline   Pallav 

  • FusionCharts Team
  • Group: Administrators
  • Posts: 2386
  • Joined: 08-December 06

Posted 08 April 2008 - 10:26 PM

Is your data in XML purely numeric - without any currency or comma signs?
Thanks,
Pallav Nadhani
Co-founder & CEO, FusionCharts Team
0

Other Replies To This Topic

#5 User is offline   karenn1 

  • Forum Newbie
  • Group: Members
  • Posts: 3
  • Joined: 04-April 08

Posted 09 April 2008 - 02:26 AM

Hi Pallav,

I had look at my data and there were commas in it. I've taken it out and now it works fine. Thank you for that insight! My other question though, my table of data (as I posted in my first post above) is very lob-sided. Is there an easier way to structure my table?

Thanks!
Karen

0

Other Replies To This Topic

#6 User is offline   Pzr 

  • Junior Member
  • PipPip
  • Group: Members
  • Posts: 23
  • Joined: 29-June 09

Posted 30 June 2009 - 06:56 AM

I'm hijacking this.

New to fusioncharts and in big trouble making something out of it. in the demo I can surely see the potential. :-) In an effort to make something out of this I'm trying here for some hints and help. I have a mySQL database with a db table called: material

Table: MATERIAL

S_1  , S_2  , S_3   (columns)

20090626 fot    SUASRTGL22  

20090626 hand SUASRTGL22

20090626 fot   SUASRTGL22

20090627 fot   SUASRTGL22

20090628 hand SUASRTGL22

20090628 hand SUASRTGL22

How should I do to show this in fusioncharts? I would like the lying bar to show the dates ((S_1) 26, 27, 28 etc...), and the the other bar the count of similar S_2 for that date. (Eg. S_2 is for the 20090626 2*fot and 1*hand, that is two bars in different colours.)

Just need a hint or point in the right direction. :-)

/P

 

0

Other Replies To This Topic

#7 User is offline   Rajroop 

  • FusionCharts Team
  • PipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1803
  • Joined: 19-May 09

Posted 02 July 2009 - 07:02 AM

Hello,



Could you please conjure a SQL query and send it over to us for only then can we implement it into our FusionCharts?



Also, please include your results.



We will more than happy to be of help. :)
Regards,

Rajroop Bhaduri

FusionCharts Team

Help us improve our documentation with your precious feedback at:
http://documentation...sioncharts.com/

Follow us @Twitter
0

Other Replies To This Topic

#8 User is offline   Pzr 

  • Junior Member
  • PipPip
  • Group: Members
  • Posts: 23
  • Joined: 29-June 09

Posted 08 July 2009 - 05:34 AM

I have tried to give this a shot, but i'm not capable of gettig it to work...



Please advice what i'm doing wrong:



<?php



include('Includes/FusionCharts.php');

include('Includes/Connection_inc.php');



?>



<HTML>

<HEAD>

<TITLE>FusionCharts - Database Example</TITLE>

<SCRIPT LANGUAGE="Javascript" SRC="FusionCharts/FusionCharts.js"></SCRIPT>

</HEAD>

<BODY>

<CENTER>





<?php



$link = connectToDB();



$strXML = "<chart caption='DATUM' subCaption='ANTAL' pieSliceDepth='30' showBorder='1' formatNumberScale='0' numberSuffix=' Units'>";



$strQuery="SELECT s_00100010, s_00400254, s_00400244 from study ORDER BY s_00400244";

$result=mysql_query($strQuery) or die(mysql_error());



if ($result) {

while($ors = mysql_fetch_array($result)) {



$strQuery = "select sum(ANTAL) as TotOutput from study where s_000040254=" . $ors['s_00400254'];

$result2 = mysql_query($strQuery) or die(mysql_error());

$ors2 = mysql_fetch_array($result2);



$strXML .= "set label='" . $ors['s_00100010'] . "' value='" . $ors2['s_0040244'] . "' />;



mysql_free_results($result2);

}

}

mysql_close($link);



$strXML .= "</chart>";



echo renderChart("FusionsCharts/Pie.swf", "", $strXML, "Antal us" 600, 300, false, false);



?>





</BODY>

</HTML>



I get error: Parse error: syntax error, unexpected '/' in C:xampplitehtdocsindex3.php on line 40



(I dont want to use a piechart, but just wanted to see if I could get some result and then go from there..)



:-( /Regards



*edit*

Got it working now and I am really happy! :-)

My new challenge is to create a "nested chart", move some variables with the user as he press on a bar and get more in detail information about that one.



But that's for tomorrow! Thank you for a GREAT product!!! :)
0

Other Replies To This Topic

#9 User is offline   Rajroop 

  • FusionCharts Team
  • PipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1803
  • Joined: 19-May 09

Posted 11 July 2009 - 02:30 AM

Hello,



Firstly, please accept our apologies for the delay in the reply.



In response to your second query: "My new challenge is to create a "nested chart", move some variables with the user as he press on a bar and get more in detail information about that one.", you can use the Drill down attribute of FusionCharts which uses a Javascript function to pass custom set additional information of the data item.



Please note the following link which gives a simple example of Drill down charts and its functionalities: http://www.fusioncha...own/Simple.html



Hope this helps. :P



Please accept our gratitude for your kind words. :)
Regards,

Rajroop Bhaduri

FusionCharts Team

Help us improve our documentation with your precious feedback at:
http://documentation...sioncharts.com/

Follow us @Twitter
0

Other Replies To This Topic

#10 User is offline   Pzr 

  • Junior Member
  • PipPip
  • Group: Members
  • Posts: 23
  • Joined: 29-June 09

Posted 14 July 2009 - 06:10 AM

I'm set! :-) And stunned over the possibilites.

Have a wierd problem I think comes from importing *.xml fi´les in UTF-8 into the dabatase.

When I get the values from within fusioncharts I't doesent show Å, Ä, Ö (and some other characters...) Instead I have some jobberish. I'm currently searching for a solution for this on the web.

If you have som helpful hints they would be much appreciated!

As for now, I have a chart showing med a column with the name BCKEN, but when hovering the column it say's : BÄCKEN (witch is the right thing to show.)

/Emanuel

0

Other Replies To This Topic

#11 User is offline   Rajroop 

  • FusionCharts Team
  • PipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1803
  • Joined: 19-May 09

Posted 14 July 2009 - 09:19 AM

Hello Emanuel,



To insert the accent characters you would need to first add BOM characters to the file after that need to encode your string with utf8_encode() function.



Please see the following code for an example:

$fp = fopen("relatorios/DataXMLFusion.xml" , "w");

$fw = fwrite($fp, "xEFxBBxBF");

$fw = fwrite($fp,utf8_encode($xml));



Hope this helps.
Regards,

Rajroop Bhaduri

FusionCharts Team

Help us improve our documentation with your precious feedback at:
http://documentation...sioncharts.com/

Follow us @Twitter
0

Other Replies To This Topic

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic