Focal Point
[SOLVED] Advanced Graph problem

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

February 16, 2011, 08:29 AM
Wep5622
[SOLVED] Advanced Graph problem
Hello,

I'm having a bit of trouble getting an advanced graph to look a certain way. I've posted about this issue before, but didn't get any useful replies back then, probably because the lack of examples.

The basic issue is that I have - in this case - a number of machines in our factory for which I want to draw graphs of "units produced" per "machine" over time, where time is split in "years" and "months".

I managed to simulate a similar data-set using the finance sample table.
First, let's split the account in two to simulate having separate YEAR and MONTH columns:
DEFINE FILE finance
	DIV/A1 = EDIT(ACCOUNT, '9');
	ACC/A3 = EDIT(ACCOUNT, '$999');
END


Now have a look at this graph:
GRAPH FILE finance
SUM AMOUNT
BY YEAR
BY DIV
BY ACC

ON GRAPH SET LOOKGRAPH VLINE
ON GRAPH SET GRAPHEDIT SERVER
ON GRAPH SET BARNUMB ON
ON GRAPH SET 3D OFF
ON GRAPH SET VZERO ON
ON GRAPH SET GRID ON

ON GRAPH SET GRMERGE ADVANCED
ON GRAPH SET GRMULTIGRAPH 1
ON GRAPH SET GRLEGEND 0
ON GRAPH SET GRXAXIS 2

ON GRAPH PCHOLD FORMAT PNG

END


As you can see, this produces two graphs. Take note of the horizontal axis, which has a comb-line grouping DIV and ACC together - I want to use that for YEAR and MONTH for our machines.

I'd like to merge the two graphs into one, with a separate graph-line for each year. There can be two years, like in the example, but there can be more - in fact, there will be with the passing of time.

I can also do this:
TABLE FILE finance
SUM AMOUNT
ACROSS YEAR
BY DIV
BY ACC
ON TABLE HOLD FORMAT FOCUS INDEX DIV ACC
END

GRAPH FILE HOLD
SUM AMO1982 AS '1982' AMO1983 AS '1983'
BY DIV
BY ACC

ON GRAPH SET LOOKGRAPH VLINE
ON GRAPH SET GRAPHEDIT SERVER
ON GRAPH SET BARNUMB ON
ON GRAPH SET 3D OFF
ON GRAPH SET VZERO ON
ON GRAPH SET GRID ON

ON GRAPH SET GRMERGE ADVANCED
ON GRAPH SET GRMULTIGRAPH 0
ON GRAPH SET GRLEGEND 0
ON GRAPH SET GRXAXIS 2

ON GRAPH PCHOLD FORMAT PNG

END


This has the desired output, but now my years (machines in my actual situation) are hard-coded! Which means I need to change the graph definition every year (or every time a new machine is added in my actual case).

So... How do I get my graph the way it looks in the second example, but without hard-coding machine names (like in the first example)?

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


WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010
: Member of User Group Benelux :
February 16, 2011, 09:42 AM
<FreSte>
Hi Wep,

You can use the FOCUS-hold file for getting the fieldnames (see CHECK FILE ...):

DEFINE FILE FINANCE
	DIV/A1 = EDIT(ACCOUNT, '9');
	ACC/A3 = EDIT(ACCOUNT, '$999');
END


TABLE FILE FINANCE
SUM AMOUNT
ACROSS YEAR
BY DIV
BY ACC
ON TABLE HOLD AS HLD1 FORMAT FOCUS INDEX DIV ACC
END

CHECK FILE HLD1 HOLD AS TMP
TABLE FILE TMP
  PRINT 
    FIELDNAME
  WHERE FIELDNAME CONTAINS 'AMO';
  ON TABLE HOLD AS FLDS FORMAT ALPHA
END
-RUN


GRAPH FILE HLD1
  SUM 
-INCLUDE FLDS
BY DIV
BY ACC

ON GRAPH SET LOOKGRAPH VLINE
ON GRAPH SET GRAPHEDIT SERVER
ON GRAPH SET BARNUMB ON
ON GRAPH SET 3D OFF
ON GRAPH SET VZERO ON
ON GRAPH SET GRID ON

ON GRAPH SET GRMERGE ADVANCED
ON GRAPH SET GRMULTIGRAPH 0
ON GRAPH SET GRLEGEND 0
ON GRAPH SET GRXAXIS 2

ON GRAPH PCHOLD FORMAT PNG

END


-Fred-
February 16, 2011, 10:45 AM
Wep5622
Thanks a lot, I got it working now.


WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010
: Member of User Group Benelux :