}
public void addChart(Subject user, EntityContext context, String viewName, String viewKey) {
String key = context.getLegacyKey();
MeasurementPreferences measurementPreferences = new MeasurementPreferences(user);
MetricViewData viewData = measurementPreferences.getMetricViewData(key, viewName);
// only add chart if it's not already in the list
if (!viewData.charts.contains(viewKey)) {
viewData.charts.add(viewKey); // new charts always go at the end
measurementPreferences.setMetricViewData(key, viewName, viewData);
}