Focal Point
[closed] Manual Legend - Graph

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

January 05, 2015, 02:29 PM
Enigma006
[closed] Manual Legend - Graph
Hello

I have a customized bar graph with colors based on year.

Is there a way to manually display legend with customizations to text, marker type etc.?
I used below code but no legend is displayed
setFontName(getLegendText(),"SansSerif");
setFontSizeAbsolute(getLegendText(),true);
setFontSizeInPoints(getLegendText(),10);
setPlaceResize(getLegendText(),0);
setFontStyle(getLegendText(),2);
setLegendSeriesStart(1);
setTextString(getLegendLabel(0),"2015");
setDisplay(getLegendLabel(0),true);
setTextString(getLegendLabel(1),"2014");
setDisplay(getLegendLabel(1),true);
setTextString(getLegendLabel(2),"2013");
setDisplay(getLegendLabel(2),true);
setTextString(getLegendLabel(3),"2012");
setDisplay(getLegendLabel(3),true);
setMarkerShape(getLegendLabelMarker(0),1);
setMarkerShape(getLegendLabelMarker(1),1);
setMarkerShape(getLegendLabelMarker(2),1);
setMarkerShape(getLegendLabelMarker(3),1);
setFillColor(getLegendLabelMarker(0),new Color(115,115,115));
setFillColor(getLegendLabelMarker(1),new Color(243,93,19));
setFillColor(getLegendLabelMarker(2),new Color(130,184,201));
setFillColor(getLegendLabelMarker(3),new Color(168 182 124));


Please suggest.

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


8.1.05
HTML,PDF,EXL2K, Active, All
January 05, 2015, 02:56 PM
Francis Mariani
You may need to include one or both of these as well:

setLegendAutomatic(false);             // Turn off legend automatic setting
setLegendDisplay(true);                // Turn onlegend



Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
January 05, 2015, 03:16 PM
Enigma006
quote:
Originally posted by Francis Mariani:
You may need to include one or both of these as well:

setLegendAutomatic(false);             // Turn off legend automatic setting
setLegendDisplay(true);                // Turn onlegend


Franics

It tried but it doesn't work. Below is the graph code. I have all legend code at the end.
ON GRAPH PCHOLD FORMAT PNG
ON GRAPH SET HTMLENCODE ON
ON GRAPH SET GRAPHDEFAULT OFF
ON GRAPH SET VZERO OFF
ON GRAPH SET HAXIS 900
ON GRAPH SET VAXIS 600
ON GRAPH SET UNITS PIXELS
ON GRAPH SET LOOKGRAPH VBAR
ON GRAPH SET GRMERGE ON
ON GRAPH SET GRMULTIGRAPH 0
ON GRAPH SET GRLEGEND 0
ON GRAPH SET GRXAXIS 1
ON GRAPH SET GRAPHSTYLE *
setTemplateFile("/images/tdg/template/IBISouthWestern.txt");
setReportParsingErrors(false);
setSelectionEnableMove(false);
setTransparentBorderColor(getChartBackground(),true);
setTransparentBorderColor(getAllSeries(),true);
setPlace(true);
setDepthRadius(0);
setDepthAngle(0);
setTransparentBorderColor(getFrame(),true);
setTransparentFillColor(getFrame(),true);
setDisplay(getDataText(),true);
setFontSizeAbsolute(getDataText(),true);
setFontSizeInPoints(getDataText(),10);
setPlaceResize(getDataText(),0);


setConnectLineMarkers(true);
setMarkerDisplay(false);


-* START COLORS
-REPEAT :YR1 FOR &SRS1 FROM 0 TO 11 STEP 1
setFontSizeAbsolute(getLegendText(), true);
setFontSizeInPoints(getLegendText(), 10);
setPlaceResize(getLegendText(), 0);
setFontStyle(getLegendText(),2);
setFillColor(getSeries(&SRS1),new Color(70,70,70));
-:YR1
-REPEAT :YR2 FOR &SRS2 FROM 12 TO 23 STEP 1
setFillColor(getSeries(&SRS2),new Color(248,93,19));
-:YR2
-SET &LUPEND = 23 + &CURRMO;
-REPEAT :YR3 FOR &SRS3 FROM 24 TO &LUPEND STEP 1
setFillColor(getSeries(&SRS3),new Color(130,184,201));
-:YR3
-SET &AVGBAR = &LUPEND+1;
-SET &AVGBARZ=&LUPEND+2;
-REPEAT :AVGS FOR &AV FROM &AVGBAR TO &AVGBARZ STEP 1
setFillColor(getSeries(&AV),new Color(168,182,124));
-:AVGS
-*-END COLORS


-* LEGEND CODE

setLegendAutomatic(false);
setLegendDisplay(true);
setFontName(getLegendText(),"SansSerif");
setFontSizeAbsolute(getLegendText(),true);
setFontSizeInPoints(getLegendText(),10);
setPlaceResize(getLegendText(),0);
setFontStyle(getLegendText(),2);
-*setLegendSeriesStart(1);
setTextString(getLegendLabel(0),"2015");
setDisplay(getLegendLabel(0),true);
setTextString(getLegendLabel(1),"2014");
setDisplay(getLegendLabel(1),true);
setTextString(getLegendLabel(2),"2013");
setDisplay(getLegendLabel(2),true);
setTextString(getLegendLabel(3),"2012");
setDisplay(getLegendLabel(3),true);
setMarkerShape(getLegendLabelMarker(0),1);
setMarkerShape(getLegendLabelMarker(1),1);
setMarkerShape(getLegendLabelMarker(2),1);
setMarkerShape(getLegendLabelMarker(3),1);
setFillColor(getLegendLabelMarker(0),new Color(70,70,70));
setFillColor(getLegendLabelMarker(1),new Color(248,93,19));
setFillColor(getLegendLabelMarker(2),new Color(130,184,201));
setFillColor(getLegendLabelMarker(3),new Color(168 182 124));

ENDSTYLE

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


8.1.05
HTML,PDF,EXL2K, Active, All
January 05, 2015, 05:45 PM
Francis Mariani
Us developers (not users) like having some reproducible code to play with.

I've created a program that anyone with the CAR file can run. I've left your graph style pretty much intact. The code does produce a graph with the legend.

GRAPH FILE CAR
SUM 
LENGTH
WIDTH
HEIGHT

WHEELBASE
FUEL_CAP
BHP

MPG
ACCEL

ACROSS BODYTYPE

ON GRAPH PCHOLD FORMAT PNG
ON GRAPH SET HTMLENCODE ON
ON GRAPH SET GRAPHDEFAULT OFF
ON GRAPH SET VZERO OFF
ON GRAPH SET HAXIS 900
ON GRAPH SET VAXIS 600
ON GRAPH SET UNITS PIXELS
ON GRAPH SET LOOKGRAPH VBAR
ON GRAPH SET GRMERGE ON
ON GRAPH SET GRMULTIGRAPH 0
ON GRAPH SET GRLEGEND 0
ON GRAPH SET GRXAXIS 1
ON GRAPH SET GRAPHSTYLE *

setTemplateFile("/images/tdg/template/IBISouthWestern.txt");
setReportParsingErrors(false);
setSelectionEnableMove(false);
setTransparentBorderColor(getChartBackground(),true);
setTransparentBorderColor(getAllSeries(),true);
setPlace(true);
setDepthRadius(0);
setDepthAngle(0);
setTransparentBorderColor(getFrame(),true);
setTransparentFillColor(getFrame(),true);
setDisplay(getDataText(),true);
setFontSizeAbsolute(getDataText(),true);
setFontSizeInPoints(getDataText(),10);
setPlaceResize(getDataText(),0);

setConnectLineMarkers(true);
setMarkerDisplay(false);

-* START COLORS
setFontSizeAbsolute(getLegendText(), true);
setFontSizeInPoints(getLegendText(), 10);
setPlaceResize(getLegendText(), 0);
setFontStyle(getLegendText(),2);

-REPEAT :YR1 FOR &SRS1 FROM 0 TO 2 STEP 1
setFillColor(getSeries(&SRS1),new Color(70,70,70));
-:YR1

-REPEAT :YR2 FOR &SRS2 FROM 3 TO 5 STEP 1
setFillColor(getSeries(&SRS2),new Color(248,93,19));
-:YR2

-*-SET &LUPEND = 23 + &CURRMO;
-SET &LUPEND = 6;
-REPEAT :YR3 FOR &SRS3 FROM 6 TO &LUPEND STEP 1
setFillColor(getSeries(&SRS3),new Color(130,184,201));
-:YR3

-SET &AVGBAR = &LUPEND+1;
-SET &AVGBARZ=&LUPEND+2;
-REPEAT :AVGS FOR &AV FROM &AVGBAR TO &AVGBARZ STEP 1
setFillColor(getSeries(&AV),new Color(168,182,124));
-:AVGS
-* END COLORS


-* LEGEND CODE

setFontName(getLegendText(),"SansSerif");
setPlaceResize(getLegendText(),0);
setFontSizeAbsolute(getLegendText(), true);
setFontSizeInPoints(getLegendText(), 10);

setFontStyle(getLegendText(),2);
setLegendSeriesStart(1);
setTextString(getLegendLabel(0),"2015");
setDisplay(getLegendLabel(0),true);
setTextString(getLegendLabel(1),"2014");
setDisplay(getLegendLabel(1),true);
setTextString(getLegendLabel(2),"2013");
setDisplay(getLegendLabel(2),true);
setTextString(getLegendLabel(3),"2012");
setDisplay(getLegendLabel(3),true);
setMarkerShape(getLegendLabelMarker(0),1);
setMarkerShape(getLegendLabelMarker(1),1);
setMarkerShape(getLegendLabelMarker(2),1);
setMarkerShape(getLegendLabelMarker(3),1);
setFillColor(getLegendLabelMarker(0),new Color(70,70,70));
setFillColor(getLegendLabelMarker(1),new Color(248,93,19));
setFillColor(getLegendLabelMarker(2),new Color(130,184,201));
setFillColor(getLegendLabelMarker(3),new Color(168 182 124));
ENDSTYLE
END




Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
January 05, 2015, 05:46 PM
Francis Mariani
You may need to view the source of your graph to see if any error/warning messages were generated.


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server