[FIX] survey: missing vote count on top of bars

Start the a live session, I used Burger Quizz, answer a question. On the
manager side, the current vote count for each choice should be visible
on top of each bar in the chart. That vote count is missing.

During the migration of chartjs from v2 to v4, the datalabel plugin was
updated from v0.7 to v2.2 in the same time. Using the new version of the
datalabel plugin, the plugin is not automatically loaded anymore, one
must explicitely loads it.

We also removed the datalabel plugin from the bundle to load it
explicitelly instead. The JS framework finds it cleaner this way.

Task-3537480

Reference-to: 7e3c1ecdb8 ([REF] *: Update Chart.js to V4.3)
Part-of: odoo/odoo#139204
Co-authored-by: Pierre Pulinckx <pipu@odoo.com>
This commit is contained in:
Julien Castiaux
2023-11-07 11:21:50 +00:00
co-authored by Pierre Pulinckx
parent 8f77a30cc5
commit 36882a45c7
2 changed files with 7 additions and 2 deletions
-1
View File
@@ -80,7 +80,6 @@ sent mails with personal token for the invitation of the survey.
'survey/static/src/xml/survey_breadcrumb_templates.xml',
],
'survey.survey_user_input_session_assets': [
'survey/static/src/js/libs/chartjs-plugin-datalabels.js',
'survey/static/src/js/survey_session_colors.js',
'survey/static/src/js/survey_session_chart.js',
'survey/static/src/js/survey_session_text_answers.js',
@@ -1,5 +1,7 @@
/** @odoo-module **/
/* global ChartDataLabels */
import { loadJS } from "@web/core/assets";
import publicWidget from "@web/legacy/js/public/public_widget";
import SESSION_CHART_COLORS from "@survey/js/survey_session_colors";
@@ -22,6 +24,10 @@ publicWidget.registry.SurveySessionChart = publicWidget.Widget.extend({
});
},
willStart: async function () {
await loadJS("/survey/static/src/js/libs/chartjs-plugin-datalabels.js");
},
//--------------------------------------------------------------------------
// Public
//--------------------------------------------------------------------------
@@ -167,7 +173,7 @@ publicWidget.registry.SurveySessionChart = publicWidget.Widget.extend({
}
}
},
plugins: [{
plugins: [ChartDataLabels, {
/**
* The way it works is each label is an array of words.
* eg.: if we have a chart label: "this is an example of a label"