I am trying to generate an XY plot in a widget in Workshop, based on data contained in an object set (‘States’), but having trouble.
Each object has two properties: an array of dates (‘Weekend Date’) and an array of floats (‘Hospitalization Rate’). I have loaded a variable into workshop which is an object set comprised of one State (‘Michigan’), which has those two properties, and I want to assign the dates to the x-axis and the hospitalization rates to the y-axis.
In the widget setup, I have chosen the object set as the data input, and am able to choose ‘Weekend Date’ as the x-axis property. But I think this forces the x-axis data type to be categorical, and I want a continuous time variable. And then I can’t use the hospitalization rate array as the y-axis. Is there a better way to represent date data as a continuous variable (especially if I have unevenly sampled data, and want the spacing between the data points on the plot to accurately represent time lags)?
I don’t believe arrays are going to work for this purpose within the XY chart widget in Workshop. Have you considered creating a secondary object type with the weekend date and hospitalization rate as non-array properties, and then linking these to your primary objects? This way you can traverse the link whenever you need to get the values, which should allow you to do the plot you are wanting. If you need the values as array for some purpose, an aggregation on the link would allow you to get them as well.
Thank you Eirik! I suppose then that I should handle my data transformations differently. Currently I am starting with three-column data (image attached) and aggregating by the state column to put the other two columns into arrays (image also attached), then creating objects based on this output dataset.
Would it instead make sense to split the original dataset into smaller datasets based on the values in the left column, and create objects from these, so that the data are non-array properties? Which data transformations in pipeline builder would make that possible?
There are several ways you could do this. If you want to split it into multiple datasets in pipeline builder you will have to create a path for each dataset (i.e. add a filter transform for Utah which outputs to the Utah dataset and so on).
Alternatively, you could create an object type from the original dataset with all the states before aggregations (See this for more info about primary key generation), and do filtering within Workshop.
Thanks Eirik, I am having success with your latter suggestion. However I’m still having difficulty generating the XY plots with date data on the x-axis (I think the widget will only accept this data as categorical). I have tried formatting these values both as timestamps and as dates, without success. Do you have a suggestion for how to properly format this data for the XY widget (especially if the dates are unevenly sampled?)