尝试阅读Jobin Kuruvilla的巨著“ JIRA 5.x Development Cookbook ”中的文章在 JIRA 中创建饼图。
最重要的是填充您的数据集,该数据集将用于生成所需的图表。考虑那本书中的示例,它显示了该插件的 java 方面:
public Chart generateChart(JiraAuthenticationContext authenticationContext, int width, int height) {
try {
final Map<String, Object> params = new HashMap<String, Object>();
// Create Dataset
DefaultPieDataset dataset = new DefaultPieDataset();
dataset.setValue("One", 10L);
dataset.setValue("Two", 15L);
final ChartHelper helper = new PieChartGenerator(dataset, authenticationContext.getI18nHelper()).generateChart();
helper.generate(width, height);
params.put("chart", helper.getLocation());
params.put("chartDataset", dataset);
params.put("imagemap", helper.getImageMap());
params.put("imagemapName", helper.getImageMapName());
params.put("width", width);
params.put("height", height);
return new Chart(helper.getLocation(), helper.getImageMap(), helper.getImageMapName(), params);
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("Error generating chart", e);
}
}
以及用于此目的的速度模板:
#if ($chart)
#if ($imagemap)
$imagemap
#end
<p class="report-chart">
<img src='$baseurl/charts?filename=$chart' border='0' #if ($imagemap) usemap="\#$imagemapName" #end/>
</p>
#end
这就是最基本的例子。此外,请查看ChartFactory和ChartUtils接口,以更深入地了解如何创建各种类型的图表。