Chart
Purpose¶
Access and control of the Charts service behaviour.
Methods¶
Binding name: p6.chart
getConfigFromPipeline¶
Returns the configuration of the chart from the pipeline. (Converted using JsonSlurper.parseText)
Syntax
Object p6.chart.getConfigFromPipeline()
Example
def config = p6.chart.getConfigFromPipeline()
getConfig¶
Returns the configuration of the chart. (Converted using JsonSlurper.parseText)
Syntax
Object p6.chart.getConfig(String chartName)
Example
def config = p6.chart.getConfig("myChart")
updateConfig (json)¶
Update the computed configuration of the chart from the Json representation (Converted using JsonOutput.toJson).
Syntax
void p6.chart.updateConfig(String chartName, Object config)
Info
Data is pretty printed before being saved
Example
def config = p6.chart.getConfig("myChart")
config.series[0].data = //Inject your data here
p6.chart.updateConfig("myChart", config)
updateConfig (string)¶
Update the computed configuration of the chart
Syntax
void p6.chart.updateConfig(String chartName, String config)
Example
p6.chart.updateConfig("myChart", "{\"config\": \"here\"}")
synchronize¶
Refresh the computed configuration of the chart
Syntax
void p6.chart.synchronize(String chartName)
Example
p6.chart.synchronize("myChart")
getData¶
Returns the data of the chart. (Converted using JsonSlurper.parseText)
Syntax
Map<String, Object> p6.chart.getData(String chartName)
Note
See Charts service on demand
about calculation mode
Example
def data = p6.chart.getData("myChart")
convertRecordsForLineAndBars¶
Convert the data records to a line or bar chart
Syntax
Map<String, List<String>> p6.chart.convertRecordsForLineAndBars(
Tuple2<List<String>, List<List<String>>> result
)
Example
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]],
// ]
convertRecordsToSeries (string)¶
Convert the data records to a series on a specific column name
Syntax
List<String> p6.chart.convertRecordsToSeries(
Tuple2<List<String>, List<List<String>>> result,
String valueColumn
)
Example
def result = p6.sproc.executewithColumns("extraction data stored procedure")
println p6.chart.convertRecordsToSeries(result, "key")
// Output: ["fee", "foo", "bar"]
convertRecordsToSeries (index)¶
Convert the data records to a series on a specific column id
Syntax
List<String> p6.chart.convertRecordsToSeries(
Tuple2<List<String>, List<List<String>>> result,
int valueColumnId
)
Example
def result = p6.sproc.executewithColumns("extraction data stored procedure")
println p6.chart.convertRecordsToSeries(result, 1)
// Output: ["fee", "foo", "bar"]
convertRecordsForPie (string)¶
Convert the data records to a pie chart by specifying the names of the name and the value columns.
Syntax
List<Map<String, String>> p6.chart.convertRecordsForPie(
Tuple2<List<String>, List<List<String>>> result,
String nameColumn,
String valueColumn
)
Note
The first value of the tuple is the name, and the second the value
Example
def result = p6.sproc.executewithColumns("extraction data stored procedure")
println p6.chart.convertRecordsForPie(result, "key", "value")
// Output: [
// ["name": "fee", "value": 1],
// ["name": "foo", "value": 2],
// ["name": "bar", "value": 3],
// ]
convertRecordsForPie (index)¶
Convert the data records to a pie chart by specifying the id of the name and the value columns.
Syntax
List<Map<String, String>> p6.chart.convertRecordsForPie(
Tuple2<List<String>, List<List<String>>> result,
int nameColumnId,
int valueColumnId
)
Example
def result = p6.sproc.executewithColumns("extraction data stored procedure")
println p6.chart.convertRecordsForPie(result, 1, 2)
// Output: [
// ["name": "fee", "value": 1],
// ["name": "foo", "value": 2],
// ["name": "bar", "value": 3],
// ]
convertRecordsToTable¶
Convert the data records to a table format.
Syntax
List<Map<String, String>> p6.chart.convertRecordsToTable(
Tuple2<List<String>, List<List<String>>> result
)
Example
println p6.chart.convertRecordsToTable(result)
// Output: [
// ["key": "fee", "value": 1],
// ["key": "foo", "value": 2],
// ["key": "bar", "value": 3],
// ]