diff --git a/app/components/ViewParsed.js b/app/components/ViewParsed.js index a14dc9b..a0215f7 100644 --- a/app/components/ViewParsed.js +++ b/app/components/ViewParsed.js @@ -19,6 +19,7 @@ export default class ViewParsed extends Component { this.state = { parsedContent: '', balanceZoom: false, + balanceSort: false, balanceZoomIndex: 0, balanceZoomPageSize: 30, balanceZoomData: {}, @@ -42,6 +43,26 @@ export default class ViewParsed extends Component { }); } + toggleBalanceSort() { + this.setState({ balanceSort: !this.state.balanceSort }, () => { + if (this.state.balanceSort) { + this.setState({ + balanceZoomData: this.state.parsedContent.balanceDataSorted + }); + } else { + this.setState({ + balanceZoomData: this.state.parsedContent.balanceData + }); + } + this.setState({ + balanceZoom: false, + balanceZoomIndex: 1, + balanceZoomStart: true, + balanceZoomEnd: false + }); + }); + } + unZoomBalanceData() { if (this.state.parsedContent.balanceData.labels) { this.recalculateBalanceData( @@ -94,17 +115,30 @@ export default class ViewParsed extends Component { recalculateBalanceData(start, end) { let newBalanceData = { - labels: this.state.parsedContent.balanceData.labels.slice(start, end), - datasets: this.state.parsedContent.balanceData.datasets.map(dataset => { - return { - label: dataset.label, - fill: dataset.fill, - backgroundColor: dataset.backgroundColor, - borderColor: dataset.borderColor, - pointHoverBackgroundColor: dataset.pointHoverBackgroundColor, - data: dataset.data.slice(start, end) - }; - }) + labels: this.state.balanceSort + ? this.state.parsedContent.balanceDataSorted.labels.slice(start, end) + : this.state.parsedContent.balanceData.labels.slice(start, end), + datasets: this.state.balanceSort + ? this.state.parsedContent.balanceDataSorted.datasets.map(dataset => { + return { + label: dataset.label, + fill: dataset.fill, + backgroundColor: dataset.backgroundColor, + borderColor: dataset.borderColor, + pointHoverBackgroundColor: dataset.pointHoverBackgroundColor, + data: dataset.data.slice(start, end) + }; + }) + : this.state.parsedContent.balanceData.datasets.map(dataset => { + return { + label: dataset.label, + fill: dataset.fill, + backgroundColor: dataset.backgroundColor, + borderColor: dataset.borderColor, + pointHoverBackgroundColor: dataset.pointHoverBackgroundColor, + data: dataset.data.slice(start, end) + }; + }) }; this.setState({ balanceZoomData: newBalanceData }); } @@ -143,6 +177,7 @@ export default class ViewParsed extends Component {