Skip to content

Commit

Permalink
Sentiment Analysis Graph
Browse files Browse the repository at this point in the history
  • Loading branch information
anhduc130 committed Nov 1, 2016
1 parent e1c20e5 commit f750e0f
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"react": "^15.3.2",
"react-dom": "^15.3.2",
"react-dropzone": "^3.6.0",
"victory": "^0.13.3",
"webpack": "^1.13.2"
},
"devDependencies": {
Expand Down
50 changes: 50 additions & 0 deletions src/components/SentimentAnalysisGraph.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import React, { Component } from 'react';
import { VictoryAxis } from 'victory';
import { VictoryBar } from 'victory';
import { VictoryChart } from 'victory';

class SentimentAnalysisGraph extends Component {
static displayName = 'PieChart';

state = {
callFunc: this.getData(),
data: {pos_value: 90, neg_value: 10}
};

getData(){
setInterval(() => {
const rand = Math.floor(Math.random() * 100);
this.setState({
data:{pos_value: rand,
neg_value: 100 - rand}
});
}, 2500);
}

render() {
return (
<VictoryChart domain={{y: [0, 100]}} height={220}>
<VictoryAxis
style={{
axisLabel: {fontSize: 25}}}
tickValues={[' ', '', 'Positive', 'Negative', '', '']}
label = "Sentiment Anaylysis Report"/>

<VictoryBar
style={{
data: {width: 30},
labels: {fontSize: 7}
}}
animate={{velocity: 0.01}}
padding={{top:20}}
data={[
{x: 3, y: this.state.data.pos_value},
{x: 4, y: this.state.data.neg_value}
]}
labels={[this.state.data.pos_value + '%', this.state.data.neg_value + '%']}/>
</VictoryChart>
);
}
}

export default SentimentAnalysisGraph;
2 changes: 2 additions & 0 deletions src/views/UploadForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import Button from './../components/Button';
import ConceptInput from './../components/ConceptInput';
import DropArea from './../components/DropArea';
import React from 'react';
import SentimentAnalysisGraph from './../components/SentimentAnalysisGraph';

const UploadForm = () => (
<div>
<DropArea />
<Button />
<ConceptInput />
<SentimentAnalysisGraph />
</div>
);

Expand Down

0 comments on commit f750e0f

Please sign in to comment.