PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.7.9
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.7.9
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 3.10.4 All 148 releases
← All changes | js/render-chartjs.js +24 -78 4.0.33.7.9 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;
@@ -69,9 +64,9 @@
69 64
70 65 for (i = 0; i < data.length; i++) {
71 66 row = [];
72 67 for (j = 0; j < series.length; j++) {
73 - if (series[j].type === 'date' || series[j].type === 'datetime') {
68 + if (series[j].type === 'date' || series[j].type === 'datetime') {
74 69 date = new Date(data[i][j]);
75 70 data[i][j] = null;
76 71 if (Object.prototype.toString.call(date) === "[object Date]") {
77 72 if (!isNaN(date.getTime())) {
@@ -117,45 +112,8 @@
117 112 }
118 113
119 114 handleSettings(settings, chart);
120 115
121 - const getChart = Chart.getChart(context);
122 - if ( getChart ) {
123 - return;
124 - }
125 -
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 116 var chartjs = new Chart(context, {
159 117 type: type,
160 118 data: {
161 119 labels: labels,
@@ -167,9 +125,9 @@
167 125 var canvas = $( 'canvas' )[0];
168 126 if ( $( '#chart-img' ).length ) {
169 127 $( '#chart-img' ).val( canvas.toDataURL() );
170 128 }
171 - }
129 + },
172 130 }],
173 131 });
174 132
175 133 // this line needs to be included twice. This is not an error.
@@ -205,8 +163,12 @@
205 163 if(typeof settings['animation'] !== 'undefined' && parseInt(settings['animation']['duration']) === 0){
206 164 settings['animation']['duration'] = 1000;
207 165 }
208 166
167 + if(typeof settings['title'] !== 'undefined' && settings['title']['text'] !== ''){
168 + settings['title']['display'] = true;
169 + }
170 +
209 171 if(typeof settings['tooltip'] !== 'undefined' && typeof settings['tooltip']['intersect'] !== 'undefined'){
210 172 // jshint ignore:line
211 173 settings['tooltip']['intersect'] = settings['tooltip']['intersect'] == true || parseInt(settings['tooltip']['intersect']) === 1; // jshint ignore:line
212 174 }
@@ -229,19 +191,11 @@
229 191 }
230 192 }
231 193 }
232 194
233 - settings.plugins = {
234 - legend: settings.legend,
235 - };
195 + handleAxes(settings, chart);
236 196
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);
197 + override(settings, chart);
244 198 }
245 199
246 200 function handleAxes(settings, chart){
247 201 if(typeof settings['yAxes'] !== 'undefined' && typeof settings['xAxes'] !== 'undefined'){
@@ -278,9 +232,9 @@
278 232 var $o = {};
279 233 if(Array.isArray(settings[axis][i]) || typeof settings[axis][i] === 'object'){
280 234 for(var j in settings[axis][i]){
281 235 var $val = '';
282 - if(j === 'labelString'){
236 + if(j === 'labelString'){
283 237 $o['display'] = true;
284 238 $val = settings[axis][i][j];
285 239 }else if(i === 'ticks'){
286 240 // number values under ticks need to be converted to numbers or the library throws a JS error.
@@ -394,24 +348,21 @@
394 348
395 349 // format the axes labels.
396 350 if(typeof settings[axis + '_format'] !== 'undefined' && settings[axis + '_format'] !== ''){
397 351 var format = settings[axis + '_format'];
398 - var isDateFormat = moment( moment().format( format ),format, true ).isValid();
399 - if ( ! isDateFormat ) {
400 - switch(axis){
401 - case 'xAxes':
402 - settings.scales.x.ticks.callback = function(value, index, values){
403 - return format_datum(value, format);
404 - };
405 - break;
406 - case 'yAxes':
407 - settings.scales.y.ticks.callback = function(value, index, values){
408 - return format_datum(value, format);
409 - };
410 - break;
411 - }
412 - delete settings[axis + '_format'];
413 - }
352 + switch(axis){
353 + case 'xAxes':
354 + settings.scales.x.ticks.callback = function(value, index, values){
355 + return format_datum(value, format);
356 + };
357 + break;
358 + case 'yAxes':
359 + settings.scales.y.ticks.callback = function(value, index, values){
360 + return format_datum(value, format);
361 + };
362 + break;
363 + }
364 + delete settings[axis + '_format'];
414 365 }
415 366 delete settings[axis];
416 367 }
417 368
@@ -474,9 +425,9 @@
474 425
475 426 switch(type) {
476 427 case 'number':
477 428 // 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, '');
429 + format = format.replace(/#/g, '0');
479 430 // we also replace all instance of '$' as that is more relevant for ticks.
480 431 if(removeDollar){
481 432 format = format.replace(/\$/g, '');
482 433 }
@@ -493,13 +444,8 @@
493 444
494 445 function format_data(datum, j, settings, series){
495 446 j = j - 1;
496 447 var format = typeof settings.series !== 'undefined' && typeof settings.series[j] !== 'undefined' ? settings.series[j].format : '';
497 - if ( '' === format && typeof settings.yAxes_format !== 'undefined' ) {
498 - format = settings.yAxes_format;
499 - } else if ( '' === format && typeof settings.xAxes_format !== 'undefined' ) {
500 - format = settings.xAxes_format;
501 - }
502 448 return format_datum(datum, format, series[j + 1].type);
503 449 }
504 450
505 451 function override(settings, chart) {
@@ -505,9 +451,9 @@
505 451 function override(settings, chart) {
506 452 if (settings.manual) {
507 453 try{
508 454 var options = JSON.parse(settings.manual);
509 - $.extend(true, settings, options);
455 + $.extend(settings, options);
510 456 delete settings.manual;
511 457 }catch(error){
512 458 console.error("Error while adding manual configuration override " + settings.manual);
513 459 }