Focal Point
[SOLVED] Add Multiple Annotation

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

February 26, 2019, 10:29 AM
Addy
[SOLVED] Add Multiple Annotation
Hello All,
I have a dual axis graph with Bars and Lines.

I dont want to display the legends for Lines, just the Bar. I was checking some options and using annotations looks like the best option.
The challenge I am facing is how to add multiple annotations on the same garph.
Have a look at the below code, should give you an idea of what I am trying to do.

 
ENGINE INT CACHE SET ON
SET PAGE-NUM=NOLEAD
SET ARGRAPHENGINE=JSCHART
SET EMBEDHEADING=ON
SET GRAPHDEFAULT=OFF
-DEFAULTH &WF_STYLE_UNITS='PIXELS';
-DEFAULTH &WF_STYLE_HEIGHT='405.0';
-DEFAULTH &WF_STYLE_WIDTH='770.0';
-DEFAULTH &WF_TITLE='WebFOCUS Report';
GRAPH FILE ggsales
-* Created by Info Assist for Graph
SUM GGSALES.SALES01.DOLLARS
GGSALES.SALES01.BUDDOLLARS
PCT.GGSALES.SALES01.DOLLARS
PCT.GGSALES.SALES01.BUDDOLLARS
BY GGSALES.SALES01.ST
ON GRAPH PCHOLD FORMAT JSCHART
ON GRAPH SET VZERO OFF
ON GRAPH SET GRWIDTH 1
ON GRAPH SET AUTOFIT ON
ON GRAPH SET UNITS &WF_STYLE_UNITS
ON GRAPH SET HAXIS &WF_STYLE_WIDTH
ON GRAPH SET VAXIS &WF_STYLE_HEIGHT
ON GRAPH SET LOOKGRAPH BAR
ON GRAPH SET AUTOFIT ON
ON GRAPH SET STYLE *
*GRAPH_SCRIPT
setPieDepth(0);
setPieTilt(0);
setDepthRadius(0);
setPlace(true);
setCurveFitEquationDisplay(false);
*END
INCLUDE=IBFS:/FILE/IBI_HTML_DIR/ibi_themes/Target.sty,$
TYPE=REPORT, TITLETEXT=&WF_TITLE.QUOTEDSTRING, $
TYPE=DATA, COLUMN=N1, BUCKET=x-axis, $
TYPE=DATA, COLUMN=N2, BUCKET=y-axis(1), $
TYPE=DATA, COLUMN=N3, BUCKET=y-axis(1), $
TYPE=DATA, COLUMN=N4, BUCKET=y-axis(2), $
TYPE=DATA, COLUMN=N5, BUCKET=y-axis(2), $
*GRAPH_SCRIPT
setReportParsingErrors(false);
setSelectionEnableMove(false);
setSeriesType(2,2);
setSeriesType(3,2);
*GRAPH_JS_FINAL
"pieProperties": {
    "holeSize": "0%"
},
"agnosticSettings": {
    "dual": true,
    "chartTypeFullName": "Bar_Clustered_Dual_Axis"
},

"legend": {"visible":false},
"annotations": [{
"position": {
"x": "10%",
"y": "98%",
"parent": "background"},
"marker": {"visible": true, "color": "blue",
"shape": "fiveStar", "rotation": 0,
"border": {"width": 1, "color": "black", "dash": ""}},
"label": {"visible": true, "text": "Series annotation",
"font": "10pt Times New Roman", "color": "black", "position":
"right"}
}]
*END
ENDSTYLE
END
-RUN
 

This message has been edited. Last edited by: Addy,


WF 8.2.04
Windows/Unix
All Formats
In Focus since 2006
February 27, 2019, 04:24 AM
Tony A
You might be over thinking this Addy, try -

"legend": {maxEntries: 2}, 


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 
February 27, 2019, 06:48 AM
Addy
quote:
Originally posted by Tony A:
You might be over thinking this Addy, try -

"legend": {maxEntries: 2}, 


T


Hi Tony,
Sorry for a misleading example. My code is similar to the one below.
I want to display only the Bar Legends hide Line legends.
when checked the forum, someone suggested using annotations might be a solution, and it works.
Problem is how to add multiple annotations. If there is a workaround or some other approach more than happy to implement it.


 ENGINE INT CACHE SET ON
SET PAGE-NUM=NOLEAD
SET ARGRAPHENGINE=JSCHART
SET EMBEDHEADING=ON
SET GRAPHDEFAULT=OFF
-DEFAULTH &WF_STYLE_UNITS='PIXELS';
-DEFAULTH &WF_STYLE_HEIGHT='405.0';
-DEFAULTH &WF_STYLE_WIDTH='770.0';
-DEFAULTH &WF_TITLE='WebFOCUS Report';
GRAPH FILE ggsales
-* Created by Info Assist for Graph
SUM GGSALES.SALES01.DOLLARS
PCT.GGSALES.SALES01.BUDDOLLARS
BY GGSALES.SALES01.PRODUCT
BY GGSALES.SALES01.REGION
WHERE GGSALES.SALES01.PRODUCT EQ 'Capuccino' OR 'Espresso';
ON GRAPH PCHOLD FORMAT JSCHART
ON GRAPH SET VZERO OFF
ON GRAPH SET GRWIDTH 1
ON GRAPH SET UNITS &WF_STYLE_UNITS
ON GRAPH SET HAXIS &WF_STYLE_WIDTH
ON GRAPH SET VAXIS &WF_STYLE_HEIGHT
ON GRAPH SET LOOKGRAPH BAR
ON GRAPH SET AUTOFIT ON
ON GRAPH SET STYLE *
*GRAPH_SCRIPT
setPieDepth(0);
setPieTilt(0);
setDepthRadius(0);
setPlace(true);
setCurveFitEquationDisplay(false);
*END
INCLUDE=IBFS:/FILE/IBI_HTML_DIR/ibi_themes/warm.sty,$
TYPE=REPORT, TITLETEXT=&WF_TITLE.QUOTEDSTRING, $
TYPE=DATA, COLUMN=N1, BUCKET=color, $
TYPE=DATA, COLUMN=N2, BUCKET=x-axis, $
TYPE=DATA, COLUMN=N3, BUCKET=y-axis(1), $
TYPE=DATA, COLUMN=N4, BUCKET=y-axis(2), $
*GRAPH_SCRIPT
setReportParsingErrors(false);
setSelectionEnableMove(false);
setSeriesType(1,2);
setSeriesType(3,2);
setMarkerShape(getSeries(3),3);
setMarkerShape(getSeries(1),2);
*GRAPH_JS_FINAL
"pieProperties": {
    "holeSize": "0%"
},
"agnosticSettings": {
    "dual": true,
    "chartTypeFullName": "Bar_Clustered_Dual_Axis"
},
"annotations": [{
"position": {
"x": "10%",
"y": "98%",
"parent": "background"},
"marker": {"visible": true, "color": "blue",
"shape": "fiveStar", "rotation": 0,
"border": {"width": 1, "color": "black", "dash": ""}},
"label": {"visible": true, "text": "Series annotation",
"font": "10pt Times New Roman", "color": "black", "position":
"right"}
}]
*END
ENDSTYLE
END
-RUN 



WF 8.2.04
Windows/Unix
All Formats
In Focus since 2006
February 27, 2019, 07:12 AM
Tony A
quote:
I want to display only the Bar Legends hide Line legends.


Not misleading I think, I was suggesting that you do not have to resort to using annotations as there is a perfecty simple method of achieving just 2 entries within the legend (providing your measures are in the right order).

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 
February 27, 2019, 07:51 AM
Tony A
However, if you really want to go to the multiple annotations then you just need to extend the array of annotations. You already have the code, you just need to add another annotation to your array -

"annotations": [{
"position": {
"x": "10%",
"y": "98%",
"parent": "background"},
"marker": {"visible": true, "color": "blue",
"shape": "fiveStar", "rotation": 0,
"border": {"width": 1, "color": "black", "dash": ""}},
"label": {"visible": true, "text": "Series annotation",
"font": "10pt Times New Roman", "color": "black", "position":
"right"}
},
{
"position": {
"x": "20%",
"y": "98%",
"parent": "background"},
"marker": {"visible": true, "color": "red",
"shape": "fiveStar", "rotation": 0,
"border": {"width": 1, "color": "black", "dash": ""}},
"label": {"visible": true, "text": "Series annotation",
"font": "10pt Times New Roman", "color": "green", "position":
"right"}
}]


See documentation at this link

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 
February 27, 2019, 08:32 AM
Addy
Thansk Tony,
I tried this earlier but it just got replaced by the second value.
I am sure i must have missed something as your solution is working as expected.


WF 8.2.04
Windows/Unix
All Formats
In Focus since 2006