Try reading the article Creating a pie chart in JIRA from the big book " JIRA 5.x Development Cookbook " by Jobin Kuruvilla.
The most important thing is to fill in your data set, which will be used to create the desired chart. Consider an example from this book that shows the java side of this plugin:
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); } }
and a speed template for this purpose:
#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
This is it in the most basic example. But also take a look at ChartFactory and ChartUtils to get a deeper idea about creating different types of charts.
source share