** ** wwwebgraphs.fxp ** SET PROCEDURE TO wwWebGraphs ADDITIVE SET PROCEDURE TO wwUtils ADDITIVE SET PROCEDURE TO wwAPI ADDITIVE RETURN EXTERNAL ARRAY laGraphs, laLabels, laLegend ENDPROC * DEFINE CLASS wwWebGraphs AS Relation ngRaphtype = 0 ccAption = "" ooWc = .NULL. coWcprogid = "OWC10.ChartSpace" cpHysicalpath = "" clOgicalpath = "" niMagetimeout = 300 ciMagename = "" niMagewidth = 750 niMageheight = 480 cbAckcolor = "lightyellow" csEries1color = "darkred" csEries2color = "darkblue" csEries3color = "darkgreen" csEries4color = "orange" csEries5color = "purple" csEries6color = "pink" nMaxColors = 6 nsHowlegend = 1 * FUNCTION Init LPARAMETER llNoexistcheck IF .NOT. llNoexistcheck .AND. .NOT. isComobject(thIs.coWcprogid) RETURN .F. ENDIF thIs.ooWc = CREATEOBJECT(thIs.coWcprogid) IF VARTYPE(thIs.ooWc)<>"O" RETURN .F. ENDIF RETURN ENDFUNC * FUNCTION GraphSetup LOCAL loGraph loGraph = thIs.ooWc.chArts.adD() loGraph.tyPe = thIs.ngRaphtype IF thIs.nsHowlegend>0 loGraph.haSlegend = .T. ENDIF loGraph.plOtarea.inTerior.coLor = thIs.cbAckcolor IF .NOT. EMPTY(thIs.ccAption) thIs.ooWc.haSchartspacetitle = .T. thIs.ooWc.chArtspacetitle.caPtion = thIs.ccAption thIs.ooWc.chArtspacetitle.foNt.boLd = .T. ENDIF RETURN loGraph ENDFUNC * PROCEDURE ShowGraphFromCursor LOCAL x, y, loGraph, lnFields, lnRows, lnSeries, lcElement, lcArray, lnx, ocOnst lnFields = AFIELDS(laFields, ALIAS()) lnRows = RECCOUNT() lnSeries = lnFields-1 DIMENSION laLabels[lnRows] FOR x = 1 TO lnSeries lcArray = "DIMENSION laValues"+TRANSFORM(x)+"["+ ; TRANSFORM(lnRows)+"]" &lcArray ENDFOR x = 0 SCAN x = x+1 laLabels[x] = TRIM(EVALUATE(FIELD(2))) FOR y = 1 TO lnSeries lcElement = "laValues"+TRANSFORM(y)+"["+TRANSFORM(x)+"]" &lcElement = EVALUATE(FIELD(y+1)) ENDFOR ENDSCAN ocOnst = thIs.ooWc.coNstants loGraph = thIs.grAphsetup() lnx = 0 FOR x = 1 TO lnSeries loGraph.seRiescollection.adD() loSeries = loGraph.seRiescollection(x-1) lnx = lnx + 1 IF .NOT. INLIST(thIs.ngRaphtype, 18, 19, 58, 59) IF lnx > this.nMaxColors && 6 culori maxim lnx = 1 ENDIF loSeries.inTerior.coLor = EVALUATE("THIS.cSeries"+ ; TRANSFORM(lnx)+"Color") ELSE IF x>1 EXIT ENDIF ENDIF lcArray = "@laValues"+TRANSFORM(x) loSeries.caPtion = PROPER(STRTRAN(TRIM(laFields(x+1,1)), "_", " ")) loSeries.seTdata(ocOnst.chDimcategories,ocOnst.chDataliteral, ; @laLabels) loSeries.SetData(oConst.chDimValues, oConst.chDataLiteral, &lcArray) ENDFOR ENDPROC * PROCEDURE ShowGraphFromArray LPARAMETER laLabels, laSeries1, lcSeries1, laSeries2, lcSeries2, ; laSeries3, lcSeries3, laSeries4, lcSeries4, laSeries5, ; lcSeries5, laSeries6, lcSeries6 LOCAL x, loGraph, lnSeries, lcArray, lcLabel lnSeries = (PCOUNT()-1)/2 loGraph = thIs.grAphsetup() ocOnst = thIs.ooWc.coNstants FOR x = 1 TO lnSeries loGraph.seRiescollection.adD() IF .NOT. INLIST(thIs.ngRaphtype, 18, 19) loGraph.seRiescollection(x-1).inTerior.coLor = ; EVALUATE("THIS.cSeries"+ ; TRANSFORM(x)+"Color") ENDIF lcArray = "@laSeries"+TRANSFORM(x) lcLabel = EVALUATE("lcSeries"+TRANSFORM(x)) loGraph.seRiescollection(x-1).caPtion = lcLabel loGraph.seRiescollection(x-1).seTdata(ocOnst.chDimcategories, ; ocOnst.chDataliteral,@laLabels) loGraph.SeriesCollection(x-1).SetData(oConst.chDimValues, oConst.chDataLiteral, &lcArray) ENDFOR ENDPROC * PROCEDURE ShowGraphFromMultiDimensionalArray LPARAMETER laGraphs, laLegend LOCAL loGraph, lnSeries, lnRows, llLegend, x, y lnSeries = ALEN(laGraphs, 2)-1 lnRows = ALEN(laGraphs, 1) loGraph = thIs.grAphsetup() IF TYPE('ALEN(laLegend)')="N" llLegend = .T. ELSE llLegend = .F. loGraph.haSlegend = .F. ENDIF ocOnst = thIs.ooWc.coNstants DIMENSION laLabels[lnRows] FOR y = 1 TO lnRows laLabels[y] = laGraphs(y,1) ENDFOR FOR x = 2 TO lnSeries+1 loGraph.seRiescollection.adD() IF .NOT. INLIST(thIs.ngRaphtype, 18, 19) loGraph.seRiescollection(x-2).inTerior.coLor = ; EVALUATE("THIS.cSeries"+ ; TRANSFORM(x)+"Color") ENDIF DIMENSION laArray[lnRows] FOR y = 1 TO lnRows laArray[y] = laGraphs(y,x) ENDFOR IF llLegend loGraph.seRiescollection(x-2).caPtion = laLegend(x-1) ENDIF loGraph.seRiescollection(x-2).seTdata(ocOnst.chDimcategories, ; ocOnst.chDataliteral,@laLabels) loGraph.seRiescollection(x-2).seTdata(ocOnst.chDimvalues, ; ocOnst.chDataliteral,@laArray) ENDFOR ENDPROC * FUNCTION GetOutput thIs.seTgraphicsoptions(thIs.ooWc.chArts(0)) deLetefiles(thIs.cpHysicalpath+"IMG*.gif",thIs.niMagetimeout) thIs.ciMagename = "IMG"+SYS(2015)+TRANSFORM(apPlication.prOcessid)+".gif" thIs.ooWc.exPortpicture(thIs.cpHysicalpath+thIs.ciMagename,"gif", ; thIs.niMagewidth,thIs.niMageheight) RETURN '' ENDFUNC * PROCEDURE Clear thIs.ooWc.clEar() ENDPROC * FUNCTION ShowGraphInForm LPARAMETER lcFormcaption LOCAL loForm, as, foRm loForm = CREATEOBJECT("GraphForm") loForm.adDobject("oPicture","image") loForm.heIght = thIs.niMageheight loForm.wiDth = thIs.niMagewidth loForm.auTocenter = .T. IF .NOT. EMPTY(lcFormcaption) loForm.caPtion = lcFormcaption ENDIF loForm.opIcture.leFt = 0 loForm.opIcture.toP = 0 loForm.opIcture.heIght = thIs.niMageheight loForm.opIcture.wiDth = thIs.niMagewidth loForm.opIcture.piCture = thIs.cpHysicalpath+thIs.ciMagename loForm.opIcture.viSible = .T. loForm.shOw() RETURN loForm ENDFUNC * PROCEDURE GetGraphTypes LPARAMETER lcCursorname IF EMPTY(lcCursorname) lcCursorname = "wwWebGraphTypes" ENDIF CREATE CURSOR (lcCursorname) (naMe C (80), id I) TEXT TO lcVar #define chChartTypeColumnClustered 0 #define chChartTypeColumnStacked 1 #define chChartTypeColumnStacked100 2 #define chChartTypeBarClustered 3 #define chChartTypeBarStacked 4 #define chChartTypeBarStacked100 5 #define chChartTypeLine 6 #define chChartTypeLineStacked 8 #define chChartTypeLineStacked100 10 #define chChartTypeLineMarkers 7 #define chChartTypeLineStackedMarkers 9 #define chChartTypeLineStacked100Markers 11 #define chChartTypeSmoothLine 12 #define chChartTypeSmoothLineStacked 14 #define chChartTypeSmoothLineStacked100 16 #define chChartTypeSmoothLineMarkers 13 #define chChartTypeSmoothLineStackedMarkers 15 #define chChartTypeSmoothLineStacked100Markers 17 #define chChartTypePie 18 #define chChartTypePieExploded 19 #define chChartTypePieStacked 20 #define chChartTypeScatterMarkers 21 #define chChartTypeScatterLine 25 #define chChartTypeScatterLineMarkers 24 #define chChartTypeScatterLineFilled 26 #define chChartTypeScatterSmoothLine 23 #define chChartTypeScatterSmoothLineMarkers 22 #define chChartTypeBubble 27 #define chChartTypeBubbleLine 28 #define chChartTypeArea 29 #define chChartTypeAreaStacked 30 #define chChartTypeAreaStacked100 31 #define chChartTypeDoughnut 32 #define chChartTypeDoughnutExploded 33 #define chChartTypeRadarLine 34 #define chChartTypeRadarLineMarkers 35 #define chChartTypeRadarLineFilled 36 #define chChartTypeRadarSmoothLine 37 #define chChartTypeRadarSmoothLineMarkers 38 #define chChartTypeStockHLC 39 #define chChartTypeStockOHLC 40 #define chChartTypePolarMarkers 41 #define chChartTypePolarLine 42 #define chChartTypePolarLineMarkers 43 #define chChartTypePolarSmoothLine 44 #define chChartTypePolarSmoothLineMarkers 45 #define chChartTypeColumn3D 46 #define chChartTypeColumnClustered3D 47 #define chChartTypeColumnStacked3D 48 #define chChartTypeColumnStacked1003D 49 #define chChartTypeBar3D 50 #define chChartTypeBarClustered3D 51 #define chChartTypeBarStacked3D 52 #define chChartTypeBarStacked1003D 53 #define chChartTypeLine3D 54 #define chChartTypeLineOverlapped3D 55 #define chChartTypeLineStacked3D 56 #define chChartTypeLineStacked1003D 57 #define chChartTypePie3D 58 #define chChartTypePieExploded3D 59 #define chChartTypeArea3D 60 #define chChartTypeAreaOverlapped3D 61 #define chChartTypeAreaStacked3D 62 #define chChartTypeAreaStacked1003D 63 ENDTEXT lnLines = ALINES(laLines, lcVar) FOR x = 1 TO lnLines lcValue = exTract(laLines(x)," ",CHR(13), ,.T.) INSERT INTO (lcCursorname) (naMe, id) VALUES ; (exTract(laLines(x),"#define "," "), VAL(lcValue)) ENDFOR REPLACE naMe WITH STRTRAN(naMe, "chChartType", "") ALL ENDPROC * PROCEDURE SetGraphicsOptions LPARAMETER loChart RETURN ENDPROC * PROCEDURE nGraphType_Assign LPARAMETER lvGraphtype IF VARTYPE(lvGraphtype)="N" thIs.ngRaphtype = lvGraphtype RETURN ENDIF IF VARTYPE(lvGraphtype)="C" lvGraphtype = UPPER(lvGraphtype) DO CASE CASE lvGraphtype="BAR3D" thIs.ngRaphtype = 50 CASE lvGraphtype="BAR" thIs.ngRaphtype = 0 CASE lvGraphtype="PIE3D" thIs.ngRaphtype = 58 CASE lvGraphtype="PIE" thIs.ngRaphtype = 18 CASE lvGraphtype="PIEEXPLODED3D" thIs.ngRaphtype = 59 CASE lvGraphtype="PIEEXPLODED" thIs.ngRaphtype = 19 CASE lvGraphtype="COLUMN3D" thIs.ngRaphtype = 51 CASE lvGraphtype="COLUMN" thIs.ngRaphtype = 3 CASE lvGraphtype="LINE3D" thIs.ngRaphtype = 54 CASE lvGraphtype="LINEPOINTS" thIs.ngRaphtype = 7 CASE lvGraphtype="LINE" thIs.ngRaphtype = 6 ENDCASE ENDIF ENDPROC * ENDDEFINE * DEFINE CLASS GraphForm AS Form shOwwindow = 2 caPtion = "Graph Results" maXbutton = .F. boRderstyle = 2 ENDDEFINE * FUNCTION IsCOMObject LPARAMETER lcProgid, lcClassid, lcClassdescript IF EMPTY(lcProgid) RETURN .F. ENDIF loApi = CREATEOBJECT("wwAPI") lcClassid = loApi.reAdregistrystring(-2147483648,lcProgid+"\CLSID","") IF ISNULL(lcClassid) lcClassid = "" lcClassdescription = "" RETURN .F. ENDIF lcClassdescript = loApi.reAdregistrystring(-2147483648,lcProgid,"") IF ISNULL(lcClassdescript) lcClassdescript = "" ENDIF RETURN .T. ENDFUNC FUNCTION DeleteFiles PARAMETER lcFilespec, lnTimeout PRIVATE lnX, lnFiles, loApi lnTimeout = IIF(EMPTY(lnTimeout), 300, lnTimeout) lnFiles = ADIR(laFiles, lcFilespec) FOR lnX = 1 TO lnFiles ldTime = CTOT(DTOC(laFiles(lnX,3))+" "+laFiles(lnX,4)) IF ldTime+lnTimeout