A Highchart is defined in a calculation logic, using the api.buildHighchart
method. Refer to the Highcharts API reference to explore the full variety of settings.
At the very least you need to provide series[n].type
and series[n].data
, or you can omit series.type
if there is a default chart.type
value.
If a message displays, saying that a JavaScript module may be missing, go to the Highcharts documentation and find out which modules are required for each chart type.
The following example fetches data from the Datamart and creates a variwide chart:
Tips
- If you cannot find an example of an existing logic that uses a chart type that you intend to use, it should be fairly easy to adapt one of the Highcharts Demos. Select your chart and click on the 'View Options' button and you will see the JS source code, including a
Highcharts.chart('container', {...})
call. This{...}
content is thedefinition
map. You will have to convert it from JS to Groovy. This always implies replacing the curly brackets by square brackets ({} -> []
). But you may also sometimes encounter code likeHighcharts.color(colors[5]).brighten(0.2).get()
which you should replace by your own hard coded colors, orformatter: function () {...}
which you would have to replace by a simpler pattern formatterformat: '{point.name}: {point.y:.1f}%'
. If you want to remove the “Highcharts.com” watermark and link from the chart, use the
credits
property in your definition:def chartDef = [ chart: [ type: 'column' ], credits: [ enabled: false ], title: [ text: 'My Chart' ],
See also:
- General Chart Settings for information about how to configure a global theme definition.
- How to Create Clickable Highcharts/Highmaps