Focal Point
[SOLVED]Stacked Bar Chart

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

December 01, 2009, 11:45 AM
DMA
[SOLVED]Stacked Bar Chart
Hi,

I am trying to graph a stacked bar chart for social media websites (facebook, twitter, myspace, etc.) My fieldname is source and in that field are the names of the websites. I get an error that says "VERTICAL AXIS IS NOT NUMERIC..CAN'T GRAPH".

Any suggestions on how I can go about doing this?

Thanks,
Denise

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


WebFOCUS v. 7.6.8 || Windows XP || Format Output: HTML, PDF, EXCEL
December 01, 2009, 11:58 AM
Danny-SRL
Denise,

What do you want on your X-axis and on your Y-axis?


Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

December 01, 2009, 12:09 PM
DMA
Daniel,

I need to have the stacked bars show all(9) of my websites on the x-axis on a monthly basis, and the current total number of hits to each site on the y-axis.

Thanks,
Denise


WebFOCUS v. 7.6.8 || Windows XP || Format Output: HTML, PDF, EXCEL
December 01, 2009, 12:36 PM
Danny-SRL
Denise,

So, on your X-axis you have MONTH.

On the Y-axis you have 9 fields, representing the websites, each containing the number of hits per month.

But, I understand that you have one field, "SOURCE", with the name of website. So in order to get the values desired you need a preliminary program to count the number of hits, something like:
SET ASNAMES=ON  
TABLE FILE ...
SUM CNT.SOURCE AS WEB
BY MONTH
ACROSS SOURCE
ON TABLE HOLD
END

This will give you a file with 10 fields:
MONTH and WEBname1 ... WEBname9

Ok till now?


Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

December 01, 2009, 02:34 PM
DMA
Daniel,

I should have mentioned earlier that the fileds I'm using are SOURCE, CURRENT_TOTAL, PRIOR_TOTAL, and a DEFINEd field, GMONTH. I need the months on the x-axis and the CURRENT_TOTAL on the y-axis, left side and the PRIOR_TOTAL on the y-axis, right side. All 9 sources stacked on top of each other for each month.

I'm not quite sure how to explain what I need without a drawing. I hope this makes sense.

Denise


WebFOCUS v. 7.6.8 || Windows XP || Format Output: HTML, PDF, EXCEL
December 01, 2009, 08:18 PM
Doug
Go for it... Give it a try... Perhaps a screenshot of a graph created (dare I say) in Excel...




   In FOCUS Since 1983 ~ from FOCUS to WebFOCUS.
   Current: WebFOCUS Administrator at FIS Worldpay | 8204, 8206
December 02, 2009, 05:18 AM
Danny-SRL
Denise,

Things are becoming clearer...
So, for each GMONTH and SOURCE you have 2 values CURRENT_TOTAL and PRIOR_TOTAL.
In order for WebFocus to stack your totals, you will have to:
1. create 2 fields for each SOURCE, one for the CURRENT and one for the PRIOR
2. Create a Dual-Axis stacked graph
3. Change the assignment of the CURRENT fields to one stack and the PRIOR fields to the second stack.

Here is an example using the CAR file.
COUNTRY is your GMONTH
DEALER and RETAIL are the CURRENT and PRIOR
SEATS is the SOURCE

  
SET ASNAMES = ON
-*creating file with DEALER and RETAIL fields for each value of SEATS 
TABLE FILE CAR
SUM
     DEALER_COST AS DEALER
     RETAIL_COST AS RETAIL
BY COUNTRY
ACROSS SEATS
ON TABLE HOLD AS DENISE 
END
GRAPH FILE DENISE
SUM 
RETAIL2
RETAIL4
RETAIL5
DEALER2
DEALER4
DEALER5
ACROSS COUNTRY
ON GRAPH SET LOOKGRAPH VBRSTK2
ON GRAPH SET GRAPHEDIT SERVER
ON GRAPH SET BARNUMB OFF
ON GRAPH SET 3D OFF
ON GRAPH SET VZERO ON
ON GRAPH SET GRID ON
ON GRAPH PCHOLD FORMAT PNG
ON GRAPH SET GRAPHSTYLE *
setMarkerDisplay(true);
setConnectLineMarkers(false);
setConnectScatterMarkers(false);
setO1LabelDisplay(true);
setO1AxisSide(0);
setO1MajorGridDisplay(true);
setO1MajorGridStyle(0);
setO1MinorGridDisplay(false);
-* changed assignments to create 2 stacks
setAxisAssignment(0,0);
setSeriesType(0,1);
setAxisAssignment(1,0);
setSeriesType(1,1);
setAxisAssignment(2,0);
setSeriesType(2,1);
setAxisAssignment(3,1);
setSeriesType(3,1);
setAxisAssignment(4,1);
setSeriesType(4,1);
setAxisAssignment(5,1);
setSeriesType(5,1);
setY1LabelDisplay(true);
setY1AxisSide(0);
setY1MajorGridDisplay(true);
setY1MajorGridStyle(0);
setY1MinorGridDisplay(false);
setTextFormatPreset(getY1Label(),-1);
setTextFormatPattern(getY1Label(),"#.##");
setY2LabelDisplay(true);
setY2AxisSide(1);
setY2MajorGridDisplay(true);
setY2MajorGridStyle(0);
setY2MinorGridDisplay(false);
setTextFormatPreset(getY2Label(),-1);
setTextFormatPattern(getY2Label(),"#.##");
setPieFeelerTextDisplay(1);
setPieLabelDisplay(0);
setTextFormatPreset(getPieSliceLabel(),1);
setRiserBorderMode(1);
setSeriesDefaultTransparentBorderColor(true);
setUseSeriesBorderDefaults(true);
setLegendDisplay(true);
setFontSizeAbsolute(getY1Title(),true);
setFontSizeAbsolute(getY1Label(),true);
setFontSizeAbsolute(getY2Title(),true);
setFontSizeAbsolute(getY2Label(),true);
setFontSizeAbsolute(getO1Title(),true);
setPlace(true);
ENDSTYLE
ON GRAPH SET STYLE *
     SQUEEZE=ON,
     ORIENTATION=PORTRAIT,
$
TYPE=REPORT,
     GRID=OFF,
     FONT='TIMES NEW ROMAN',
     SIZE=10,
$
ENDSTYLE
END


Good luck!


Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

December 02, 2009, 09:25 AM
DMA
Doug,

How can I insert a screenshot image? I'm not allowed to paste images.

Denise


WebFOCUS v. 7.6.8 || Windows XP || Format Output: HTML, PDF, EXCEL
December 02, 2009, 09:40 AM
Danny-SRL
Denise,

Please cut and paste the fex I sent you in DS and run it. See if this is what you expected.


Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

December 02, 2009, 01:35 PM
DMA
Danny, I did the following:

DEFINE FILE METRIC_DATA_REFERRERS
GDATE/MDYY=HDATE(METRIC_DT, 'MDYY');
GMONTH/MtYY=GDATE;
-*
CURR_DELICIOUS/P20C =IF &SOURCE EQ 'delicious' THEN CURRENT_TOTAL ELSE 0;
CURR_DIGG/P20C =IF &SOURCE EQ 'digg' THEN CURRENT_TOTAL ELSE 0;
-*
PRIOR_DELICIOUS/P20C =IF &SOURCE EQ 'delicious' THEN PRIOR_TOTAL ELSE 0;
PRIOR_DIGG/P20C =IF &SOURCE EQ 'digg' THEN PRIOR_TOTAL ELSE 0;
END
-*
TABLE FILE METRIC_DATA_REFERRERS
SUM
CURR_DELICIOUS
CURR_DIGG
PRIOR_DELICIOUS
PRIOR_DIGG
BY GMONTH AS 'Month'
-*
WHERE SOURCE IN (&SOURCE);
WHERE METRIC_DT FROM DT('&ST_DT') TO DT('&END_DT');
ON TABLE HOLD AS SOC_MED_GRAPH
END

GRAPH FILE SOC_MED_GRAPH
SUM
CURR_DELICIOUS
CURR_DIGG
PRIOR_DELICIOUS
PRIOR_DIGG
ACROSS GMONTH AS 'Month'
-*
ON GRAPH SET LOOKGRAPH VBRSTK2
ON GRAPH SET GRAPHEDIT SERVER
ON GRAPH SET BARNUMB OFF
ON GRAPH SET 3D OFF
ON GRAPH SET VZERO ON
ON GRAPH SET GRID ON
ON GRAPH PCHOLD FORMAT PNG
ON GRAPH SET GRAPHSTYLE *

The ouput for the TABLE FILE is correct as long as I choose a specific SOURCE (delicious), except that it's not reading the hold file (ON TABLE HOLD AS SOC_MED_GRAPH).
I get the following so I don't get the graph:
(FOC205) THE DESCRIPTION CANNOT BE FOUND FOR FILE NAMED: SOC_MED_GRAPH
BYPASSING TO END OF COMMAND

When I choose to display all SOURCEs I get the following:
0 ERROR AT OR NEAR LINE 35 IN PROCEDURE social_media_main
(FOC003) THE FIELDNAME IS NOT RECOGNIZED: CURR_DELICIOUS
BYPASSING TO END OF COMMAND
(FOC009) INCOMPLETE REQUEST STATEMENT
(FOC205) THE DESCRIPTION CANNOT BE FOUND FOR FILE NAMED: SOC_MED_GRAPH
BYPASSING TO END OF COMMAND


Any ideas?


WebFOCUS v. 7.6.8 || Windows XP || Format Output: HTML, PDF, EXCEL
December 02, 2009, 02:03 PM
mrguru
In your DEFINE should it read SOURCE EQ and not &SOURCE EQ since it looks like &SOURCE is a filename reference? (WHERE SOURCE IN (&SOURCE))


WF 8.2.01M
8.2.01M Reporting Server
Windows 2012 Srvr R2
PDF,Excel, HTML
Graphs - a lot of graphs
December 02, 2009, 02:23 PM
Danny-SRL
Denise,

What is in &SOURCE ?


Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

December 02, 2009, 02:39 PM
DMA
SOURCE is a field in the table that contains the different social media sites (eg. facebook, myspace, youtube).


WebFOCUS v. 7.6.8 || Windows XP || Format Output: HTML, PDF, EXCEL
December 02, 2009, 02:43 PM
Danny-SRL
quote:
SOURCE is a field in the table that contains the different social media sites (eg. facebook, myspace, youtube)


And, again, what is in &SOURCE?


Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

December 02, 2009, 02:52 PM
DMA
There is a parameter, SOURCE, which allows the user to choose a specific source, such as facebook. Whichever source is chosen is in &SOURCE.


WebFOCUS v. 7.6.8 || Windows XP || Format Output: HTML, PDF, EXCEL
December 02, 2009, 03:23 PM
Danny-SRL
Do we assume, as you said, that the field SOURCE can have up to 9 values?
Do we assume that the user can enter up to 9 values in the variable &SOURCE - e.g. &SOURCE=facebook,myspace,youtube,digg - but you do not know in advance how many?


Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

December 02, 2009, 03:25 PM
mrguru
At the beginning of your fex
-SET &ECHO = ALL;

THEN

-TYPE SOURCE IS &SOURCE

run your fex and look at the value of &SOURCE when you select all. You can then see what other errors may be generated. I suspect your error is in the table request. Try isolating the table request by commenting out the ON TABLE HOLD and puting a -EXIT after the END and see if you get the results you are looking for. Also, in the table request you do not need an AS since you are saving this to a file. If ASNAMES is on then your output file will use that as the field name and not the original(in this case GMONTH).


WF 8.2.01M
8.2.01M Reporting Server
Windows 2012 Srvr R2
PDF,Excel, HTML
Graphs - a lot of graphs
December 02, 2009, 03:31 PM
DMA
Yes, the user will be able to choose mutiple sources.


WebFOCUS v. 7.6.8 || Windows XP || Format Output: HTML, PDF, EXCEL
December 02, 2009, 03:55 PM
mrguru
The way you have your DEFINE written it cannot handle multiple requests. If more than one is selected then the value will always be zero for each defined field. Put single quotes around the variable &SOURCE in your define and that will probably stop generating the errors.


WF 8.2.01M
8.2.01M Reporting Server
Windows 2012 Srvr R2
PDF,Excel, HTML
Graphs - a lot of graphs
December 02, 2009, 04:23 PM
Danny-SRL
Denise,

Try this:
  
DEFINE FILE METRIC_DATA_REFERRERS
GDATE/MDYY=HDATE(METRIC_DT, 'MDYY');
GMONTH/MtYY=GDATE;
-*
-* GETTOK(infield, inlen, token_number, 'delim', outlen, outfield)
-* retrieve each source from the &SOURCE parameter
-*    assumption &SOURCE is of the form  facebook,myspace,youtube,digg 
-SET &I=1;
-#NEXTI
-* isolate one source in &P
-SET &P=GETTOK(&SOURCE, &SOURCE.LENGTH, &I, ',', 15, 'A15');
-IF &P EQ ' ' GOTO #DONE;
-* source within quotes in &Q
-SET &Q='''' | &P || '''';
-* generate CURR and PRIOR for each source
CURR_&P /P20C=IF SOURCE EQ &Q THEN CURRENT_TOTAL ELSE 0;
PRIOR_&P /P20C=IF SOURCE EQ &Q THEN PRIOR_TOTAL ELSE 0;
-SET &I=&I+1;
-GOTO #NEXTI
-#DONE
END
-* save number of input sources
-SET &IMAX=&I-1;
-*
GRAPH FILE METRIC_DATA_REFERRERS
SUM
-* generate all the CURR
-REPEAT #CURR FOR &I FROM 1 TO &IMAX;
CURR_&P
-#CURR
-* generate all the PRIOR
-REPEAT #PRIOR FOR &I FROM 1 TO &IMAX;
PRIOR_&P
-#PRIOR
ACROSS GMONTH AS 'Month'
-*
WHERE SOURCE IN (&SOURCE);
WHERE METRIC_DT FROM DT('&ST_DT') TO DT('&END_DT');
ON GRAPH SET LOOKGRAPH VBRSTK2
ON GRAPH SET GRAPHEDIT SERVER
ON GRAPH SET BARNUMB OFF
ON GRAPH SET 3D OFF
ON GRAPH SET VZERO ON
ON GRAPH SET GRID ON
ON GRAPH PCHOLD FORMAT PNG
ON GRAPH SET GRAPHSTYLE *
setMarkerDisplay(true);
setConnectLineMarkers(false);
setConnectScatterMarkers(false);
setO1LabelDisplay(true);
setO1AxisSide(0);
setO1MajorGridDisplay(true);
setO1MajorGridStyle(0);
setO1MinorGridDisplay(false);
-* create 2 stacks
-* CURR stack
-SET &CMAX=&IMAX - 1;
-REPEAT #ASSIGN0 FOR &I FROM 0 TO &CMAX; 
setAxisAssignment(&I,0);
setSeriesType(&I,1);
-#ASSIGN0
-* PRIOR stack
-SET &PMAX=&IMAX * 2 - 1;
-REPEAT #ASSIGN1 FOR &I FROM &IMAX TO &PMAX; 
setAxisAssignment(&I,1);
setSeriesType(&I,1);
-#ASSIGN1
setY1LabelDisplay(true);
setY1AxisSide(0);
setY1MajorGridDisplay(true);
setY1MajorGridStyle(0);
setY1MinorGridDisplay(false);
setTextFormatPreset(getY1Label(),-1);
setTextFormatPattern(getY1Label(),"#.##");
setY2LabelDisplay(true);
setY2AxisSide(1);
setY2MajorGridDisplay(true);
setY2MajorGridStyle(0);
setY2MinorGridDisplay(false);
setTextFormatPreset(getY2Label(),-1);
setTextFormatPattern(getY2Label(),"#.##");
setPieFeelerTextDisplay(1);
setPieLabelDisplay(0);
setTextFormatPreset(getPieSliceLabel(),1);
setRiserBorderMode(1);
setSeriesDefaultTransparentBorderColor(true);
setUseSeriesBorderDefaults(true);
setLegendDisplay(true);
setFontSizeAbsolute(getY1Title(),true);
setFontSizeAbsolute(getY1Label(),true);
setFontSizeAbsolute(getY2Title(),true);
setFontSizeAbsolute(getY2Label(),true);
setFontSizeAbsolute(getO1Title(),true);
setPlace(true);
ENDSTYLE
ON GRAPH SET STYLE *
     SQUEEZE=ON,
     ORIENTATION=PORTRAIT,
$
TYPE=REPORT,
     GRID=OFF,
     FONT='TIMES NEW ROMAN',
     SIZE=10,
$
ENDSTYLE
END



Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

December 02, 2009, 05:48 PM
Doug
quote:
How can I insert a screenshot image?
Upload it to a website and use the <IMG SRC="(the url for that image)">
in your reply...

Although, it seems that you have you answer... Or, do you?
December 03, 2009, 01:45 AM
Danny-SRL
Denise,

If what I sent you doesn't work and if it is possible, please create a HOLD file, format ALPHA, in which there will be the fields:
GMONTH
SOURCE
CURR_TOTAL
PRIOR_TOTAL

  
TABLE FILE METRIC_DATA_REFERRERS
PRINT GMONTH SOURCE CURR_TOTAL PRIOR_TOTAL
ON TABLE HOLD AS DENISE FORMAT ALPHA
END

Send DENISE.FTM and DENISE.MAS.
You will find my e-mail address on my profile.


Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

December 03, 2009, 11:15 AM
DMA
Thank you all! I really appreciate your help. I took a little bit of everything that was posted and managed to get the desired output. WHOO HOO!


WebFOCUS v. 7.6.8 || Windows XP || Format Output: HTML, PDF, EXCEL