|
User Details |
message
|
|
David Stoltz
post date:
2011-01-31 20:26:54
|
Trying to make a simple chart that compares the male population to female population within a zipcode.
Here are the following fields as defined in the database:
population = 11488
malepopulation = 5700
female population = 5788
Here is the chart:
http://www.stoltz.us/random.asp
And here is the code - not sure what I'm doing wrong:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="allconnections/db.asp" -->
<!--#include file="includes/FusionCharts/dynamic/DWFChart.inc.asp" 'fusion charts include -->
<%
Dim RS
Dim RS_cmd
Dim RS_numRows
Set RS_cmd = Server.CreateObject ("ADODB.Command")
RS_cmd.ActiveConnection = MM_cnx_STRING
RS_cmd.CommandText = "SELECT population, malepopulation, femalepopulation FROM a_zipinfo WHERE zipcode = '18014'"
RS_cmd.Prepared = true
Set RS = RS_cmd.Execute
RS_numRows = 0
%>
<%
Dim dFCFusionChart4: Set dFCFusionChart4 = new DWFChart
FusionChart4_dataXML = ReadDisplayFile("includes/FusionCharts/dynamic/data/fc_FusionChart4_data.asp")
dFCFusionChart4.Init "FusionChart4", "Column2D", "includes/FusionCharts/charts/", 400, 400, "", "", "", "", "", ""
dFCFusionChart4.setVersion "1.1.1"
dFCFusionChart4.setConfigXML FusionChart4_dataXML
dFCFusionChart4.setCategory RS, "population", "", "", RS_cmd
dFCFusionChart4.addSeries RS, "malepopulation", "", "color='11f82f' seriesName='malepopulation' renderAs='Column' parentYAxis='P'", "default", "", RS_cmd
dFCFusionChart4.addSeries RS, "femalepopulation", "", "color='d99fbd' seriesName='femalepopulation' renderAs='Column' parentYAxis='P'", "default", "", RS_cmd
dFCFusionChart4.setOrdering "None", "asc"
dFCFusionChart4.prepareData
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" src="includes/FusionCharts/dynamic/js/FusionCharts.js"></script>
</head>
<body>
<%
' (FCChart Begin) #FusionChart4
renderFusionChart dFCFusionChart4, 400, 400
' #FusionChart4 (FCChart End)
%>
</body>
</html>
<%
RS.Close()
Set RS = Nothing
%>
|
|
|
Andrei Rinciog [Extend Studio]
post date:
2011-02-01 05:11:21
|
Hello again David,
The chart is displayed correctly based on its settings.
You selected the male population, the female population and placed them as series and then the total population as category.
There are some structural problems with your database.
First of all, you don't need the total population column at all, as it can be calculated using the other two columns.
The category column of a chart defines the labels of the columns and what columns should be used. So you should define as category for the chart the column that defines what a column is for, female count or male count.
This way we get to another problem with your table. The values from the male and female columns are combined in a single record. So, if you want to change one, you have to change the second as well. That is not a good thing. Instead of having one recordset with two values, you should have two recordset with one value each and type.
This is how your table should look:
zipcode (index)
population
gender
Now the recordset for the data:
SELECT gender,population FROM a_zipinfo WHERE zipcode = '18014'
The chart will be defined with:
Category - gender
Series - population
And that's about all.
Hope I was able to explain decently. Tell me if you have any more questions.
Regards,
Andrei Rinciog
|
|
|
David Stoltz
post date:
2011-02-01 05:40:30
|
Ok - I think I get it - thanks...
The database was purchased from a zipcode company. All the data related to a single zip code is combined into a single row.
It would also be cool if your component would allow me to type in the dynamic values, instead of selecting a column.
For instance, for population, I could enter:
<%=RS("population")%>
or
<%=request("population")%>
stuff like that....then it wouldn't matter if all the data was in the same row, or different recordsets...
Perhaps you can do this, I'm still just learning....thanks
|
|
|
David Stoltz
post date:
2011-02-02 12:39:06
|
Is there any way of using the simple (non-dynamic) chart and inserting dynamic values into the generated code?
I work with a lot of calculated variables in code, and would like to know if I can use ASP to "insert" a value like:
<%=myvalue%>
I realize this would probably break the editing chart, but is it possible?
thanks
|
|
|
Andrei Rinciog [Extend Studio]
post date:
2011-02-07 08:57:23
|
Hello David,
I've answered this here: http://www.extendstudio.com/forum/24/1869/simple-charts-can-be-dynamic.html
|
|