@@ -107,7 +107,7 @@ const createPieChart = (columns, id, targetModal, colours) => {
107107 return newChart ;
108108}
109109
110- const createBarChart = ( labels , columns , id , targetModal , colours , dataType ) => {
110+ const createBarChart = ( t , labels , columns , id , targetModal , colours , dataType ) => {
111111 let newChart = c3 . generate ( {
112112 bindto : targetModal ? targetModal : id ,
113113 data : {
@@ -134,7 +134,7 @@ const createBarChart = (labels, columns, id, targetModal, colours, dataType) =>
134134 } ,
135135 y : {
136136 label : {
137- text : 'Candidates registered' ,
137+ text : t ( 'Candidates registered' , { ns : 'statistics' } ) ,
138138 position : 'inner-top'
139139 } ,
140140 } ,
@@ -254,10 +254,11 @@ const getChartData = async (target, filters) => {
254254
255255/**
256256 * unloadCharts - unload all charts in a section to clear their data
257+ * @param {t } The i18next translation callback
257258 * @param {object } chartDetails
258259 * @param {string } section
259260 */
260- const unloadCharts = ( chartDetails , section ) => {
261+ const unloadCharts = ( t , chartDetails , section ) => {
261262 Object . keys ( chartDetails [ section ] ) . forEach ( ( chartID ) => {
262263 const chart = chartDetails [ section ] [ chartID ] . chartObject ;
263264 if ( chart && typeof chart . unload === 'function' ) {
@@ -266,7 +267,7 @@ const unloadCharts = (chartDetails, section) => {
266267 // Clear the chart container completely
267268 const element = document . getElementById ( chartID ) ;
268269 if ( element ) {
269- element . innerHTML = '<p>Loading...</p>' ;
270+ element . innerHTML = '<p>' + t ( ' Loading...' , { ns : 'loris' } ) + ' </p>';
270271 }
271272 } ) ;
272273} ;
@@ -278,7 +279,7 @@ const unloadCharts = (chartDetails, section) => {
278279 * This is determined by the original chart type of the data provided from the API
279280 * If data was provided as a Pie, and the requested chartType is Bar, then the data will be reformatted
280281 */
281- const setupCharts = async ( targetIsModal , chartDetails , totalLabel ) => {
282+ const setupCharts = async ( t , targetIsModal , chartDetails , totalLabel ) => {
282283 const chartPromises = [ ] ;
283284 let newChartDetails = { ...chartDetails }
284285 Object . keys ( chartDetails ) . forEach ( ( section ) => {
@@ -314,7 +315,7 @@ const setupCharts = async (targetIsModal, chartDetails, totalLabel) => {
314315 if ( chart . chartType === 'pie' ) {
315316 chartObject = createPieChart ( columns , `#${ chartID } ` , targetIsModal && '#dashboardModal' , colours ) ;
316317 } else if ( chart . chartType === 'bar' ) {
317- chartObject = createBarChart ( labels , columns , `#${ chartID } ` , targetIsModal && '#dashboardModal' , colours , chart . dataType ) ;
318+ chartObject = createBarChart ( t , labels , columns , `#${ chartID } ` , targetIsModal && '#dashboardModal' , colours , chart . dataType ) ;
318319 } else if ( chart . chartType === 'line' ) {
319320 chartObject = createLineChart ( chartData , columns , `#${ chartID } ` , chart . label , targetIsModal && '#dashboardModal' , chart . titlePrefix ) ;
320321 }
@@ -382,4 +383,4 @@ export {
382383 // recruitment.js and studyProgression.js
383384 setupCharts ,
384385 unloadCharts ,
385- } ;
386+ } ;
0 commit comments