Skip to content

Commit

Permalink
fix incosistent data problem with bar chart
Browse files Browse the repository at this point in the history
  • Loading branch information
raptox committed Sep 8, 2019
1 parent 5ccfe88 commit 11c8170
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
31 changes: 18 additions & 13 deletions app/components/ViewParsed.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,34 @@ export default class ViewParsed extends Component {
balanceZoom: false,
balanceZoomIndex: 0,
balanceZoomPageSize: 30,
balanceZoomData: '',
balanceZoomData: {},
balanceZoomEnd: false,
balanceZoomStart: true
};
}

toggleBalanceZoom() {
this.setState({ balanceZoom: !this.state.balanceZoom });
this.recalculateBalanceData(0, this.state.balanceZoomPageSize);
this.setState({ balanceZoom: !this.state.balanceZoom }, () => {
if (this.state.balanceZoom) {
this.recalculateBalanceData(0, this.state.balanceZoomPageSize);
} else {
this.unZoomBalanceData();
}
});
this.setState({
balanceZoomIndex: 1,
balanceZoomStart: true,
balanceZoomEnd: false
});
}

unZoomBalanceData() {
this.recalculateBalanceData(
0,
this.state.parsedContent.balanceData.labels.length
);
}

nextPageBalance() {
if (this.state.balanceZoomEnd) {
window.alert('already on the last page');
Expand Down Expand Up @@ -79,7 +91,6 @@ export default class ViewParsed extends Component {
}

recalculateBalanceData(start, end) {
this.setState({ parsedContent: JSON.parse(this.state.rawContent) });
let newBalanceData = {
labels: this.state.parsedContent.balanceData.labels.slice(start, end),
datasets: this.state.parsedContent.balanceData.datasets.map(dataset => {
Expand Down Expand Up @@ -205,11 +216,7 @@ export default class ViewParsed extends Component {
</div>
)}
<Bar
data={
this.state.balanceZoom
? this.state.balanceZoomData
: content.balanceData
}
data={this.state.balanceZoomData}
options={{
scales: {
xAxes: [
Expand Down Expand Up @@ -363,10 +370,8 @@ export default class ViewParsed extends Component {
});
if (file) {
fs.readFile(file[0], (err, data) => {
this.setState({
parsedContent: JSON.parse(data),
rawContent: data
});
this.setState({ parsedContent: JSON.parse(data) });
this.unZoomBalanceData();
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ipm-hpc-v2",
"productName": "IPM-HPC-v2",
"version": "0.7.0",
"version": "0.7.1",
"description": "Interactive Visualization of MPI Performance Data (Bachelor Thesis)",
"scripts": {
"build": "concurrently \"yarn build-main\" \"yarn build-renderer\"",
Expand Down

0 comments on commit 11c8170

Please sign in to comment.