Hi Devs
I want to make a graph with a given table, but i don`t want to see the
table in the xwiki page, so i`m trying to make the graph inside my function:
Map data = new HashMap();
data.put("x", "1");
data.put("y", "110");
ChartingPlugin chartplugin = new
ChartingPlugin("chartingplugin", ChartingPlugin.class.toString(), context);
chartplugin.init(context);
// ChartingPluginApi chart = new
ChartingPluginApi(chartplugin,context);
ChartParams chartParams = new ChartParams();
try {
chartParams = new ChartParams(data,
DefaultChartParams.getInstance(), true);
chartParams.addParam(new
MapChartParam("source=type:table", false));
chartParams.addParam(new
MapChartParam("type=pie", false));
// chartParams.set("SOURCE", "type:table");
// chartParams.set("TYPE", "pie");
chartParams.check();
} catch (ParamException e) {
}
* Chart chart = new ChartImpl(chartParams,null,null);
try {
chart = chartplugin.generateChart(chartParams,
context);
} catch (GenerateException ge) {
}*
String title = chartParams.getString(
ChartParams.TITLE_PREFIX+ChartParams.TITLE_SUFFIX);
Integer height = chartParams.getInteger(ChartParams.HEIGHT);
Integer width = chartParams.getInteger(ChartParams.WIDTH);
Map imageAttr =
chartParams.getMap(ChartParams.IMAGE_ATTRIBUTES);
Map linkAttr =
chartParams.getMap(ChartParams.LINK_ATTRIBUTES);
// output the image links
StringBuffer sbuffer = new StringBuffer();
sbuffer.append("<a href=\""+ chart.getPageURL() +
"\" ");
if (title != null) {
sbuffer.append("title=\"" + title +
"\"");
}
if (linkAttr != null) {
Iterator it = linkAttr.keySet().iterator();
while (it.hasNext()) {
String name = (String)it.next();
String value = (String)imageAttr.get(name);
sbuffer.append(name+"=\"" + value + "\"
");
}
}
sbuffer.append(">");
sbuffer.append("<img src=\"");
sbuffer.append(chart.getImageURL());
sbuffer.append("\" ");
if (title != null) {
sbuffer.append("alt=\""+ title + "\"
");
}
sbuffer.append("height=\"" + height + "\"
");
sbuffer.append("width=\"" + width + "\" ");
if (imageAttr != null) {
Iterator it = imageAttr.keySet().iterator();
while (it.hasNext()) {
String name = (String)it.next();
if (name != ChartParams.HEIGHT && name !=
ChartParams.WIDTH) {
String value = (String)imageAttr.get(name);
sbuffer.append(name + "=\"" + value +
"\" ");
} else {
}
}
}
sbuffer.append("/>");
sbuffer.append("</a>");
return sbuffer.toString();
I get some problems in :
* Chart chart = new ChartImpl(chartParams,null,null);
try {
chart = chartplugin.generateChart(chartParams,
context);
} catch (GenerateException ge) {
}
*I think is some problem with the source,
Any ideas?
Thanks in advance :)