Focal Point
[SOLVED] Change order of the X Axis for a Bar Chart

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

August 23, 2010, 07:50 AM
mark66
[SOLVED] Change order of the X Axis for a Bar Chart
Hi all,

Starting to make my first ventures into Graphs and have got stuck quite quickly!

I have a simple table that contains summarised data with the following fields with one record per day of the week:

DAY (Eg MON, TUE, WED,...)
DAY_NO (Eg 1,2,3,...)
ORDERED

For my Bar Chart I was hoping to have the days of the week on the X Axis with the Order Qty on the Y Axis. However if I use the field DAY the chart orders the columns alphabetically, so the columns are in the order FRI, MON, SAT, THU etc.

I was hoping I could set my sort by DAY_NO by DAY and make DAY_NO NOPRINT but I am not having any success.

GRAPH FILE SQLOUT
PRINT SQLOUT.SQLOUT.ORDERED
ACROSS SQLOUT.SQLOUT.DAY 
ON GRAPH SET LOOKGRAPH VBRSTK1
ON GRAPH SET 3D ON
ON GRAPH SET BARNUMB OFF
ON GRAPH SET GRID ON
ON GRAPH SET GRAPHEDIT SERVER
ON GRAPH SET VZERO ON
ON GRAPH SET GRAPHSTYLE *
setSeriesType($0,1);
setSeriesType($1,1);
setSeriesType($2,1);
setLegendDisplay(true);
setLegendMarkerPosition(0);
setMarkerDisplay(true);
setUseSeriesShapes(false);
setConnectLineMarkers(false);
setConnectScatterMarkers(false);
setO1LabelDisplay(true);
setO1AxisSide(0);
setO1MajorGridDisplay(true);
setO1MajorGridStyle(0);
setO1MinorGridDisplay(false);
setY1LabelDisplay(true);
setY1AxisSide(0);
setTextFormatPreset(getY1Label(),1);
setY1MajorGridDisplay(true);
setY1MajorGridStyle(0);
setY1MinorGridDisplay(false);
setFontSize(getO1Label(),12);
setFontSizeAbsolute(getO1Label(),true);
setPlace(true);
ENDSTYLE
END


Any ideas?

Many thanks

Mark

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


WebFocus 765. iSeries v5r4
August 23, 2010, 08:29 AM
Tony A
Mark,

What is the format of your Day field? Is it internal date format, something like Dt? If not, then try that as it should order it the way you need.

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 
August 23, 2010, 08:36 AM
Tom Flynn
I don't see how using your DAY_NO column would not work??? Probably because you are using PRINT instead of SUM:

GRAPH FILE SQLOUT
SUM
SQLOUT.SQLOUT.ORDERED
ACROSS SQLOUT.SQLOUT.DAY_NO NOPRINT
ACROSS SQLOUT.SQLOUT.DAY

This would work also:
DEFINE FILE SQLOUT
  DAY_NUMB/I2 = DECODE DAY (
       'MON' 1
       'TUE' 2
       'WED' 3
       'THU' 4
       'FRI' 5
       'SAT' 6
   ELSE 7);
END
GRAPH FILE SQLOUT
SUM
  SQLOUT.SQLOUT.ORDERED

ACROSS DAY_NUMB NOPRINT
ACROSS SQLOUT.SQLOUT.DAY 



You should SUM not PRINT...

hth

This message has been edited. Last edited by: Tom Flynn,


Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
August 23, 2010, 10:48 AM
mark66
Hi Tom,

Thanks, I have changed my PRINT to SUM but the DAYNO field that I have set to NOPRINT is still appearing on the X Axis and the DAYS label is not showing at all.

I should add that I am currently working on a Webquery project (cut down version of WebFocus), however I would still expect this to work??


WebFocus 765. iSeries v5r4
August 23, 2010, 10:55 AM
Tom Flynn
Hi Mark,

Try this:

GRAPH FILE SQLOUT
SUM
SQLOUT.SQLOUT.ORDERED
BY SQLOUT.SQLOUT.DAY_NO NOPRINT
BY SQLOUT.SQLOUT.DAY


Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
August 23, 2010, 11:01 AM
Tom Flynn
Mark, this works.

I added ON GRAPH SET GRMERGE ON to your style code...
  
APP PREPENDPATH ODS_FINANCE IBISAMP
-RUN
DEFINE FILE GGSALES
  DAY_ENG/A4 = DOWK(DATE, 'A4');
  DAY_NUM/I2 = DECODE DAY_ENG (
       'MON' 1
       'TUE' 2
       'WED' 3
       'THU' 4
       'FRI' 5
       'SAT' 6
   ELSE 7);
END
GRAPH FILE GGSALES
SUM
    DOLLARS/P12.2MC
  BY DAY_NUM NOPRINT
  BY DAY_ENG
ON GRAPH SET LOOKGRAPH VBRSTK1
ON GRAPH SET 3D ON
ON GRAPH SET GRMERGE ON 
ON GRAPH SET BARNUMB OFF
ON GRAPH SET GRID ON
ON GRAPH SET GRAPHEDIT SERVER
ON GRAPH SET VZERO ON
ON GRAPH SET GRAPHSTYLE *
setSeriesType($0,1);
setSeriesType($1,1);
setSeriesType($2,1);
setLegendDisplay(true);
setLegendMarkerPosition(0);
setMarkerDisplay(true);
setUseSeriesShapes(false);
setConnectLineMarkers(false);
setConnectScatterMarkers(false);
setO1LabelDisplay(true);
setO1AxisSide(0);
setO1MajorGridDisplay(true);
setO1MajorGridStyle(0);
setO1MinorGridDisplay(false);
setY1LabelDisplay(true);
setY1AxisSide(0);
setTextFormatPreset(getY1Label(),1);
setY1MajorGridDisplay(true);
setY1MajorGridStyle(0);
setY1MinorGridDisplay(false);
setFontSize(getO1Label(),12);
setFontSizeAbsolute(getO1Label(),true);
setPlace(true);
ENDSTYLE
END
-EXIT



Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
August 23, 2010, 11:47 AM
mark66
Hi Tom,

Excellent! Changing the ACROSS's to BY's and using GRMERGE did it.

Many thanks Smiler


WebFocus 765. iSeries v5r4
August 23, 2010, 12:34 PM
Tom Flynn
Hi Mark,

Welcome, glad it worked for you...

Tom


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