Link to home
Start Free TrialLog in
Avatar of Yannie
Yannie

asked on

Unable to refresh graph created by OWC

Dear all,

I need help urgently.

I have a file called quarter1.asp with a graph1.asp included inside. However, in quarter1, I can choose to direct to quarter2.asp or quarter3.asp by using response.Redirect in choosequarter.asp. So It functions in such a way from

quarter1.asp -> choosequarterlist.asp -> quarter1.asp or quarter2.asp or quarter3.asp(depending which i chose to go from the initial quarter1.asp)

However i'm unable to load the graph successfully as it seems to be always selected at current year's graph even I have choose other year's graph.

The parameters passed to different pages are correct.
Only when I hit F5 then the graph can be loaded again.

I had also tried putting this below but doesn't help..

Response.Expires = -1
Response.AddHeader "pragma", "no-cache"
Response.CacheControl = "no-cache"
Response.CacheControl = "no-store" ' HTTP 1.1 Cache-Control header : prevent all caching of a particular Web resource
Response.CacheControl = "no-cache" ' HTTP 1.1 Cache-Control header : prevent all caching of a particular Web resource
Response.AddHeader "Pragma", "no-cache" ' (META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE")


Can anyone help this asap?!
 
Avatar of Yannie
Yannie

ASKER

<%
      dim MasterID, selYear, selQuarter
      MasterID = request.QueryString("MasterID")
      selYear = request("selYear")
      selQuarter = request("selQuarter")
      'response.write(selQuarter)
      'response.write(selYear)
      
      
      if selYear = "" then
            selYear = Year(date)
      end if

      currentmth= month(now())
      if selMonth = "" then
            selMonth = currentmth
      end if
      
      
      Select Case selQuarter
            case 001
                  strDestPage = "quarter1.asp?MasterID="&MasterID&"&selYear="&selYear&""
            case 002
                  strDestPage = "quarter2.asp?MasterID="&MasterID&"&selYear="&selYear&""
            case 003
                  strDestPage = "quarter3.asp?MasterID="&MasterID&"&selYear="&selYear&""
      End Select
      
      if strDestPage <> "" then
            response.Redirect strDestPage
            'Response.Redirect    url  & "?" & Server.URLEncode(cstr(now))
            'Response.Redirect    url  & "?" & (Int( 555555 * Rnd ) + 1)                        
      end if
      %>

This is wad i did so far for choosequarterlist.asp...
Anyone can help fast?
i allways put this code in my page and work fine, try putting this on the begining of your pages
choosequarterlist.asp, quarter1.asp, quarter2.asp and quarter3.asp

Response.Expires = 60
Response.Expiresabsolute = Now() - 1
Response.AddHeader "pragma","no-cache"
Response.AddHeader "cache-control","private"
Response.CacheControl = "no-cache"
Avatar of Yannie

ASKER

It's still the same after putting this in..i even put it on the graph page itself..
But still unable to refresh..any ideas?
can you put the ode of quarter1.asp to see what it does?

or put this code in your page

response.write(selQuarter)
response.write(selYear)
response.end

before
if selYear = "" then

and post here the output
Avatar of Yannie

ASKER

This is quarter1.asp codes..In it has Graph1...it's always the graph1.asp that cannot be reloaded..

<%
'DO NOT CACHE THIS PAGE!
Response.Expires = 60
Response.Expiresabsolute = Now() - 1
Response.AddHeader "pragma","no-cache"
Response.AddHeader "cache-control","private"
Response.CacheControl = "no-cache"

MasterID = request("MasterID")
'MasterID = request.QueryString("MasterID")
selYear = request("selYear")

      currentyear= year(now())
      if selYear = "" then
            selYear = currentyear
      end if

      currentmth= month(now())
      if selMonth = "" then
            selMonth = currentmth
      end if
      
%>
<script language="javascript">
<!-- Begin
//function redirTimer() {
   // window.open('quarter1.asp?MasterID='+MasterID+'&selYear='+selYear);
      
    //setTimeout(window.open("http://www.cnn.com","cnn",height="400",width="400",toolbar="no",scrollbars="yes",resizable="no",menubar="no"), redirTime);
 //    }
//END Script-->

//if (!location.search || ( location.search && location.search.indexOf('done') == -1)) location = location.href+'?done';
</script>
<html>
<head>
<title>Oil Consumption Report</title>
<link rel="stylesheet" type="text/css" href="Style.css">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="expires" content="0">

</head>


<body>
<!--#include file="conn.asp"-->

<%
'===========================================================
'Calculate the number of days in a particular month
'===========================================================

'=======Calculate the number of days for the requested month=========
      function getDaysInMonth(iMonth,iYear)
          Select Case (iMonth)
                  '// If the requested month is April, June, Sept, Nov, number of days in that month is 30 days
                Case 4,6,9,11
                      getDaysInMonth = 30
                '// If the requested month is Feb, number of days in that month is either 28 or 29            
                  Case 2
                      if (iYear Mod 4 = 0 And iYear Mod 100 <> 0) Or iYear Mod 400 = 0 Then
                            getDaysInMonth = 29
                      Else
                            getDaysInMonth = 28
                      End if
                '// For other cases, number of days in that month is 31 days            
                  Case Else
                      getDaysInMonth = 31
          End Select
      End function
%>

<%

      query_displayVessel = "SELECT * FROM Vessel WHERE MasterID="&MasterID&""
      Set rs_displayVessel = Server.CreateObject("ADODB.Recordset")
      Set rs_displayVessel = conn.Execute(query_displayVessel)
%>
<%
  If Request("quarter1.asp?MasterID="&MasterID&"&selYear="&selYear&"&reload") Then Response.Write "window.location.reload();"
%>
<table width="72%" border="1" bordercolor="#cccccc" cellspacing="0" cellpadding="5" align="center">
<tr>
      <th align="left" height="40" colspan="9"><b><center>
        <%=rs_displayVessel("VesselName")%> LUB OIL CONSUMPTION REPORT
       </center>
<br>

      <center><form name="quarter1" method="post" action="quarter1.asp">
      <font size ="2" face="Verdana, Arial, Helvetica, sans-serif">Year:</font>
        <select name="selYear" style="font-size:12px">
          <option selected value="<%=selYear%>"><%=selYear%></option>
          <% for k=currentyear-4 to currentyear %>
          <option value="<%=k%>"><%=k%></option>
          <% next %>
        </select>
            
        <strong>&nbsp;</strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Sort by:</font>
        <select name="selQuarter" style="font-size:12px">
            <option select value="001">Jan - Apr</option>
           <option value="002">May - Aug</option>
           <option value="003">Sept - Dec</option>
        </select>
        &nbsp;
            <input type="hidden" name="MasterID" value="<%=MasterID%>">
            <input type="submit" name="btn_submit" value="Go" style="width:40px; font-size:10px">&nbsp;&nbsp;&nbsp;&nbsp;
            </form>
            </center>
      </th>
      </tr>
</table>
<p>
<!--#include file="graph1.asp"-->
<%
Dim MonthArray(4)
Dim i ' i is monthcount
i = 1
For j = 0 to 3
i = 1 + j
%>
<p>
<table width="72%" border="1" bordercolor="#cccccc" cellspacing="0" cellpadding="5" align="center">
<link rel="stylesheet" href="stylesheet.css" type="text/css">
 
  <tr>
      <th align="left" height="40" colspan="9"><b><center>
        <%=UCASE(monthName(i))%>&nbsp;<%=selYear%>
      </center>
      </b></th>
</tr>
<tr bgcolor="e8e8e8">
      <td width="19%" class="blue">LOGDATE</td>
      <td width="18%" class="blue"><div align="center">AT SEA (HRS)</div></td>
      <td width="26%" class="blue"><div align="center">HFO CONSUMPTION (MT)</div></td>
      <td width="37%" class="blue"><div align="center">ME LUB OIL CONSUMPTION (LTRS)</div></td>
      
</tr>
     <tr>
        <%
       query_getReport = "SELECT Main_Eng_Log.MASTERID, Main_Eng_Log.LOGDATE AS expr1, isnull(AT_SEA_1,0) AT_SEA_1, isnull(FULL_AWAY_1,0) FULL_AWAY_1, isnull( ME_LUB_OIL_SUMP_32,0) ME_LUB_OIL_SUMP_32, Consumption_Report.LOGDATE AS LOGDATE1 FROM Main_Eng_Log full join Consumption_Report ON Main_Eng_Log.LOGDATE = Consumption_Report.LOGDATE AND Consumption_Report.MASTERID = Main_Eng_Log.MasterID WHERE  (Consumption_Report.MASTERID = " & MASTERID & ") AND (YEAR(Consumption_Report.LOGDATE) = " & selYear & ") AND (MONTH(Consumption_Report.LOGDATE) = " & i & ")  ORDER BY Main_Eng_Log.LOGDATE "
       Set rs_getReport = Server.CreateObject("ADODB.Recordset")
     Set rs_getReport = conn.Execute(query_getReport)

     dim iDay
     dim iMonth
     dim iYear
     
      iDay = 1
     if not rs_getReport.eof then
     
     while NOT rs_getReport.EOF
     iMonth =  month(rs_getReport("LOGDATE1"))
     iYear  =  year(rs_getReport("LOGDATE1"))
        
       'while the day doesnt exist, will show row.
     while iDay <> day((rs_getReport("LOGDATE1")))
     %>
        <tr><td class="black"><%=iDay%>/<%=month(rs_getReport("LOGDATE1"))%>/<%=year(rs_getReport("LOGDATE1"))%></td>
     <td class="black"><center>0</center></td>
     <td class="black"><center>0</center></td>
     <td class="black"><center>0</center></td>
     </tr>
       <%
          iDay = iDay + 1
     Wend
       %>
     <td class="black"><%=day((rs_getReport("LOGDATE1")))%>/<%=month((rs_getReport("LOGDATE1")))%>/<%=year((rs_getReport("LOGDATE1")))%></td>
     <td class="black"><center><%=rs_getReport("AT_SEA_1")%></center></td>
     <td class="black"><center><%=rs_getReport("FULL_AWAY_1")%></center></td>
     <td class="black"><center><%=rs_getReport("ME_LUB_OIL_SUMP_32")%></center></td>
      </tr>  
     <%
     iDay = iDay + 1
     rs_getReport.MoveNext
     Wend
       %>
          
       <%
     dim iDaysInMonth      
     iDaysInMonth = getDaysInMonth(iMonth,iYear)
      while (iDay <= iDaysInMonth)%>
        
     <tr><td class="black"><%=iDay%>/<%=iMonth%>/<%=iYear%></td>
     <td class="black"><center>0</center></td>
     <td class="black"><center>0</center></td>
     <td class="black"><center>0</center></td>
     </tr>  
    <%
          iDay = iDay + 1
     Wend
       %>
      
       <%
      query_getSum = "SELECT SUM(FULL_AWAY_1) AS SFA, SUM(ME_LUB_OIL_SUMP_32) AS SMLOC FROM Consumption_Report WHERE Masterid="&MasterId&" AND year(LOGDATE)="&selYear&" AND month(LOGDATE)="&i&" "
      Set rs_getSum = Server.CreateObject("ADODB.Recordset")
      Set rs_getSum = conn.Execute(query_getSum)
      
      query_getSum1 = "SELECT SUM(AT_SEA_1) AS SAS FROM Main_Eng_Log WHERE Masterid="&MasterId&" AND year(LOGDATE)="&selYear&" AND month(LOGDATE)="&i&" "
      Set rs_getSum1 = Server.CreateObject("ADODB.Recordset")
      Set rs_getSum1 = conn.Execute(query_getSum1)
      
      SAS = rs_getSum1("SAS")
      SFA = rs_getSum("SFA")
      SMLOC = rs_getSum("SMLOC")
      
      if SFA <> 0 then
      A_SFA = ROUND((SFA/SAS),5)
      A_SMLOC = ROUND((SMLOC/SAS),5)
      else
      A_SFA = 0
      A_SMLOC = 0
      end if
       %>
  <tr>
      <td width="18%" align="right" bgcolor="e8e8e8" class="blue">MTHLY CONS</td>
      <td width="19%" align="center" class="black"><b><%=rs_getSum1("SAS")%></b></td>
      <td width="26%" align="center" class="black"><b><%=rs_getSum("SFA")%></b></td>
      <td width="37%" align="center" class="black"><b><%=rs_getSum("SMLOC")%></b></td>
</tr>
<tr>
      <td class="blue" bgcolor="e8e8e8" align="right">AVERAGE CONS</td>
      <td align="center" class="black"></td>
      <td align="center" class="black"><b><%=A_SFA%></b></td>
      <td align="center" class="black"><b><%=A_SMLOC%></b></td>
</tr>
</table>
      <%
            rs_getSum.close()
              rs_getSum1.close()
       %>
        
<%else%>
<table width="72%" border="1" bordercolor="#cccccc" cellspacing="0" cellpadding="5" align="center">
  <tr>
      <td colspan="14" height="60" align="center" class="black"><strong>No data log found for the month.</strong></td>
</tr>
</table>

<%end if%>
<%next%>
<%
      if Request.Form("btn_submit") = "Go" then
            response.Redirect("choosequarterlist.asp?MasterID="&MasterID&"&selYear="&request("selYear")&"&selQuarter="&request("selQuarter")&"")
      end if
%>
<!--#include file="disconn.asp"-->
</body>
</html>
Avatar of Yannie

ASKER

This is how graph1.asp looks like which might clear any of ur doubts of the codes i used..

<table width="72%" border="1" bordercolor="#cccccc" cellspacing="0" cellpadding="5" align="center">
<tr>
      <th align="left" height="40" colspan="9"><b><center>
        <%=rs_displayVessel("VesselName")%> LUB OIL CONSUMPTION REPORT  <%=selYear%>
       </center></b>
          </th>
</tr>
<tr align="center"><td>
 <%
Sub CleanUpGIF(GIFpath)
   Dim objFS
   Dim objFolder
   Dim gif

   set objFS = Server.CreateObject("Scripting.FileSystemObject")
   set objFolder = objFS.GetFolder(GIFpath)
   
   'Loop through each file in the GIFpath folder
   for each gif in objFolder.Files
       'Delete GIF files older than 10 minutes
       if instr(gif.Name, ".gif") > 0 and _
         DateDiff("n", gif.DateLastModified, now) > 10 then
           objFS.DeleteFile GIFpath & "\" & gif.Name, True
       end if
   next
   set objFolder = nothing
   set objFS = nothing
End Sub
      Call CleanUpGIF("\\oceanflow\iat$\lubOilConsump\reports\")
%>
<%
      Dim Line1Val(4)
    Dim LineVal(4)
    Dim Val(4)
      Dim monthCount
      monthCount = 1
      'blue for fuel oil
      for j = 0 to 3
      
      
      query_getReport1 = "SELECT (SUM(FULL_AWAY_1)) AS TFA, SUM(AT_SEA_1) as SAS, CASE WHEN SUM(AT_SEA_1) <> 0 THEN ((SUM(FULL_AWAY_1))/(SUM(AT_SEA_1))) ELSE 0 END AS AFA FROM Consumption_Report, Main_Eng_Log WHERE Main_Eng_Log.MasterId = Consumption_Report.MasterID AND Main_Eng_Log.MasterId = "&MasterId&" AND Year(Main_Eng_Log.LOGDATE) = YEAR(Consumption_Report.LOGDATE) AND Year(Main_Eng_Log.LOGDATE) = "&selYear&" AND Month(Main_Eng_Log.LOGDATE) = Month(Consumption_Report.LOGDATE) AND Month(Main_Eng_Log.LOGDATE) = "&monthCount&""
      Set rs_getReport1 = conn.Execute(query_getReport1)
      if not rs_getReport1.eof then
            Line1Val(j) = rs_getReport1("AFA")
            'response.write ((rs_getReport1("AFA"))&"---")
            'response.write(selYear&"&nbsp;")
             ' response.write(monthcount&"&nbsp;=")
      else
            Line1Val(j) = 0
      end if
      
      ' red for lub oil
      query_getReport = "SELECT (SUM(ME_LUB_OIL_SUMP_32)) AS TMELO, SUM(AT_SEA_1) as SAS, CASE WHEN SUM(AT_SEA_1) <> 0 THEN ((SUM(ME_LUB_OIL_SUMP_32))/(SUM(AT_SEA_1))) ELSE 0 END AS AMELO FROM Consumption_Report, Main_Eng_Log WHERE Main_Eng_Log.MasterId = Consumption_Report.MasterID AND Main_Eng_Log.MasterId = "&MasterId&" AND Year(Main_Eng_Log.LOGDATE) = YEAR(Consumption_Report.LOGDATE) AND Year(Main_Eng_Log.LOGDATE) = "&selYear&" AND Month(Main_Eng_Log.LOGDATE) = Month(Consumption_Report.LOGDATE) AND Month(Main_Eng_Log.LOGDATE) = "&monthCount&""
      Set rs_getReport = conn.Execute(query_getReport)
      
      if not rs_getReport.eof then
            LineVal(j) = rs_getReport("AMELO")
            'response.write  ((rs_getReport("AMELO"))&"***")
      else
            LineVal(j) = 0
      end if
      monthCount = monthCount + 1
      next
%>

<%
      'label the months.
    Val(0) = 1
    Val(1) = 2
    Val(2) = 3
    Val(3) = 4
   
    Dim ObjChart
    Dim ChaCon
    Dim ObjCharts
    Dim SerCol
      Dim objAxis
      Dim objFont
    Set ObjChart = Server.CreateObject("OWC.Chart")
    Set ChaCon = ObjChart.Constants
    Set ObjCharts = ObjChart.Charts.Add
    'adding my line
      Set SerCol = ObjCharts.SeriesCollection.Add
    Set SerCol1 = ObjCharts.SeriesCollection.Add
    'ObjCharts.Type = ChaCon.chChartTypeColumnClustered
      ObjCharts.Type = ChaCon.chChartTypeLine
                'this is in purple line
                SerCol.Caption = "Fuel Oil Cons"
                SerCol.SetData ChaCon.chDimCategories, ChaCon.chDataLiteral, Val
                SerCol.SetData ChaCon.chDimValues, ChaCon.chDataLiteral, Line1Val
                  SerCol.Type = ChaCon.chChartTypeLineMarkers
                '-------------------------------
                'this is my line in the graph
                SerCol1.Caption = "Lub Oil Cons"
                SerCol1.SetData ChaCon.chDimCategories, ChaCon.chDataLiteral, Val
                SerCol1.SetData ChaCon.chDimValues, ChaCon.chDataLiteral, LineVal
                'change      from the default bar graph To a line
                SerCol1.Type = ChaCon.chChartTypeLineMarkers
                '----------------------------
                  
    'Title of graph
    ObjChart.HasChartSpaceTitle=True
      'Legend in the graph
    ObjChart.ChartSpaceTitle.Caption = "FO/LO CONSP / HR"
      ' Set a variable to the Value (X) axis.
      Set axCategoryAxis = ObjChart.Charts(0).Axes(0)
    ' Set a variable to the Value (Y) axis.
    Set axValueAxis = ObjChart.Charts(0).Axes(1)

    ' The following two lines of code enable, and then
    ' set the title for the category axis.
    axCategoryAxis.HasTitle = True
    axCategoryAxis.Title.Caption = "LITRES / TONNES"
   
    ' The following three lines of code set the font
    ' for the values displayed on the category axis.
    axCategoryAxis.Font = "Arial"
    axCategoryAxis.Font.Size = 8
    axCategoryAxis.Font.Bold = True

    ' The following two lines of code enable, and then
    ' set the title for the value axis.
    axValueAxis.HasTitle = True
    axValueAxis.Title.Caption = "MONTH"  'Put your Cation for Y-Axis
      axValueAxis.Font = "Arial"
    axValueAxis.Font.Size = 8
    axValueAxis.Font.Bold = True
      
    ObjChart.HasChartSpaceLegend = True
    ObjChart.ChartSpaceLegend.Position = ChaCon.chLegendPositionRight
      
    ImagePath=server.mappath("reports/oilgraph.gif")
   
    ObjChart.ExportPicture ImagePath,"gif", 700, 400
    Set ChaCon = nothing
    Set ObjCharts = nothing
    Set ObjChart = nothing %>
      
    <Img src="reports/oilgraph.gif" width="700" height="400">
      </td>
      </tr>
</table>
Avatar of Yannie

ASKER

Hi Lennon..Did the
response.write(selQuarter)
response.write(selYear)
 and everthing seems alrite..cos it's retrieving the right data each time i do the dropdownlist and i got wad i wanted from the url each time i checked..no problem in getting the data juz that only the graph cannot be refreshed though data in my table quarter1.asp can be displayed successfully...
i don't quite get whats the use of this:

If Request("quarter1.asp?MasterID="&MasterID&"&selYear="&selYear&"&reload") Then Response.Write "window.location.reload();"

is there a variable name 'quarter1.asp?MasterID="&MasterID&"&selYear="&selYear&"&reload'

try commenting this line and see what it does
Avatar of Yannie

ASKER

Oh I was trying to use a variable to refresh the page..anyway..this line can be left out..

opps sorry forgot to comment it out..
can you tell us what you do to solve your problem?
Avatar of Yannie

ASKER

Instead of refreshing the page I made it load a new window instead of everytime the selection was made. This saves the risk of the page being unable to load properly. Cos somehow the reloading fucntion has been in vain when i tried countless times.
ASKER CERTIFIED SOLUTION
Avatar of GranMod
GranMod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial