PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.9.1
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.9.1
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.10.1 3.10.10 3.10.11 3.10.12 3.10.13 3.10.14 3.10.15 3.10.2 3.10.3 All 149 releases
← All changes | js/render-chartjs.js +10 -51 4.0.33.9.1 View file →
@@ -18,13 +18,8 @@
18 18
19 19 if(chart.library !== 'chartjs'){
20 20 return;
21 21 }
22 -
23 - // Bail if the chart is already rendered or is being rendered.
24 - if ( ! window.isResizeRequest && ( $('#' + id).hasClass('visualizer-chart-loaded') || ( 'canvas' !== id && $('#' + id).children( ':not(.loader, style)' ).length > 0 ) ) ) {
25 - return;
26 - }
27 22 rendered_charts[id] = 'yes';
28 23
29 24 series = chart.series;
30 25 data = chart.data;
@@ -122,40 +117,8 @@
122 117 if ( getChart ) {
123 118 return;
124 119 }
125 120
126 - // Format series label.
127 - settings.plugins.tooltip = {
128 - callbacks: {
129 - label: function(context) {
130 - var label = '';
131 - if ( 'object' === typeof context.dataset.label ) {
132 - label = context.label || '';
133 - } else {
134 - label = context.dataset.label || '';
135 - }
136 - if ( label ) {
137 - label += ': ';
138 - }
139 - var format = context.dataset.format || '';
140 - if ( format ) {
141 - var lastSuffix = numeral(context.formattedValue).format(format).replace(/[0-9]/g, '');
142 - label += context.formattedValue + lastSuffix;
143 - } else {
144 - format = 'undefined' !== typeof context.chart.config._config.options.format ? context.chart.config._config.options.format : '';
145 - if ( format ) {
146 - label += format_datum( context.formattedValue, format );
147 - } else {
148 - label += context.formattedValue;
149 - }
150 - }
151 - return label;
152 - }
153 - }
154 - };
155 -
156 - override(settings, chart);
157 -
158 121 var chartjs = new Chart(context, {
159 122 type: type,
160 123 data: {
161 124 labels: labels,
@@ -167,9 +130,9 @@
167 130 var canvas = $( 'canvas' )[0];
168 131 if ( $( '#chart-img' ).length ) {
169 132 $( '#chart-img' ).val( canvas.toDataURL() );
170 133 }
171 - }
134 + },
172 135 }],
173 136 });
174 137
175 138 // this line needs to be included twice. This is not an error.
@@ -205,8 +168,12 @@
205 168 if(typeof settings['animation'] !== 'undefined' && parseInt(settings['animation']['duration']) === 0){
206 169 settings['animation']['duration'] = 1000;
207 170 }
208 171
172 + if(typeof settings['title'] !== 'undefined' && settings['title']['text'] !== ''){
173 + settings['title']['display'] = true;
174 + }
175 +
209 176 if(typeof settings['tooltip'] !== 'undefined' && typeof settings['tooltip']['intersect'] !== 'undefined'){
210 177 // jshint ignore:line
211 178 settings['tooltip']['intersect'] = settings['tooltip']['intersect'] == true || parseInt(settings['tooltip']['intersect']) === 1; // jshint ignore:line
212 179 }
@@ -229,19 +196,11 @@
229 196 }
230 197 }
231 198 }
232 199
233 - settings.plugins = {
234 - legend: settings.legend,
235 - };
200 + handleAxes(settings, chart);
236 201
237 - if(typeof settings['title'] !== 'undefined' && settings['title']['text'] !== ''){
238 - settings.plugins['title'] = {};
239 - settings.plugins['title']['display'] = true;
240 - settings.plugins['title']['text'] = settings['title']['text'];
241 - }
242 -
243 - handleAxes(settings, chart);
202 + override(settings, chart);
244 203 }
245 204
246 205 function handleAxes(settings, chart){
247 206 if(typeof settings['yAxes'] !== 'undefined' && typeof settings['xAxes'] !== 'undefined'){
@@ -278,9 +237,9 @@
278 237 var $o = {};
279 238 if(Array.isArray(settings[axis][i]) || typeof settings[axis][i] === 'object'){
280 239 for(var j in settings[axis][i]){
281 240 var $val = '';
282 - if(j === 'labelString'){
241 + if(j === 'labelString'){
283 242 $o['display'] = true;
284 243 $val = settings[axis][i][j];
285 244 }else if(i === 'ticks'){
286 245 // number values under ticks need to be converted to numbers or the library throws a JS error.
@@ -474,9 +433,9 @@
474 433
475 434 switch(type) {
476 435 case 'number':
477 436 // numeral.js works on 0 instead of # so we just replace that in the ICU pattern set.
478 - format = format.replace(/#/g, '0').replace(/%/g, '');
437 + format = format.replace(/#/g, '0');
479 438 // we also replace all instance of '$' as that is more relevant for ticks.
480 439 if(removeDollar){
481 440 format = format.replace(/\$/g, '');
482 441 }
@@ -505,9 +464,9 @@
505 464 function override(settings, chart) {
506 465 if (settings.manual) {
507 466 try{
508 467 var options = JSON.parse(settings.manual);
509 - $.extend(true, settings, options);
468 + $.extend(settings, options);
510 469 delete settings.manual;
511 470 }catch(error){
512 471 console.error("Error while adding manual configuration override " + settings.manual);
513 472 }