Discussions
Categories
Choose a Product
THRUST SERVICES
CORE APPS
CE PRODUCTS
...
Quick Links
POPULAR
HELPFUL TIPS
Groups
My Links
FOR SIGNED IN MEMBERS:
Back to website
Home
Designing Analytics Reports
Scripted area chart shading using embedded images
Migrateduser
Hi,
I am trying to script started area chart fills such that I get the desired pattern in the fill area for each type. Currently using the series palette, I do not ahve control over the pattern selected.
I am able to script the legend part correctly, but for some reason, the area fill on the chart doesnt work.
Here is the script.
==============================================
Before Factory Method
//Set green pattern as a persistant variable
var myimg =reportContext.getDesignHandle().getAllImages().get(0);
var tt = Base64.encodeBase64(myimg.getData());
var mydt = new String( tt, "UTF-8" );
reportContext.setPersistentGlobalVariable("greenPattern", mydt);
//Set Red Pattern as a persistent variable
var myimgr =reportContext.getDesignHandle().getAllImages().get(1);
var ttr = Base64.encodeBase64(myimgr.getData());
var mydtr = new String( ttr, "UTF-8" );
reportContext.setPersistentGlobalVariable("redPattern", mydtr);
//Set Grey Pattern as a persistent variable
var myimgg =reportContext.getDesignHandle().getAllImages().get(2);
var ttg = Base64.encodeBase64(myimgg.getData());
var mydtg = new String( ttg, "UTF-8" );
reportContext.setPersistentGlobalVariable("greyPattern", mydtg);
===============================================================
function beforeDrawLegendItem( lerh, bounds, icsc ) //This works!!!!!!!!!!!!!!!!!!!!
{
System.out.println("lerh.getLabel().getCaption().getValue():"+lerh.getLabel().getCaption().getValue());
var rc = icsc.getExternalContext().getScriptable();
if (lerh.getFill().getClass().isAssignableFrom(EmbeddedImageImpl)){ // PGVs set in beforeFactory
if (lerh.getLabel().getCaption().getValue() == "Goal Achieved"){
lerh.getFill().setData(rc.getPersistentGlobalVariable("greenPattern"));
}else if (lerh.getLabel().getCaption().getValue() == "Goal Not Achieved"){
lerh.getFill().setData(rc.getPersistentGlobalVariable("redPattern"));
}else {
lerh.getFill().setData(rc.getPersistentGlobalVariable("greyPattern"));
}
}
}
=======================================================
function beforeDrawDataPoint( dph, fill, icsc ) //Does not work!~!!!!!!! the if conditions are correct, but fill.setdata does not seem to have any effect
{
System.out.println("dph.getSeriesValue():"+dph.getSeriesValue());
System.out.println("dph.getBaseDisplayValue():"+dph.getBaseDisplayValue());
var rc = icsc.getExternalContext().getScriptable();
if (fill.getClass().isAssignableFrom(EmbeddedImageImpl)){ // PGVs set in beforeFactory
System.out.println("Inside if 1");
if (dph.getSeriesValue() == "Goal Achieved"){
System.out.println("Inside if ga");
fill.setData(rc.getPersistentGlobalVariable("greenPattern"));
}else if (dph.getSeriesValue() == "Goal Not Achieved"){
System.out.println("Inside if gna");
fill.setData(rc.getPersistentGlobalVariable("redPattern"));
}else {
System.out.println("Inside if others");
fill.setData(rc.getPersistentGlobalVariable("greyPattern"));
}
}
}
==========================================================
Attached are two images. One is the output without scripting, and another the progress so far.
Notice the area part, does not correctly have the pattern i need. Any advice ?
Thanks
Joseph
Find more posts tagged with
Comments
There are no comments yet