How to Set Data with Null Values in FlexCharts?

Context

We use a library named Wicked Charts for server side validation of the chart. Unfortunately this library doesn't support null values, even though they are valid for Highcharts.

Workaround

Replacing the null values by empty maps ("[ ]" in Groovy) will pass the validation successfully, and the final Highchart will look as if nulls had been provided.

A typical FlexChart that would fail due to nulls looks like this:

def chartDefinition = [ chart: [ type: 'column' ], ... series: [ [ name : 'Series 1', data: [null, null, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, null] ], ... ] ] api.buildFlexChart(chartDefinition)

And this is the result after applying the workaround:

def chartDefinition = [ chart: [ type: 'column' ], ... series: [ [ name : 'Series 1', data: [ [], [], 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, []] ], ... ] ] api.buildFlexChart(chartDefinition)

Found an issue in documentation? Write to us.

Â