|
|
|
@ -176,6 +176,70 @@ var BuoyAnalysisChart = { |
|
|
|
|
}; |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
setAxisProperties: function() { |
|
|
|
|
var json = BuoyAnalysisData.stationJson; |
|
|
|
|
var property = BuoyAnalysisData.property; |
|
|
|
|
var tickValues = BuoyAnalysisChart.bars.tickValues; |
|
|
|
|
|
|
|
|
|
BuoyAnalysisChart.axis.min = 100; |
|
|
|
|
BuoyAnalysisChart.axis.max = 0; |
|
|
|
|
|
|
|
|
|
for (var id in json) { |
|
|
|
|
for (var year = BuoyAnalysisData.years.start; year <= BuoyAnalysisData.years.end; year++) { |
|
|
|
|
for (var i = 0; i < 12; i++) { |
|
|
|
|
if (json[id]['a' + year][property]['m'][i] <= 0) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (json[id]['a' + year][property]['m'][i] < BuoyAnalysisChart.axis.min) { |
|
|
|
|
BuoyAnalysisChart.axis.min = json[id]['a' + year][property]['m'][i]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (json[id]['a' + year][property]['m'][i] > BuoyAnalysisChart.axis.max) { |
|
|
|
|
BuoyAnalysisChart.axis.max = json[id]['a' + year][property]['m'][i]; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
BuoyAnalysisChart.axis.scale = d3.scale.linear().domain([0, BuoyAnalysisChart.axis.max]) |
|
|
|
|
.range([BuoyAnalysisChart.bars.height, 0]); |
|
|
|
|
|
|
|
|
|
BuoyAnalysisChart.axis.imperial = d3.svg.axis() |
|
|
|
|
.scale(BuoyAnalysisChart.axis.scale) |
|
|
|
|
.orient("right") |
|
|
|
|
.tickFormat(function(d) { |
|
|
|
|
var val; |
|
|
|
|
|
|
|
|
|
switch(BuoyAnalysisData.property) { |
|
|
|
|
case 'at': |
|
|
|
|
case 'wt': |
|
|
|
|
val = Math.round(d * 9 / 5 + 32); |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
case 'wh': |
|
|
|
|
case 'ws': |
|
|
|
|
val = Math.round(d * 3.28 * 10) / 10; |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
case 'wp': |
|
|
|
|
val = d; |
|
|
|
|
break; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
return val; |
|
|
|
|
}) |
|
|
|
|
.tickValues(tickValues); |
|
|
|
|
|
|
|
|
|
BuoyAnalysisChart.axis.metric = d3.svg.axis() |
|
|
|
|
.scale(BuoyAnalysisChart.axis.scale) |
|
|
|
|
.orient("right") |
|
|
|
|
.tickValues(tickValues); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
@ -189,7 +253,7 @@ var BuoyAnalysisChart = { |
|
|
|
|
var len = BuoyAnalysisData.years.end - BuoyAnalysisData.years.start + 1; |
|
|
|
|
var h = (BuoyAnalysisChart.bars.height + BuoyAnalysisChart.bars.spacing) * len + BuoyAnalysisChart.bars.padding; |
|
|
|
|
|
|
|
|
|
BuoyAnalysisData.setAxisProperties(); |
|
|
|
|
BuoyAnalysisChart.setAxisProperties(); |
|
|
|
|
BuoyAnalysisChart.appendAxes(); |
|
|
|
|
BuoyAnalysisChart.appendYearLabels(); |
|
|
|
|
|
|
|
|
@ -226,11 +290,11 @@ var BuoyAnalysisChart = { |
|
|
|
|
.attr('fill', BuoyAnalysisChart.bars.color) |
|
|
|
|
.attr('width', BuoyAnalysisChart.bars.width) |
|
|
|
|
.attr('height', function(d) { |
|
|
|
|
return BuoyAnalysisChart.axis.scale(d.average); |
|
|
|
|
return BuoyAnalysisChart.bars.height - BuoyAnalysisChart.axis.scale(d.average); |
|
|
|
|
}) |
|
|
|
|
.attr('x', BuoyAnalysisChart.barYearX) |
|
|
|
|
.attr('y', function(d) { |
|
|
|
|
return BuoyAnalysisChart.bars.height - BuoyAnalysisChart.axis.scale(d.average); |
|
|
|
|
return BuoyAnalysisChart.axis.scale(d.average); |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -241,11 +305,11 @@ var BuoyAnalysisChart = { |
|
|
|
|
.attr('fill', 'rgba(0, 0, 0, 0.2)') |
|
|
|
|
.attr('width', 1) |
|
|
|
|
.attr('height', function(d) { |
|
|
|
|
return BuoyAnalysisChart.axis.scale(d.average); |
|
|
|
|
return BuoyAnalysisChart.bars.height - BuoyAnalysisChart.axis.scale(d.average); |
|
|
|
|
}) |
|
|
|
|
.attr('x', BuoyAnalysisChart.barMonthX) |
|
|
|
|
.attr('y', function(d) { |
|
|
|
|
return BuoyAnalysisChart.bars.height - BuoyAnalysisChart.axis.scale(d.average); |
|
|
|
|
return BuoyAnalysisChart.axis.scale(d.average); |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|