setTimeout(() => lineGraph.build({
namespace: name('lines'),
dataSource: `data/crimes-in-${currentArea.toLowerCase()}.json`,
category: currentCategory,
canvas,
scrawl,
}), 0);
}
}
break;
case 'graph-types' :
if (value !== currentGraphType) {
currentGraphType = value;
if (currentGraphType === 'bars') {
lineGraph.kill();
barGraph.build({
namespace: name('bars'),
dataSource: `data/crimes-in-${currentArea.toLowerCase()}.json`,
canvas,
scrawl,
});
crimeCategoryInput.setAttribute('disabled', '');
}
else if (currentGraphType === 'lines') {
barGraph.kill();
lineGraph.build({
namespace: name('lines'),
dataSource: `data/crimes-in-${currentArea.toLowerCase()}.json`,
category: currentCategory,
canvas,
scrawl,
});
crimeCategoryInput.removeAttribute('disabled');
}
}
break;
case 'crime-categories' :
if (currentGraphType === 'lines' && value !== currentCategory) {
currentCategory = value;
lineGraph.update({
namespace: name('lines'),
category: currentCategory,
canvas,
scrawl,
});
}
break;
}
}
}, '.control-item');