Halloween Offers

FusionCharts for Dreamweaver - Developer Edition Forum


box FusionCharts for Dreamweaver - Developer Edition
FusionCharts is a Dreamweaver Charting Extension that can be used to render data-driven & animated charts for web applications and presentations. FusionChartsDW is a cross-browser and cross-platform solution that can be used with ASP.VB, PHP, and ColdFusion to deliver interactive and powerful flash charts.

Find out more about FusionCharts for Dreamweaver - Developer Edition

Thread: Adding data series automatically?

title left
User Details
message
title right
Daniel Guldfors

post date:
2010-01-11 12:10:47
I am trying to create a page that will show weight progression of the users, over time.rnrnIn my MySQL I have a column for week#, userid, and weight.rnrnThe chart I would like to create, is one with multiple lines (one for each user/userid) which shows their weight over the weeks.rnrnI can make this work for a individual user, by creating a data series for that userid, with the week# as categories. The weight show great over the weeks with a nice graph.rnrnBut what if I have 300 users? I don't want to add a data series (line on the chart) everytime someone new enters the game, as well as I don't want to go thru several hundred userid's and add a data serie for each one by hand.rnrnIs there anyway to do this so that fusioncharts just creates a new series (line) for each userid?rnrnThank you very much for any assistance, love the plugin!
Andrei Rinciog [Extend Studio]

post date:
2010-01-12 06:04:31
Hello Daniel,From what I understand you want to create a chart that shows "weight" over weeks for each user. To do that, you can use a single recordset that has a parameter "userId". That parameter it's used to filter the data so it only shows the results for that user. Check out this tutorial that shows how you can filter a recordset data:http://www.extendstudio.com/dynamic-web-charts-dreamweaver-fusioncharts-developer/Tutorial_Filtering_Charts_data_FusionCharts_Dreamweaver_PHP_%20vars.htmlNow all you have to do is to connect that recordset to the chart and the same chart will display different results depending on the user.Regards,Andrei Rinciog
Daniel Guldfors

post date:
2010-01-12 07:24:26
Thank you for your reply Andrei!That is what I've done, and it works great. However, what I want to do is display a chart with for example 50 users, each one with their own line.The thing I am searching for, is how to tell fusioncharts to "add a new series (line) for each userid".Thank you once again!
Andrei Rinciog [Extend Studio]

post date:
2010-01-12 07:41:55
Hello again Daniel,I don't really understand how you want the chart to look like. You use weeks as categories and weight as data for one user. If you want you can change the category from weeks to users and it will take the users automatically from the database. You want to insert the users column as a second category (third dimension) for the chart? The only way you could create a chart with three dimensions is by using the Bubble charts. And add the users and weeks as x an y coordinates and then weight as the z coordinate. The z coordinate controls the diameter of the bubble. But I don't know how correct it will be and how much you can understand from that chart.You can do the same thing that you did for the users and filter the data for each week. This way you would have a different chart with all the user for every week from your database.Regards,Andrei Rinciog
Daniel Guldfors

post date:
2010-01-12 09:00:59
I will try and explain what I am looking to do.The chart should have week# along the x axis (columns).Each user should be represented by a line, that displays the users weight input for each week. (The chart should have all users on one chart with multiple lines)I could do this simply by having week numbers as columns, and adding a series for each user with the weight-data. The problem with that is that if another user joins, I need to manually enter a new data-series each time (in order to add another line to the chart.What I want to achieve is that the chart automatically adds one line for each unique userid.So it really is a simple 2D chart with multiple lines, but I don't wan't to add the lines for each user manually. I just want a timeline for all users weight over time.I hope this makes any sense to you, and once again, a huge thank you for your assistance!
Andrei Rinciog [Extend Studio]

post date:
2010-01-12 11:55:41
Hello,Well, when a new user joins isn't he included automatically in the database? Cause if he is, then it should be included in the chart automatically because the chart gets all the data from the database.Regards,Andrei
Daniel Guldfors

post date:
2010-01-12 12:16:02
Yes that is correct, but since all users require their own data-series to draw their line, that doesn't happen automatically.Each line requires their own data-series, as far as I understand it.If I only create one data-series (line) then that's it. It gets the weight and week number automatically of course, but not the users.I hope I'm making sense.
Andrei Rinciog [Extend Studio]

post date:
2010-01-13 05:23:10
Hello Daniel,Yes, I understand now what you need and you are correct, the new user line is not inserted when a new user connects. This needs to be done dynamically for each user from the recordset. I will try to make a script today that does this and will post it when it's ready.Regards,Andrei Rinciog
Andrei Rinciog [Extend Studio]

post date:
2010-01-13 06:06:22
Hello again,Could you please tell me what structure do you have in your database? What tables do you use for the chart and what connections are between them?Regards,Andrei
Daniel Guldfors

post date:
2010-01-13 07:41:45
Certainly,The table that contains the data is kalled "vikt".The "vikt" table uses five columns:vikt_id = unique id for the rowvikt_anst = userid numbervikt_date = date of reported weightvikt_vikt = the weight reported as a FLOAT 5,2 value. (kilograms with two decimals)vikt_vecka = week number of reported weightThe only connection with other tables is with the userid "vikt_anst", to the tables that hold the users other information (name etc.). This chart however only uses the information from the table "vikt", since it only should display weight progress.Thanks a million!
Andrei Rinciog [Extend Studio]

post date:
2010-01-14 14:04:32
Hello Daniel, Here's what you need to do.First of all, create a three recordsets. First one will get id's and names for all the users from the users table. The second recordset will get all the distinct week numbers from the "vikt" table. The third recordset will be used to populate the chart.Ok, now that you have all the recordsets, create a new chart and select "Line Chart" from the multi series category. Change to "data" tab and select the week column from the first recordset as category. Then add the "weight" value from the third recordset. Press ok to insert the chart on the page.Now comes the tricky part. First of all, if you haven't already, change to code view cause we need to write a little php. I will assume that the name of your chart is 'FusionChart1'. So, when you see beneath that name, it must be the name of your chart. Oh, and i used "weight" as a table name instead of "vikt".Check this line on the page: " // fusion chart #FusionChart1 dynamic filter data". Under there are 7 lines of code that define a new chart and its data. Duplicate those lines and place the second copy right beneath. We will break that second block of 7 lines in order to insert more series. Between the lines: $dFCFusionChart1->setCategory( ... and $dFCFusionChart1->addSeries( ...insert this code: $records = array(); $colors = array('FFFFFF','FF00FF','33FF66','3333FF'); do { $i = $i + 1; $query_Record = your query + a where clause that filters the result based on user id that you get from the $getUsersId recordsets $records[$i] = mysql_query($query_Record, $weightDB) or die(mysql_error()); $dFCFusionChart1->addSeries($records[$i], "value", "", "color='".$colors[$i]."' seriesName='".$row_getUsersId['name']."' renderAs='Column' parentYAxis='P'", "default", ""); } while ($row_getUsersId = mysql_fetch_assoc($getUsersId));Then delete the add series code below and that should be all. The resulting code should be : $dFCFusionChart1 = new DWFChart("FusionChart1", "MSLine", "includes/FusionCharts/charts/", 400, 400, "", "", "", "", "", ""); $dFCFusionChart1->setVersion("1.1.1"); $dFCFusionChart1->setConfigXML($FusionChart1_dataXML); $dFCFusionChart1->setCategory($rsWeeks, "week", "", ""); ... code above .. $dFCFusionChart1->setOrdering('None', 'asc'); $dFCFusionChart1->prepareData();Don't forget. This is the copy of the code. You should leave the original code inserted by the chart as it is. Well, I hope that I was able to explain the process. If you want I can send you a copy of the website and the database by email. I have your email, so you don't have to post it here. Just tell me if it would help you.Regards,Andrei
Daniel Guldfors

post date:
2010-01-18 11:19:34
Hey Andrei,I'm not getting anywhere with the code, I'm sure it's due to inexperience on my part. Maybe if you send me the copy I will be able to make some sense of it!Thanks!
Andrei Rinciog [Extend Studio]

post date:
2010-01-18 11:33:28
Hi again Daniel,I will send you an archive by email. Regards,Andrei Rinciog