on 01-29-2010 10:19 AM
Hi Experts,
I have a requirement to create 10 different pie chart in a view in a Grid layout.
The charts will be created dynamically because the data will be known at runtime.
Any type of help will be appreciated
Regards.
Hi,
Here is a simple example:
you must write this code in wdDoModfy() method, in if (firstTime){}
in the layout there is already created one transperent container with id BG_CONTAINER
//add a node
IWDNodeInfo loDynNode = wdContext.getNodeInfo().addChild("DynNode", null, true, false, true, false, false, true, null, null, null);
//add some attributes to it
loDynNode.addAttribute("DynAttr1Str", "ddic:com.sap.dictionary.string");
loDynNode.addAttribute("DynAttr2Int", "ddic:com.sap.dictionary.integer");
//get the node
IWDNode node = wdContext.getChildNode("DynNode", 0);
//fill the node with some values
for (int i = 0; i < 10; i ++){
IWDNodeElement element = node.createElement();
element.setAttributeValue("DynAttr1Str", "Str value " + i);
element.setAttributeValue("DynAttr2Int", new Integer(i));
// Add to the content
node.addElement(element);
}
//get the attributes, we will use the attrinfo to bind them to the series
IWDAttributeInfo loDynAttr1StrInfo = loDynNode.getAttribute("DynAttr1Str");
IWDAttributeInfo loDynAttr2IntInfo = loDynNode.getAttribute("DynAttr2Int");
//create the graphics
IWDBusinessGraphics loGraphics = (IWDBusinessGraphics)view.createElement(IWDBusinessGraphics.class,"bg1");
//set the type to pie
loGraphics.setChartType(WDBusinessGraphicsType.PIE);
//create a simple series and bind the integer attribute to it
IWDSimpleSeries loSSeries = (IWDSimpleSeries)view.createElement(IWDSimpleSeries.class, "Series1");
loSSeries.bindValue(loDynAttr2IntInfo);
//create the category and bind the string attribute to it
IWDCategory loCategory = (IWDCategory)view.createElement(IWDCategory.class,"Category1");
loCategory.bindDescription(loDynAttr1StrInfo);
//add series and category
loGraphics.addSeries(loSSeries);
loGraphics.setCategory(loCategory);
//I assume that there is a transperent container already created design time to put the graphics there
//container with id BG_CONTAINER
IWDTransparentContainer loContainer = (IWDTransparentContainer)view.getElement("BG_CONTAINER");
//add the graphics
loContainer.addChild(loGraphics);
If this is the type of graphics you need then you must simply do a for cycle and supply the graphics with the right node elements and you are ready.
Best regards,
Anton
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What does that mean: "because the data will be known at runtime"? Is the number of charts depending on the data?
Armin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
25 | |
12 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.