From bf710b68bcc6172a3b2ab99ec24cc5033286a595 Mon Sep 17 00:00:00 2001 From: Alfred Melch Date: Tue, 6 Aug 2019 14:34:39 +0200 Subject: [PATCH] Add chart labels --- benchmarking/src/components/chart.js | 7 ++++- benchmarking/src/components/chartOptions.js | 30 ++++++++++++++++++--- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/benchmarking/src/components/chart.js b/benchmarking/src/components/chart.js index e1b7773..32f4b2b 100644 --- a/benchmarking/src/components/chart.js +++ b/benchmarking/src/components/chart.js @@ -47,7 +47,12 @@ class WasmVsJsChart extends React.Component { render() { 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, + this.state.values + ) if (this.state.values === 'hz') this.convertDataToHz(data) return ( <> diff --git a/benchmarking/src/components/chartOptions.js b/benchmarking/src/components/chartOptions.js index 193e052..910ef8b 100644 --- a/benchmarking/src/components/chartOptions.js +++ b/benchmarking/src/components/chartOptions.js @@ -26,11 +26,31 @@ export const datasetTemplates = { transformToObjectFormCase: genDataset('transformToObjectFormCase', 'green') } -export function genOptions(title, stacked = false, scaleY = 'linear') { +function genScaleLabel(label) { + return { + display: true, + labelString: label, + fontStyle: 'bold' + } +} + +export function genOptions( + title, + stacked = false, + scaleY = 'linear', + perfUnit = 'mean' +) { + const perfUnitText = { + mean: 'Milliseconds per operation (ms)', + hz: 'Operations per second (hz)' + } return { animation: { duration: 0 }, + legend: { + position: 'bottom' + }, title: { display: true, text: title @@ -46,7 +66,7 @@ export function genOptions(title, stacked = false, scaleY = 'linear') { scales: { xAxes: [ { - // type: scaleX, + scaleLabel: genScaleLabel('Tolerance (length)'), stacked } ], @@ -57,7 +77,8 @@ export function genOptions(title, stacked = false, scaleY = 'linear') { stacked, ticks: { min: 0 - } + }, + scaleLabel: genScaleLabel(`Performance - ${perfUnitText[perfUnit]}`) }, { id: 'nodes', @@ -68,7 +89,8 @@ export function genOptions(title, stacked = false, scaleY = 'linear') { }, ticks: { min: 0 - } + }, + scaleLabel: genScaleLabel('Number of positions in result (#)') } ] }