Add chart labels
This commit is contained in:
parent
6308b16f34
commit
bf710b68bc
@ -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 (
|
||||
<>
|
||||
|
@ -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 (#)')
|
||||
}
|
||||
]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user