mcgrogan40
11-10-2008, 09:09 AM
I have tried to run the following Java Script in Design Studio but cannot get it to work with the ChartComponent. It will work with a report output though! Anyone know why? Parameters are defined in the Java Script window...
**********************************************
***************Java Script**********************
i=0;
while (query_result.getValueAt(i,1) > 0)
{
i++;
}
SsnActual = query_result.getValueAt(i-1,1);
SsnTarget = query_result.getValueAt(i-1,2);
**************************************************
**************Xaction excerpt ***********************
<actions>
<action-definition>
<component-name>SQLLookupRule</component-name>
<action-type>rule</action-type>
<action-inputs>
<Country type="string"/>
</action-inputs>
<action-outputs>
<query-result type="result-set" mapping="query_result"/>
</action-outputs>
<component-definition>
<jndi><![CDATA[mande-jDTS]]></jndi>
<live><![CDATA[true]]></live>
<query><![CDATA[SELECT convert(char(10),wm.date,103) as Date,
CASE WHEN Sum(cherry_received)>0 THEN (select (sum(cherry_received)/1000) from wet_mill_weekly_scorecard where date<=wm.date and left(wm_id,2) in ('{Country}')) ELSE NULL END AS Actual,
(select sum(TARGET/1000) from wet_mill_weekly_scorecard where date<=wm.date and left(wm_id,2)='{Country}') AS Target,
(select (sum(cherry_received)/1000) from wet_mill_weekly_scorecard where date<=wm.date and left(wm_id,2) in ('{Country}'))+(select(sum(target)/1000) from wet_mill_weekly_scorecard where date>(select max(date) from wet_mill_weekly_scorecard where cherry_received>0) and date<=wm.date and left(Wm_id,2) in ('{Country}')) AS Forecast
FROM wet_mill_weekly_scorecard AS wm
WHERE (((Left([wm_id],2)) in ('{Country}')))
GROUP BY wm.date;]]></query>
</component-definition>
</action-definition>
<action-definition>
<component-name>ChartComponent</component-name>
<action-type>Line Chart</action-type>
<action-inputs>
<chart-data type="result-set" mapping="query_result"/>
<Country type="string"/>
</action-inputs>
<action-resources/>
<action-outputs>
<chart-filename type="string"/>
<chart-mapping type="string"/>
<image-tag type="string"/>
</action-outputs>
<component-definition>
<by-row>false</by-row>
<subtitles>
<subtitle>a simple sample</subtitle>
</subtitles>
<title>CHART 1 - Cherry Collection: Total Actual v. Total Target {SsnActual}</title>
<width><![CDATA[700]]></width>
<height><![CDATA[400]]></height>
</component-definition>
</action-definition>
<action-definition>
<component-name>JavascriptRule</component-name>
<action-type>JavaScript</action-type>
<action-inputs>
<Country type="string"/>
<query_result type="result-set"/>
</action-inputs>
<action-outputs>
<SsnActual type="bigdecimal"/>
<SsnTarget type="string"/>
</action-outputs>
<component-definition>
<script><![CDATA[i=0;
while (query_result.getValueAt(i,1) > 0)
{
i++;
}
SsnActual = query_result.getValueAt(i-1,1);
SsnTarget = query_result.getValueAt(i-1,2);]]></script>
</component-definition>
</action-definition>
</actions>
</action-sequence>
**********************************************
***************Java Script**********************
i=0;
while (query_result.getValueAt(i,1) > 0)
{
i++;
}
SsnActual = query_result.getValueAt(i-1,1);
SsnTarget = query_result.getValueAt(i-1,2);
**************************************************
**************Xaction excerpt ***********************
<actions>
<action-definition>
<component-name>SQLLookupRule</component-name>
<action-type>rule</action-type>
<action-inputs>
<Country type="string"/>
</action-inputs>
<action-outputs>
<query-result type="result-set" mapping="query_result"/>
</action-outputs>
<component-definition>
<jndi><![CDATA[mande-jDTS]]></jndi>
<live><![CDATA[true]]></live>
<query><![CDATA[SELECT convert(char(10),wm.date,103) as Date,
CASE WHEN Sum(cherry_received)>0 THEN (select (sum(cherry_received)/1000) from wet_mill_weekly_scorecard where date<=wm.date and left(wm_id,2) in ('{Country}')) ELSE NULL END AS Actual,
(select sum(TARGET/1000) from wet_mill_weekly_scorecard where date<=wm.date and left(wm_id,2)='{Country}') AS Target,
(select (sum(cherry_received)/1000) from wet_mill_weekly_scorecard where date<=wm.date and left(wm_id,2) in ('{Country}'))+(select(sum(target)/1000) from wet_mill_weekly_scorecard where date>(select max(date) from wet_mill_weekly_scorecard where cherry_received>0) and date<=wm.date and left(Wm_id,2) in ('{Country}')) AS Forecast
FROM wet_mill_weekly_scorecard AS wm
WHERE (((Left([wm_id],2)) in ('{Country}')))
GROUP BY wm.date;]]></query>
</component-definition>
</action-definition>
<action-definition>
<component-name>ChartComponent</component-name>
<action-type>Line Chart</action-type>
<action-inputs>
<chart-data type="result-set" mapping="query_result"/>
<Country type="string"/>
</action-inputs>
<action-resources/>
<action-outputs>
<chart-filename type="string"/>
<chart-mapping type="string"/>
<image-tag type="string"/>
</action-outputs>
<component-definition>
<by-row>false</by-row>
<subtitles>
<subtitle>a simple sample</subtitle>
</subtitles>
<title>CHART 1 - Cherry Collection: Total Actual v. Total Target {SsnActual}</title>
<width><![CDATA[700]]></width>
<height><![CDATA[400]]></height>
</component-definition>
</action-definition>
<action-definition>
<component-name>JavascriptRule</component-name>
<action-type>JavaScript</action-type>
<action-inputs>
<Country type="string"/>
<query_result type="result-set"/>
</action-inputs>
<action-outputs>
<SsnActual type="bigdecimal"/>
<SsnTarget type="string"/>
</action-outputs>
<component-definition>
<script><![CDATA[i=0;
while (query_result.getValueAt(i,1) > 0)
{
i++;
}
SsnActual = query_result.getValueAt(i-1,1);
SsnTarget = query_result.getValueAt(i-1,2);]]></script>
</component-definition>
</action-definition>
</actions>
</action-sequence>