Skip to content

Add historic reporting for Home activity levels #543

@brylie

Description

@brylie

Now that our platform supports historical reporting, we can focus on improving the visibility of home activity levels over "deeper" periods.

We will start with historic charting for the individual homes before working on visualising the whole care-system.

Goals

  • Home report page should load with rendered charts in under ~2 seconds
  • Charts should be easy to read and understand
  • Charts should be localized
  • Charts should fit within a single eye span, or page, reducing the likelihood of scrolling

Task

  • Design mock-ups for historic charts @brylie
  • Describe types of aggregations needed for each chart mock-up (e.g. using mode or mean calculations for daily activity levels) @brylie
  • From a technical standpoint, describe how to pre-compute the aggregations if useful
  • Determine if/how we might leverage the database layer directly to do aggregations
  • Determine if there is a more performant JavaScript library or "standard library" approach for data aggregations (currently using D3 but may use Lodash)
  • Describe how to handle different periods for reporting, e.g. monthly or yearly (e.g. there may only be a few months of data on newer deployments.
  • Discuss required changes before implementing the improvements
  • Add selected historical reports to Home report view

Current report view

image

Note: the current report view takes several seconds to populate with data in a production deployment.

Mock-ups

image

The following code was used to generate the "Resident activity levels over time" chart.

Details var xData = [ ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sept", "Oct", "Nov", "Dec"], ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sept", "Oct", "Nov", "Dec"], ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sept", "Oct", "Nov", "Dec"], ];

var yData = [
[74, 82, 80, 74, 73, 72, 74, 70, 70, 66, 66, 69],
[45, 42, 50, 46, 36, 36, 34, 35, 32, 31, 31, 28],
[13, 14, 20, 24, 20, 24, 24, 40, 35, 41, 43, 50],
];

var colors = ['green', 'red', 'yellow',];

var lineSize = [2, 2, 4, 2];

var labels = ['Excellent', 'Poor', 'Good',];

var data = [];

for ( var i = 0 ; i < xData.length ; i++ ) {
var result = {
x: xData[i],
y: yData[i],
type: 'scatter',
mode: 'lines',
line: {
color: colors[i],
width: lineSize[i]
}
};
var result2 = {
x: [xData[i][0], xData[i][11]],
y: [yData[i][0], yData[i][11]],
type: 'scatter',
mode: 'markers',
marker: {
color: colors[i],
size: 12
}
};
data.push(result, result2);
}

var layout = {
showlegend: false,
height: 350,
width: 1000,
xaxis: {
showline: true,
showgrid: false,
showticklabels: true,
linecolor: 'rgb(204,204,204)',
linewidth: 2,
autotick: false,
ticks: 'outside',
tickcolor: 'rgb(204,204,204)',
tickwidth: 2,
ticklen: 5,
tickfont: {
family: 'Arial',
size: 12,
color: 'rgb(82, 82, 82)'
}
},
yaxis: {
showgrid: false,
zeroline: false,
showline: false,
showticklabels: false
},
autosize: false,
margin: {
autoexpand: false,
l: 100,
r: 20,
t: 100
},
annotations: [
{
xref: 'paper',
yref: 'paper',
x: 0.0,
y: 1.05,
xanchor: 'left',
yanchor: 'bottom',
text: 'Resident activity levels over time',
font:{
family: 'Arial',
size: 30,
color: 'rgb(37,37,37)'
},
showarrow: false
},
]
};

for( var i = 0 ; i < xData.length ; i++ ) {
var result = {
xref: 'paper',
x: 0.05,
y: yData[i][0],
xanchor: 'right',
yanchor: 'middle',
text: labels[i] + ' ' + yData[i][0] +'%',
showarrow: false,
font: {
family: 'Arial',
size: 16,
color: 'black'
}
};
var result2 = {
xref: 'paper',
x: 0.95,
y: yData[i][11],
xanchor: 'left',
yanchor: 'middle',
text: yData[i][11] +'%',
font: {
family: 'Arial',
size: 16,
color: 'black'
},
showarrow: false
};

layout.annotations.push(result, result2);
}

Plotly.newPlot('myDiv', data, layout);

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions