|
|
|
@ -7,8 +7,8 @@ var BuoyAnalysisChart = { |
|
|
|
|
bars: { |
|
|
|
|
padding: 15, |
|
|
|
|
spacing: 2, |
|
|
|
|
height: 23, |
|
|
|
|
width: 190, |
|
|
|
|
height: 200, |
|
|
|
|
width: 23, |
|
|
|
|
color: '#f00', |
|
|
|
|
|
|
|
|
|
showMonths: true, |
|
|
|
@ -30,16 +30,16 @@ var BuoyAnalysisChart = { |
|
|
|
|
/** |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
barYearY: function(d, i) { |
|
|
|
|
return i * BuoyAnalysisChart.bars.height + i * BuoyAnalysisChart.bars.spacing + BuoyAnalysisChart.bars.padding; |
|
|
|
|
barYearX: function(d, i) { |
|
|
|
|
return i * BuoyAnalysisChart.bars.width + i * BuoyAnalysisChart.bars.spacing + 30; |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
barMonthY: function(d, i) { |
|
|
|
|
barMonthX: function(d, i) { |
|
|
|
|
var year = Math.floor(i / 12); |
|
|
|
|
return year * BuoyAnalysisChart.bars.height + BuoyAnalysisChart.bars.padding + year * BuoyAnalysisChart.bars.spacing + (i % 12) * 2; |
|
|
|
|
return year * BuoyAnalysisChart.bars.width + year * BuoyAnalysisChart.bars.spacing + (i % 12) * 2 + 30; |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -72,29 +72,29 @@ var BuoyAnalysisChart = { |
|
|
|
|
chart.append("g") |
|
|
|
|
.classed('axis', true) |
|
|
|
|
.classed('axis-imperial', true) |
|
|
|
|
.attr('transform', 'translate(0, 19)') |
|
|
|
|
.attr('transform', 'translate(0, 0)') |
|
|
|
|
.attr('fill', '#000') |
|
|
|
|
.call(BuoyAnalysisChart.axis.imperial); |
|
|
|
|
|
|
|
|
|
chart.append("g") |
|
|
|
|
.classed('axis', true) |
|
|
|
|
.classed('axis-metric', true) |
|
|
|
|
.attr('transform', 'translate(0, 860)') |
|
|
|
|
.attr('transform', 'translate(875, 0)') |
|
|
|
|
.call(BuoyAnalysisChart.axis.metric); |
|
|
|
|
|
|
|
|
|
chart.append('text') |
|
|
|
|
.classed('label-axis-x', true) |
|
|
|
|
.attr('text-anchor', 'middle') |
|
|
|
|
.text(BuoyAnalysisChart.bars.imperialLabel) |
|
|
|
|
.attr('x', 180) |
|
|
|
|
.attr('x', 20) |
|
|
|
|
.attr('y', 10) |
|
|
|
|
|
|
|
|
|
chart.append('text') |
|
|
|
|
.classed('label-axis-x', true) |
|
|
|
|
.attr('text-anchor', 'middle') |
|
|
|
|
.text(BuoyAnalysisChart.bars.metricLabel) |
|
|
|
|
.attr('x', 180) |
|
|
|
|
.attr('y', 876) |
|
|
|
|
.attr('x', 890) |
|
|
|
|
.attr('y', 10) |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -116,7 +116,7 @@ var BuoyAnalysisChart = { |
|
|
|
|
b += parseInt(tmp[2], 16); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
BuoyAnalysisChart.bars.color = 'rgba(' + avg(r) + ',' + avg(g) + ',' + avg(b) + ', 0.1)'; |
|
|
|
|
BuoyAnalysisChart.bars.color = 'rgba(' + avg(r) + ',' + avg(g) + ',' + avg(b) + ', 0.5)'; |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -125,7 +125,7 @@ var BuoyAnalysisChart = { |
|
|
|
|
updateAxes: function() { |
|
|
|
|
switch(BuoyAnalysisData.property) { |
|
|
|
|
case 'at': |
|
|
|
|
BuoyAnalysisChart.bars.tickValues = [8, 12, 16, 20]; |
|
|
|
|
BuoyAnalysisChart.bars.tickValues = [4, 8, 12, 16, 20]; |
|
|
|
|
|
|
|
|
|
BuoyAnalysisChart.bars.imperialLabel = '°F'; |
|
|
|
|
BuoyAnalysisChart.bars.metricLabel = '°C'; |
|
|
|
@ -135,7 +135,7 @@ var BuoyAnalysisChart = { |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
case 'wt': |
|
|
|
|
BuoyAnalysisChart.bars.tickValues = [8, 12, 16, 20]; |
|
|
|
|
BuoyAnalysisChart.bars.tickValues = [4, 8, 12, 16, 20]; |
|
|
|
|
|
|
|
|
|
BuoyAnalysisChart.bars.imperialLabel = '°F'; |
|
|
|
|
BuoyAnalysisChart.bars.metricLabel = '°C'; |
|
|
|
@ -155,7 +155,7 @@ var BuoyAnalysisChart = { |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
case 'wp': |
|
|
|
|
BuoyAnalysisChart.bars.tickValues = [5, 7, 9, 11, 13]; |
|
|
|
|
BuoyAnalysisChart.bars.tickValues = [3, 5, 7, 9, 11, 13]; |
|
|
|
|
|
|
|
|
|
BuoyAnalysisChart.bars.imperialLabel = 'SEC'; |
|
|
|
|
BuoyAnalysisChart.bars.metricLabel = 'SEC'; |
|
|
|
@ -198,38 +198,40 @@ var BuoyAnalysisChart = { |
|
|
|
|
chart.selectAll('.bar-month').remove(); |
|
|
|
|
chart.selectAll('.tick-line').remove(); |
|
|
|
|
|
|
|
|
|
chart.append('line') |
|
|
|
|
.classed('tick-line', true) |
|
|
|
|
.attr('x1', 1) |
|
|
|
|
.attr('x2', 1) |
|
|
|
|
.attr('y1', 15) |
|
|
|
|
.attr('y2', h) |
|
|
|
|
|
|
|
|
|
chart.append('line') |
|
|
|
|
.classed('tick-line', true) |
|
|
|
|
.attr('x1', BuoyAnalysisChart.axis.scale(BuoyAnalysisChart.bars.tickValues[0])) |
|
|
|
|
.attr('x2', BuoyAnalysisChart.axis.scale(BuoyAnalysisChart.bars.tickValues[0])) |
|
|
|
|
.attr('y1', 15) |
|
|
|
|
.attr('y2', h) |
|
|
|
|
|
|
|
|
|
chart.append('line') |
|
|
|
|
.classed('tick-line', true) |
|
|
|
|
.attr('x1', BuoyAnalysisChart.axis.scale(BuoyAnalysisChart.bars.tickValues[BuoyAnalysisChart.bars.tickValues.length - 1])) |
|
|
|
|
.attr('x2', BuoyAnalysisChart.axis.scale(BuoyAnalysisChart.bars.tickValues[BuoyAnalysisChart.bars.tickValues.length - 1])) |
|
|
|
|
.attr('y1', 15) |
|
|
|
|
.attr('y2', h) |
|
|
|
|
// chart.append('line')
|
|
|
|
|
// .classed('tick-line', true)
|
|
|
|
|
// .attr('x1', 1)
|
|
|
|
|
// .attr('x2', 1)
|
|
|
|
|
// .attr('y1', 15)
|
|
|
|
|
// .attr('y2', h)
|
|
|
|
|
//
|
|
|
|
|
// chart.append('line')
|
|
|
|
|
// .classed('tick-line', true)
|
|
|
|
|
// .attr('x1', BuoyAnalysisChart.axis.scale(BuoyAnalysisChart.bars.tickValues[0]))
|
|
|
|
|
// .attr('x2', BuoyAnalysisChart.axis.scale(BuoyAnalysisChart.bars.tickValues[0]))
|
|
|
|
|
// .attr('y1', 15)
|
|
|
|
|
// .attr('y2', h)
|
|
|
|
|
//
|
|
|
|
|
// chart.append('line')
|
|
|
|
|
// .classed('tick-line', true)
|
|
|
|
|
// .attr('x1', BuoyAnalysisChart.axis.scale(BuoyAnalysisChart.bars.tickValues[BuoyAnalysisChart.bars.tickValues.length - 1]))
|
|
|
|
|
// .attr('x2', BuoyAnalysisChart.axis.scale(BuoyAnalysisChart.bars.tickValues[BuoyAnalysisChart.bars.tickValues.length - 1]))
|
|
|
|
|
// .attr('y1', 15)
|
|
|
|
|
// .attr('y2', h)
|
|
|
|
|
|
|
|
|
|
if (BuoyAnalysisChart.bars.showYears === true) { |
|
|
|
|
chart.selectAll('.bar-year').data(years).enter() |
|
|
|
|
.append('rect') |
|
|
|
|
.classed('bar-year', true) |
|
|
|
|
.attr('fill', BuoyAnalysisChart.bars.color) |
|
|
|
|
.attr('height', 23) |
|
|
|
|
.attr('width', function(d) { |
|
|
|
|
.attr('width', BuoyAnalysisChart.bars.width) |
|
|
|
|
.attr('height', function(d) { |
|
|
|
|
return BuoyAnalysisChart.axis.scale(d.average); |
|
|
|
|
}) |
|
|
|
|
.attr('x', 0) |
|
|
|
|
.attr('y', BuoyAnalysisChart.barYearY) |
|
|
|
|
.attr('x', BuoyAnalysisChart.barYearX) |
|
|
|
|
.attr('y', function(d) { |
|
|
|
|
return BuoyAnalysisChart.bars.height - BuoyAnalysisChart.axis.scale(d.average); |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (BuoyAnalysisChart.bars.showMonths === true) { |
|
|
|
@ -237,18 +239,14 @@ var BuoyAnalysisChart = { |
|
|
|
|
.append('rect') |
|
|
|
|
.classed('bar-month', true) |
|
|
|
|
.attr('fill', 'rgba(0, 0, 0, 0.2)') |
|
|
|
|
.attr('height', 1) |
|
|
|
|
.attr('width', function(d) { |
|
|
|
|
var w = BuoyAnalysisChart.axis.scale(d.average); |
|
|
|
|
|
|
|
|
|
if (w <= 20) { |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return w; |
|
|
|
|
.attr('width', 1) |
|
|
|
|
.attr('height', function(d) { |
|
|
|
|
return BuoyAnalysisChart.axis.scale(d.average); |
|
|
|
|
}) |
|
|
|
|
.attr('x', BuoyAnalysisChart.barMonthX) |
|
|
|
|
.attr('y', function(d) { |
|
|
|
|
return BuoyAnalysisChart.bars.height - BuoyAnalysisChart.axis.scale(d.average); |
|
|
|
|
}) |
|
|
|
|
.attr('x', 0) |
|
|
|
|
.attr('y', BuoyAnalysisChart.barMonthY) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|