|
@@ -5,6 +5,7 @@ module.exports = {
|
5
|
5
|
pixel: filledPath(d3.curveStep),
|
6
|
6
|
roundBars: bars(true),
|
7
|
7
|
bars: bars(),
|
|
8
|
+ halfbars: halfbars(),
|
8
|
9
|
bricks: bricks(),
|
9
|
10
|
equalizer: bricks(true),
|
10
|
11
|
line: strokedPath(),
|
|
@@ -71,6 +72,39 @@ function filledPath(interpolator) {
|
71
|
72
|
|
72
|
73
|
}
|
73
|
74
|
|
|
75
|
+function halfbars () {
|
|
76
|
+ return function(context, data, options) {
|
|
77
|
+
|
|
78
|
+ context.fillStyle = options.waveColor;
|
|
79
|
+
|
|
80
|
+ var waveHeight = options.waveBottom - options.waveTop;
|
|
81
|
+
|
|
82
|
+ var baseline = options.waveTop + waveHeight / 2;
|
|
83
|
+
|
|
84
|
+ var barX = d3.scaleBand()
|
|
85
|
+ .paddingInner(0.5)
|
|
86
|
+ .paddingOuter(0.01)
|
|
87
|
+ .domain(d3.range(data.length))
|
|
88
|
+ .rangeRound([options.waveLeft, options.waveRight]);
|
|
89
|
+
|
|
90
|
+ var height = d3.scaleLinear()
|
|
91
|
+ .domain([0, 1])
|
|
92
|
+ .range([0, waveHeight / 2]);
|
|
93
|
+
|
|
94
|
+ var barWidth = barX.bandwidth();
|
|
95
|
+
|
|
96
|
+ data.forEach(function(val, i){
|
|
97
|
+
|
|
98
|
+ var h = height(val[0]) * 2,
|
|
99
|
+ x = barX(i),
|
|
100
|
+ y = waveHeight - h;
|
|
101
|
+
|
|
102
|
+ context.fillRect(x, y, barWidth, h);
|
|
103
|
+
|
|
104
|
+ });
|
|
105
|
+ }
|
|
106
|
+}
|
|
107
|
+
|
74
|
108
|
function bars(round) {
|
75
|
109
|
|
76
|
110
|
return function(context, data, options) {
|