Fix conversion mean - hz

This commit is contained in:
Alfred Melch 2019-08-05 14:05:06 +02:00
parent ba3813c1f4
commit 41c82cfe9b

View File

@ -37,16 +37,16 @@ class WasmVsJsChart extends React.Component {
values: 'mean' values: 'mean'
} }
} }
convertDataToHz() { convertDataToHz(data) {
let datasets = this.props.data.datasets let datasets = data.datasets
for (let dataset of datasets.filter(d => d.label !== 'numberOfNodes')) { for (let dataset of datasets.filter(d => d.label !== 'numberOfNodes')) {
dataset.data = dataset.data.map(mean => 1000 / mean) dataset.data = dataset.data.map(mean => 1000 / mean)
} }
} }
render() { render() {
let data = this.props.data let data = JSON.parse(JSON.stringify(this.props.data)) // deep copy
let options = genOptions('Wasm vs. JavaScript', false, this.state.scaleY) let options = genOptions('Wasm vs. JavaScript', false, this.state.scaleY)
if (this.state.values === 'hz') this.convertDataToHz() if (this.state.values === 'hz') this.convertDataToHz(data)
return ( return (
<> <>
<Line height={400} width={400} data={data} options={options} /> <Line height={400} width={400} data={data} options={options} />