Charts
Purpose¶
Access and control of the Charts service behaviour.
Methods¶
Binding name: p6.chart
Method: Object getConfigFromPipeline()
Returns the configuration of the chart from the pipeline. (Converted using JsonSlurper.parseText)
Method: Object getConfig(String chartName)
Returns the configuration of the chart. (Converted using JsonSlurper.parseText)
Method: void updateConfig(String chartName, Object config)
Update the computed configuration of the chart from the Json representation (Converted using JsonOutput.toJson). Data is pretty printed before being saved
Method: void updateConfig(String chartName, String config)
Update the computed configuration of the chart
Method: void synchronize(String chartName)
Refresh the computed configuration of the chart
Method: Map<String, Object> getData(String chartName)
Returns the data of the chart. (Converted using JsonSlurper.parseText)
Note
See Charts service on demand
about calculation mode
Method: Map<String, List<String>> convertRecordsForLineAndBars(Tuple2<List<String>, List<List<String>>> result)
Convert the data records to a line or bar chart
Method: List<String> convertRecordsToSeries(Tuple2<List<String>, List<List<String>>> result, String valueColumn)
Convert the data records to a series on a specific column name
Method: List<String> convertRecordsToSeries(Tuple2<List<String>, List<List<String>>> result, int valueColumnId)
Convert the data records to a series on a specific column id
Method: List<Map<String, String>> convertRecordsForPie(Tuple2<List<String>, List<List<String>>> result, int nameColumnId, int valueColumnId)
Convert the data records to a pie chart by specifying the id of the name and the value columns.
Method: List<Map<String, String>> convertRecordsForPie(Tuple2<List<String>, List<List<String>>> result, String nameColumn, String valueColumn)
Convert the data records to a pie chart by specifying the names of the name and the value columns.
Note
The first value of the tuple is the name, and the second the value
Method: List<Map<String, String>> convertRecordsToTable(Tuple2<List<String>, List<List<String>>> result)
Convert the data records to a table format.
Examples¶
Example 1
Synchronize a chart
p6.chart.synchronize("invoicePie12")
Example 2
Update a chart configuration
def config = p6.chart.getConfig('invoiceBar')
config.series[0].data = // Inject your data here
p6.chart.updateConfig("invoiceBar", config)
Example 3
Data conversion
def result = p6.sproc.executewithColumns("extraction data stored procedure")
println result.v1
// Output: [date, key, value]
println result.v2
// [
// ["D1", "fee", 1],
// ["D2", "foo", 2],
// ["D3", "bar", 3],
// ]
println result.v3
// Output: [91, 12, 4]
println p6.chart.convertRecordsForLineAndBars(result)
// Output: [
// ["date": ["D1", "D2", "D3"]],
// ["key": ["fee", "foo", "bar"]],
// ["value": [1, 2, 3]],
// ]
println p6.chart.convertRecordsForPie(result, "key", "value")
println p6.chart.convertRecordsForPie(result, 1, 2)
// Output: [
// ["name": "fee", "value": 1],
// ["name": "foo", "value": 2],
// ["name": "bar", "value": 3],
// ]
println p6.chart.convertRecordsToSeries(result, "key")
println p6.chart.convertRecordsToSeries(result, 1)
// Output: ["fee", "foo", "bar"]
println p6.chart.convertRecordsToTable(result)
// Output: [
// ["key": "fee", "value": 1],
// ["key": "foo", "value": 2],
// ["key": "bar", "value": 3],
// ]
Note
Groovy Tuple deprecated first
, second
and third
use. Please use v1
, v2
and v3
instead.