Focal Point
[SOLVED] Dynamic Bands in Gauge Chart - Format GIF or PNG

This topic can be found at:
http://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/6947019096

November 08, 2018, 03:22 PM
YY
[SOLVED] Dynamic Bands in Gauge Chart - Format GIF or PNG
Hi,

I am trying to make a gauge chart that shows current sales, 1st target and 2nd target. The min/max values of each band are calculated using the total sales and therefore, are dynamic.

I was able to do it using the scripts below but the format is JSCHART. I'd like to make it as an image (png/gif...) Does anyone know how to do it?

-*Use Car as an example: BTW The scripts is running well in App Studio but returns an error message in info assistant and I don't know why...

SET HOLDLIST=PRINTONLY
TABLE FILE CAR
SUM SALES
COMPUTE 1ST_TARGET/I10=TOT.SALES * 1.15;
COMPUTE 2ND_TARGET/I10=1ST_TARGET * 1.15;
BY COUNTRY
WHERE COUNTRY EQ 'ENGLAND';
ON TABLE HOLD AS A1
END
-RUN

TABLE FILE A1
SUM A1.A1.1ST_TARGET NOPRINT
COMPUTE REDMAX/I10=C1/3;
COMPUTE YELLOWMIN/I10=C1/3*2;
COMPUTE YELLOWMAX/I10=C1;
COMPUTE DARKGREENMIN/I10=C1*1.15;
COMPUTE DARKGREENMAX/I10=C1*1.33;
ON TABLE HOLD AS VALUES FORMAT ALPHA
PRINT *
END
-RUN
-READ VALUES &REDMAX.A10 &YELLOWMIN.A10.&YELLOWMAX.A10.&DARKGREENMIN.A10.&DARKGREENMAX.A10.

GRAPH FILE CAR
SUM SALES
COMPUTE 1ST_TARGET/I10=TOT.SALES * 1.15;
COMPUTE 2ND_TARGET/I10=1ST_TARGET * 1.15;
BY COUNTRY
WHERE COUNTRY EQ 'ENGLAND';
ON GRAPH PCHOLD FORMAT JSCHART
ON GRAPH SET VZERO OFF
ON GRAPH SET HTMLENCODE ON
ON GRAPH SET GRMERGE ADVANCED
ON GRAPH SET GRMULTIGRAPH 0
ON GRAPH SET GRLEGEND 0
ON GRAPH SET GRXAXIS 1
ON GRAPH SET LOOKGRAPH GAUGE1
ON GRAPH SET AUTOFIT ON
ON GRAPH SET STYLE *
*GRAPH_SCRIPT
setPieDepth(0);
setPieTilt(0);
setDepthRadius(0);
setCurveFitEquationDisplay(false);
setPlace(true);
*END
INCLUDE=IBFS:/FILE/IBI_HTML_DIR/javaassist/intl/EN/ENIADefault_combine.sty,$
TYPE=REPORT, TITLETEXT=&WF_TITLE.QUOTEDSTRING, $
*GRAPH_SCRIPT
setReportParsingErrors(false);
setSelectionEnableMove(false);
setY1ExcludeMaxLabel(true);
setPlace(true);
setGaugeBackgroundStyle(6);
setGaugeStopAngle(0.0);
setGaugeSizeMode(false);
setGaugeStartAngle(180.0);
setTransparentFillColor(getFrame(),true);
setTextFormatPreset(getY1Label(),0);
setFillColor(getSeries(0),new Color(255,128,0));
setFillColor(getSeries(1), new Color(187,0,187,38));
setFillColor(getSeries(2), new Color(187,0,187,38));
setGaugeMinorTickRelativeTickLength(0.02);
setGaugeMajorTickRelativeTickLength(0.06);
setGaugeNeedleStyle(0);

*GRAPH_JS
"series": [{"series": 0,"color": "orange"},
{"series": 1,"marker": {"shape": "house","border": {"color": "purple","width": 1},"size": 12},"color": "purple"},
{"series": 2,"marker": {"shape": "house","border": {"color": "purple","width": 1},"size": 12},"color": "purple"} ],
"yaxis": {"min": 0,"colorBands":
[{"stop": &REDMAX.EVAL,"color": "red","start": 0},
{"stop": &YELLOWMIN.EVAL,"color": "orange","start": &REDMAX.EVAL},
{"stop": &YELLOWMAX.EVAL,"color": "yellow","start": &YELLOWMIN.EVAL},
{"stop": &DARKGREENMIN.EVAL,"color": "lightgreen","start": &YELLOWMAX.EVAL},
{"stop": &DARKGREENMAX.EVAL,"color": "green","start": &DARKGREENMIN.EVAL}],
"max": &DARKGREENMAX.EVAL},
"gaugeProperties":
{"totalLabel": {"visible": false},
"axisWidth": "8%",
"outerBorder": {"fill": {"color": "grey"},"width": 18,"border": {"color":"white","width": 20}},
"startAngle": 180,
"endAngle": 0,
"needleBase": {"color": "white","border": {"color": "orange", "width": 3},"size": 6},"groupLabel": {"visible": false},"secondaryNeedlesAsMarkers": true},
*END

ENDSTYLE
END
-RUN

This message has been edited. Last edited by: FP Mod Chuck,
November 08, 2018, 03:24 PM
YY
Thanks in advance! Smiler
November 09, 2018, 03:30 AM
Tony A
quote:
the format is JSCHART. I'd like to make it as an image (png/gif...) Does anyone know how to do it?

JSCHART is HTML and JavaScript which, as you've found out, only result in your chart when using FORMAT JSCHART.

If you were to change the format to an image format then the code that would be used would be the PFJ (Perspective for Java) engine which would result in a different looking chart.

You could use PhantomJS - as has been mentioned before in other posts. Unfortunately, this is too involved for this forum Frowner

Your code, saved within App Studio, runs perfectly OK in InfoAssist.


T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
November 09, 2018, 04:19 PM
YY
Hi Tony,

Thanks a lot for your reply!


I tried with InfoAssist 8.1.09 and it worked but with 8.2.03 it asked me to put values in parameters "&REDMAX.A10 &YELLOWMIN.A10.&YELLOWMAX.A10.&DARKGREENMIN.A10.&DARKGREENMAX.A10.". It seems the "-Read Values" does not work very well.


I also tried to call values from database to define band starts and band ends. I almost got the gauge chart I need. The only problem is that the ScaleMax is a bit smaller than the value I defined. I will post the sample codes using car data later.

Best,
November 12, 2018, 07:33 AM
MartinY
And if you try with the following, is that look better and make any differences under 8.2.0.3 ?
-DEFAULTH &REDMAX = 0
-DEFAULTH &YELLOWMIN = 0
-DEFAULTH &YELLOWMAX = 0
-DEFAULTH &DARKGREENMIN = 0
-DEFAULTH &DARKGREENMAX = 0
TABLE FILE A1
SUM A1.A1.1ST_TARGET NOPRINT
    COMPUTE REDMAX/I10=C1/3;
    COMPUTE YELLOWMIN/I10=C1/3*2;
    COMPUTE YELLOWMAX/I10=C1;
    COMPUTE DARKGREENMIN/I10=C1*1.15;
    COMPUTE DARKGREENMAX/I10=C1*1.33;
ON TABLE HOLD AS VALUES
END
-RUN
-READFILE VALUES
-RUN



WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007