Focal Point
Data text in a bar graph overlapping onto bars

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

July 31, 2008, 02:45 PM
Michele
Data text in a bar graph overlapping onto bars
I have a bar graph that has percentages that appear alongside the bars because I'm using this code setDataTextPosition(1); What's happening is that the percentages are overlapping onto the bars. I tried moving the text data to the left in the Graph Editor but it won't let me move the data. Any suggestions?

WF 7.1.7 Windows XP 5.1
July 31, 2008, 03:04 PM
Tom Flynn
Hi Michele,

Try this:

  
setDisplay(getDataTextStackedTotalOnTop(), true);
setFillColor(getDataTextStackedTotalOnTop(),new Color(0,0,255));
setDataTextPosition(0);
setTextRotation(getDataTextStackedTotalOnTop(), 0);
setPlace(true);

July 31, 2008, 03:31 PM
Michele
quote:
setDisplay(getDataTextStackedTotalOnTop(), true);
setFillColor(getDataTextStackedTotalOnTop(),new Color(0,0,255));
setDataTextPosition(0);
setTextRotation(getDataTextStackedTotalOnTop(), 0);
setPlace(true);
I tried your suggestion and the data text did move, however the first data text is below the first bar. The 2nd, 3rd and 5th data text is on the bar and the 4th data text is outside the bar graph. Please run the following program against the Car file. Thanks so much.
-* File icr_c15g.fex

APP HOLD ibisamp

-*SET GRAPHENGINE = OLD
-*SET XRETRIEVAL = OFF
-SET &ECHO=ALL;
SET PANEL=346
SET WIDTH=346


-*************************************************************************************************************************
-******* CAR GRAPH IMAGE APPEARING ON THE LEFT-SIDE OF THE REPORT *******
-*************************************************************************************************************************

DEFINE FILE CAR
SORTER/I1 = DECODE CAR (
'JAGUAR' 1
'JENSEN' 2
'TRIUMPH' 3
'DATSUN' 4
'TOYOTA' 5
ELSE 0);
APCT/D8.2% = IF CAR EQ 'JAGUAR' THEN 59.00 ELSE
IF CAR EQ 'JENSEN' THEN 19.00 ELSE
IF CAR EQ 'TRIUMPH' THEN 18.00 ELSE
IF CAR EQ 'DATSUN' THEN 2.00 ELSE
IF CAR EQ 'TOYOTA' THEN 60.00 ELSE 0;
END
GRAPH FILE CAR
PRINT APCT NOPRINT COMPUTE APCTA/D8%=APCT / 100; AS ''
BY SORTER
WHERE SORTER NE 0
ON GRAPH SET LOOKGRAPH HBAR
ON GRAPH SET GRAPHEDIT SERVER
ON GRAPH SET BARNUMB ON
ON GRAPH SET 3D OFF
ON GRAPH SET VZERO ON
ON GRAPH SET GRID OFF
ON GRAPH PCHOLD FORMAT PNG
-*ON GRAPH HOLD AS ICRLGRPH FORMAT SVG
-*ON GRAPH SET VAXIS 220
-*ON GRAPH SET HAXIS 260
ON GRAPH SET GRAPHSTYLE *
setTextFormatPreset(getDataText(0), 2);
setDataTextFormat(2);
setTransparentBorderColor(getFrame(), true);
setAxisAssignment(3,0);
setSeriesType(3,1);
setY1ScaleMaxAuto(true);
setY1MajorGridStepAuto(false);
setGridStep(getY1MajorGrid(),0.10);
setAxisAssignment(2,0);
setSeriesType(2,1);
setRect(getFrame(),new Rectangle(-14715,-7040,24444,17196));
setY1MinorGridStepAuto(false);
setFontSizeAbsolute(getDataText(),true);
setGridStep(getY1MinorGrid(),0.125);
setGridStepAuto(getY1MinorGrid(),true);
setAxisDescending(getY1Axis(),true);
setDataTextAngle(getSeriesGroup(0,0),22);
setGridStep(getY1MinorGrid(),0.5);
setFontStyle(getDataText(),0);
setFontSize(getDataText(),8);
setAutofit(getY1Label(),false);
setAutofit(getDataText(),false);
setDataTextPosition(2);
setO1AxisSide(1);
-*setDataTextAngleDefault(0);
-*setDataTextRadiusDefault(0);
setRiserBarGroupSpacing(100);
setRiserWidth(55);
setFillColor(getSeries(0),new Color(0,0,255));
setFillColor(getSeries(1),new Color(0,0,255));
setFillColor(getSeries(2),new Color(0,0,255));
setFillColor(getSeries(3),new Color(0,0,255));
setFillColor(getSeries(4),new Color(0,0,255));
-*setDataTextAngleDefault(49);
setScaleMax(getY1Axis(),0.7);
-*setDataTextRadiusDefault(22);
-*setDataTextRadius(getSeriesGroup(0,0),0);
setY1AxisSide(0);
setFontSize(getY1Label(),8);
-*setDataTextRadiusDefault(100);
-*setDataTextAngleDefault(150);
setDataTextRadiusDefault(100);
-*setBorderColor(getO1AxisLine(),new Color(223,223,223));
-*setBorderColor(getY1AxisLine(),new Color(212,212,212));
-*setBorderColor(getX1MinorGrid(),new Color(133,133,133));
-*setBorderColor(getY1MinorGrid(),new Color(133,133,133));
setAxisDescending(getY2Axis(),false);
setFillType(getColorByHeight(),2);
setGradientDirection(getColorByHeight(),1);
setGradientNumPins(getColorByHeight(),2);
setGradientPinPosition(getColorByHeight(),0.0,0);
setGradientPinLeftColor(getColorByHeight(),new Color(255,255,255),0);
setGradientPinRightColor(getColorByHeight(),new Color(0,0,255),0);
setGradientPinPosition(getColorByHeight(),1.0,1);
setGradientPinLeftColor(getColorByHeight(),new Color(255,0,0),1);
setGradientPinRightColor(getColorByHeight(),new Color(255,255,255),1);
setLegendMarkerPosition(1);
setMarkerDisplay(false);
setUseSeriesShapes(true);
setConnectLineMarkers(true);
setConnectScatterMarkers(true);
setO1LabelDisplay(false);
setO1MajorGridDisplay(false);
setO1MinorGridDisplay(false);
setAxisAssignment(0,0);
setSeriesType(0,1);
setAxisAssignment(1,1);
setSeriesType(1,1);
setY1LabelDisplay(true);
setY1AxisSide(0);
setY1MajorGridDisplay(false);
setY1MinorGridDisplay(false);
setTextFormatPreset(getY1Label(),2);
setY2LabelDisplay(true);
setY2AxisSide(0);
setY2MajorGridDisplay(true);
setY2MajorGridStyle(0);
setY2MinorGridDisplay(false);
setTextFormatPreset(getY2Label(),-1);
setTextFormatPattern(getY2Label(),"#.##");
setPieFeelerTextDisplay(1);
setPieLabelDisplay(0);
setTextFormatPreset(getPieSliceLabel(),1);
setLegendDisplay(false);
setLegendTextAutofit(true);
setFontSizeAbsolute(getY1Title(),true);
setFontSizeAbsolute(getY1Label(),true);
setFontSize(getY1Label(),8);
-*setFillColor(getY1Label(),new Color(133,133,133));
setFontSizeAbsolute(getY2Title(),true);
setFontSizeAbsolute(getY2Label(),true);
setFontSizeAbsolute(getO1Title(),true);
setFontSizeAbsolute(getO1Label(),true);
setPlace(false);
setY1MajorTickDisplay(true);
setY1MajorTickStyle(3);
-*setY1MAJORGRIDSTYLE(true);
-*setY1MinorGridDisplay(true);
-*setY1MinorGridStyle(3);
-*setY1MinorTickStep(2);
-*setSeriesDefaultTransparentBorderColor(false);
-*setUseSeriesBorderDefaults(false);
setDisplay(getDataTextStackedTotalOnTop(), true);
setFillColor(getDataTextStackedTotalOnTop(),new Color(0,0,255));
setDataTextPosition(0);
setTextRotation(getDataTextStackedTotalOnTop(), 0);
setPlace(true);
ENDSTYLE
ON GRAPH SET STYLE *
PAGESIZE='Letter',
LEFTMARGIN=0.250000,
RIGHTMARGIN=0.250000,
TOPMARGIN=0.250000,
BOTTOMMARGIN=0.250000,
SQUEEZE=ON,
ORIENTATION=LANDSCAPE,
$
TYPE=REPORT,
GRID=OFF,
FONT='TIMES NEW ROMAN',
SIZE=10,
COLOR='WHITE',
BACKCOLOR='WHITE',
STYLE=NORMAL,
RIGHTGAP=0.125000,
$
ENDSTYLE
END
-RUN
July 31, 2008, 03:38 PM
Tom Flynn
Hi Michele,

Take out:

setDataTextPosition(0);

Didn't know it was a horizontal bar HBAR

May not like that look either...

Tom


Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
July 31, 2008, 03:45 PM
Michele
I took out the setDataTextPosition(0), but the data text percentages are still overlapping onto the bars. I don't know if this has something to with my using this set command "setAxisDescending(getY2Axis(),false);" which causes the graph to face towards the left. I'm creating a report that has two graph images at the top, one graph facing towards the left and the other graph facing towards the right. The graph that faces towards the right doesn't have the problem of text data overlapping onto the bars. Any other suggestions? Thanks.
July 31, 2008, 04:44 PM
Tom Flynn
Michele,

Copy the API's from the one facing the right (Y1, I assume) to the one facing the left and change the Y1 to Y2???

Just a thought. Outside of that, all that API code for a simple HBAR Graph? Amazing!!!

I'd start over from scratch, and go 1 step at a time, and, after each change you make, look at the text and see what's being generated.

Have Fun!!!

Tom


Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
August 01, 2008, 08:07 AM
Michele
Tom, great suggestion! It worked. I copied the code from the bar graph facing the right to the bar graph facing the left and added the setAxisDescending(getY1Axis(),true); and setO1AxisSide(1); commands so that the graph and the axis would face to the left. You're right when you stated that it's amazing that a whole lot of code is generated for a simple bar graph. Each time you go into the Graph Editor, it generates a lot of unnecessary code. Thanks again.
August 01, 2008, 08:17 AM
Tom Flynn
Hi Michele,

Glad it worked out for you, PLUS, "YOU" made the appropriate changes to make it work...

GOOD JOB!!!

Tom


Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe