insights: [frontend] randomly select color for capture group generated series
Created by: coury-clark
Insight series generated by capture groups will need randomly generated colors.
Currently, there is a problem in the relationships exposed by the API such that the time series returned by dataSeries will not match the cardinality in the presentation or dataSeriesDefinitions when generated by capture groups. We cannot trivially add fake series to the presentation or dataSeriesDefinitions without clients being unable to decipher "real" from "fake" series, and being able to populate edit forms for example.
In the short term, it may be easiest to do the following:
- On the frontend perform some kind of hacky substitution for capture group generated insights. Something like
data?.view.content.forEach(content => content.series.forEach( (series, i) => series.stroke = series.stroke || DEFAULT_COLOURS[Math.floor(Math.random() * DEFAULT_COLOURS.length)].color))when we load the series.
Long term, we would like to evolve the API to be able to provide presentationDefinition as well as presentation options that expose different cardinality for different purposes, the first being the "truth" of how the series was defined, and the second being the reality "which series are returning".