Dynamic DateListPlot with multiple categories backed by DataSet

I have a DataSet that contains records with:

• an "activityName" string representing the kind of activity
• a "duration" value representing minutes
• a DateObject representing a date and time named "startTime"

I can access the records in the DataSet with this code:

myDataSet[All, {"activityName", "duration", "startTime"}]


I can plot all the records with this code:

DateListPlot[myDataSet[All, {"startTime", "duration"}] // Values  // Normal


But what I want to do is identify in the graph the different activities such that each activity is rendered in a different line / points, along the lines of this sort of output:

Note that the data across the various activities is not consistent nor is it supposed to be.

It would be ideal to leverage the dynamic capabilities of the language so that the user can see all the data overlaid and then select the (multiple) activities of interest to look only at those data.

You may use GroupBy in Dataset's Query syntax.

For individual plots per activity.

res1 = myDataSet[GroupBy["activityName"], DateListPlot, {"startTime", "duration"}]


With individual plots accessed by activity name.

res1["Weights"]


For one combined plot the position of DateListPlot needs to move up one level in the hierarchy.

myDataSet[
GroupBy["activityName"] /* DateListPlot,
All,
{"startTime", "duration"}
]


Hope this helps.

• Thanks a lot for this, Edmund. I see what you are doing with the GroupBy and this makes sense. However, I'm not familiar with the "/* operator which appears to pass the output to the next function. I looked for this operator but have not been able to find it in the documentation. Also, I would like to do more customisation to the DateListPlot, so it would be nice to call it alone. I tried assigning the GroupBy to a variable and passing that to DateListPlot and got an error saying: Message: Part {startTime, duration} is not applicable to expressions of the form {__Association}. – Barton Friedland Dec 8 '18 at 11:25
• @BartonFriedland I'm on my phone so a bit limited but look up RightComposition in the documentation. Also, you must make a pure function of DateListPlot. For example, (DateListPlot[#, Filling -> Axis]&). The brackets are import to isolate the pure function within RightComposition. Will update when I'm back at my computer. – Edmund Dec 8 '18 at 14:32