Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Power SIL Reporting Gadget allows users to write SIL code and use the predefined chart structures in order to generate line, bar, pie or doughnut charts.

Contents

Table of Contents

...

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

Note

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.

Anchor
Examples
Examples
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. 

Code Block
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;

Image Removed

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.

Code Block
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;

Image Removed

Chart from JSON

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

Write the JSON file with the chart configuration.

Code Block
{
    "type": "line",
    "data": {
        "datasets": [{
            "data": [20, 50, 100, 75, 25, 0],
            "label": "Left dataset",
            "fill" : true,
            "backgroundColor" : "rgba(66, 182, 244, 0.2)",
            "borderColor" : "#42b6f4",
            "yAxisID": "left-y-axis"
        }, {
            "data": [0.1, 0.5, 1.0, 2.0, 1.5, 0],
            "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"
            }]
        }
    }
}

Write the SIL script which reads the JSON file.

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

return chart;

The generated report:

...

Report

Include Page
Opened vs Resolved Issues (Chart Report)
Opened vs Resolved Issues (Chart Report)

Issues in status report

Include Page
Issues in status report
Issues in status report

Chart from JSON

Include Page
Chart from JSON
Chart from JSON