|
It isn't even an error..... |
Posted by Tim on Jul-26-2012 00:39 |
|
Hi I have written some code in asp classic and have debugged it to the best of my abilities and now that I don't get any more errors I get something even more confusing(so it isn't posting a picture but I saved it into a file and attached it)Mainly it is a bunch of boxes and random letters/symbols!!!! Any help or advice on what to do here would be great!!! Here is my code! Thanks in advance!
pointLine2.asp |
---|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Language=VBScript %>
<!-- #INCLUDE Virtual="ChartDirector/DBConn2.asp" -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link href="../assets/ui/css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="jquery.min.js"></script>
<style type="text/css">
body,html,head,div{height:100%; min-height:100%;width:100%; }
</style>
<SCRIPT LANGUAGE="Javascript" SRC="FusionCharts.js"></SCRIPT>
</head>
<body >
<div class="gen-chart-render" >
<%
Dim count, lc, hWeek,lWeek,month,year,cateCount,today, diffDate,sum,monthsA(6), monthsB(3),x, isInA,isInB
dim FC, monthNm,i
Dim labels(),data()
redim labels(100)
redim data(100)
Set cd = CreateObject ("ChartDirector.API")
set c = cd.XYChart(500,500)
call c.setPlotArea(30,20,500,500)
monthsA(0)=1
monthsA(1)=3
monthsA(2)=5
monthsA(3)=7
monthsA(4)=8
monthsA(5)=10
monthsA(6)=12
monthsB(0)=4
monthsB(1)=6
monthsB(2)=9
monthsB(3)=11
i=0
lc=0
Set oConn = Server.CreateObject("ADODB.Connection")
Set oRs = Server.CreateObject("ADODB.Recordset")
oConn.Open strConnQuery
today=Date()
year=2010
hWeek=31
lWeek=01
month=05
syear=2011
cateCount=0
count = 1
endDate=month&"/"&hWeek&"/"&year
do While DateDiff("d",CDate(endDate),today)>7
do While month<=12 And DateDiff("d",CDate(endDate),today)>40
diffDate = DateDiff("d",CDate(endDate),today)
x=0
isInA=false
isInB=false
do while x <= 6 and isInA = false
if monthsA(x) = month then
isInA = true
end if
x=x+1
loop
x=0
do while x <= 3 and isInB = false
if monthsB(x)=month then
isInB = true
end if
x=x+1
loop
sum = 0
if isInA then
hWeek=31
'response.Write("work")
strQuery = "select sum(zStratumID) as totOutput from zRandomizationCode where zRandomizedOn BETWEEN '"&year&"-"&month&"-"&lweek&"' AND '"&year&"-"&month&"-"&hweek&"' "
Set oRs = oConn.Execute(strQuery)
sum = oRs("TotOutput")
monthNm= MonthName(month)
If month =1 then
labels(i)="1st Quarter of "&year&""
data(i) = oRs("totOutput")
Elseif month =10 then
labels(i)="4th Quarter of "&year&""
data(i) = oRs("totOutput")
elseif month = 7 then
labels(i)="3rd Quarter of "&year&""
data(i) = oRs("totOutput")
Else
labels(i)=""
data(i) = oRs("totOutput")
End if
end if
If isInB then
hWeek=30
strQuery = "select sum(zStratumID) as TotOutput from zRandomizationCode where zRandomizedOn BETWEEN '"&year&"-"&month&"-"&lweek&"' AND '"&year&"-"&month&"-"&hweek&"' "
Set oRs = oConn.Execute(strQuery)
monthNm= MonthName(month)
sum = oRs("TotOutput")
if month = 4 then
labels(i)="2nd Quarter of "&year&""
data(i) = oRs("totOutput")
else
labels(i)=""
data(i) = oRs("totOutput")
end if
end if
if isInA = false and isInB=false then 'for leapyear can use % of year
hWeek=28
strQuery = "select sum(zStratumID) as TotOutput from zRandomizationCode where zRandomizedOn BETWEEN '"&year&"-"&month&"-"&lweek&"' AND '"&year&"-"&month&"-"&hweek&"' "
Set oRs = oConn.Execute(strQuery)
monthNm= MonthName(month)
sum = oRs("TotOutput")
labels(i)=""
data(i) = oRs("totOutput")
end if
month = month + 1
i=i+1
loop
month = 1
year=year+1
endDate=month&"/"&hWeek&"/"&year
Loop
response.Write(i)
Call c.addLineLayer(data)
Call c.xAxis().setLabels(labels)
response.ContentType = "image/png"
response.BinaryWrite c.makeChart2(cd.PNG)
Response.End
strparam=" caption=Quarterly Enrollment; subcaption=Current; xAxisName=Months; yAxisName=# of People; hovercapbg=FFECAA; hovercapborder=F47E00; formatNumberScale='0'; decimalPrecision='0'; showvalues=0; numdivlines=5; numVdivlines=6; yaxisminvalue='0'; lineThickness=2; rotateNames=1; baseFontSize='15'; animation=0; shadow =0; alpha=0; anchorAlpha='0';showshadow=0; anchorRadius = 2;"
Call FC.addTrendLine("startValue=35;endValue=35;color=FF0000;displayvalue=Target Enrollment;thickness=2;alpha=100;isTrendZone=0;showOnTop=0")
Set oRs = Nothing
oConn.close
%>
</div>
</body>
</html> |
|
| |
Re: It isn't even an error..... |
Posted by Peter Kwan on Jul-26-2012 01:09 |
|
Hi Tim,
The error is because your output includes both HTML and an image. According to HTML standard, HTML cannot include any image. It can only include <IMG> tags. The image should be in a separate URL referenced by the <IMG> tag.
In your attachment, the output is HTML (there is an <html> tag). It also tries to output a chart image, which is not allowed.
To include a chart image in a web page, please use an <IMG> tag, just like including any other image. The code is:
<img src="createMyChart.asp">
In the above, the createMyChart.asp is a script that generates the chart image. The script should output the chart image, but not any HTML.
Hope this can help.
Regards
Peter Kwan |
Re: It isn't even an error..... |
Posted by Tim on Jul-26-2012 02:20 |
|
Thanks for the quick response! So all I should have to do is remove all html code and it should work atleast display the chart or give me an error? Here is the updated code without the html.(Also can I use the <-- #include part or is that messing with the code?)
|
Re: It isn't even an error..... |
Posted by Peter Kwan on Jul-26-2012 03:52 |
|
Hi Tim,
I can still see HTML in your code.
In ASP, anything that is not included in <% .... %> is HTML. Even an empty space or empty line is HTML. In your ASP, I can see an empty line not inside any <% .... %> block.
Also, "response.Write(i)" is outputting HTML. In ASP, everything you output is HTML, unless you specify it is not HTML. In our charting code, we always use response.ContentType = "image/png" to specify that the output is an image, before we actually use response.BinaryWrite to output the image.
To solve the problem, please remove the empty line, and also the response.Write statement.
Hope this can help.
Regards
Peter Kwan |
Re: It isn't even an error..... |
Posted by Tim on Jul-26-2012 03:59 |
|
YEAH!!!! it works! Now on to my next problem. I am trying to figure out how to space out the x-axis labels. Also is there a way to rotate the names so they don't run into each other? Thanks again for the prompt and helpful response! |
Re: It isn't even an error..... |
Posted by Tim on Jul-26-2012 04:14 |
|
I found the axis.setlinearScale but so far I am unable to figure out if I use the cd object or call the function/how to implement it? Thanks and sorry for the dumb question(there will probably be many more to come....) |
Re: It isn't even an error..... |
Posted by Tim on Jul-26-2012 04:39 |
|
I think I found the syntax call c.xAxis().setLinearScale(cd.NoValue, myupperlimit) but it currently doesn't do anything for me. If my x-axis is labeled by strings, ex "1st Quarter of 2010" and ends with "3rd Quarter of 2012" what can I put?. I also would like to be able to not have to update the upper limit, so when we get to the 4th Quarter of 2012 it will be the upper limit. I was just thinking of putting myupperlimit = to the current labels(i) variable at the end of every loop. Any ideas? |
Re: It isn't even an error..... |
Posted by Peter Kwan on Jul-26-2012 15:13 |
|
Hi Tim,
If you are using labels for the x-axis (configured using Axis.setLabels), you may use Axis.setLabelStyle to rotate the labels. There are some examples in ChartDirector in which the labels are rotated, such as "Trend Line Chart" and "High-Low-Open-Close Chart" (you may look them up from the ChartDirector documentation index). The code is like:
'Set the font style to be Arial 8 points black (&H000000) and rotate by 45 degrees
Call c.xAxis().setLabelStyle("arialbd.ttf", 8, &H000000, 45)
Hope this can help.
Regards
Peter Kwan |
Re: It isn't even an error..... |
Posted by Tim on Jul-26-2012 21:53 |
|
Nice the style works perfect, but when I use the c.xaxis().setLabels(labels) it crams all of my labels to about the first third of the tabel... Is there any way to space out the ticks? I tried using setTickDensity() but it didn't do anything. Attached is a picture
|
Re: It isn't even an error..... |
Posted by Tim on Jul-26-2012 21:54 |
|
Nice the style works perfect, but when I use the c.xaxis().setLabels(labels) it crams all of my labels to about the first third of the table... Is there any way to space out the ticks? I tried using setTickDensity() but it didn't do anything. Attached is a picture |
Re: It isn't even an error..... |
Posted by Peter Kwan on Jul-26-2012 23:11 |
|
Hi Tim,
I suspect the reason is because there are many empty labels in your labels array. So ChartDirector needs to put many empty labels in the axis and this fills up the right side of the axis.
In your code, it seems there is a line ReDim labels(100). This line declares 101 labels (from 0 to 100). If you actually use only 30 labels, then the remaining 71 labels will be empty. This may be the cause of the problem.
To solve the problem, after reading in all the labels from your database, you may consider to use:
'Trim the arrays to the actual number of elements used
ReDim Preserve labels(i - 1)
Redim Preserve data(i - 1)
Hope this can help.
Regards
Peter Kwan |
|