nbaig
05-17-2006, 07:49 AM
Hi There,
I have simple interface which shows account information (no, name, profit & loss and risk limit). Risk limit is that amount which account can can lose max.
I also have method which changed background color of Profit & Loss (Green with positive and Red with negative amount).
When loss becomes more than risk limit I want to change the background color of Risk Limit. I tried to get the P & L in the column for Risk Limit, but I am unable to get it.
Can anyone help me to write a method in which I can change the background color of Risk Limit column when it becomes less than Profit & Loss.
Here is my code:
-------------------------------------------------
<canvas bgcolor="#EAEAEA" width="900" height="600" debug="true">
<bluestyle name="bluecolors"/>
<dataset name="accountsInfo" request="true" type="http" src="http://../../create_accountsinfo_xml.php"/>"/>
<constantlayout axis="x" value="20"/>
<simplelayout axis="y" inset="30" spacing="60"/>
<class name="polling">
<attribute name="datasetName" type="string"/>
<attribute name="rate" value="60"/>
<method event="oninit">
this.pollDelegate = new LzDelegate (this, 'pollDataSource');
LzTimer.addTimer(this.pollDelegate, rate*1000);
</method>
<method name="pollDataSource">
canvas.datasets[datasetName].doRequest();
LzTimer.resetTimer(this.pollDelegate, rate*1000);
</method>
</class>
<view id="mainview" layout="axis:x; spacing:20">
<polling rate="6" datasetName="accountsInfo"/>
<method name="changebgcolor" args="txtObj,flag2">
<![CDATA[
var abc=txtObj.text;
if(flag2 == 1)
{
if(abc < 0)
txtObj.setAttribute("bgcolor","16711680");
else
txtObj.setAttribute("bgcolor","32768");
}
if(flag2==2)
{
if(abc < 0)
txtObj.setAttribute("bgcolor","16711935");
else
txtObj.setAttribute("bgcolor","8421376");
}
if(flag2==3)
{
if(abc != 0)
txtObj.setAttribute("bgcolor","65535");
else
txtObj.setAttribute("bgcolor","32896");
}
]]>
</method>
<view layout="axis:y; spacing:10">
<grid id="accountgrid" style="bluecolors" height = "100%" datapath="accountsInfo:/resultset" />
<gridcolumn width="30" resizable="false"> <b>No.</b>
<text> <datapath xpath="position()" replication="lazy"/> </text>
</gridcolumn>
<gridcolumn width="180" resizable="false"> <b> Account No </b>
<text> <datapath xpath="@accountnumber" replication="lazy"/> </text>
</gridcolumn>
<gridcolumn width="70" resizable="false"> <b> Name </b>
<text> <datapath xpath="@name" replication="lazy"/> </text>
</gridcolumn>
<gridcolumn width="70" resizable="false"> <b> Profit & Loss </b>
<text> <datapath xpath="@profitnloss" replication="lazy"/>
<method event="ontext" >
mainview.changebgcolor(this,1);
</method>
</text>
</gridcolumn>
<gridcolumn width="60" resizable="false"> <b> Risk Limit </b>
<text> <datapath xpath="@risklimit" replication="lazy"/>
<!-- If Risk Limit is less than Profit and Loss
then change the background color -->
<method event="ontext" >
</method>
</text>
</gridcolumn>
</grid>
</view>
</view>
</canvas>
--------------------------------------------------
I really appreciate your help.
NBaig
I have simple interface which shows account information (no, name, profit & loss and risk limit). Risk limit is that amount which account can can lose max.
I also have method which changed background color of Profit & Loss (Green with positive and Red with negative amount).
When loss becomes more than risk limit I want to change the background color of Risk Limit. I tried to get the P & L in the column for Risk Limit, but I am unable to get it.
Can anyone help me to write a method in which I can change the background color of Risk Limit column when it becomes less than Profit & Loss.
Here is my code:
-------------------------------------------------
<canvas bgcolor="#EAEAEA" width="900" height="600" debug="true">
<bluestyle name="bluecolors"/>
<dataset name="accountsInfo" request="true" type="http" src="http://../../create_accountsinfo_xml.php"/>"/>
<constantlayout axis="x" value="20"/>
<simplelayout axis="y" inset="30" spacing="60"/>
<class name="polling">
<attribute name="datasetName" type="string"/>
<attribute name="rate" value="60"/>
<method event="oninit">
this.pollDelegate = new LzDelegate (this, 'pollDataSource');
LzTimer.addTimer(this.pollDelegate, rate*1000);
</method>
<method name="pollDataSource">
canvas.datasets[datasetName].doRequest();
LzTimer.resetTimer(this.pollDelegate, rate*1000);
</method>
</class>
<view id="mainview" layout="axis:x; spacing:20">
<polling rate="6" datasetName="accountsInfo"/>
<method name="changebgcolor" args="txtObj,flag2">
<![CDATA[
var abc=txtObj.text;
if(flag2 == 1)
{
if(abc < 0)
txtObj.setAttribute("bgcolor","16711680");
else
txtObj.setAttribute("bgcolor","32768");
}
if(flag2==2)
{
if(abc < 0)
txtObj.setAttribute("bgcolor","16711935");
else
txtObj.setAttribute("bgcolor","8421376");
}
if(flag2==3)
{
if(abc != 0)
txtObj.setAttribute("bgcolor","65535");
else
txtObj.setAttribute("bgcolor","32896");
}
]]>
</method>
<view layout="axis:y; spacing:10">
<grid id="accountgrid" style="bluecolors" height = "100%" datapath="accountsInfo:/resultset" />
<gridcolumn width="30" resizable="false"> <b>No.</b>
<text> <datapath xpath="position()" replication="lazy"/> </text>
</gridcolumn>
<gridcolumn width="180" resizable="false"> <b> Account No </b>
<text> <datapath xpath="@accountnumber" replication="lazy"/> </text>
</gridcolumn>
<gridcolumn width="70" resizable="false"> <b> Name </b>
<text> <datapath xpath="@name" replication="lazy"/> </text>
</gridcolumn>
<gridcolumn width="70" resizable="false"> <b> Profit & Loss </b>
<text> <datapath xpath="@profitnloss" replication="lazy"/>
<method event="ontext" >
mainview.changebgcolor(this,1);
</method>
</text>
</gridcolumn>
<gridcolumn width="60" resizable="false"> <b> Risk Limit </b>
<text> <datapath xpath="@risklimit" replication="lazy"/>
<!-- If Risk Limit is less than Profit and Loss
then change the background color -->
<method event="ontext" >
</method>
</text>
</gridcolumn>
</grid>
</view>
</view>
</canvas>
--------------------------------------------------
I really appreciate your help.
NBaig