The Chart Data Scripts screen lists all available scripts, providing the following information:
|Name||The name of the script|
|Author||The creator of the script|
|Created||The timestamp of script creation|
|Updated||The timestamp of the last update|
|Operations||Available operations for each script|
Creating a Chart Data Script
The following video shows how to create a data script.
Editing a Chart Data Script
On the Chart Data Scripts Page, click on the pencil icon to edit a saved configuration.
In the General section you can edit the Name and the Description of your template.
- Style - CSS style that can be used in the chart
In order to provide maximum flexibility and usability of charts, xCharts allows creation of parameters for a scripted chart.
Parameters are variables used in the scripted chart, which at chart render time provide certain Jira specific (user/group/project/date picker) fields or custom (chart type picker, text) fields.
Parameters must have unique names, so try not to use keywords, or variable names from the script. This might lead to errors when running the script!
There are multiple types of parameters, and we also plan on adding new types as we release new versions. For a complete reference on parameters, and the versions they were introduced in, see Script Parameters.
Available types include:
- TEXT - simple text parameter, simply replace some labels, chart title, etc.
- BOOLEAN - checkbox which sets the value of a boolean (since version 1.2.0)
- PICKER - as shown in the picture below, possibility to choose some Jira Inputs, like:
- User Picker (single and multi-select)
- Group Picker (single and multi-select)
- JQL Autocomplete
- Project/Issue Picker (single/multi select)
- Date Picker
- Interval Picker (since version 1.1.4)
- Time Period Picker (since version 1.1.4)
- Value Picker (single and multi-picker - since version 1.1.4)
- Text Area
- SQL Text Area
This makes charts very customizable, and a general template with multiple parameters can provide a lot of different statistics.
The Script section is where your actual chart logic written in Groovy goes.
There are two ways for doing that, namely:
- using a Groovy script from the JIRA_HOME directory SINCE VERSION 1.5.0
- writing the script in the the provided text area
Click Save in order to save or update the script. Click Cancel to get back to the Chart Data Scripts screen.
Using files from JIRA_HOME when scripting charts
There is no Jira restart needed for this action. Once copied there, the resources will be available when scripting charts, like in this following example screenshot:
It is currently not possible to edit the files from JIRA_HOME directly in the UI, and therefore, when using such a file, the editor text area is deactivated.
Context variables can be used in the Groovy Script without declaring them, because they are available at run-time, and they can be called by name.
By default in xCharts, you have access to some context variables:
|user||the logged in user|
|dateUtils||com.decadis.jira.xchart.api.util.DateUtils - for easier formatting of dates (see xCharts API Javadoc)|
|chartBuilder||com.decadis.jira.xchart.api.util.ChartBuilder - helper class that provides easy access to the most important classes (see xCharts API Javadoc)|
instead of using:
ApplicationUser user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser();
you could use:
Possibility to visualize modifications done to a scripted chart before saving. For maximizing development efficiency changes in parameters are also reflected here.