Last active
January 4, 2018 17:34
-
-
Save artembykov/6443b383d6852db0639bd9590fc81cdd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* global controller, Chart */ | |
const canvas = document.createElement('canvas'); | |
controller.element.appendChild(canvas); | |
const chart = new Chart(canvas, { | |
type: 'radar', | |
data: getChartData([]), | |
options: { | |
layout: { | |
padding: { | |
bottom: 30 | |
} | |
} | |
} | |
}); | |
controller.createAxisLabel({ | |
picks: 'Group By', | |
orientation: 'horizontal', | |
position: 'bottom', | |
popoverTitle: 'Group' | |
}); | |
controller.createAxisLabel({ | |
picks: 'Metric', | |
orientation: 'horizontal', | |
position: 'bottom' | |
}); | |
controller.update = function(data, progress) { | |
chart.data = getChartData(data); | |
chart.update(); | |
}; | |
function getChartData(data) { | |
const groupAccessor = controller.dataAccessors['Group By']; | |
const metricAccessor = controller.dataAccessors['Metric']; | |
return { | |
labels: data.map(item => groupAccessor.raw(item)), | |
datasets: [{ | |
data: data.map(item => metricAccessor.raw(item)), | |
label: groupAccessor.getLabel(), | |
backgroundColor: 'rgba(110, 174, 79, 0.7)', | |
borderColor: 'rgb(110, 174, 79)' | |
}] | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment