diff --git a/project_report/static/src/js/graph_renderer.js b/project_report/static/src/js/graph_renderer.js index 78e1f18..de6c8fa 100755 --- a/project_report/static/src/js/graph_renderer.js +++ b/project_report/static/src/js/graph_renderer.js @@ -324,6 +324,32 @@ var MAX_LEGEND_LENGTH = 25 * (1 + config.device.size_class); boxColor: boxColor, }; }, + /** + * This function extracts the information from the data points in tooltipModel.dataPoints + * (corresponding to datapoints over a given label determined by the mouse position) + * that will be displayed in a custom tooltip. + * + * @private + * @param {Object} tooltipModel see chartjs documentation + * @return {Object[]} + */ + _getTooltipItems: function (tooltipModel) { + var self = this; + var data = this.chart.config.data; + + var orderedItems = tooltipModel.dataPoints.sort(function (dPt1, dPt2) { + return dPt2.yLabel - dPt1.yLabel; + }); + return orderedItems.reduce( + function (acc, item) { + if (item.value > 0) { + acc.push(self._getTooltipItemContent(item, data)); + } + return acc; + }, + [] + ); + }, _isRedirectionEnabled: function () { return !this.disableLinking &&