def GetCompetitorTitlesHtml(strJnlIssn, intMonths, strReportDate, intCompJnlMinAfp, intCompJnlMinAcrossFBProgs, oConn): """ Return the html data for the Competitor titles for a specific Elsevier journal For a specific statement, months (reporting period) and Report date. Inputs : Journal ISSN, StatmentID, Months (Report time period), Report data Output : Html data in string format """ strChartHtml = "<table BORDER='1' BGCOLOR='#ffffff' CELLSPACING='0' id='table1'><font FACE='Arial' COLOR='#000000'><caption> </caption></font><thead><tr><th BGCOLOR='#c0c0c0' BORDERCOLOR='#000000'><font SIZE='2' FACE='Arial' COLOR='#000000'>Journal</font></th><th BGCOLOR='#c0c0c0' BORDERCOLOR='#000000'><font SIZE='2' FACE='Arial' COLOR='#000000'>Count</font></th></tr></thead>" oData = GetCompetitorTitlesData(strJnlIssn, intMonths, strReportDate, intCompJnlMinAfp, intCompJnlMinAcrossFBProgs, oConn) if (oData != None): intRowCount = len(oData) for i in range(intRowCount): strTitle = oData[i][0] strEncodedTitle = strTitle.encode('utf8') strChartHtml = strChartHtml + "<tr VALIGN='TOP'><td BORDERCOLOR='#c0c0c0'><font SIZE='2' FACE='Arial' COLOR='#000000'>"+strEncodedTitle+"</font></td><td BORDERCOLOR='#c0c0c0' ALIGN='RIGHT'><font SIZE='2' FACE='Arial' COLOR='#000000'>"+str(oData[i][1])+"</font></td></tr>" strChartHtml = strChartHtml + "<tfoot></tfoot></table>" else: lgExceptionLog(6, strJnlIssn, strReportDate, intMonths , 'EXCEPTION|CompetitorTitles', strLogFileName) return None return strChartHtml
def GetDiffFromAverageHtml(intLevel, intChartWidth, strCode, intMonths, strReportDate, strLogFileName, strAverageIdentifier, oConn): """ Return the html data for the Factor Percentage Differences from the averages for a specific Elsevier journal For a specific statement, months (reporting period) and Report date. Inputs : intLevel, intChartWidth, strCode, intMonths, strReportDate, strAverageIdentifier, oConn Output : Html data in string format """ oData = GetDiffFromAverageData(intLevel, strCode, intMonths, strReportDate, strAverageIdentifier, oConn) intDiv = 10 #The x-axis divisions lstScores = list() if (oData != None): intRowCount = len(oData) for x in range(intRowCount): #lstScores.append(oData[x][3]) lstScores.append(oData[x][1]) intMaxScore = max(lstScores) intMinScore = min(lstScores) if (abs(intMinScore) > intMaxScore): intMaxScore = abs(intMinScore) intRange = (int(intMaxScore/intDiv) + 1) * intDiv intRange = intRange * 2 # for -ve and +ve sides to the chart intChartWidth = 350 decWidthPerScoreNumber = float(intChartWidth)/float(intRange) intRange = 3 strXml = "<graph showAlternateVGridColor='1' adjustDiv='0' animation='0' showLegend='0' shownames='1' showvalues ='0' alternateVGridAlpha='10' yAxisMinValue='-10' yAxisMaxValue='10'alternateVGridColor='AFD8F8' numDivLines='"+str(intRange)+"' divLineIsDashed='1' divLineDashLen='1' showhovercap = '0' divLineDashGap='2' decimalPrecision='0' canvasBorderThickness='1' showBarShadow='0' canvasBorderColor='114B78' baseFont='verdana' yAxisName='%25 Difference from Overall Competitor Average' baseFontColor='666666' baseFontSize='11' hoverCapBorderColor='114B78' hoverCapBgColor='E7EFF6' >" for i in range(intRowCount): decScore = oData[i][1] if (decScore > 10): decScore = 10 if (decScore < -10): decScore = -10 strXml = strXml + "<set name='"+str(oData[i][0])+"' value='"+str(decScore)+"' color='F14D53' alpha='70' />" strXml = strXml + "</graph>" else: lgExceptionLog(6, strCode, strReportDate, 12, 'EXCEPTION|StatementBarChart', strLogFileName) return None return strXml
def GetAccessChartTwoXml(intLevel, strCode, strReportDate, strQuest, intCompJnlMinAfp, intCompJnlMinAcrossFBProgs, strCompetitorOrderStatementID, strCompanyName, strAverageIdentifier, oConn, strLogFileName, intMonths = None): tupLineColors = ("ff8000", "c0c0c0", "68e1fe", "000000", "0808de", "cd2d7d", "804000", "528B8B", "2F4F4F") strXml = "<graph yAxisMinValue='0' showvalues='1' shownames='1' animation='0' showBarShadow='0' showShadow='0' chartLeftMargin='20' chartRightMargin='20' decimalPrecision='0' canvasBgColor='FFE5BD' zeroPlaneAlpha='0' outCnvBaseFont='Verdana' OutCnvBaseFontSize='10' numberSuffix='%25' >" oXmlData = GetAccessChartTwoData(intLevel, strCode, strReportDate, strQuest, intCompJnlMinAfp, intCompJnlMinAcrossFBProgs, strCompetitorOrderStatementID, strCompanyName, strAverageIdentifier, oConn, intMonths) if (oXmlData != None): intRowCount = len(oXmlData) for i in range(intRowCount): strXml = strXml + "<set name='"+str(GetXmlSafeString(oXmlData[i][1]))+"' value='"+str(oXmlData[i][2])+"' color='"+str(tupLineColors[i])+"' alpha='100' />" strXml = strXml + "</graph>" else: lgExceptionLog(6, strCode, strReportDate, 12, 'EXCEPTION|StatementBarChart', strLogFileName) return None return strXml
def GetJnlStatementBarChartXml(intLevel, strCode, strStatementID, strReportDate, strSubTitle,intCompJnlMinAfp, intCompJnlMinAcrossFBProgs, strAverageIdentifier, strCompanyName, oConn, strLogFileName, strCompetitorOrderStatementID, strType = 'statement', intMonths = None): """ Return the xml data for the Bar Chart for a specific Elsevier journal and its competitors. For a specific statement, months (reporting period) and Report date. The xml data is for the fusion charts application to display the chart. Inputs : intLevel, strCode, strStatementID, intMonths, strReportDate, strSubTitle,intCompJnlMinAfp, intCompJnlMinAcrossFBProgs, oConn Output : Xml data in string format """ tupLineColors = ("ff8000", "c0c0c0", "68e1fe", "000000", "0808de", "cd2d7d", "804000", "528B8B", "2F4F4F") if (strType == 'statement'): strXml = "<graph showAlternateVGridColor='1' animation='0' showLegend='0' shownames='0' showvalues ='1' alternateVGridAlpha='10' chartRightMargin='25' alternateVGridColor='AFD8F8' numDivLines='2' decimalPrecision='0' canvasBorderThickness='1' showBarShadow='0' canvasBorderColor='114B78' baseFontColor='114B78' hoverCapBorderColor='114B78' hoverCapBgColor='E7EFF6' yAxisMinValue='40' yAxisMaxValue='100'>" else: strXml = "<graph yAxisMinValue='0' showvalues='1' animation='0' shownames='1' showBarShadow='0' showShadow='0' chartLeftMargin='20' chartRightMargin='20' decimalPrecision='0' canvasBgColor='FFE5BD' zeroPlaneAlpha='0' outCnvBaseFont='Verdana' OutCnvBaseFontSize='10' numberSuffix='%25' >" oXmlData = GetStatementBarChartData(intLevel, strCode, strStatementID, strReportDate, intCompJnlMinAfp, intCompJnlMinAcrossFBProgs, strAverageIdentifier, strCompanyName,oConn, strCompetitorOrderStatementID, strType, intMonths) if (oXmlData != None): intRowCount = len(oXmlData) for i in range(intRowCount): strXml = strXml + "<set name='"+str(GetXmlSafeString(oXmlData[i][5]))+"' value='"+str(oXmlData[i][2])+"' color='"+str(tupLineColors[i])+"' alpha='100' />" strXml = strXml + "</graph>" else: lgExceptionLog(6, strCode, strReportDate, 12, 'EXCEPTION|StatementBarChart', strLogFileName) return None return strXml
def GetJnlStatementBarChartXml(strJnlIssn, strStatementID, intMonths, strReportDate, strSubTitle,intCompJnlMinAfp, intCompJnlMinAcrossFBProgs, oConn): """ Return the xml data for the Bar Chart for a specific Elsevier journal and its competitors. For a specific statement, months (reporting period) and Report date. The xml data is for the fusion charts application to display the chart. Inputs : Journal ISSN, StatementID, Months (Report time period), Report data Output : Xml data in string format """ tupLineColors = ("ee3202", "006050", "ffc000", "006aed", "000000", "542c51", "804000", "528B8B", "2F4F4F") oXmlData = GetJnlStatementBarChartData(strJnlIssn, strStatementID, intMonths, strReportDate, intCompJnlMinAfp, intCompJnlMinAcrossFBProgs, oConn) if (oXmlData != None): intRowCount = len(oXmlData) #caption='"+strSubTitle+"' yaxisname='Test Y-axis' xaxisname='Test x-axis' strXml = "<graph showAlternateVGridColor='1' showLegend='0' shownames='1' showvalues ='1' alternateVGridAlpha='10' alternateVGridColor='AFD8F8' numDivLines='2' decimalPrecision='0' canvasBorderThickness='1' canvasBorderColor='114B78' baseFontColor='114B78' hoverCapBorderColor='114B78' hoverCapBgColor='E7EFF6' yAxisMinValue='40' yAxisMaxValue='100'>" for i in range(intRowCount): strXml = strXml + "<set name='"+str(oXmlData[i][5])+"' value='"+str(oXmlData[i][2])+"' color='"+str(tupLineColors[i])+"' alpha='70' />" strXml = strXml + "</graph>" #SELECT T6.ISSN, T6.intOrder, ROUND(T6.intRating,2) As intRating, T6.intSE, T6.ReportDate, IIf((intOrder=3), 'AVERAGE',T7.ISI_Abbrev) As ISI_Abbrev else: lgExceptionLog(6, strJnlIssn, strReportDate, 12, 'EXCEPTION|BarChartSatisfaction', strLogFileName) return None return strXml
def GetJnlTabularFactorChartHtml( intLevel, strCode, strReportDate, intCompJnlMinAfp, intCompJnlMinAcrossFBProgs, blnHasCompetitors, strCompetitorOrderStatementID, strAverageIdentifier, strCompanyName, strRelativePath, oConn, strLogFileName, intMonths=None, ): """ Return the html data for the Journal Tabular Chart for a specific Elsevier journal and its competitors. For a specific statement, months (reporting period) and Report date. The xml data is for the fusion charts appliction to display the chart. Inputs : Journal ISSN, StatmentID, Months (Report time period), Report data Output : Xml data in string format """ strHelpRequiredLink = "" strStatementID = "" # strChartHtml = "<table width='100%' border='0' cellspacing='1' cellpadding='0'><tr><th scope='col' > </th>" strChartTitle = "" strChartHtml = ( "<table style='table-layout:fixed;' width='100%' border='0' cellspacing='1' cellpadding='0'><tr><th scope='col' class='tableStatementTitle'>" + strChartTitle + "<br /></th>" ) lstJnlAbbrev = list() oData = GetTabularFactorChartData( intLevel, strCode, strReportDate, intCompJnlMinAfp, intCompJnlMinAcrossFBProgs, strCompetitorOrderStatementID, strAverageIdentifier, strCompanyName, oConn, intMonths, ) oName = GetTabFactorFieldNames(intLevel) if oData != None: intRowCount = len(oData) intFieldCount = len(oData[0]) intNoOfJournals = 0 for i in range(intRowCount): lstJnlAbbrev.append(oData[i][oName["strJnlAbbrev"]]) if i == 0: # Elsevier Jnl strOurFormattedTitle = FormatTitle(lstJnlAbbrev[i]) # str(lstJnlAbbrev[i]) strChartHtml = ( strChartHtml + "<th scope='col' class='tableStatementHeaderTop'>" + strOurFormattedTitle + "</th><td class='tableStatementEmptyCol'></td><th scope='col' class='tableStatementOrangeTop'>Diff to Avg</th>" ) # strChartHtml = strChartHtml + "<th scope='col' class='tableHeaderTop'>"+str(lstJnlAbbrev[i])+"</th><th scope='col' class='tableOrangeTop'>Diff to Avg</th>" if (i != 0) and (blnHasCompetitors == True): # Competition Journals if lstJnlAbbrev[0] == lstJnlAbbrev[i]: break strFormattedTitle = FormatTitle(lstJnlAbbrev[i]) # strChartHtml = strChartHtml + "<th scope='col' class='tableHeaderTop'>"+FormatTitle(lstJnlAbbrev[i])+"</th>" # strChartHtml = strChartHtml + "<th scope='col' class='tableHeaderTop'>"+strFormattedTitle+"</th>" strChartHtml = ( strChartHtml + "<td class='tableStatementEmptyCol'></td><th scope='col' class='tableStatementHeaderTop'>" + strFormattedTitle + "</th>" ) intNoOfJournals = intNoOfJournals + 1 strChartHtml = strChartHtml + "</tr>" y = 0 strChartHtml = strChartHtml + "<tr class='tableStatementEmptyRow'></tr>" for x in range(intRowCount): strStatementID = oData[x][oName["strStatementID"]] strHelpDecisionTreeFileName = GetDecisonTreeFileName(strStatementID) if (x != 0) and (oData[x][oName["intOrder"]] == 1): strChartHtml = strChartHtml + "</tr>" + "<tr class='tableStatementEmptyRow'></tr>" # strChartHtml = strChartHtml + "</tr>" if oData[x][oName["intOrder"]] == 1: # The row is an Elsevier journal score strSign = "" if oData[x][oName["intDiffToAll"]] > 0: strSign = "+" if ((intLevel != 1) or (intLevel != 2)) and (blnHasCompetitors == True): # print 'intDiffToAll:'+str(oData[x][oName['intDiffToAll']])+'|minusSE:'+str(-oData[x][oName['intSE']]) if oData[x][oName["intDiffToAll"]] < -oData[x][oName["intSE"]]: # Then display link to help sheet strHelpRequiredLink = ( "<a href='http://nonsolus/rarbestpractice/afp_" + strHelpDecisionTreeFileName + ".htm'><img border=0 alt='Click here to view Decision tree' align=right src='" + strRelativePath + "images/dectreesm.gif'></a>" ) # strChartHtml = strChartHtml + "<tr><td class='tableHeaderSide'>"+strHelpRequiredLink+"<a href='#"+str(oData[x][oName['strQuest']])+"'>"+str(oData[x][oName['strQuestDescription']])+"</a></td><td class='"+str(oData[x][oName['strColor']])+"'>"+str(int(oData[x][oName['intDisplayRating']]))+"</td><td class='orange'>"+strSign+str(int(oData[x][oName['intDiffToAll']]))+"</td>" strChartHtml = ( strChartHtml + "<tr><td class='tableStatementHeaderSide'>" + strHelpRequiredLink + "<a href='#" + str(oData[x][oName["strQuest"]]) + "'>" + str(oData[x][oName["strQuestDescription"]]) + "</a></td><td class='tableStatement" + str(oData[x][oName["strColor"]]) + "'>" + str(int(oData[x][oName["intDisplayRating"]])) + "</td><td class='tableStatementEmptyCol'></td><td class='tableStatementOrange'>" + strSign + str(int(oData[x][oName["intDiffToAll"]])) + "</td>" ) else: # strChartHtml = strChartHtml + "<td class='"+str(oData[x][oName['strColor']])+"'>"+str(int(oData[x][oName['intDisplayRating']]))+"</td>" strChartHtml = ( strChartHtml + "<td class='tableStatementEmptyCol'></td><td class='tableStatement" + str(oData[x][oName["strColor"]]) + "'>" + str(int(oData[x][oName["intDisplayRating"]])) + "</td>" ) y = y + 1 strHelpRequiredLink = "" strChartHtml = strChartHtml + "</tr></table>" else: lgExceptionLog(6, strCode, strReportDate, 12, "EXCEPTION|TabularFactor", strLogFileName) return strChartHtml
def GetJournalStatementTimeSeriesChartXml(intLevel, strCode, strStatementID, strReportDate, strFirstReportDate, strSubTitle, intCompJnlMinAfp, intCompJnlMinAcrossFBProgs, strLogFileName, strCompetitorOrderStatementID, strCompanyName, strAverageIdentifier, lstLegend, oConn, intMonths=None): """ Return the xml data for the Time Series Chart for a specific Elsevier journal and its competitors. For a specific statement, months (reporting period) and Report date. The xml data is for the fusion charts appliction to display the chart. Inputs : Journal ISSN, StatmentID, Months (Report time period), Report data Output : Xml data in string format """ #Line colors for the chart tupLineColors = ("ff8000", "c0c0c0", "68e1fe", "000000", "0808de", "cd2d7d", "804000", "528B8B", "2F4F4F") oXmlData = GetStatementHorTimeSeriesChartData( intLevel, strCode, strStatementID, strReportDate, strFirstReportDate, intCompJnlMinAfp, intCompJnlMinAcrossFBProgs, strCompetitorOrderStatementID, strCompanyName, strAverageIdentifier, oConn, intMonths) oName = GetTimeSeriesFieldNames() if (oXmlData != None): intRowCount = len(oXmlData) intFieldCount = len(oXmlData[0]) lstScores = list() lstJournalName = list() lstReportDate = list() lstLengthOfJnlName = list() for i in range(intRowCount): lstScores.append(oXmlData[i][oName['intDisplayRating']]) lstJournalName.append(oXmlData[i][oName['strJnlAbbrev']]) lstReportDate.append(oXmlData[i][oName['strReportDate']]) lstLengthOfJnlName.append(oXmlData[i][oName['intLenJnlAbbrev']]) intMaxLengthOfJnlName = max(lstLengthOfJnlName) lstJournalName = uniqfy( lstJournalName ) #Get a unique list of the journals in the order they are in the query intJnlCount = len(lstJournalName) for x in range(intJnlCount): lstTemp = list() lstTemp = [ lstJournalName[x], tupLineColors[x], intMaxLengthOfJnlName ] lstLegend.append(lstTemp) decMaxValue = max(lstScores) decMinValue = min(lstScores) oGetChartConfigValues = GetChartConfigData(decMaxValue, decMinValue) intYmax = oGetChartConfigValues["intYmax"] intTempMin = oGetChartConfigValues["intTempMin"] intNoOfLines = oGetChartConfigValues["intNoOfLines"] intDecimalPrecision = oGetChartConfigValues["intDecimalPrecision"] lstReportDate = uniqfy(lstReportDate) lstReportDate.sort() strXml = "<graph yAxisMinValue='" + str( intTempMin ) + "' yAxisMaxValue='" + str(intYmax) + "' numdivlines='" + str( intNoOfLines ) + "' animation='0' showLegend ='0' showvalues='0' showAlternateVGridColor='1' alternateVGridAlpha='10' alternateVGridColor='AFD8F8' showShadow='0' decimalPrecision='" + str( intDecimalPrecision ) + "' canvasBorderThickness='1' canvasBorderColor='114B78' baseFontColor='114B78' hoverCapBorderColor='114B78' hoverCapBgColor='E7EFF6'>" strCategories = "<categories>" for datDate in lstReportDate: strCategories = strCategories + "<category name='" + ChartDateLabel( datDate) + "' />" strCategories = strCategories + "</categories>" #eventually want to return strXml , else if no records then no return which results in function returning object None which when compared #equates to boolean false else: lgExceptionLog(6, strCode, strReportDate, 12, 'EXCEPTION|TimeSeries', strLogFileName) return None strXml = strXml + strCategories strColor = 'ffff' x = 0 i = 0 y = 0 intRowDataCount = len(oXmlData) intRowJnlCount = len(lstJournalName) intRowReportDateCount = len(lstReportDate) tupLineColor = ("ff8000", "c0c0c0", "68e1fe", "000000", "0808de", "cd2d7d", "804000", "528B8B", "2F4F4F") strDataSet = "" while True: strDataSet = strDataSet + "<dataset seriesname = '" + GetXmlSafeString( oXmlData[i][oName['strJnlAbbrev']] ) + "' color='" + tupLineColor[ x] + "' lineThickness = '2' anchorRadius='5' ShowValue='0' alpha='100' showAnchors='1'>" while (oXmlData[i][oName['strJnlAbbrev']] == lstJournalName[x]): if (CompareDates(oXmlData[i][oName['strReportDate']], lstReportDate[y])): strDataSet = strDataSet + "<set value='" + str( oXmlData[i][oName['intDisplayRating']]) + "' />" i = i + 1 #data is valid for this report date so can go to next data record. else: strDataSet = strDataSet + "<set />" y = y + 1 # increase count to get next reporting date if ( i == intRowDataCount ): # reached end of recordset of data stop retreiving anymore data break x = x + 1 #new dataset select next line color y = 0 #new dataset reset to beginining of report dates for graph strDataSet = strDataSet + "</dataset>" if (i == intRowDataCount ): # reached end of recordset of data stop retreiving anymore data break if (x == intRowJnlCount ): # no more journals left in data so do not retreive anymore data break strDataSet = strDataSet + "</graph>" strXml = strXml + strDataSet return strXml
def CreateSatisfactionChart(intLevel,strJnlIssn, strStatementID, intMonths, strReportDate, intCompJnlMinAfp, intCompJnlMinAcrossFBProgs, strDatabaseType, oConn, oConn2, oFile, strLogFileName): strImageFilePath = "../../../images/satisfaction/" blnAverageScore = False strStatementID = "Over" intMonths = 12 oData = GetOverallSatisfactionChartData(strJnlIssn, strStatementID, intMonths, strReportDate, intCompJnlMinAfp, intCompJnlMinAcrossFBProgs, strDatabaseType, oConn2) lstScores = list() lstCompScores = list() lstChartData = list() if (oData != None): intRowCount = len(oData) for i in range(intRowCount): #strTest = str(oData[i][0])+'|'+str(oData[i][1])+'|'+str(oData[i][2])+'|'+str(oData[i][3]) if (oData[i][0] == 3): blnAverageScore = True lstScores.append(oData[i][1]) if (oData[i][0] == 2): lstCompScores.append(oData[i][1]) lstChartData.append([oData[i][0], oData[i][1], oData[i][3]] ) else: lgExceptionLog(6, strJnlIssn, strReportDate, 12, 'EXCEPTION|BarChartSatisfaction', strLogFileName) return None fltMaxScore = max(lstScores) fltMinScore = min(lstScores) x = int(round(((fltMaxScore - fltMinScore) / 5), 0)) + 1 y = int(round(fltMaxScore, 0) + 5 - (int(round(fltMinScore, 0)) % 5)) y1 = y intMaxScore = int(fltMaxScore) intMinScore = int(fltMinScore) maxminusmin = int(round(((fltMaxScore - fltMinScore) / 5) , 0)) + 1 oData = GetOverallSatisfactionChartData(strJnlIssn, strStatementID, intMonths, strReportDate, intCompJnlMinAfp, intCompJnlMinAcrossFBProgs, strDatabaseType, oConn2) oFile.write("<script language='javascript'>\n") oFile.write("\n") oFile.write(" \n") oFile.write(" function positionImg(Order,Position,diff,count)\n") oFile.write(" {\n") oFile.write(" var a,top,x;\n") oFile.write(" a=(240/diff);\n") oFile.write(" \n") oFile.write(" top=a*Position;\n") oFile.write(" if (Order==1)\n") oFile.write(" {\n") oFile.write(" document.getElementById('Img1').style.top=parseInt(document.getElementById('Img1').style.top.substring(0,document.getElementById('Img1').style.top.length-2))+top;\n") oFile.write(" document.getElementById('lbl1').style.top=parseInt(document.getElementById('Img1').style.top.substring(0,document.getElementById('Img1').style.top.length-2))-5;\n") oFile.write(" document.getElementById('lbl1').style.left=110;\n") oFile.write(" }\n") oFile.write(" if (Order==2)\n") oFile.write(" {\n") oFile.write(" x='Img'+count;\n") oFile.write(" document.getElementById(x).style.top=parseInt(document.getElementById(x).style.top.substring(0,document.getElementById(x).style.top.length-2))+top;\n") oFile.write(" document.getElementById('lbl'+count).style.top=parseInt(document.getElementById(x).style.top.substring(0,document.getElementById(x).style.top.length-2))-5;\n") oFile.write(" document.getElementById('lbl'+count).style.left=110;\n") oFile.write(" }\n") oFile.write(" if (Order==3)\n") oFile.write(" {\n") oFile.write(" document.getElementById('Img6').style.top=parseInt(document.getElementById('Img6').style.top.substring(0,document.getElementById('Img6').style.top.length-2))+top;\n") oFile.write(" document.getElementById('Img6').style.left=54;\n") oFile.write(" }\n") oFile.write(" }\n") oFile.write(" \n") oFile.write(" </script>\n") oFile.write("<html >\n") oFile.write("<body >\n") oFile.write("<table height='240' width='240' cellpadding='0' cellspacing='0' >\n") while (y > intMinScore): oFile.write("<tr >\n") oFile.write("<td width='43px' height='<%="+str(240/x)+"%>px' align=right valign=top style='margin-left:0px;border-left:0px;border-right:1px;border-top:0px;border-bottom:0px;border-style:solid;border-color:#000000;'> <font face='Arial' size=2><%=+"+str(y)+"%></font>\n") oFile.write("</td>\n") oFile.write("<td width='197px' height='<%="+str(240/x)+"%>px' style='margin-left:0px;background-color:FFF8C6;border-left:0px;border-right:0px;border-top:1px;border-bottom:0px;border-style:dashed;border-color:#000000;'> \n") oFile.write("</td>\n") oFile.write("</tr>\n") y = y - 5 GraphDiff = y1 - y oFile.write("<% GraphDiff = " + str(GraphDiff) + "%>\n") oFile.write("\n") oFile.write("<tr>\n") oFile.write("<td width='43px' height='<%="+str(240/x)+"%>px' align=right valign=top style='margin-left:0px;border-left:0px;border-right:0px;border-top:0px;border-bottom:0px;border-style:solid;border-color:#000000;'> <font face='Arial' size=2><%="+str(y)+"%></font>\n") oFile.write("</td>\n") oFile.write("<td align=left width='197px' height='<%="+str(240/x)+"%>px' style='margin-left:0px;border-left:0px;border-right:0px;border-top:1px;border-bottom:0px;border-style:dashed;border-color:#000000;'> \n") oFile.write("<img STYLE='top:12px;position:absolute' id='Img1' src='"+strImageFilePath+"1.jpg'>\n") intCount = 2 for x in lstCompScores: oFile.write("<img STYLE='top:12px;position:absolute' id='Img"+str(intCount)+"' src='"+strImageFilePath+str(intCount)+".jpg'>\n") intCount = intCount + 1 intCount = 2 for y in lstChartData: if (y[0] == 1): oFile.write("<label style='position:absolute;white-space: nowrap;' id='lbl1'><font face='Tahoma' size='1.9'>"+str(y[2])+"</font></label>\n") oFile.write("<script language='javascript'>\n") oFile.write("positionImg('1','"+str(y1 - y[1])+"','"+str(GraphDiff)+"','1');\n") oFile.write("</script>\n") if (y[0] == 2): oFile.write("<label style='position:absolute;white-space: nowrap;' id='lbl"+str(intCount)+"'><font face='Tahoma' size='1.9'>"+str(y[2])+"</font></label>\n") oFile.write("<script language='javascript'>\n") oFile.write("positionImg('2','"+str(y1 - y[1])+"','"+str(GraphDiff)+"','"+str(intCount)+"');\n") oFile.write("</script>\n") intCount = intCount + 1 if ((y[0] == 3) and (blnAverageScore == True)): oFile.write(" <script language='javascript'>\n") oFile.write(" positionImg('3','<%=y1-oData("+chr(34)+"intRating"+chr(34)+")%>','<%=GraphDiff%>','1');\n") oFile.write(" </script>\n") oFile.write("</td>\n") oFile.write("</tr>\n") oFile.write("</table>\n") oFile.write("</body>\n") oFile.write("</html>\n") oFile.write("\n") oFile.write("<script language='javascript'>\n") oFile.write("var obj1,obj2\n") oFile.write("for(i=1;i<<%=oData.RecordCount-1%>;i++)\n") oFile.write("{\n") oFile.write(" obj1='lbl'+i;\n") oFile.write(" for(j=i+1;j<<%=oData.RecordCount%>;j++)\n") oFile.write(" {\n") oFile.write(" obj2='lbl'+j;\n") oFile.write(" if(Math.abs(parseInt(document.getElementById(obj1).style.top.substring(0,document.getElementById(obj1).style.top.length-2))-parseInt(document.getElementById(obj2).style.top.substring(0,document.getElementById(obj2).style.top.length-2)))<34)\n") oFile.write(" {\n") oFile.write(" if(document.getElementById(obj1).style.top.substring(0,document.getElementById(obj1).style.top.length-2)<document.getElementById(obj2).style.top.substring(0,document.getElementById(obj2).style.top.length-2))\n") oFile.write(" {\n") oFile.write(" document.getElementById(obj1).style.top=parseInt(document.getElementById(obj1).style.top.substring(0,document.getElementById(obj1).style.top.length-2))-1;\n") oFile.write(" document.getElementById(obj2).style.top=parseInt(document.getElementById(obj2).style.top.substring(0,document.getElementById(obj2).style.top.length-2))+1;\n") oFile.write(" }\n") oFile.write(" else\n") oFile.write(" {\n") oFile.write(" document.getElementById(obj1).style.top=parseInt(document.getElementById(obj1).style.top.substring(0,document.getElementById(obj1).style.top.length-2))+1;\n") oFile.write(" document.getElementById(obj2).style.top=parseInt(document.getElementById(obj2).style.top.substring(0,document.getElementById(obj2).style.top.length-2))-1;\n") oFile.write(" }\n") oFile.write(" }\n") oFile.write(" }\n") oFile.write("}\n") oFile.write("</script>\n")
def GetJnlTabularStatementPublServChartHtml(intLevel, strChartTitle, strJnlIssn, strStatementID, strReportDate, intCompJnlMinAfp, intCompJnlMinAcrossFBProgs, blnHasCompetitors, strCompetitorOrderStatementID, strCompanyName, strAverageIdentifier, strRelativePath, oConn, strLogFileName, blnNatureOfQuery, strPublisherResponseToQueryStatementID, intMonths = None): """ Return the html data for the Journal Tabular Chart Publsihing Services for a specific Elsevier journal and its competitors. For a specific statement, months (reporting period) and Report date. The xml data is for the fusion charts appliction to display the chart. Inputs : strChartTitle, Journal ISSN, StatementID, Months (Report time period), Report data Output : Html data in string format """ oName = GetFieldNames() strHelpDecisionTreeFileName = GetDecisonTreeFileName(strStatementID) strHelpRequiredLink = '' blnCompetitors = False strNatureOfQueryLink = "<a href='#natureofquery'><img border=0 alt='Click here to view chart - Nature of query to publisher' align=right src='"+strRelativePath+"images/naturequery.gif'></a>" strDisplayNatureOfQueryLink = '' strChartHtml = "<table style='table-layout:fixed;' width='100%' border='0' cellspacing='1' cellpadding='0'><tr><th scope='col' class='tableStatementTitle'>"+strChartTitle+"<br />Statements</th>" lstJnlAbbrev = list() oData = GetTabularStatementChartData(intLevel, strJnlIssn, strStatementID, strReportDate, intCompJnlMinAfp, intCompJnlMinAcrossFBProgs, strCompetitorOrderStatementID, strCompanyName, strAverageIdentifier, oConn, intMonths) if (oData != None): intRowCount = len(oData) intFieldCount = len(oData[0]) intNoOfJournals = 0 # Produce html table column information for i in range(intRowCount): lstJnlAbbrev.append(oData[i][oName['strJnlAbbrev']]) if (i == 0): # Elsevier Jnl strOurFormattedTitle = FormatTitle(lstJnlAbbrev[i]) # strChartHtml = strChartHtml + "<th scope='col' class='tableStatementHeaderTop'>"+strOurFormattedTitle+"</th><td class='tableStatementEmptyCol'></td><th scope='col' class='tableStatementOrangeTop'>Diff to Avg</th>" if ((i != 0) and (blnHasCompetitors == True)): #Competition Journals if (lstJnlAbbrev[0] == lstJnlAbbrev[i]): break strFormattedTitle = FormatTitle(lstJnlAbbrev[i]) strChartHtml = strChartHtml + "<td class='tableStatementEmptyCol'></td><th scope='col' class='tableStatementHeaderTop'>"+strFormattedTitle+"</th>" intNoOfJournals = intNoOfJournals + 1 strChartHtml = strChartHtml + "</tr>" # Produce html table row information y = 0 strChartHtml = strChartHtml + "<tr class='tableStatementEmptyRow'></tr>" for x in range(intRowCount): if ((x != 0) and (oData[x][oName['intOrder']] == 1)): strChartHtml = strChartHtml + "</tr>" + "<tr class='tableStatementEmptyRow'></tr>" if (oData[x][oName['intOrder']] == 1): # The row is an Elsevier journal score strSign = '' if (oData[x][oName['intDiffToAll']] > 0): strSign = '+' if (((intLevel != 1) or (intLevel != 2)) and (blnHasCompetitors == True)): if (oData[x][oName['intDiffToAll']] < -oData[x][oName['intSE']]): #Then display link to help sheet strHelpRequiredLink = "<a href='http://nonsolus/rarbestpractice/afp_"+strHelpDecisionTreeFileName+".htm'><img border=0 alt='Click here to view Decision tree' align=right src='"+strRelativePath+"images/dectreesm.gif'></a>" if (blnNatureOfQuery and (oData[x][oName['strQuest']] == strPublisherResponseToQueryStatementID)): strDisplayNatureOfQueryLink = strNatureOfQueryLink strChartHtml = strChartHtml + "<tr><td class='tableStatementHeaderSide'>"+strDisplayNatureOfQueryLink+strHelpRequiredLink+"<a href='#"+str(oData[x][oName['strQuest']])+"'>"+str(oData[x][oName['strQuestDescription']])+"</a></td><td class='tableStatement"+str(oData[x][oName['strColor']])+"'>"+str(int(oData[x][oName['intDisplayRating']]))+"</td><td class='tableStatementEmptyCol'></td><td class='tableStatementOrange'>"+strSign+str(int(oData[x][oName['intDiffToAll']]))+"</td>" strDisplayNatureOfQueryLink = '' else: strChartHtml = strChartHtml + "<td class='tableStatementEmptyCol'></td><td class='tableStatement"+str(oData[x][oName['strColor']])+"'>"+str(int(oData[x][oName['intDisplayRating']]))+"</td>" y = y + 1 strHelpRequiredLink = '' # Close html table information strChartHtml = strChartHtml + "</tr></table>" else: lgExceptionLog(6, strJnlIssn, strReportDate, 12, 'EXCEPTION|TabularStatement', strLogFileName) return None return strChartHtml
def CreateSatisfactionChart(intLevel,strJnlIssn, strStatementID, strReportDate, strCompanyName, strAverageIdentifier, intCompJnlMinAfp, intCompJnlMinAcrossFBProgs, oConn, oConn2, oFile, strLogFileName, intMonths = None): strImageFilePath = "../../../images/satisfaction/" strYaxisTitle = GetOSChartYaxisTitle(intLevel) blnAverageScore = False strAverageScore = '' strScore = '' oData = GetOverallSatisfactionChartData(intLevel, strJnlIssn, strStatementID, strReportDate, intCompJnlMinAfp, intCompJnlMinAcrossFBProgs, strAverageIdentifier, strCompanyName, oConn2, intMonths) lstScores = list() lstCompScores = list() lstChartData = list() if (oData != None): intRowCount = len(oData) for i in range(intRowCount): if (oData[i][0] == 2): lstCompScores.append(oData[i][1]) lstChartData.append([oData[i][0], oData[i][1], oData[i][3]] ) if (oData[i][0] == 3): blnAverageScore = True strAverageScore = str(round(oData[i][1],1)) lstScores.append(oData[i][1]) if (oData[i][0] == 1): decScore = round(oData[i][1],1) strScore = str(round(oData[i][1],1)) else: lgExceptionLog(6, strJnlIssn, strReportDate, 12, 'EXCEPTION|BarChartSatisfaction', strLogFileName) return None fltMaxScore = max(lstScores) fltMinScore = min(lstScores) y = int(int(round(fltMaxScore, 0)) + 5 - (int(round(fltMaxScore, 0)) % 5)) y1 = y intMaxScore = int(math.ceil(fltMaxScore)) intMinScore = int(math.floor(fltMinScore)) intMaxDividedByFive = intMaxScore/5 intMinDividedByFive = intMinScore/5 intMaxScoreModuloFive = intMaxScore % 5 if (intMaxScoreModuloFive != 0 ): intMaxYaxisValue = intMaxDividedByFive*5 + 5 else: intMaxYaxisValue = intMaxDividedByFive*5 intMinYaxisValue = intMinDividedByFive*5 y1 = intMaxYaxisValue y = intMaxYaxisValue intYaxisRange = intMaxYaxisValue - intMinYaxisValue intNoOfChartSections = intYaxisRange/5 x = intNoOfChartSections maxminusmin = int(round(((fltMaxScore - fltMinScore) / 5) , 0)) + 1 oData = GetOverallSatisfactionChartData(intLevel, strJnlIssn, strStatementID, strReportDate, intCompJnlMinAfp, intCompJnlMinAcrossFBProgs, strAverageIdentifier, strCompanyName, oConn2, intMonths) #oFile.write("<html >\n") #oFile.write("<body >\n") oFile.write("<table width=100% cellpadding='0' cellspacing='0'>\n") oFile.write("<th ></th>\n") oFile.write("<th width=50%> </th>\n") oFile.write("<th width=50%> </th>\n") oFile.write("<tr>\n") oFile.write("<td valign=top><br><br><br><br><br><span class="+chr(34)+"verticaltext"+chr(34)+">"+strYaxisTitle+"</span><br></td>") oFile.write("<td style='text:align=right;'>") oFile.write("<table height='240' width='240' cellpadding='0' cellspacing='0' >\n") while (y > intMinScore): oFile.write("<tr >\n") oFile.write("<td width='43px' height='<%="+str(240/x)+"%>px' align=right valign=top style='margin-left:0px;border-left:0px;border-right:1px;border-top:0px;border-bottom:0px;border-style:solid;border-color:#000000;'> <font face='Arial' size=2><%=+"+str(y)+"%></font>\n") oFile.write("</td>\n") oFile.write("<td width='197px' height='<%="+str(240/x)+"%>px' style='margin-left:0px;background-color:FFF8C6;border-left:0px;border-right:0px;border-top:1px;border-bottom:0px;border-style:dashed;border-color:#000000;'> \n") oFile.write("</td>\n") oFile.write("</tr>\n") y = y - 5 GraphDiff = y1 - y if (intNoOfChartSections == 1): intSmallerTdHeight = intNoOfChartSections * 4 else: intSmallerTdHeight = intNoOfChartSections oFile.write("\n") oFile.write("<tr>\n") #oFile.write("<td width='43px' height='<%="+str(240/intSmallerTdHeight)+"%>px' align=right valign=top style='margin-left:0px;border-left:0px;border-right:0px;border-top:0px;border-bottom:0px;border-style:solid;border-color:#000000;'> <font face='Arial' size=2><%="+str(y)+"%></font>\n") #oFile.write("</td>\n") #oFile.write("<td align=left width='197px' height='<%="+str(240/intSmallerTdHeight)+"%>px' style='margin-left:0px;background-color:FFF8C6;border-left:0px;border-right:0px;border-top:1px;border-bottom:0px;border-style:dashed;border-color:#000000;'> \n") oFile.write("<td width='43px' height='1px' align=right valign=top style='margin-left:0px;border-left:0px;border-right:0px;border-top:0px;border-bottom:0px;border-style:solid;border-color:#000000;'> <font face='Arial' size=2><%="+str(y)+"%></font>\n") oFile.write("</td>\n") oFile.write("<td align=left width='197px' height='1px' style='margin-left:0px;background-color:FFF8C6;border-left:0px;border-right:0px;border-top:1px;border-bottom:0px;border-style:dashed;border-color:#000000;'> \n") if (blnAverageScore == True): oFile.write ("<img STYLE='top:6px;position:absolute' id='Img6' src='"+strImageFilePath+"6.gif'>\n") oFile.write("<img STYLE='top:12px;position:absolute' id='Img1' src='"+strImageFilePath+"1.jpg'>\n") intCount = 2 for x in lstCompScores: oFile.write("<img STYLE='top:12px;position:absolute' id='Img"+str(intCount)+"' src='"+strImageFilePath+str(intCount)+".jpg'>\n") intCount = intCount + 1 blnUseAlteredPositions = True lstOriginalScores = list() lstOriginalScores = deepcopy(lstChartData) listTest = list() lstChartDataPositionAdjusted = AdjustScoresAndLabels(y1, decScore, lstChartData) lstChartDataPositionAdjusted = sorted(lstChartDataPositionAdjusted, key=itemgetter(2)) lstOriginalScores = sorted(lstOriginalScores, key=itemgetter(2)) for y in lstOriginalScores: decPositionDiff = y1 - y[1] y.append(float(decPositionDiff)) intCount = 2 #for y in lstChartData: for y,z in map(None,lstOriginalScores, lstChartDataPositionAdjusted): strImageValue = str(y[3]) strLabelValue = str(z[3]) if ((y[0] == 3) and (blnAverageScore == True)): oFile.write(" <script language='javascript'>\n") oFile.write("positionImg('3','"+strImageValue+"', '"+strLabelValue+"', '"+str(GraphDiff)+"','1','"+str(intLevel)+"');\n") oFile.write(" </script>\n") if (y[0] == 1): oFile.write("<label class='SatisfactionLabels' style='position:absolute;white-space: nowrap;' id='lbl1'>"+str(y[2])+"</label>\n") oFile.write("<script language='javascript'>\n") oFile.write("positionImg('1','"+strImageValue+"','"+strLabelValue+"','"+str(GraphDiff)+"','1','"+str(intLevel)+"');\n") oFile.write("</script>\n") if (y[0] == 2): oFile.write("<label class='SatisfactionLabels' style='position:absolute;white-space: nowrap;' id='lbl"+str(intCount)+"'>"+str(y[2])+"</label>\n") oFile.write("<script language='javascript'>\n") oFile.write("positionImg('2','"+strImageValue+"','"+strLabelValue+"','"+str(GraphDiff)+"','"+str(intCount)+"','"+str(intLevel)+"');\n") oFile.write("</script>\n") intCount = intCount + 1 oFile.write("</td>\n") oFile.write("</tr>\n") oFile.write("</table>\n") oFile.write("</td>\n") oFile.write("<td valign="+chr(34)+"top"+chr(34)+" style="+chr(34)+"text-align:center;"+chr(34)+">\n") oFile.write("<br><br><br><br><span class=SatisfactionHeading"+chr(34)+">"+strYaxisTitle+"</span><br>\n") oFile.write("<span class="+chr(34)+"SatisfactionScore"+chr(34)+">"+strScore+"</span>\n") oFile.write("<br><br><br><br>\n") oFile.write("<span class=SatisfactionHeading"+chr(34)+">\n") oFile.write(GetCompText(intLevel)+"</span><br>\n") oFile.write("<span class="+chr(34)+"SatisfactionScore"+chr(34)+">\n") oFile.write(strAverageScore+"\n") oFile.write("</span>\n") oFile.write("</td>\n") oFile.write("</tr>\n") oFile.write("</table>\n") #oFile.write("</body>\n") #oFile.write("</html>\n") oFile.write("\n")
def GetDemographicChartXml(intLevel, strCode, strDemographicChart, strChartType , strReportDate, oConn, strLogFileName): """ Return the data for the Time Series chart for a Journal and its competitors for a specific Statement and Report Date Inputs : Journal ISSN, StatmentID, Months (Report time period), Report data Output : Tuple in the form of a recordset of the chart data or None if no records retrieved """ strCaption = '' intNoOfResponses = GetNoOfDemographicResponses(intLevel, strCode, strDemographicChart , strReportDate, oConn) if (intNoOfResponses == None): intNoOfResponses = 1 oData = GetMaxValueData(intLevel, strCode, strDemographicChart, strReportDate, oConn) intRowCount = len(oData) intMaxValue = 0 intDivLines = 0 intLines = 0 if ((intRowCount == 0) or (intNoOfResponses == 0)): lgExceptionLog(6, strJnlIssn, strReportDate, 12, 'EXCEPTION|Demographic|'+strDemographicChart, strLogFileName) return None if (intRowCount !=0): if (oData[0][0] != None): intValue = int(oData[0][0]) else: intValue = 0 intMaxValue = round((intValue*100/intNoOfResponses)/20)*20 + 20 intDivLines = (intMaxValue/20) - 1 intLines = 0 else: intMaxValue = 80 intDivLines = (intMaxValue/20) - 1 intLines = 0 #Retrieve the Demographic data oData = GetDemographicChartData(intLevel, strCode, strDemographicChart, strReportDate, oConn) strXml = "" if (strChartType =='Bar'): strXml = strXml + "<graph caption='" + strCaption + "' yAxisMinValue='0' yAxisMaxValue='" + str(intMaxValue) + "' animation='0' showvalues='1' shownames='1' showBarShadow='0' showShadow='0' chartLeftMargin='20' chartRightMargin='20' decimalPrecision='0' canvasBgColor='FFE5BD' zeroPlaneAlpha='0' outCnvBaseFont='Verdana' OutCnvBaseFontSize='10' numberSuffix='%25' numdivlines='" + str(intDivLines) + "'>" if (strChartType == 'Pie'): strXml = strXml + "<graph caption='" + strCaption + "' pieRadius='70' animation='0' showvalues='1' shownames='1' showBarShadow='0' showShadow='0' chartLeftMargin='20' chartRightMargin='20' decimalPrecision='0' canvasBgColor='FFE5BD' zeroPlaneAlpha='0' outCnvBaseFont='Verdana' OutCnvBaseFontSize='10' numberSuffix='%25'>" if (oData != None): intRowCount = len(oData) for i in range(intRowCount): intLineColor = GetLineColor(strChartType, intLines) strData = oData[i][0] strData = strData.replace("&","%26") strData = strData.replace("'","") #intData = round(oData[i][1]*100/intNoOfResponses) intData = round(float(oData[i][1])*100/float(intNoOfResponses)) strXml = strXml+"<set name='" + strData+"' value ='"+str(intData)+"' color='"+intLineColor+"' />" intLines = intLines + 1 strXml = strXml+"</graph>" else: strXml = None return strXml