Hello experts out there,
I try to generate line graph based on cewolf open source graph software.
What I want to do is I want to get some data from 'GraphByFruit' class that passed in object of array. This object is stored in a session attribute "GraphData".
My below code produce error msg : "local variable request is accessed from within inner class; needs to be declared final"
How should I get the value from "GraphByFruits" class??
pls help...
my code in jsp:
DatasetProducer categoryData = new DatasetProducer() {
HttpSession logSession = request.getSession(false);
public Object produceDataset(Map params) {
GraphByFruit[] graph = (GraphByFruit[])session.ge
tAttribute
("GraphDat
a");
String state = "";
String fruit = "";
float[] qty = null;
final String[] arrayOfFruit = new String[graph.length];
System.out.print("arrayOfF
ruit ="+arrayOfFruit.length+"\n
");
final String[] categories= { "a", "s", "d", "f", "g", "h", "j", "k", "r"};
for (int i=0; i < graph.length; i++) {
state=graph[i].getStateID(
);
qty = graph[i].getProdQty();
fruit = ""+graph[i].getFruitID();
if (i<graph.length-1) fruit = fruit+",";
arrayOfFruit [i] = fruit;
}
//final String[] categories = { "apples", "pies", "bananas", "oranges" };
//final String[] seriesNames = { "Peter", "Helga", "Franz", "Olga" };
final Integer[][] startValues = new Integer[arrayOfFruit.lengt
h][categor
ies.length
];
final Integer[][] endValues = new Integer[arrayOfFruit.lengt
h][categor
ies.length
];
for (int series = 0; series < arrayOfFruit.length; series++) {
for (int i = 0; i < categories.length; i++) {
int y =0;
startValues[series][i] = new Integer(y);
endValues[series][i] = new Integer(y + (int) (Math.random() * 10));
}
}
DefaultIntervalCategoryDat
aset ds =
new DefaultIntervalCategoryDat
aset(serie
sNames, categories, startValues, endValues);
return ds;
}
public String getProducerId() {
return "CategoryDataProducer";
}
public boolean hasExpired(Map params, Date since) {
return false;
}
};
pageContext.setAttribute("
categoryDa
ta", categoryData);
%>
<html>
<head>
<link href="cewolf.css" rel="stylesheet" type="text/css"></head>
<BODY bgcolor="#DDE8F2">
<H1>Cewolf Chart Set</H1>
<p>
<cewolf:chart id="lineChart" title="LineChart" type="line" xaxislabel="Fruit" yaxislabel="favorite">
<cewolf:data>
<cewolf:producer id="categoryData" />
</cewolf:data>
</cewolf:chart>
<cewolf:img chartid="lineChart" renderer="cewolf" width="300" height="300"/>
</body>
</html>