Chart Reports

Power Dashboard Reports and Gadgets allow users to write SIL code and use the predefined chart structures in order to generate line, bar, pie or doughnut charts.

Contents

Configuring SIL Reporting Gadget

First you need to add the SIL Reporting Gadget to your dashboard. To do that, click Add new gadget. In the Add new gadget dialog, click Load all gadgets. Search for the SIL Reporting Gadget and add it to your dashboard.

To see more instructions about adding a gadget to your dashboard see Atlassian documentation.

The configuration screen is only available to Jira Administrators and System Administrators.

To configure the gadget you have to select the script file and add the default values for the parameters used in the selected script.

The parameters will be passed into the program using the argv variable. The values will be available using a construct like argv["parameter_name"] or argv[position]. For the above example, the project can be retrieved using argv["project"] or argv[0]

First the gadget will run with the default values for the parameters, if the values for those parameters were specified in the gadget configuration. 

Once you save the gadget configuration, the report will be displayed. 

The script that you are using to generate the report needs to return the chart structure that you are building otherwise the report will throw an error.

If you want to return information about another project without having to configure the gadget, all you have to do is add a field for the project using one of the routines for creating fields from gadget routines. After that you will be able to set parameter in the parameter section and run the report with the new value.

Examples

Opened vs Resolved Issues Report

The report is a bar chart showing the number of opened issues vs number of resolved issues for a given list of projects. 

string [] projects = argv[0];
int [] resolvedIssues;
int [] openedIssues;
for(string p in projects) {
    resolvedIssues += countIssues("project = " + p  + " AND status in (Done, Closed, Resolved)");
    openedIssues += countIssues("project = " + p  + " AND status not in (Done, Closed, Resolved)");
}
 
SILReportingChartDataset openedDataset;
openedDataset.label = "Opened Issues";
openedDataset.backgroundColor = {"#3cba9f""#3cba9f""#3cba9f""#3cba9f""#3cba9f","#3cba9f"};
openedDataset.data = openedIssues;
 
SILReportingChartDataset resolvedDataset;
resolvedDataset.label = "Resolved Issues";
resolvedDataset.backgroundColor = {"#3e95cd""#3e95cd""#3e95cd""#3e95cd""#3e95cd""#3e95cd"};
resolvedDataset.data = resolvedIssues;
 
SILReportingChartData data;
data.labels = projects;
data.datasets = {openedDataset, resolvedDataset};
 
SILReportingChartTitle title;
title.display = true;
title.position = "top";
title.text = "Opened vs Resolved Issues Report";
 
SILReportingChartLegend legend;
legend.display = true;
legend.position = "top";
 
SILReportingChartTicks ticks;
ticks.beginAtZero = true;
 
SILReportingChartYAxes yAxes;
yAxes.ticks = ticks;
 
SILReportingChartScales scales;
scales.yAxes = {yAxes};
 
SILReportingChartOptions options;
options.title = title;
options.legend = legend;
options.scales = scales;
options.aspectRatio = 1.5;
 
SILReportingChart barChart;
barChart.type = "bar";
barChart.data = data;
barChart.options = options;
 
return barChart;


Issues in status report

The fallowing code will display a report showing how many issues are in a certain status, based on your choice of project and chart type.

number[] statusCount;
 
string [] issues = selectIssues("project = " + argv[0]);
for(string iss in issues) {
    string currStatus = iss.status;
    if(isNull(statusCount[currStatus])) {
        statusCount[currStatus] = 1;
    else {
        statusCount[currStatus] += 1;
    }
}
 
SILReportingChartDataset datasets;
datasets.label = "Issues";
datasets.backgroundColor = {"#3e95cd""#8e5ea2","#3cba9f","#e8c3b9","#c45850"};
datasets.data = statusCount;
 
SILReportingChartData data;
data.labels = arrayKeys(statusCount);
data.datasets = {datasets};
 
SILReportingChartTitle title;
title.display = true;
title.text = "Issues in status";
 
SILReportingChartLegend legend;
legend.display = true;
legend.position = "top";
 
SILReportingChartOptions options;
options.title = title;
options.aspectRatio = 1.5;
 
 
SILReportingChart chart;
chart.type = argv[1]; //line, bar, pie, doughnut
chart.data = data;
chart.options = options;
 
silreporting_createAutocompleteSelectList("Project", {"TEST""test""test" "FIBER""FIBR""fibr""GERBEI""GRBI""grbi"}, "TEST");
silreporting_createSelectList("Chart Type", {"Line""line""line" "Bar""bar""bar""Pie""pie""pie""Doughnut""doughnut""doughnut"}, "pie");
 
return chart;

Chart from JSON

In order to generate a chart report from a JSON file you have to :

  1. Write the JSON file with the chart configuration.

    {
        "type""line",
        "data": {
            "datasets": [{
                "data": [205010075250],
                "label""Left dataset",
                "fill" true,
                "backgroundColor" "rgba(66, 182, 244, 0.2)",
                "borderColor" "#42b6f4",
                "yAxisID""left-y-axis"
            }, {
                "data": [0.10.51.02.01.50],
                "label""Right dataset",
                "fill" true,
                "backgroundColor" "rgba(244, 65, 86, 0.2)",
                "borderColor" "#f44156",
                "yAxisID""right-y-axis"
            }],
            "labels": ["Jan""Feb""Mar""Apr""May""Jun"]
        },
        "options": {
            "scales": {
                "yAxes": [{
                    "id""left-y-axis",
                    "type""linear",
                    "position""left"
                }, {
                    "id""right-y-axis",
                    "type""linear",
                    "position""right"
                }]
            }
        }
    }

  2. Write the SIL script which reads the JSON file.

    string json = readFromTextFile("multipleAxes.json");
    SILReportingChart chart = fromJson(json);
     
    return chart;

The generated report: