Skip to content

Commit 3fa5fe4

Browse files
committed
legend for word frequency chart
1 parent b4f855a commit 3fa5fe4

File tree

4 files changed

+29
-14
lines changed

4 files changed

+29
-14
lines changed

app/views/react_js.scala.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@
135135
<hr />
136136
<div id="wordCloud" class="cloud" ></div>
137137
<hr />
138+
<h5>word frequency</h5>
138139
<div id="react-bar-chart" class="barchart" ></div>
139140
</div>
140141

public/react-js/birdwatch.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ var BirdWatch = BirdWatch || {};
505505
return {ratioHist: [], posHist: [], lastUpdate: now(), posArrDir: "RIGHT", ratioArrDir: "RIGHT-UP"}
506506
},
507507
componentWillReceiveProps: function(props) {
508-
this.setState({ratioHist: _.last(this.state.ratioHist.concat(props.val / props.count), 50)});
508+
this.setState({ratioHist: _.last(this.state.ratioHist.concat(props.val / props.count), 100)});
509509
this.setState({posHist: _.last(this.state.posHist.concat(props.idx+1), 2)});
510510

511511
// slope of the fitted position change function
@@ -548,12 +548,16 @@ var BirdWatch = BirdWatch || {};
548548
var w = bar.value / arr[0].value * (barChartElem.width() - 190);
549549
return Bar( {t:bar.key, y:y, w:w, key:bar.key, idx:i, val:bar.value, count:this.props.count} );
550550
}.bind(this));
551-
return React.DOM.svg( {width:"750", height:"400"},
552-
React.DOM.g(null,
553-
bars,
554-
React.DOM.line( {transform:"translate(168, 0)", y:"0", y2:"375", stroke:"#000000"})
555-
)
556-
)
551+
return React.DOM.div(null,
552+
React.DOM.svg( {width:"750", height:"380"},
553+
React.DOM.g(null,
554+
bars,
555+
React.DOM.line( {transform:"translate(168, 0)", y:"0", y2:"375", stroke:"#000000"})
556+
)
557+
),
558+
React.DOM.p( {className:"legend"}, React.DOM.strong(null, "1st trend indicator:"), " position changes in last minute"),
559+
React.DOM.p( {className:"legend"}, React.DOM.strong(null, "2nd trend indicator:"), " ratio change termCount / totalTermsCounted over last 100 tweets")
560+
)
557561
}
558562
});
559563

public/stylesheets/main.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
body {
2+
padding-bottom: 25px;
23
}
34

45
a {
@@ -120,3 +121,8 @@ a {
120121
#tweet-count {
121122
font-weight: bold;
122123
}
124+
125+
.legend {
126+
font-size: 0.8em;
127+
margin-bottom: 0;
128+
}

react-js/jsx/barchart.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ var BirdWatch = BirdWatch || {};
4242
return {ratioHist: [], posHist: [], lastUpdate: now(), posArrDir: "RIGHT", ratioArrDir: "RIGHT-UP"}
4343
},
4444
componentWillReceiveProps: function(props) {
45-
this.setState({ratioHist: _.last(this.state.ratioHist.concat(props.val / props.count), 50)});
45+
this.setState({ratioHist: _.last(this.state.ratioHist.concat(props.val / props.count), 100)});
4646
this.setState({posHist: _.last(this.state.posHist.concat(props.idx+1), 2)});
4747

4848
// slope of the fitted position change function
@@ -85,12 +85,16 @@ var BirdWatch = BirdWatch || {};
8585
var w = bar.value / arr[0].value * (barChartElem.width() - 190);
8686
return <Bar t={bar.key} y={y} w={w} key={bar.key} idx={i} val={bar.value} count={this.props.count} />;
8787
}.bind(this));
88-
return <svg width="750" height="400">
89-
<g>
90-
{bars}
91-
<line transform="translate(168, 0)" y="0" y2="375" stroke="#000000"></line>
92-
</g>
93-
</svg>
88+
return <div>
89+
<svg width="750" height="380">
90+
<g>
91+
{bars}
92+
<line transform="translate(168, 0)" y="0" y2="375" stroke="#000000"></line>
93+
</g>
94+
</svg>
95+
<p className="legend"><strong>1st trend indicator:</strong> position changes in last minute</p>
96+
<p className="legend"><strong>2nd trend indicator:</strong> ratio change termCount / totalTermsCounted over last 100 tweets</p>
97+
</div>
9498
}
9599
});
96100

0 commit comments

Comments
 (0)