Focal Point
[Case Closed] Graphics: problem positioning data text in two series graph

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

December 16, 2010, 12:15 PM
Dan Satchell
[Case Closed] Graphics: problem positioning data text in two series graph
The example code below, using the CAR file, demonstrates the problem. Normally method "setDataTextPosition" will position data text for the risers in a bar graph. Comment out the COMPUTE for TOT_RATIO below and you will see how the data text values are placed inside of the risers. But when the second graph series (the line graph for TOT_RATIO) is added, this method no longer works properly. Thinking that maybe I needed to specifically identify the series I wanted to control, I experimented with using "get" methods in conjunction with this method (ex.: setDataTextPosition(getSeries(0),4) and setDataTextPosition(getDataText(0),4)), but these attempts only resulted in error messages. Does anyone have other ideas for moving the data text back inside the risers? Thanks.

DEFINE FILE CAR
 CAR_WGT/D6  = IF (CAR LIKE 'A%' OR 'T%') THEN WEIGHT ELSE 0 ;
 CAR_MPG/D6  = IF (CAR LIKE 'A%' OR 'T%') THEN MPG    ELSE 0 ;
END
-*
GRAPH FILE CAR
 SUM
  WEIGHT  NOPRINT
  MPG     NOPRINT
  CAR_WGT NOPRINT
  CAR_MPG NOPRINT
  COMPUTE CAR_RATIO/D6.2 = CAR_MPG / CAR_WGT * 100 ; AS 'A & T Cars'
  COMPUTE TOT_RATIO/D6.2 = MPG / WEIGHT * 100 ; AS 'All Cars'
 ACROSS COUNTRY AS ''
 HEADING
  "Example of Data Text Problem"
-* ON GRAPH SET LOOKGRAPH VBAR
 ON GRAPH SET GRAPHEDIT OFF
 ON GRAPH SET BARNUMB OFF
 ON GRAPH SET 3D OFF
 ON GRAPH SET VZERO ON
 ON GRAPH SET GRID OFF
 ON GRAPH SET VAXIS 400
 ON GRAPH SET HAXIS 1200
 ON GRAPH PCHOLD FORMAT PNG
 ON GRAPH SET GRAPHSTYLE *
-*setGraphType(17);
setViewableSeries(2);
setSeriesType(0,1);
setSeriesType(1,2);
setAxisAssignment(0,0);
setRiserWidth(50);
setLegendPosition(3);
setFillColor(getSeries(0),new Color(255,204,0));
setFillColor(getSeries(1),new Color(0,0,255));
-*
setO1LabelDisplay(true);
setO1MajorGridDisplay(false);
setO1MajorGridStyle(0);
setO1MinorGridDisplay(false);
setO1LabelRotate(3);
setFontSizeAbsolute(getO1Label(),true);
setFontSize(getO1Label(),14);
-*
setY1LabelDisplay(true);
setY1LabelFormat(1)
setY1AxisSide(0);
setY1MajorGridDisplay(true);
setY1MajorGridStyle(0);
setY1MinorGridDisplay(false);
-*
setDataTextDisplay(true);
setDataTextPosition(4);
setDataTextFormat(0);
setDisplay(getDataText(1),false);
setCustomDataText(getSeries(0),true);
-*setTextRotation(getDataText(0),1);
 ENDSTYLE
 ON GRAPH SET STYLE *
  SQUEEZE=ON, ORIENTATION=LANDSCAPE, $
  TYPE=REPORT, GRID=OFF, FONT='TIMES NEW ROMAN', SIZE=10, $
  TYPE=HEADING, SIZE=12, COLOR='WHITE', BACKCOLOR='GRAY', STYLE=BOLD, JUSTIFY=CENTER, $
 ENDSTYLE
END

This message has been edited. Last edited by: Dan Satchell,


WebFOCUS 7.7.05
December 16, 2010, 12:55 PM
Tom Flynn
Hi Dan,

Because your incorporating a Line Graph with the Bar graph, the Line "needs" the middle for display, so the values move above.

Why not use a dual axis, which, does what you want:

  
DEFINE FILE CAR
 CAR_WGT/D6  = IF (CAR LIKE 'A%' OR 'T%') THEN WEIGHT ELSE 0 ;
 CAR_MPG/D6  = IF (CAR LIKE 'A%' OR 'T%') THEN MPG    ELSE 0 ;
END
-*
GRAPH FILE CAR
 SUM
  WEIGHT  NOPRINT
  MPG     NOPRINT
  CAR_WGT NOPRINT
  CAR_MPG NOPRINT
  COMPUTE CAR_RATIO/D6.2 = CAR_MPG / CAR_WGT * 100 ; AS 'A & T Cars'
  COMPUTE TOT_RATIO/D6.2 = MPG / WEIGHT * 100 ; AS 'All Cars'
 ACROSS COUNTRY AS ''
 HEADING
  "Example of Data Text Problem"
-* ON GRAPH SET LOOKGRAPH VBAR
 ON GRAPH SET LOOKGRAPH VBAR2AX
 ON GRAPH SET GRAPHEDIT OFF
 ON GRAPH SET BARNUMB OFF
 ON GRAPH SET 3D OFF
 ON GRAPH SET VZERO ON
 ON GRAPH SET GRID OFF
 ON GRAPH SET VAXIS 400
 ON GRAPH SET HAXIS 1200
 ON GRAPH PCHOLD FORMAT PNG
 ON GRAPH SET GRAPHSTYLE *
-*setGraphType(17);
setViewableSeries(2);
-*setSeriesType(0,1);
-*setSeriesType(1,2);
setAxisAssignment(0,0);
setRiserWidth(50);
setLegendPosition(3);
setFillColor(getSeries(0),new Color(255,204,0));
setFillColor(getSeries(1),new Color(0,0,255));
-*
setO1LabelDisplay(true);
setO1MajorGridDisplay(false);
setO1MajorGridStyle(0);
setO1MinorGridDisplay(false);
setO1LabelRotate(3);
setFontSizeAbsolute(getO1Label(),true);
setFontSize(getO1Label(),14);
-*
setY1LabelDisplay(true);
setY1LabelFormat(1)
setY1AxisSide(0);
setY1MajorGridDisplay(true);
setY1MajorGridStyle(0);
setY1MinorGridDisplay(false);
-*
setDataTextDisplay(true);
setDataTextPosition(4);
setDataTextFormat(0);
-*setDisplay(getDataText(1),false);
setCustomDataText(getSeries(0),true);
-*setTextRotation(getDataText(0),1);
 ENDSTYLE
 ON GRAPH SET STYLE *
  SQUEEZE=ON, ORIENTATION=LANDSCAPE, $
  TYPE=REPORT, GRID=OFF, FONT='TIMES NEW ROMAN', SIZE=10, $
  TYPE=HEADING, SIZE=12, COLOR='WHITE', BACKCOLOR='GRAY', STYLE=BOLD, JUSTIFY=CENTER, $
 ENDSTYLE
END
-EXIT


Dan, you have been an enormous help to quite a few of us; THANKS!!!

Happy Holidays to you and yours!!!

Tom


Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
December 16, 2010, 01:53 PM
Dan Satchell
Tom,

Thank you very much for your input. Unfortunately I am trying to replace some Excel graphs that have been in use for several years. The users are accustomed to seeing their department/section in relation to the overall organization in the manner depicted in my example (organization line graph overlaying department sections as bars). I will probably have an easier time selling the re-positioning or removal of of the data text than the redesign of the graph styles. But ultimately the changes I am allowed to make may depend on just how badly the production staff wants to off-load the manual production of those Excel graphs!

And a big THANK YOU! to you, too, and to the many other contributors who have given freely of their time and knowledge to make this forum the tremendous resource that it is. Best wishes for the holidays and the New Year to one and all.


WebFOCUS 7.7.05
December 21, 2010, 12:35 PM
Dan Satchell
I opened IBI case #63512544 regarding this issue. Here is IBI's response:

quote:
Dan,

I was not able to work around this problem. This looks like a bug, even
in 7.7.01. The good news is that I have tested this in 7.7.02 and this
is no longer a problem. The correct output is displayed.

Sincerely,
Jim



WebFOCUS 7.7.05
January 07, 2011, 11:33 AM
Dan Satchell
IBI has provided a work-around for this specific problem. It is unclear to me why the minor changes made to my original code make a difference, but the code below does move the data values just inside the top of the bar risers. However, using any other setting for method setDataTextPosition() besides "3" results in the data values moving to a position outside and above the risers again. So this is a work-around that only works when the moon and stars are in a certain alignment.


DEFINE FILE CAR
 CAR_WGT/D6 = IF (CAR LIKE 'A%' OR 'T%') THEN WEIGHT ELSE 0 ;
 CAR_MPG/D6 = IF (CAR LIKE 'A%' OR 'T%') THEN MPG    ELSE 0 ;
END
 -*
GRAPH FILE CAR
 SUM
 WEIGHT  NOPRINT
 MPG     NOPRINT
 CAR_WGT NOPRINT
 CAR_MPG NOPRINT
 COMPUTE CAR_RATIO/D6.2 = CAR_MPG / CAR_WGT * 100 ; AS 'A & T Cars'
 COMPUTE TOT_RATIO/D6.2 = MPG / WEIGHT * 100 ; AS 'All Cars'
 ACROSS COUNTRY AS ''
 HEADING
  "Example of Data Text Problem"
 ON GRAPH SET GRAPHEDIT OFF
 ON GRAPH SET BARNUMB OFF
 ON GRAPH SET 3D OFF
 ON GRAPH SET VZERO ON
 ON GRAPH SET GRID OFF
 ON GRAPH SET VAXIS 400
 ON GRAPH SET HAXIS 1200
 ON GRAPH PCHOLD FORMAT PNG
 ON GRAPH SET GRAPHSTYLE *
  setViewableSeries(2);
  setSeriesType(getSeries(0),1);
  setSeriesType(getSeries(1),2);
  setRiserWidth(50);
  setLegendPosition(3);
  setFillColor(getSeries(0),new Color(255,204,0));
  setFillColor(getSeries(1),new Color(0,0,255));
  setPlace(true);
-*
  setO1LabelDisplay(true);
  setO1MajorGridDisplay(false);
  setO1MajorGridStyle(0);
  setO1MinorGridDisplay(false);
  setO1LabelRotate(3);
  setFontSizeAbsolute(getO1Label(),true);
  setFontSize(getO1Label(),14);
-*
  setY1LabelDisplay(true);
  setY1LabelFormat(1)
  setY1AxisSide(0);
  setY1MajorGridDisplay(true);
  setY1MajorGridStyle(0);
  setY1MinorGridDisplay(false);
-*
  setDataTextDisplay(true);
  setDataTextPosition(3);
  setDataTextFormat(0);
  setDisplay(getDataText(1),false);
  setCustomDataText(getSeries(0),true);
 ENDSTYLE
 ON GRAPH SET STYLE *
  SQUEEZE=ON, ORIENTATION=LANDSCAPE, $
  TYPE=REPORT, GRID=OFF, FONT='TIMES NEW ROMAN', SIZE=10, $
  TYPE=HEADING, SIZE=12, COLOR='WHITE', BACKCOLOR='GRAY', STYLE=BOLD,JUSTIFY=CENTER, $
 ENDSTYLE
END



WebFOCUS 7.7.05