Here is an example from trends view that plots a table of pmc data and workout code for those days that contain an activity, note how the workouts (sparse) and pmc data (daily) are matched and folded together.
Also, of course Metadata is already a string.
{
# column names, if using metrics then best
# to use metricname() to get correct name for locale
# otherwise it won't translate to other languages
names {
c("Date", "Daily", "Chronic", "Acute", "Stress", "Workout");
}
# column units, if using metrics then best
# to use metricunit() function to get correct string
# for locale and metric/imperial
units {
c("", "TSS", "Load","Load","Balance", "Code");
}
# values to display as doubles or strings
# if using metrics always best to use asstring()
# to convert correctly with dp, metric/imperial
# or specific formats eg. rowing pace xx/500m
values {
# get metadata
ridedates <- metrics(date);
pmcdates <- pmc(BikeStress,date);
index <- match(ridedates, pmcdates);
meta <- rep("", length(pmcdates));
meta[index] <- metadata("Workout Code");
c(datestring(pmc(BikeStress,date)),
round(pmc(BikeStress,stress)),
round(pmc(BikeStress,lts)),
round(pmc(BikeStress,sts)),
round(pmc(BikeStress,sb)), meta);
}
heat {
c(normalize(0,0,pmc(BikeStress,lts)),
normalize(0,300,pmc(BikeStress,stress)),
normalize(0,100,pmc(BikeStress,lts)),
normalize(0,100,pmc(BikeStress,sts)),
normalize(-30,30,pmc(BikeStress,sb)),
normalize(0,0,pmc(BikeStress,lts)));
}
f {
ridedates <- metrics(date);
pmcdates <- pmc(BikeStress,date);
index <- match(ridedates, pmcdates);
returning <- rep("", length(pmcdates));
returning[index] <- filename();
returning;
}
}