package com.example.data; import java.util.List; /** * One named series of numbers plus the categories they are indexed by — the * shape every chart on the dashboard is fed with, axis-based or not (a pie * chart reads the categories as slice labels and ignores the series name). *

* {@code nameKey} and {@code categoryKeys} are translation keys, not * display text: the data layer must stay free of a {@code UI} and its locale, * so resolving them against the bundle is the view's job. Values and keys are * defensively copied, so a data set handed out by a * {@link ChartDataService} cannot be modified by its consumer. */ public record ChartSeries(String nameKey, List values, List categoryKeys) { public ChartSeries { values = List.copyOf(values); categoryKeys = List.copyOf(categoryKeys); if (values.size() != categoryKeys.size()) { throw new IllegalArgumentException( "each value needs a category: %d values, %d categories" .formatted(values.size(), categoryKeys.size())); } } }