Starting with version 1.3.0, it is possible to add Sprint and Board pickers.

For this to work, Jira Software has to be installed in your system.

Agile Board Picker example

This chart shows all open sprints in the chosen boards.

Layout Script
var c3arg = {
    onrendered: updateFrameHeight,
    data: chartData,
    axis: {
        x: {
            type: 'category', // this needed to load string x value
            label: {
                text: chartData.custom.xLabel,
                position: 'outer-left'
            }
        },
        y: {
            label: chartData.ytype
        }
    }
};
 
c3.generate(c3arg);
Data Script
import com.atlassian.jira.component.ComponentAccessor;
import com.decadis.jira.xchart.api.util.DateUtils;
import com.decadis.jira.xchart.api.model.Period;
import com.decadis.jira.xchart.api.model.ChartData;
import com.decadis.jira.xchart.api.CountGroup;
 
import com.atlassian.greenhopper.service.rapid.view.RapidViewService;
import com.atlassian.greenhopper.service.rapid.RapidViewQueryService;
import com.atlassian.greenhopper.service.sprint.Sprint;
 
import org.apache.log4j.Logger;
 
def logger = Logger.getLogger("BoardPicker");
def data = chartBuilder.newDataCollector();
 
def rapidViewService = ComponentAccessor.getOSGiComponentInstanceOfType(RapidViewService.class);
def rapidViewQueryService = ComponentAccessor.getOSGiComponentInstanceOfType(RapidViewQueryService.class);
 
for (def boardId in BoardPicker)
{
    def rapidView = rapidViewService.getRapidView(user, Long.parseLong(boardId)).getValue();
    if (rapidView != null)
    {
      List<Sprint> sprints = rapidViewQueryService.getOpenSprintsAndBacklogProjects(user, rapidView).getValue().left();
      for (Sprint sprint in sprints)
      {
            data.addValue(1, sprint.getName(), rapidView.getName());
      }
    }
}
 
data.fillMissingValues();
def chartData = chartBuilder.newChartData("Open Sprints")
chartData.setType("bar");
chartData.addCustomData("xLabel", "Boards");
  
chartBuilder.getChartUtil().transformResult(data, chartData, true);
  
return chartData;

Agile Sprint Picker example

This chart is a category chart that shows the number of issues in the selected sprints.

Layout Script
var c3arg = {
    onrendered: updateFrameHeight,
    data: chartData,
    axis: {
        x: {
            type: 'category', // this needed to load string x value
            label: {
                text: chartData.custom.xLabel,
                position: 'outer-left'
            }
        },
        y: {
            label: chartData.ytype
        }
    }
};
 
c3.generate(c3arg);
Data Script
import com.atlassian.jira.component.ComponentAccessor;
import com.decadis.jira.xchart.api.util.DateUtils;
import com.decadis.jira.xchart.api.model.Period;
import com.decadis.jira.xchart.api.model.ChartData;
import com.decadis.jira.xchart.api.CountGroup;
import com.atlassian.jira.user.ApplicationUser;
 
import com.atlassian.greenhopper.service.sprint.SprintIssueService;
import com.atlassian.greenhopper.service.sprint.SprintService;
import com.atlassian.jira.issue.Issue;
import org.apache.log4j.Logger;
 
def logger = Logger.getLogger("SprintPickerLog");
def data = chartBuilder.newDataCollector();
 
// this is how the specific Jira Agile classes can be used in xCharts
def sprintService = ComponentAccessor.getOSGiComponentInstanceOfType(SprintService.class);
def sprintIssueService = ComponentAccessor.getOSGiComponentInstanceOfType(SprintIssueService.class);
 
ApplicationUser applicationUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser();
 
for ( def sp in SprintPicker )
{
    def sprint = sprintService.getSprint(applicationUser, new Long(sp)).get();
    Iterable<Issue> issuesInSprint = sprintIssueService.getIssuesForSprint(user, sprint).get();
    long size = issuesInSprint.spliterator().getExactSizeIfKnown();
    data.addValue(size, "Issues", sprint.getName());
}
 
data.fillMissingValues();
def chartData = chartBuilder.newChartData("Issue Count")
chartData.setType("bar");
chartData.addCustomData("xLabel", "Sprint");
 
chartBuilder.getChartUtil().transformResult(data, chartData, false)
 
return chartData;



If you still have questions, feel free to refer to our support team.