Carter
01/26/2022, 5:25 PMval plotData = buildMap<String, List<Any>> {
// This creates synthetic points for each label, assigned near the first x/y coordinate. The
// first coordinate is likely to be "smothered" but it otherwise should keep the perspective of the graph.
val sortedLabels = allLabels.sorted()
.mapIndexed { index: Int, label: String ->
TimeSeriesRow(
label,
data.first().x - 1.seconds + (0.001.seconds * index),
data.first().y
)
}
val concatenatedData = sortedLabels + data
put(LABELS, concatenatedData.map { it.label })
val groups = sortedLabels.map { PRE_FIRST_GROUP_VALUE } + (data.map { it.label }.group())
// Lets Plot has an undocumented hardcoded limit of 1,000 groups
check(groups.toSet().size < MAX_GROUPS) { "Cannot have more than 1,000 groups of data" }
put(GROUPS, groups)
put(X, concatenatedData.map { it.x })
put(Y, concatenatedData.map { it.y })
}