Hi
I am using JIRA 5.x development cookbook. I am trying to build Stacked barchart and page is erroring out and code also has lot of deprecated methods. Can you please let me know the issue. (Note: I could get the PIE chart to show up)
package com.multireport.charts;
import java.util.HashMap;
import java.util.Map;
import org.jfree.data.category.CategoryDataset;
import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.data.general.DefaultPieDataset;
import com.atlassian.jira.charts.Chart;
import com.atlassian.jira.charts.jfreechart.ChartHelper;
import com.atlassian.jira.charts.jfreechart.PieChartGenerator;
import com.atlassian.jira.charts.jfreechart.StackedBarChartGenerator;
import com.atlassian.jira.security.JiraAuthenticationContext;
import com.atlassian.jira.web.bean.I18nBean;
public class ChartGenerator {
public Chart generateChart(JiraAuthenticationContext authenticationContext, int width, int height) {
try {
final Map<String, Object> params = new HashMap<String, Object>();
// Create Dataset
//============== PIE chart =====================================
/*
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);
*/
//====================================================================
final ChartHelper helper = new StackedBarChartGenerator(createDataset(), "y-label", (I18nBean) authenticationContext.getI18nBean()).generateChart();
helper.generate(width, height);
params.put("chart", helper.getLocation());
params.put("chartDataset", createDataset());
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);
}
}
private static CategoryDataset createDataset() {
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
dataset.addValue(7445, "JFreeSVG", "Warm-up");
dataset.addValue(24448, "Batik", "Warm-up");
dataset.addValue(4297, "JFreeSVG", "Test");
dataset.addValue(21022, "Batik", "Test");
return dataset;
}
}Thanks
Abe
I18nBean i18nBean = new I18nBean(jiraAuthenticationContext.getI18nHelper());
with
Constructor dependency injection for your report component
public class StackedReport extends AbstractReport {
private final JiraAuthenticationContext jiraAuthenticationContext;
public StackedReport(JiraAuthenticationContext jiraAuthenticationContext) {
this.jiraAuthenticationContext = jiraAuthenticationContext;
}
Tried I18nBean as follows - still no luck
public I18nBean geti18nBean() {
return new I18nBean(authenticationContext.getLoggedInUser());
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.