70 lines
1.4 KiB
JavaScript

import ChartJS from 'chart.js'
function genDataset(label, color, yAxisID = 'performance', type = 'line') {
return {
label,
yAxisID,
fill: false,
backgroundColor: color,
borderColor: color
}
}
export const datasetTemplates = {
numberOfNodes: genDataset('numberOfNodes', 'grey', 'nodes'),
simplifyWASM: genDataset('simplifyWASM', 'red'),
simplifyJS: genDataset('simplifyJS', 'blue'),
simplifyJSAlt: genDataset('simplifyJSAlt', 'green'),
storeCoords: genDataset('storeCoords', 'blue'),
loadResult: genDataset('loadResult', 'green')
}
export function genOptions(title, stacked = false, scaleY = 'linear') {
return {
animation: {
duration: 0
},
title: {
display: true,
text: title
},
tooltips: {
mode: 'index',
intersect: false
},
hover: {
mode: 'nearest',
intersect: false
},
scales: {
xAxes: [
{
// type: scaleX,
stacked
}
],
yAxes: [
{
id: 'performance',
type: scaleY,
stacked,
ticks: {
min: 0
}
},
{
id: 'nodes',
position: 'right',
type: scaleY,
gridLines: {
drawOnChartArea: false
},
ticks: {
min: 0
}
}
]
}
}
}