Skip to content
Snippets Groups Projects
Commit 2f217fe9 authored by Yan, Andrew N.'s avatar Yan, Andrew N.
Browse files

get simple scatter plot of median stats working again

parent 554c776a
No related branches found
No related tags found
No related merge requests found
...@@ -37,13 +37,15 @@ const formatTime = timeFormat('%c %Z'); ...@@ -37,13 +37,15 @@ const formatTime = timeFormat('%c %Z');
class Hydrograph { class Hydrograph {
/** /**
* @param {Array} data IV data as returned by models/getTimeseries * @param {Array} data IV data as returned by models/getTimeseries
* @param {Array} calculated median for discharge
* @param {String} yLabel y-axis label * @param {String} yLabel y-axis label
* @param {String} title for svg's title attribute * @param {String} title for svg's title attribute
* @param {String} desc for svg's desc attribute * @param {String} desc for svg's desc attribute
* @param {Node} element Dom node to insert * @param {Node} element Dom node to insert
*/ */
constructor({data=[], yLabel='Data', title='', desc='', element}) { constructor({data=[], medianStats=[], yLabel='Data', title='', desc='', element}) {
this._data = data; this._data = data;
this._medianStats = medianStats;
this._yLabel = yLabel; this._yLabel = yLabel;
this._title = title; this._title = title;
this._desc = desc; this._desc = desc;
...@@ -104,7 +106,7 @@ class Hydrograph { ...@@ -104,7 +106,7 @@ class Hydrograph {
yTitle: this._yLabel yTitle: this._yLabel
}); });
this._plotDataLine(plot, xScale, yScale); this._plotDataLine(plot, xScale, yScale);
//this._plotMedianPoints(plot, xScale, yScale); this._plotMedianPoints(plot, xScale, yScale);
this._plotTooltips(plot, xScale, yScale); this._plotTooltips(plot, xScale, yScale);
} }
...@@ -135,25 +137,17 @@ class Hydrograph { ...@@ -135,25 +137,17 @@ class Hydrograph {
} }
_plotMedianPoints(plot, xScale, yScale) { _plotMedianPoints(plot, xScale, yScale) {
this._medianPromise.then( plot.selectAll('circle')
(resp) => { .data(this._medianStats)
let statistics = parseRDB(resp); .enter()
let medianData = this._parseMedianData(statistics); .append('circle')
//let data1 = {time: new Date(2018, 0, 22), value: 25}; .attr('r', '8px')
//let data2 = {time: new Date(2018, 0, 23), value: 24}; .attr('fill', 'blue')
//let medianData = [data1, data2]; .attr('cx', function(d) {
plot.selectAll('circle') return xScale(d.time);
.data(medianData) })
.enter() .attr('cy', function(d) {
.append('circle') return yScale(d.value);
.attr('r', '8px')
.attr('fill', 'blue')
.attr('cx', function(d) {
return xScale(d.time);
})
.attr('cy', function(d) {
return yScale(d.value);
});
}); });
} }
...@@ -226,6 +220,7 @@ function attachToNode(node, {siteno}) { ...@@ -226,6 +220,7 @@ function attachToNode(node, {siteno}) {
new Hydrograph({ new Hydrograph({
element: node, element: node,
data: dataIsValid ? series[0].values: [], data: dataIsValid ? series[0].values: [],
medianStats: medianStats,
yLabel: dataIsValid ? series[0].variableDescription : 'No data', yLabel: dataIsValid ? series[0].variableDescription : 'No data',
title: dataIsValid ? series[0].variableName : '', title: dataIsValid ? series[0].variableName : '',
desc: dataIsValid ? series[0].variableDescription + ' from ' + formatTime(series[0].seriesStartDate) + ' to ' + formatTime(series[0].seriesEndDate) : '' desc: dataIsValid ? series[0].variableDescription + ' from ' + formatTime(series[0].seriesStartDate) + ' to ' + formatTime(series[0].seriesEndDate) : ''
...@@ -233,19 +228,4 @@ function attachToNode(node, {siteno}) { ...@@ -233,19 +228,4 @@ function attachToNode(node, {siteno}) {
}); });
} }
// function attachToNode(node, {siteno}) {
// let ts = getTimeseries({sites: [siteno]}, series => {
// let dataIsValid = series[0] && !series[0].values.some(d => d.value === -999999);
// new Hydrograph({
// element: node,
// data: dataIsValid ? series[0].values : [],
// yLabel: dataIsValid ? series[0].variableDescription : 'No data',
// title: dataIsValid ? series[0].variableName : '',
// desc: dataIsValid ? series[0].variableDescription + ' from ' + formatTime(series[0].seriesStartDate) + ' to ' + formatTime(series[0].seriesEndDate) : ''
// });
// });
// }
module.exports = {Hydrograph, attachToNode}; module.exports = {Hydrograph, attachToNode};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment