Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Graph. Conditional formation of the lines between the points

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] Graph. Conditional formation of the lines between the points
 Login/Join
 
Member
posted
Hello,

Please give advice with the following issue.
I have a graph with two lines, one is curve and another is constant. I need to apply a conditional styling, so that if the value of the curve line is greater then the constant it would be colored.

This is what yet i have managed to do, but it is not what needed


TABLE FILE CAR
SUM DEALER_COST
COMPUTE TEST/D12.2=10000;
BY CAR
ON TABLE HOLD AS TEMP
END
-RUN

GRAPH FILE TEMP
SUM DEALER_COST
TEST
BY CAR
ON GRAPH PCHOLD FORMAT PNG
ON GRAPH SET HTMLENCODE ON
ON GRAPH SET GRAPHDEFAULT OFF
ON GRAPH SET VZERO OFF
ON GRAPH SET HAXIS 1000
ON GRAPH SET VAXIS 500
ON GRAPH SET UNITS PIXELS
ON GRAPH SET LOOKGRAPH VLINE
ON GRAPH SET GRMERGE ON
ON GRAPH SET GRMULTIGRAPH 0
ON GRAPH SET GRLEGEND 0
ON GRAPH SET GRXAXIS 1
ON GRAPH SET STYLE *
*GRAPH_SCRIPT
setPieDepth(0);
setPieTilt(0);
setDepthRadius(0);
setCurveFitEquationDisplay(false);
setPlace(true);
setPlaceResize(getFrame(),1);

setBorderColor(getSeries(0),new Color(0,128,0));
setBorderColor(getSeries(1),new Color(200,100,50));
setBorderColor(getSeries(2),new Color(255,190,90));
setBorderColor(getSeries(3),new Color(255,230,115));
setBorderColor(getSeries(4),new Color(100,130,190));
setDepthRadius(0);
setMarkerDisplay(false);
setFillColor(getSeries(0),new Color(0,128,0));
setFillColor(getSeries(1),new Color(200,100,50));
setFillColor(getSeries(2),new Color(255,190,90));
setFillColor(getSeries(3),new Color(255,230,115));
setFillColor(getSeries(4),new Color(100,130,190));
setPlaceResize(getFrame(),1);
-* colors of data values for each lines
setFillColor(getDataText(0),new Color(0,128,0));
setFillColor(getDataText(1),new Color(200,100,50));
setFillColor(getDataText(2),new Color(255,190,90));
setFillColor(getDataText(3),new Color(255,230,115));
-* setFillColor(getDataText(3),new Color(100,130,190));

setLineBasicStrokeType(getY1MajorGrid(),0);
setGridStyle(getY1MajorGrid(),1);
setGridStyle(getO1MajorGrid(),false);

setDepthRadius(0);
setDisplay(getReferenceLineY1(0),false);
setTransparentBorderColor(getChartBackground(),true);
setTransparentBorderColor(getFrame(),true);
setGridStyle(getY1MajorGrid(),1);
setDisplay(getY1MinorGrid(),false);
setLineWidth(getY1MajorGrid(),1);
setReportParsingErrors(false);
setSelectionEnableMove(false);
setFontSizeAbsolute(getY1Label(), true);
setFontSizeInPoints(getY1Label(), 8);
-* setFontSizeInPoints(getY1Label(), &VALUE_SIZE);
setPlaceResize(getY1Label(), 0);
-* setTextRotation(getO1Label(),3);
setTextRotation(getO1Label(),1);

setFontSizeAbsolute(getO1Label(), true);
setFontSizeInPoints(getO1Label(), 8);
setPlaceResize(getO1Label(), 0);
setDisplay(getO1Title(),false);

setDisplay(getO1MajorGrid(),false);
setDisplay(getO1MajorTick(),false);
setDisplay(getO1MinorGrid(),false);
setDisplay(getO1MinorTick(),true);
setTickStyle(getO1MinorTick(),1.5);
setLineWidth(getO1MinorTick(),1.5);

-*we need to set the size of the rectangle for the legend area
setLegendReverse(true);
setLegendAutomatic(false);
setRect(getLegendArea(),new Rectangle(-11318,1359,32066,3000));
setLegendPosition(4);
setPlace(true);
-* data labels
setDataTextDisplay (true);
setRemoveDuplicateDataText(true);

-*set font size for values labels
setFontStyle(getDataText(),0);
setFontSizeAbsolute(getDataText(),true);
setAutofit(getDataText(),false);
setFontSizeInPoints(getDataText(),8);
setPlaceResize(getDataText(),0);

-*set font size for O1 labels
setFontSizeAbsolute(getO1Label(), true);
setFontSizeInPoints(getO1Label(), 8);
setPlaceResize(getO1Label(), 0);
-*
setFontSizeAbsolute(getY1Label(), true);
setFontSizeInPoints(getY1Label(), 8);
setPlaceResize(getY1Label(), 0);

setSeriesLineWidthDefault(2);
setDisplay(getY1AxisLine(),true);
setDisplay(getY1MajorGrid(),false);
-*-*set font size for legend;
setFontSizeAbsolute(getLegendText(),true);
setAutofit(getLegendText(),false);
setFontSizeInPoints(getLegendText(),8);
-*setFontSizeInPoints(getLegendText(),5.2);
setPlaceResize(getLegendText(),0);
*END
DEFMACRO=Condition_1, MACTYPE=RULE, WHEN=N2 LT TEST, $
TYPE=DATA, COLUMN=N2, MACRO=Condition_1, COLOR=RGB(255 0 0), $
ENDSTYLE
END



This is how the output look like now


This is how it should be



Please give an advice.

Thank you,
Anton

This message has been edited. Last edited by: <Kathryn Henning>,


WebFOCUS 8.0.08
Windows, All Outputs
 
Posts: 5 | Registered: February 06, 2015Report This Post
<nick z>
posted
Hi,
You can't do this with a Line Chart.
There are 2 options that you can use.
Option 1.
Disconnect Line Markers, which essentially makes it a Scatter chart.
And use conditional styling to color markers above your Reference Line.

Option 2.
Use Stacked Bar chart.
Calculate the difference between your value and the Reference Line.

Here are the examples..
Disconnected Line Markers(Option 1):

GRAPH FILE car
SUM CAR.BODY.DEALER_COST
COMPUTE RefLine/I5=10000 ; NOPRINT
BY CAR.ORIGIN.COUNTRY
ON GRAPH PCHOLD FORMAT PNG
ON GRAPH SET HTMLENCODE ON
ON GRAPH SET GRAPHDEFAULT OFF
ON GRAPH SET ARGRAPHENGIN JSCHART
ON GRAPH SET VZERO OFF
ON GRAPH SET GRMERGE ADVANCED
ON GRAPH SET GRMULTIGRAPH 0
ON GRAPH SET GRLEGEND 0
ON GRAPH SET GRXAXIS 1
ON GRAPH SET LOOKGRAPH VLINE
ON GRAPH SET STYLE *
*GRAPH_SCRIPT

setPieDepth(0);
setPieTilt(0);
setDepthRadius(0); 
setCurveFitEquationDisplay(false); 
setPlace(true); 
setUseSeriesShapes(true);
setMarkerSizeDefault(50); 

*END
DEFMACRO=Condition_1, MACTYPE=RULE, WHEN=N2 GT RefLine, $
TYPE=REPORT, TITLETEXT=&WF_TITLE.QUOTEDSTRING, ORIENTATION=LANDSCAPE, $
TYPE=DATA, COLUMN=N2, MACRO=Condition_1, COLOR=RGB(0 255 0), $
COLUMN=N3, ITEM=1, GRAPH-COMMAND='setReferenceLineValue(getReferenceLineY1(0),$VALUE)', $
*GRAPH_SCRIPT

setReportParsingErrors(false);
setSelectionEnableMove(false);
setConnectLineMarkers(false);
setSeriesType(1,2);
setReferenceTextPosition(getReferenceLineTextY1(0),0);
setDisplay(getReferenceLineY1(0),true);
setBorderColor(getReferenceLineY1(0),new Color(0,0,0));
setFillColor(getReferenceLineTextY1(0),new Color(0,0,0));
setLineWidth(getReferenceLineY1(0),1);
setBorderColor(getReferenceLineY1(0),new Color(255,128,64));
setFillColor(getReferenceLineY1(0),new Color(255,128,64));
setFillColor(getReferenceLineTextY1(0),new Color(255,128,64));
setLineWidth(getReferenceLineY1(0),3);
setLineBasicStrokeType(getReferenceLineY1(0),0);
setTextString(getReferenceLineTextY1(0),"");
setFillColor(getSeries(0),new Color(255,0,0));

*END
ENDSTYLE
END

-RUN




Stacked BAR Chart(Option 2):

 
GRAPH FILE car
SUM COMPUTE RefLine/I5=10000 ; NOPRINT
COMPUTE BELOW_RefLine/D12.2=IF CAR.BODY.DEALER_COST GT 10000 THEN 10000 ELSE CAR.BODY.DEALER_COST ;
COMPUTE ABOVE_RefLine/D12.2=IF CAR.BODY.DEALER_COST GE 10000 THEN ( CAR.BODY.DEALER_COST -10000) ELSE 0;
BY CAR.COMP.CAR
ON GRAPH PCHOLD FORMAT PNG
ON GRAPH SET HTMLENCODE ON
ON GRAPH SET GRAPHDEFAULT OFF
ON GRAPH SET ARGRAPHENGIN JSCHART
ON GRAPH SET VZERO OFF
ON GRAPH SET GRMERGE ADVANCED
ON GRAPH SET GRMULTIGRAPH 0
ON GRAPH SET GRLEGEND 0
ON GRAPH SET GRXAXIS 1
ON GRAPH SET LOOKGRAPH VBRSTK1
ON GRAPH SET STYLE *
*GRAPH_SCRIPT
setPieDepth(0);
setPieTilt(0);
setDepthRadius(0); 
setCurveFitEquationDisplay(false); 
setPlace(true); 
setUseSeriesShapes(true);
setMarkerSizeDefault(50); 
*END
COLUMN=N2, ITEM=1, GRAPH-COMMAND='setReferenceLineValue(getReferenceLineY1(0),$VALUE)', $
*GRAPH_SCRIPT
setReportParsingErrors(false);
setSelectionEnableMove(false);
setReferenceTextPosition(getReferenceLineTextY1(0),0);
setDisplay(getReferenceLineY1(0),true);
setBorderColor(getReferenceLineY1(0),new Color(255,128,64));
setFillColor(getReferenceLineY1(0),new Color(255,128,64));
setFillColor(getReferenceLineTextY1(0),new Color(255,128,64));
setLineWidth(getReferenceLineY1(0),3);
setLineBasicStrokeType(getReferenceLineY1(0),0);
setTextString(getReferenceLineTextY1(0),"");
setFillColor(getSeries(0),new Color(255,0,0));
setFillColor(getSeries(1),new Color(0,255,0));

*END
ENDSTYLE
END

-RUN



Notice that I used Reference Line in both examples.

Hope this helps.

Thanks.
Nick.
 
Report This Post
Member
posted Hide Post
Hello Nick,

Thank you very much for your help.
The Line Markers seems to be a great solution for that problem.

Regards,
Anton


WebFOCUS 8.0.08
Windows, All Outputs
 
Posts: 5 | Registered: February 06, 2015Report This Post
Expert
posted Hide Post
Anton,

One thing to remember on this problem is that the charted points are the pertinent data and the lines are purely connectors - they do not relate to the actual data being presented other that serving to provide a visual guide as to the changing of data plots. Therefore it is not possible to partially colour the connecting lines because they have no salient data value - so not really a problem, more a case of mistaking the relevance of the connecting lines.

This would be true of any charting engine and not just JSCHART or PFJ that are used by WebFOCUS.

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 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
Expert
posted Hide Post
A quick demo to show you that it works in HighCharts:

SET HOLDLIST=PRINTONLY
-RUN

TABLE FILE CAR
SUM
COMPUTE HIGHCHARTS_DATA/A100 = '["' || CAR || '",' || FPRINT(DEALER_COST, 'D10c', 'A14') || '],';

BY CAR NOPRINT
ON TABLE HOLD AS HIGHCHARTS_DATA
END
-RUN

-SET &THRESHOLD = 10000;

-HTMLFORM BEGIN
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />

<title>HighCharts</title>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
<script src="http://code.highcharts.com/highcharts.js"></script>

<script type="text/javascript">

$(document).ready(function() {

    $('#container').highcharts({

        chart: {
        type: "line"
        },
        title: {
            text: 'Dealer Cost by Car'
        },
        plotOptions: {
            line: {
                threshold: !IBI.AMP.THRESHOLD;,
                negativeColor: "#ff0000"
            }
        },
        yAxis: {
            title: {
                text: ''
            },
            plotLines: [{
                value: !IBI.AMP.THRESHOLD;,
                width: 2,
                color: 'orange'
            }]
        },
        xAxis: {
            type: "category"
        },
        series: [
            {
                "index": 0,
                "name": "Dealer Cost",
                "data": [
    !IBI.FIL.HIGHCHARTS_DATA;
                ]
            }
        ]
    })
});

</script>
</head>

<body>

<div id="container" style="width: 600px; height: 400px"></div>

</body>
</html>
-HTMLFORM END




Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Expert
posted Hide Post
You go fishing and you'll always catch at least one Wink

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 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
Member
posted Hide Post
Hello All,

Thank you very much for support!

Unfortunately the code with java scripts causes the script errors. And i suppose it is caused by your system.
So i suppose i will have to leave with Nick's solution.

Thank you,
Anton

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


WebFOCUS 8.0.08
Windows, All Outputs
 
Posts: 5 | Registered: February 06, 2015Report This Post
Master
posted Hide Post
Anton,

I don't know why you need it like this.

But I once made a chart with similar needs. i.e. you need to be able to see where the line is.

What I did is use area's in the background of the graph.

Above the target line ( in this case 0 ) the background was green(ish). Below was red(ish).

This also give direct visual information where your line is.

Perhaps this is acceptable?


_____________________
WF: 8.0.0.9 > going 8.2.0.5
 
Posts: 668 | Location: Veghel, The Netherlands | Registered: February 16, 2010Report This Post
Virtuoso
posted Hide Post
quote:
Originally posted by Anton:
Unfortunately the code with java scripts causes the script errors. And i suppose it is caused by your system.


What script errors would those be? I copy-pasted Francis' code into a fex and it works just fine. The only "errors" I get are about the fact that the jquery site still uses SHA-1 in their certificate.


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 :
 
Posts: 1669 | Location: Enschede, Netherlands | Registered: August 12, 2010Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Graph. Conditional formation of the lines between the points

Copyright © 1996-2020 Information Builders