PluginProbe
Chartify – WordPress Chart Plugin / 3.8.1
Chartify – WordPress Chart Plugin v3.8.1
3.8.1 3.8.0 3.7.9 3.7.8 3.7.7 3.7.6 3.7.5 trunk 1.0.0 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 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.1.4 3.1.5 All 84 releases
← All changes | admin/js/chart-builder-admin-chartjs.js +867 -2 3.0.7 → 3.8.1 View file →
@@ -158,8 +158,268 @@
158 158 _this.$el.find('#'+_this.htmlClassPrefix+'description').on('input', function () {
159 159 _this.$el.find('.'+_this.htmlClassPrefix+'charts-description').text($(this).val());
160 160 });
161 161
162 + // chart styles
163 + _this.$el.find('#'+_this.htmlClassPrefix+'option-width').on('input', function () {
164 + var format = _this.$el.find('#'+_this.htmlClassPrefix+'option-width-format').val() == '%' ? '%' : '';
165 + _this.chartSourceData.settings.chart_width = $(this).val();
166 + _this.$el.find('.'+_this.htmlClassPrefix+'charts-main-container').css('width', $(this).val() + format);
167 + _this.chartObject.update();
168 + });
169 +
170 + _this.$el.find('#'+_this.htmlClassPrefix+'option-width-format').on('change', function () {
171 + var format = '%';
172 + if ($(this).val() == 'px') {
173 + format = '';
174 + }
175 + var value = _this.$el.find('#'+_this.htmlClassPrefix+'option-width').val();
176 + _this.$el.find('.'+_this.htmlClassPrefix+'charts-main-container').css('width', value + format);
177 + _this.chartObject.update();
178 + });
179 +
180 + _this.$el.find('#'+_this.htmlClassPrefix+'option-height').on('input', function () {
181 + var format = _this.$el.find('#'+_this.htmlClassPrefix+'option-height-format').val() == '%' ? '%' : '';
182 + _this.chartSourceData.settings.chart_height = $(this).val();
183 + _this.$el.find('.'+_this.htmlClassPrefix+'charts-main-container').css('height', $(this).val() + format);
184 + _this.chartObject.update();
185 + });
186 +
187 + _this.$el.find('#'+_this.htmlClassPrefix+'option-height-format').on('change', function () {
188 + var format = '';
189 + if ($(this).val() == '%') {
190 + format = '%';
191 + }
192 + var value = _this.$el.find('#'+_this.htmlClassPrefix+'option-height').val();
193 + _this.$el.find('.'+_this.htmlClassPrefix+'charts-main-container').css('height', value + format);
194 + _this.chartObject.update();
195 + });
196 +
197 + _this.$el.find('#'+_this.htmlClassPrefix+'option-border-width').on('input', function () {
198 + _this.chartSourceData.settings.border_width = $(this).val();
199 + _this.$el.find('.'+_this.htmlClassPrefix+'charts-main-container').css('border-width', $(this).val() + 'px');
200 + _this.chartObject.update();
201 + });
202 +
203 + _this.$el.find('#'+_this.htmlClassPrefix+'option-border-radius').on('input', function () {
204 + _this.chartSourceData.settings.border_radius = $(this).val();
205 + _this.$el.find('.'+_this.htmlClassPrefix+'charts-main-container').css('border-radius', $(this).val() + 'px');
206 + _this.chartObject.update();
207 + });
208 +
209 + _this.$el.find('#'+_this.htmlClassPrefix+'option-border-color').on('input', function () {
210 + _this.chartSourceData.settings.border_color = $(this).val();
211 + _this.$el.find('.'+_this.htmlClassPrefix+'charts-main-container').css('border-color', $(this).val());
212 + _this.chartObject.update();
213 + });
214 +
215 + _this.$el.find('#'+_this.htmlClassPrefix+'option-border-style').on('change', function () {
216 + _this.chartSourceData.settings.border_style = $(this).val();
217 + _this.$el.find('.'+_this.htmlClassPrefix+'charts-main-container').css('border-style', $(this).val());
218 + _this.chartObject.update();
219 + });
220 +
221 + _this.$el.find('#'+_this.htmlClassPrefix+'option-background-color').on('input', function () {
222 + _this.chartSourceData.settings.background_color = $(this).val();
223 + _this.$el.find('.'+_this.htmlClassPrefix+'charts-main-container').css('background-color', $(this).val());
224 + _this.chartObject.update();
225 + });
226 +
227 + _this.$el.find('#'+_this.htmlClassPrefix+'option-border-width-with-title').on('input', function () {
228 + _this.chartSourceData.settings.border_width_with_title = $(this).val();
229 + _this.$el.find('.'+_this.htmlClassPrefix+'container').css('border-width', $(this).val() + 'px');
230 + _this.chartObject.update();
231 + });
232 +
233 + _this.$el.find('#'+_this.htmlClassPrefix+'option-border-radius-with-title').on('input', function () {
234 + _this.chartSourceData.settings.border_radius_with_title = $(this).val();
235 + _this.$el.find('.'+_this.htmlClassPrefix+'container').css('border-radius', $(this).val() + 'px');
236 + _this.chartObject.update();
237 + });
238 +
239 + _this.$el.find('#'+_this.htmlClassPrefix+'option-border-color-with-title').on('input', function () {
240 + _this.chartSourceData.settings.border_color_with_title = $(this).val();
241 + _this.$el.find('.'+_this.htmlClassPrefix+'container').css('border-color', $(this).val());
242 + _this.chartObject.update();
243 + });
244 +
245 + _this.$el.find('#'+_this.htmlClassPrefix+'option-border-style-with-title').on('change', function () {
246 + _this.chartSourceData.settings.border_style_with_title = $(this).val();
247 + _this.$el.find('.'+_this.htmlClassPrefix+'container').css('border-style', $(this).val());
248 + _this.chartObject.update();
249 + });
250 +
251 + _this.$el.find('#'+_this.htmlClassPrefix+'option-box-shadow').on('change', function () {
252 + if ($(this).is(':checked')) {
253 + _this.$el.find('.'+_this.htmlClassPrefix+'charts-main-container').css('box-shadow', '2px 2px 10px 2px ' + _this.chartSourceData.settings.box_shadow_color);
254 + } else {
255 + _this.$el.find('.'+_this.htmlClassPrefix+'charts-main-container').css('box-shadow', 'unset');
256 + }
257 + _this.chartObject.update();
258 + });
259 +
260 + _this.$el.find('#'+_this.htmlClassPrefix+'option-box-shadow-color').on('input', function () {
261 + if (_this.$el.find('#'+_this.htmlClassPrefix+'option-box-shadow').is(':checked')) {
262 + _this.chartSourceData.settings.box_shadow_color = $(this).val();
263 + _this.$el.find('.'+_this.htmlClassPrefix+'charts-main-container').css('box-shadow', '2px 2px 10px 2px ' + _this.chartSourceData.settings.box_shadow_color);
264 + _this.chartObject.update();
265 + }
266 + });
267 +
268 + _this.$el.find('#'+_this.htmlClassPrefix+'option-padding-outer').on('input', function () {
269 + _this.chartSourceData.settings.padding_outer = $(this).val();
270 + _this.$el.find('.'+_this.htmlClassPrefix+'container').css('padding', $(this).val() + 'px');
271 + _this.chartObject.update();
272 + });
273 +
274 + //title
275 + _this.$el.find('#'+_this.htmlClassPrefix+'option-title-gap').on('input', function () {
276 + _this.chartSourceData.settings.title_gap = $(this).val();
277 + _this.$el.find('.'+_this.htmlClassPrefix+'header-container').attr('style', 'margin-bottom: ' + $(this).val() + 'px' + ' !important;');
278 + _this.chartObject.update();
279 + });
280 +
281 + _this.$el.find('#'+_this.htmlClassPrefix+'option-title-color').on('input', function () {
282 + _this.chartSourceData.settings.title_color = $(this).val();
283 + _this.$el.find('.'+_this.htmlClassPrefix+'charts-title').css('color', $(this).val());
284 + _this.chartObject.update();
285 + });
286 +
287 + _this.$el.find('#'+_this.htmlClassPrefix+'option-title-font-size').on('input', function () {
288 + _this.chartSourceData.settings.title_font_size = $(this).val();
289 + _this.$el.find('.'+_this.htmlClassPrefix+'charts-title').css('font-size', $(this).val() + 'px');
290 + _this.chartObject.update();
291 + });
292 +
293 + _this.$el.find('#'+_this.htmlClassPrefix+'option-title-bold').on('change', function () {
294 + _this.chartSourceData.settings.title_bold = $(this).is(':checked') ? 'checked' : '';
295 + _this.$el.find('.'+_this.htmlClassPrefix+'charts-title').css('font-weight', $(this).is(':checked') ? 'bold' : 'normal');
296 + _this.chartObject.update();
297 + });
298 +
299 + _this.$el.find('#'+_this.htmlClassPrefix+'option-title-italic').on('change', function () {
300 + _this.chartSourceData.settings.title_italic = $(this).is(':checked') ? 'checked' : '';
301 + _this.$el.find('.'+_this.htmlClassPrefix+'charts-title').css('font-style', $(this).is(':checked') ? 'italic' : 'normal');
302 + _this.chartObject.update();
303 + });
304 +
305 + _this.$el.find('#'+_this.htmlClassPrefix+'option-title-text-shadow').on('change', function () {
306 + if ($(this).is(':checked')) {
307 + _this.$el.find('.'+_this.htmlClassPrefix+'charts-title').css('text-shadow', '2px 2px 5px ' + _this.chartSourceData.settings.title_shadow_color);
308 + } else {
309 + _this.$el.find('.'+_this.htmlClassPrefix+'charts-title').css('text-shadow', 'unset');
310 + }
311 + _this.chartObject.update();
312 + });
313 +
314 + _this.$el.find('#'+_this.htmlClassPrefix+'option-title-shadow-color').on('input', function () {
315 + if (_this.$el.find('#'+_this.htmlClassPrefix+'option-title-text-shadow').is(':checked')) {
316 + _this.chartSourceData.settings.title_shadow_color = $(this).val();
317 + _this.$el.find('.'+_this.htmlClassPrefix+'charts-title').css('text-shadow', '2px 2px 5px ' + $(this).val());
318 + _this.chartObject.update();
319 + }
320 + });
321 +
322 + _this.$el.find('#'+_this.htmlClassPrefix+'option-title-position').on('change', function () {
323 + _this.chartSourceData.settings.title_position = $(this).val();
324 + _this.$el.find('.'+_this.htmlClassPrefix+'charts-title').css('text-align', $(this).val());
325 + _this.chartObject.update();
326 + });
327 +
328 + _this.$el.find('#'+_this.htmlClassPrefix+'option-title-text-transform').on('change', function () {
329 + _this.chartSourceData.settings.title_transform = $(this).val();
330 + _this.$el.find('.'+_this.htmlClassPrefix+'charts-title').css('text-transform', $(this).val());
331 + _this.chartObject.update();
332 + });
333 +
334 + _this.$el.find('#'+_this.htmlClassPrefix+'option-title-text-decoration').on('change', function () {
335 + _this.chartSourceData.settings.title_decoration = $(this).val();
336 + _this.$el.find('.'+_this.htmlClassPrefix+'charts-title').css('text-decoration', $(this).val());
337 + _this.chartObject.update();
338 + });
339 +
340 + _this.$el.find('#'+_this.htmlClassPrefix+'option-title-letter-spacing').on('input', function () {
341 + _this.chartSourceData.settings.title_letter_spacing = $(this).val();
342 + _this.$el.find('.'+_this.htmlClassPrefix+'charts-title').css('letter-spacing', $(this).val() + 'px');
343 + _this.chartObject.update();
344 + });
345 +
346 + _this.$el.find('#'+_this.htmlClassPrefix+'option-title-gap-description').on('input', function () {
347 + _this.chartSourceData.settings.title_gap_description = $(this).val();
348 + _this.$el.find('.'+_this.htmlClassPrefix+'charts-title').css('margin-bottom', $(this).val() + 'px');
349 + _this.chartObject.update();
350 + });
351 +
352 + // description
353 + _this.$el.find('#'+_this.htmlClassPrefix+'description').on('input', function () {
354 + _this.$el.find('.'+_this.htmlClassPrefix+'charts-description').text($(this).val());
355 + });
356 +
357 + _this.$el.find('#'+_this.htmlClassPrefix+'option-description-color').on('input', function () {
358 + _this.chartSourceData.settings.description_color = $(this).val();
359 + _this.$el.find('.'+_this.htmlClassPrefix+'charts-description').css('color', $(this).val());
360 + _this.chartObject.update();
361 + });
362 +
363 + _this.$el.find('#'+_this.htmlClassPrefix+'option-description-font-size').on('input', function () {
364 + _this.chartSourceData.settings.description_font_size = $(this).val();
365 + _this.$el.find('.'+_this.htmlClassPrefix+'charts-description').css('font-size', $(this).val() + 'px');
366 + _this.chartObject.update();
367 + });
368 +
369 + _this.$el.find('#'+_this.htmlClassPrefix+'option-description-bold').on('change', function () {
370 + _this.chartSourceData.settings.description_bold = $(this).is(':checked') ? 'checked' : '';
371 + _this.$el.find('.'+_this.htmlClassPrefix+'charts-description').css('font-weight', $(this).is(':checked') ? 'bold' : 'normal');
372 + _this.chartObject.update();
373 + });
374 +
375 + _this.$el.find('#'+_this.htmlClassPrefix+'option-description-italic').on('change', function () {
376 + _this.chartSourceData.settings.description_italic = $(this).is(':checked') ? 'checked' : '';
377 + _this.$el.find('.'+_this.htmlClassPrefix+'charts-description').css('font-style', $(this).is(':checked') ? 'italic' : 'normal');
378 + _this.chartObject.update();
379 + });
380 +
381 + _this.$el.find('#'+_this.htmlClassPrefix+'option-description-text-shadow').on('change', function () {
382 + if ($(this).is(':checked')) {
383 + _this.$el.find('.'+_this.htmlClassPrefix+'charts-description').css('text-shadow', '2px 2px 5px ' + _this.chartSourceData.settings.description_shadow_color);
384 + } else {
385 + _this.$el.find('.'+_this.htmlClassPrefix+'charts-description').css('text-shadow', 'unset');
386 + }
387 + _this.chartObject.update();
388 + });
389 +
390 + _this.$el.find('#'+_this.htmlClassPrefix+'option-description-shadow-color').on('input', function () {
391 + if (_this.$el.find('#'+_this.htmlClassPrefix+'option-description-text-shadow').is(':checked')) {
392 + _this.chartSourceData.settings.description_shadow_color = $(this).val();
393 + _this.$el.find('.'+_this.htmlClassPrefix+'charts-description').css('text-shadow', '2px 2px 5px ' + $(this).val());
394 + _this.chartObject.update();
395 + }
396 + });
397 +
398 + _this.$el.find('#'+_this.htmlClassPrefix+'option-description-position').on('change', function () {
399 + _this.chartSourceData.settings.description_position = $(this).val();
400 + _this.$el.find('.'+_this.htmlClassPrefix+'charts-description').css('text-align', $(this).val());
401 + _this.chartObject.update();
402 + });
403 +
404 + _this.$el.find('#'+_this.htmlClassPrefix+'option-description-text-transform').on('change', function () {
405 + _this.chartSourceData.settings.description_transform = $(this).val();
406 + _this.$el.find('.'+_this.htmlClassPrefix+'charts-description').css('text-transform', $(this).val());
407 + _this.chartObject.update();
408 + });
409 +
410 + _this.$el.find('#'+_this.htmlClassPrefix+'option-description-text-decoration').on('change', function () {
411 + _this.chartSourceData.settings.description_decoration = $(this).val();
412 + _this.$el.find('.'+_this.htmlClassPrefix+'charts-description').css('text-decoration', $(this).val());
413 + _this.chartObject.update();
414 + });
415 +
416 + _this.$el.find('#'+_this.htmlClassPrefix+'option-description-letter-spacing').on('input', function () {
417 + _this.chartSourceData.settings.description_letter_spacing = $(this).val();
418 + _this.$el.find('.'+_this.htmlClassPrefix+'charts-description').css('letter-spacing', $(this).val() + 'px');
419 + _this.chartObject.update();
420 + });
421 +
162 422 // advanced options
163 423 _this.$el.find('#'+_this.htmlClassPrefix+'option-outer-radius').on('input', function () {
164 424 _this.chartSourceData.settings.outer_radius = $(this).val();
165 425 _this.chartObject.options.radius = _this.chartSourceData.settings.outer_radius;
@@ -182,10 +442,277 @@
182 442 _this.chartSourceData.settings.start_angle = $(this).val();
183 443 _this.chartObject.options.rotation = _this.chartSourceData.settings.start_angle;
184 444 _this.chartObject.update();
185 445 });
446 +
447 + _this.$el.find('#'+_this.htmlClassPrefix+'option-rotation-degree').on('input', function () {
448 + _this.chartSourceData.settings.rotation_degree = $(this).val();
449 + _this.chartObject.options.rotation = _this.chartSourceData.settings.rotation_degree;
450 + _this.chartObject.update();
451 + });
452 +
453 + _this.$el.find('#'+_this.htmlClassPrefix+'option-data-grouping-limit, #'+_this.htmlClassPrefix+'option-data-grouping-label, #'+_this.htmlClassPrefix+'option-data-grouping-color').on('input', function () {
454 + _this.chartSourceData.settings.data_grouping_limit = _this.$el.find('#'+_this.htmlClassPrefix+'option-data-grouping-limit').val();
455 + _this.chartSourceData.settings.data_grouping_label = _this.$el.find('#'+_this.htmlClassPrefix+'option-data-grouping-label').val();
456 + _this.chartSourceData.settings.data_grouping_color = _this.$el.find('#'+_this.htmlClassPrefix+'option-data-grouping-color').val();
457 + _this.chartObject.destroy();
458 + _this.loadChartBySource();
459 + });
460 + // Slices settings
461 + _this.$el.find('.'+_this.htmlClassPrefix+'option-slice-color').on('input', function () {
462 + var id = $(this).attr('data-slice-id');
463 + _this.chartSourceData.settings.slice_color[id] = $(this).val();
464 + if (_this.chartObject.data.datasets[0].backgroundColor) {
465 + _this.chartObject.data.datasets[0].backgroundColor[id] = $(this).val();
466 + }
467 + _this.chartObject.update();
468 + });
469 +
470 + _this.$el.find('.'+_this.htmlClassPrefix+'option-slice-border-color').on('input', function () {
471 + var id = $(this).attr('data-slice-id');
472 + _this.chartSourceData.settings.slices_border_color[id] = $(this).val();
473 + if (_this.chartObject.data.datasets[0].borderColor) {
474 + _this.chartObject.data.datasets[0].borderColor[id] = $(this).val();
475 + }
476 + _this.chartObject.update();
477 + });
478 +
479 + _this.$el.find('#'+_this.htmlClassPrefix+'option-slice-border-color').on('input', function () {
480 + _this.chartSourceData.settings.slice_border_color = $(this).val();
481 + _this.chartObject.options.borderColor = _this.chartSourceData.settings.slice_border_color;
482 + _this.chartObject.update();
483 + });
484 +
485 + _this.$el.find('#' + _this.htmlClassPrefix + 'option-slice-border-width').on('input', function () {
486 + const val = parseInt($(this).val(), 10) || 0;
487 + _this.chartSourceData.settings.slice_border_width = val;
488 + _this.chartObject.data.datasets[0].borderWidth = val;
489 + _this.chartObject.update();
490 + });
491 +
492 + //tooltip settings
493 + _this.$el.find('#'+_this.htmlClassPrefix+'option-tooltip-text-color').on('input', function () {
494 + _this.chartSourceData.settings.tooltip_text_color = $(this).val();
495 + _this.chartObject.options.plugins.tooltip.titleColor = _this.chartSourceData.settings.tooltip_text_color;
496 + _this.chartObject.options.plugins.tooltip.bodyColor = _this.chartSourceData.settings.tooltip_text_color;
497 + _this.chartObject.update();
498 + });
499 +
500 + _this.$el.find('#'+_this.htmlClassPrefix+'option-tooltip-text').on('change', function () {
501 + _this.chartSourceData.settings.tooltip_text = $(this).val();
502 + _this.chartObject.options.plugins.tooltip.callbacks = _this.getTooltipCallbacks(_this.chartSourceData.settings.tooltip_text, _this.chartSourceData.settings.show_color_code);
503 + _this.chartObject.update();
504 + });
505 +
506 + _this.$el.find('#'+_this.htmlClassPrefix+'option-show-color-code').on('change', function () {
507 + _this.chartSourceData.settings.show_color_code = $(this).is(':checked') ? 'checked' : '';
508 + _this.chartObject.options.plugins.tooltip.callbacks = _this.getTooltipCallbacks(_this.chartSourceData.settings.tooltip_text, _this.chartSourceData.settings.show_color_code);
509 + _this.chartObject.update();
510 + });
511 +
512 + _this.$el.find('#'+_this.htmlClassPrefix+'option-tooltip-italic').on('change', function () {
513 + _this.chartSourceData.settings.tooltip_italic = $(this).is(':checked') ? 'checked' : '';
514 + _this.updateTooltipItalic();
515 + _this.chartObject.update();
516 + });
517 +
518 + _this.$el.find('#'+_this.htmlClassPrefix+'option-tooltip-font-size').on('input', function () {
519 + _this.chartSourceData.settings.tooltip_font_size = $(this).val();
520 + _this.updateTooltipFontSize();
521 + _this.chartObject.update();
522 + });
523 +
524 + _this.$el.find('#'+_this.htmlClassPrefix+'option-tooltip-bold').on('change', function () {
525 + _this.chartSourceData.settings.tooltip_bold = $(this).val();
526 + _this.updateTooltipBold();
527 + _this.chartObject.update();
528 + });
529 +
530 + // legend settings
531 + _this.$el.find('#'+_this.htmlClassPrefix+'option-legend-position').on('change', function () {
532 + _this.chartSourceData.settings.legend_position = $(this).val();
533 + _this.chartObject.options.plugins.legend.position = _this.chartSourceData.settings.legend_position;
534 + _this.chartObject.update();
535 + });
536 +
537 + _this.$el.find('#'+_this.htmlClassPrefix+'option-legend-alignment').on('change', function () {
538 + _this.chartSourceData.settings.legend_alignment = $(this).val();
539 + _this.chartObject.options.plugins.legend.align = _this.chartSourceData.settings.legend_alignment;
540 + _this.chartObject.update();
541 + });
542 +
543 + _this.$el.find('#'+_this.htmlClassPrefix+'option-legend-font-color').on('input', function () {
544 + _this.chartSourceData.settings.legend_font_color = $(this).val();
545 + _this.chartObject.options.plugins.legend.labels.color = _this.chartSourceData.settings.legend_font_color;
546 + _this.chartObject.update();
547 + });
548 +
549 + _this.$el.find('#'+_this.htmlClassPrefix+'option-legend-font-size').on('input', function () {
550 + _this.chartSourceData.settings.legend_font_size = $(this).val();
551 + _this.chartObject.options.plugins.legend.labels.font.size = _this.chartSourceData.settings.legend_font_size;
552 + _this.chartObject.update();
553 + });
554 +
555 + _this.$el.find('#'+_this.htmlClassPrefix+'option-legend-reverse').on('change', function () {
556 + _this.chartSourceData.settings.legend_reverse = $(this).is(':checked');
557 + _this.chartObject.options.plugins.legend.reverse = _this.chartSourceData.settings.legend_reverse ? 'checked' : '';
558 + _this.chartObject.update();
559 + });
560 +
561 + _this.$el.find('#'+_this.htmlClassPrefix+'option-legend-italic').on('change', function () {
562 + _this.chartSourceData.settings.legend_italic = $(this).is(':checked');
563 + _this.chartObject.options.plugins.legend.labels.font.style = _this.chartSourceData.settings.legend_italic ? 'italic' : 'normal';
564 + _this.chartObject.update();
565 + });
566 +
567 + _this.$el.find('#'+_this.htmlClassPrefix+'option-legend-bold').on('change', function () {
568 + _this.chartSourceData.settings.legend_bold = $(this).is(':checked');
569 + _this.chartObject.options.plugins.legend.labels.font.weight = _this.chartSourceData.settings.legend_bold ? 'bold' : 'normal';
570 + _this.chartObject.update();
571 + });
572 +
573 + // interactivity settings
574 + _this.$el.find('#'+_this.htmlClassPrefix+'option-enable-interactivity').on('change', function () {
575 + _this.chartSourceData.settings.enable_interactivity = $(this).is(':checked') ? 'checked' : '';
576 + _this.updateInteractivity();
577 + _this.chartObject.update();
578 + });
579 +
186 580 }
187 581
582 + ChartBuilderChartsJs.prototype.updateInteractivity = function() {
583 + var _this = this;
584 + var enableInteractivity = _this.chartSourceData.settings.enable_interactivity === 'checked';
585 +
586 + if (enableInteractivity) {
587 + // Enable tooltips and hover
588 + _this.chartObject.options.plugins.tooltip.enabled = true;
589 + _this.chartObject.options.hover = {
590 + mode: 'nearest',
591 + intersect: true
592 + };
593 + } else {
594 + // Disable tooltips and hover
595 + _this.chartObject.options.plugins.tooltip.enabled = false;
596 + _this.chartObject.options.hover = {
597 + mode: null,
598 + intersect: false
599 + };
600 + }
601 + }
602 +
603 + ChartBuilderChartsJs.prototype.updateTooltipColorCode = function() {
604 + var _this = this;
605 + _this.chartObject.options.plugins.tooltip.events = ['click'];
606 + _this.chartObject.options.plugins.tooltip.callbacks = _this.getTooltipCallbacks(_this.chartSourceData.settings.tooltip_text, _this.chartSourceData.settings.show_color_code);
607 + };
608 +
609 + ChartBuilderChartsJs.prototype.updateTooltipItalic = function() {
610 + var _this = this;
611 + var isItalic = _this.chartSourceData.settings.tooltip_italic === 'checked';
612 +
613 + // Set tooltip font style based on italic setting
614 + if (_this.chartObject.options.plugins.tooltip.titleFont) {
615 + _this.chartObject.options.plugins.tooltip.titleFont.style = isItalic ? 'italic' : 'normal';
616 + } else {
617 + _this.chartObject.options.plugins.tooltip.titleFont = {
618 + style: isItalic ? 'italic' : 'normal'
619 + };
620 + }
621 +
622 + if (_this.chartObject.options.plugins.tooltip.bodyFont) {
623 + _this.chartObject.options.plugins.tooltip.bodyFont.style = isItalic ? 'italic' : 'normal';
624 + } else {
625 + _this.chartObject.options.plugins.tooltip.bodyFont = {
626 + style: isItalic ? 'italic' : 'normal'
627 + };
628 + }
629 +
630 + if (_this.chartObject.options.plugins.tooltip.footerFont) {
631 + _this.chartObject.options.plugins.tooltip.footerFont.style = isItalic ? 'italic' : 'normal';
632 + } else {
633 + _this.chartObject.options.plugins.tooltip.footerFont = {
634 + style: isItalic ? 'italic' : 'normal'
635 + };
636 + }
637 + }
638 +
639 + ChartBuilderChartsJs.prototype.updateTooltipFontSize = function() {
640 + var _this = this;
641 + var fontSize = parseInt(_this.chartSourceData.settings.tooltip_font_size) || 12;
642 +
643 + // Set tooltip font size based on setting
644 + if (_this.chartObject.options.plugins.tooltip.titleFont) {
645 + _this.chartObject.options.plugins.tooltip.titleFont.size = fontSize;
646 + } else {
647 + _this.chartObject.options.plugins.tooltip.titleFont = {
648 + size: fontSize
649 + };
650 + }
651 +
652 + if (_this.chartObject.options.plugins.tooltip.bodyFont) {
653 + _this.chartObject.options.plugins.tooltip.bodyFont.size = fontSize;
654 + } else {
655 + _this.chartObject.options.plugins.tooltip.bodyFont = {
656 + size: fontSize
657 + };
658 + }
659 +
660 + if (_this.chartObject.options.plugins.tooltip.footerFont) {
661 + _this.chartObject.options.plugins.tooltip.footerFont.size = fontSize;
662 + } else {
663 + _this.chartObject.options.plugins.tooltip.footerFont = {
664 + size: fontSize
665 + };
666 + }
667 + }
668 +
669 + ChartBuilderChartsJs.prototype.updateTooltipBold = function() {
670 + var _this = this;
671 + var boldSetting = _this.chartSourceData.settings.tooltip_bold;
672 + var isBold = boldSetting === 'true';
673 +
674 + // Set tooltip font weight based on bold setting
675 + if (boldSetting === 'default') {
676 + // Use default (remove custom weight)
677 + if (_this.chartObject.options.plugins.tooltip.titleFont) {
678 + delete _this.chartObject.options.plugins.tooltip.titleFont.weight;
679 + }
680 + if (_this.chartObject.options.plugins.tooltip.bodyFont) {
681 + delete _this.chartObject.options.plugins.tooltip.bodyFont.weight;
682 + }
683 + if (_this.chartObject.options.plugins.tooltip.footerFont) {
684 + delete _this.chartObject.options.plugins.tooltip.footerFont.weight;
685 + }
686 + } else {
687 + var weight = isBold ? 'bold' : 'normal';
688 +
689 + if (_this.chartObject.options.plugins.tooltip.titleFont) {
690 + _this.chartObject.options.plugins.tooltip.titleFont.weight = weight;
691 + } else {
692 + _this.chartObject.options.plugins.tooltip.titleFont = {
693 + weight: weight
694 + };
695 + }
696 +
697 + if (_this.chartObject.options.plugins.tooltip.bodyFont) {
698 + _this.chartObject.options.plugins.tooltip.bodyFont.weight = weight;
699 + } else {
700 + _this.chartObject.options.plugins.tooltip.bodyFont = {
701 + weight: weight
702 + };
703 + }
704 +
705 + if (_this.chartObject.options.plugins.tooltip.footerFont) {
706 + _this.chartObject.options.plugins.tooltip.footerFont.weight = weight;
707 + } else {
708 + _this.chartObject.options.plugins.tooltip.footerFont = {
709 + weight: weight
710 + };
711 + }
712 + }
713 + }
714 +
188 715 ChartBuilderChartsJs.prototype.detectManualChange = function (e) {
189 716 var input = $(document).find('input[name="ays_source_type"]');
190 717 if (input.val() !== 'manual') input.val('manual');
191 718 }
@@ -351,8 +878,38 @@
351 878 }
352 879 }
353 880 }
354 881
882 + Chart.register({
883 + id: 'hoverGlowPlugin',
884 + beforeDraw(chart) {
885 + if (chart.config.type !== 'pie') {
886 + return;
887 + }
888 + const ctx = chart.ctx;
889 + const activeElements = chart.getActiveElements();
890 +
891 + if (activeElements.length === 0) {
892 + return;
893 + }
894 + const meta = chart.getDatasetMeta(activeElements[0].datasetIndex);
895 + const element = meta.data[activeElements[0].index];
896 +
897 + if (!element) {
898 + return;
899 + }
900 + const sliceColor = element.options.backgroundColor || 'rgba(0, 0, 0, 1)';
901 + ctx.save();
902 + ctx.shadowColor = sliceColor;
903 + ctx.shadowBlur = 15;
904 + ctx.shadowOffsetX = 0;
905 + ctx.shadowOffsetY = 0;
906 +
907 + element.draw(ctx);
908 + ctx.restore();
909 + }
910 + });
911 +
355 912 // Load chart by pie chart
356 913 ChartBuilderChartsJs.prototype.pieChartView = function(isChangedType){
357 914 var _this = this;
358 915 var getChartSource = _this.chartSourceData.source;
@@ -360,11 +917,36 @@
360 917 var dataTypes = _this.chartConvertData( getChartSource );
361 918
362 919 var settings = _this.chartSourceData.settings;
363 920 var nSettings = _this.configOptionsForCharts(settings);
921 + _this.applyPieDataGrouping(dataTypes, nSettings);
364 922
365 923 var ctx = document.getElementById(_this.htmlClassPrefix + '-canvas');
366 924
925 + ctx.width = nSettings.chartWidth;
926 + ctx.height = nSettings.chartHeight;
927 +
928 + if (nSettings.chartWidthFormat === 'px') {
929 + ctx.width = parseInt(nSettings.chartWidth);
930 + } else if (nSettings.chartWidthFormat === '%') {
931 + ctx.style.width = nSettings.chartWidth + '%';
932 + }
933 +
934 + if (nSettings.chartHeightFormat === 'px') {
935 + ctx.height = parseInt(nSettings.chartHeight);
936 + } else if (nSettings.chartHeightFormat === '%') {
937 + ctx.style.height = nSettings.chartHeight + '%';
938 + }
939 +
940 + var sliceCount = dataTypes?.dataSets[0]?.data?.length || 0;
941 + dataTypes.dataSets[0].backgroundColor = [];
942 + dataTypes.dataSets[0].borderColor = [];
943 +
944 + for (var i = 0; i < sliceCount; i++) {
945 + dataTypes.dataSets[0].backgroundColor[i] = i === dataTypes.dataSets[0].groupedSliceIndex ? nSettings.dataGroupingColor : (nSettings.sliceColor?.[i] || nSettings.sliceColorDefault?.[i % nSettings.sliceColorDefault.length]);
946 + dataTypes.dataSets[0].borderColor[i] = nSettings.slicesBorderColor?.[i] || 'transparent';
947 + }
948 + dataTypes.dataSets[0].borderWidth = nSettings.sliceBorderWidth;
367 949 _this.chartObject = new Chart(ctx, {
368 950 type: 'pie',
369 951 data: {
370 952 labels: dataTypes?.labels,
@@ -373,9 +955,49 @@
373 955 options: {
374 956 radius: nSettings.outerRadius,
375 957 spacing: nSettings.sliceSpacing,
376 958 circumference: nSettings.circumference,
377 - rotation: nSettings.startAngle,
959 + rotation: nSettings.rotationDegree,
960 + borderColor: nSettings.sliceBorderColor,
961 + plugins: {
962 + maintainAspectRatio: false,
963 + tooltip:{
964 + titleColor: nSettings.tooltipColor,
965 + bodyColor: nSettings.tooltipColor,
966 + footerColor: nSettings.tooltipColor,
967 + titleFont: {
968 + size: nSettings.tooltipFontSize || 12,
969 + style: nSettings.tooltipItalicText ? 'italic' : 'normal',
970 + weight: nSettings.tooltipBoldText === 'true' ? 'bold' : (nSettings.tooltipBoldText === 'false' ? 'normal' : undefined)
971 + },
972 + bodyFont: {
973 + size: nSettings.tooltipFontSize || 12,
974 + style: nSettings.tooltipItalicText ? 'italic' : 'normal',
975 + weight: nSettings.tooltipBoldText === 'true' ? 'bold' : (nSettings.tooltipBoldText === 'false' ? 'normal' : undefined)
976 + },
977 + footerFont: {
978 + size: nSettings.tooltipFontSize || 12,
979 + style: nSettings.tooltipItalicText ? 'italic' : 'normal',
980 + weight: nSettings.tooltipBoldText === 'true' ? 'bold' : (nSettings.tooltipBoldText === 'false' ? 'normal' : undefined)
981 + },
982 + position: 'nearest',
983 + events: ['click'],
984 + callbacks: _this.getTooltipCallbacks(nSettings.tooltipText, nSettings.showColorCode)
985 + },
986 + legend: {
987 + position: nSettings.legendPosition,
988 + reverse: nSettings.legendReverse,
989 + align: nSettings.legendAlignment,
990 + labels: {
991 + color: nSettings.legendColor,
992 + font: {
993 + size: nSettings.legendFontSize,
994 + weight: nSettings.legendBoldText ? 'bold' : 'normal',
995 + style: nSettings.legendItalicText ? 'italic' : 'normal'
996 + }
997 + }
998 + }
999 + }
378 1000 }
379 1001 });
380 1002
381 1003 _this.resizeChart();
@@ -392,8 +1014,23 @@
392 1014 var nSettings = _this.configOptionsForCharts(settings);
393 1015
394 1016 var ctx = document.getElementById(_this.htmlClassPrefix + '-canvas');
395 1017
1018 + ctx.width = nSettings.chartWidth;
1019 + ctx.height = nSettings.chartHeight;
1020 +
1021 + if (nSettings.chartWidthFormat === 'px') {
1022 + ctx.width = parseInt(nSettings.chartWidth);
1023 + } else if (nSettings.chartWidthFormat === '%') {
1024 + ctx.style.width = nSettings.chartWidth + '%';
1025 + }
1026 +
1027 + if (nSettings.chartHeightFormat === 'px') {
1028 + ctx.height = parseInt(nSettings.chartHeight);
1029 + } else if (nSettings.chartHeightFormat === '%') {
1030 + ctx.style.height = nSettings.chartHeight + '%';
1031 + }
1032 +
396 1033 _this.chartObject = new Chart(ctx, {
397 1034 type: 'bar',
398 1035 data: {
399 1036 labels: dataTypes?.labels,
@@ -399,9 +1036,44 @@
399 1036 labels: dataTypes?.labels,
400 1037 datasets: dataTypes?.dataSets,
401 1038 },
402 1039 options: {
1040 + maintainAspectRatio: false,
403 1041 // indexAxis: nSettings.indexAxis,
1042 + plugins: {
1043 + tooltip:{
1044 + titleColor: nSettings.tooltipColor,
1045 + bodyColor: nSettings.tooltipColor,
1046 + footerColor: nSettings.tooltipColor,
1047 + titleFont: {
1048 + size: nSettings.tooltipFontSize || 12,
1049 + style: nSettings.tooltipItalicText ? "italic" : "normal",
1050 + weight: nSettings.tooltipBoldText === 'true' ? 'bold' : (nSettings.tooltipBoldText === 'false' ? 'normal' : undefined)
1051 + },
1052 + bodyFont: {
1053 + size: nSettings.tooltipFontSize || 12,
1054 + style: nSettings.tooltipItalicText ? "italic" : "normal",
1055 + weight: nSettings.tooltipBoldText === 'true' ? 'bold' : (nSettings.tooltipBoldText === 'false' ? 'normal' : undefined)
1056 + },
1057 + footerFont: {
1058 + size: nSettings.tooltipFontSize || 12,
1059 + style: nSettings.tooltipItalicText ? "italic" : "normal",
1060 + weight: nSettings.tooltipBoldText === 'true' ? 'bold' : (nSettings.tooltipBoldText === 'false' ? 'normal' : undefined)
1061 + }
1062 + },
1063 + legend: {
1064 + position: nSettings.legendPosition,
1065 + align: nSettings.legendAlignment,
1066 + labels: {
1067 + color: nSettings.legendColor,
1068 + font: {
1069 + size: nSettings.legendFontSize,
1070 + weight: nSettings.legendBoldText ? 'bold' : 'normal',
1071 + style: nSettings.legendItalicText ? 'italic' : 'normal'
1072 + }
1073 + }
1074 + }
1075 + }
404 1076 }
405 1077 });
406 1078
407 1079 _this.resizeChart();
@@ -418,8 +1090,22 @@
418 1090 var nSettings = _this.configOptionsForCharts(settings);
419 1091
420 1092 var ctx = document.getElementById(_this.htmlClassPrefix + '-canvas');
421 1093
1094 + ctx.width = nSettings.chartWidth;
1095 + ctx.height = nSettings.chartHeight;
1096 +
1097 + if (nSettings.chartWidthFormat === 'px') {
1098 + ctx.width = parseInt(nSettings.chartWidth);
1099 + } else if (nSettings.chartWidthFormat === '%') {
1100 + ctx.style.width = nSettings.chartWidth + '%';
1101 + }
1102 +
1103 + if (nSettings.chartHeightFormat === 'px') {
1104 + ctx.height = parseInt(nSettings.chartHeight);
1105 + } else if (nSettings.chartHeightFormat === '%') {
1106 + ctx.style.height = nSettings.chartHeight + '%';
1107 + }
422 1108 _this.chartObject = new Chart(ctx, {
423 1109 type: 'line',
424 1110 data: {
425 1111 labels: dataTypes?.labels,
@@ -425,9 +1111,44 @@
425 1111 labels: dataTypes?.labels,
426 1112 datasets: dataTypes?.dataSets,
427 1113 },
428 1114 options: {
1115 + maintainAspectRatio: false,
429 1116 // indexAxis: nSettings.indexAxis,
1117 + plugins: {
1118 + tooltip:{
1119 + titleColor: nSettings.tooltipColor,
1120 + bodyColor: nSettings.tooltipColor,
1121 + footerColor: nSettings.tooltipColor,
1122 + titleFont: {
1123 + size: nSettings.tooltipFontSize || 12,
1124 + style: nSettings.tooltipItalicText ? "italic" : "normal",
1125 + weight: nSettings.tooltipBoldText === 'true' ? 'bold' : (nSettings.tooltipBoldText === 'false' ? 'normal' : undefined)
1126 + },
1127 + bodyFont: {
1128 + size: nSettings.tooltipFontSize || 12,
1129 + style: nSettings.tooltipItalicText ? "italic" : "normal",
1130 + weight: nSettings.tooltipBoldText === 'true' ? 'bold' : (nSettings.tooltipBoldText === 'false' ? 'normal' : undefined)
1131 + },
1132 + footerFont: {
1133 + size: nSettings.tooltipFontSize || 12,
1134 + style: nSettings.tooltipItalicText ? "italic" : "normal",
1135 + weight: nSettings.tooltipBoldText === 'true' ? 'bold' : (nSettings.tooltipBoldText === 'false' ? 'normal' : undefined)
1136 + }
1137 + },
1138 + legend: {
1139 + position: nSettings.legendPosition,
1140 + align: nSettings.legendAlignment,
1141 + labels: {
1142 + color: nSettings.legendColor,
1143 + font: {
1144 + size: nSettings.legendFontSize,
1145 + weight: nSettings.legendBoldText ? 'bold' : 'normal',
1146 + style: nSettings.legendItalicText ? 'italic' : 'normal'
1147 + }
1148 + }
1149 + }
1150 + }
430 1151 }
431 1152 });
432 1153
433 1154 _this.resizeChart();
@@ -440,14 +1161,73 @@
440 1161 ChartBuilderChartsJs.prototype.configOptionsForCharts = function (settings) {
441 1162 var newSettings = {};
442 1163
443 1164 // newSettings.indexAxis = (settings['index_axis'] == 'checked') ? 'y' : 'x';
1165 + newSettings.chartWidth = parseInt(settings['chart_width']);
1166 + newSettings.chartWidthFormat = settings['chart_width_format'];
1167 + newSettings.chartHeight = settings['chart_height'];
1168 + newSettings.chartHeightFormat = settings['chart_height_format'];
444 1169 newSettings.outerRadius = settings['outer_radius'];
445 1170 newSettings.sliceSpacing = settings['slice_spacing'];
446 1171 newSettings.circumference = settings['circumference'];
447 1172 newSettings.startAngle = settings['start_angle'];
1173 + newSettings.rotationDegree = settings['rotation_degree'];
1174 + newSettings.sliceColor = settings['slice_color'];
1175 + newSettings.slicesBorderColor = settings['slices_border_color'];
1176 + newSettings.sliceColorDefault = settings['slice_colors_default'];
1177 + newSettings.sliceBorderWidth = settings['slice_border_width'];
1178 + newSettings.sliceBorderColor = settings['slice_border_color'];
1179 + newSettings.dataGroupingLimit = parseFloat(settings['data_grouping_limit']) / 100;
1180 + newSettings.dataGroupingLabel = settings['data_grouping_label'];
1181 + newSettings.dataGroupingColor = settings['data_grouping_color'];
1182 + newSettings.legendColor = settings['legend_color'];
1183 + newSettings.legendPosition = settings['legend_position'];
1184 + newSettings.legendAlignment = settings['legend_alignment'];
1185 + newSettings.legendFontSize = settings['legend_font_size'];
1186 + newSettings.legendItalicText = (settings['legend_italic'] == 'checked') ? true : false;
1187 + newSettings.legendBoldText = (settings['legend_bold'] == 'checked') ? true : false;
1188 + newSettings.legendReverse = settings['legend_reverse'];
1189 + newSettings.tooltipColor = settings['tooltip_text_color'];
1190 + newSettings.showColorCode = settings['show_color_code'];
1191 + newSettings.tooltipItalicText = (settings['tooltip_italic'] == 'checked') ? true : false;
1192 + newSettings.tooltipFontSize = settings['tooltip_font_size'];
1193 + newSettings.tooltipBoldText = settings['tooltip_bold'];
1194 + newSettings.tooltipText = settings['tooltip_text'];
1195 + return newSettings;
1196 + }
448 1197
449 - return newSettings;
1198 + ChartBuilderChartsJs.prototype.applyPieDataGrouping = function (dataTypes, settings) {
1199 + var groupingLimit = parseFloat(settings.dataGroupingLimit);
1200 + var dataSet = dataTypes && dataTypes.dataSets && dataTypes.dataSets[0];
1201 +
1202 + if (!(groupingLimit > 0) || !dataSet || !Array.isArray(dataSet.data)) {
1203 + return;
1204 + }
1205 +
1206 + var total = dataSet.data.reduce(function (sum, value) {
1207 + return sum + (Number(value) || 0);
1208 + }, 0);
1209 + var groupedValue = 0;
1210 + var groupedSlices = 0;
1211 + var labels = [];
1212 + var values = [];
1213 +
1214 + dataSet.data.forEach(function (value, index) {
1215 + var numericValue = Number(value) || 0;
1216 + if (total > 0 && numericValue / total < groupingLimit) {
1217 + groupedValue += numericValue;
1218 + groupedSlices++;
1219 + } else {
1220 + labels.push(dataTypes.labels[index]);
1221 + values.push(numericValue);
1222 + }
1223 + });
1224 +
1225 + if (groupedSlices > 0) {
1226 + dataTypes.labels = labels.concat([settings.dataGroupingLabel]);
1227 + dataSet.data = values.concat([groupedValue]);
1228 + dataSet.groupedSliceIndex = values.length;
1229 + }
450 1230 }
451 1231
452 1232 // Detect window resize moment to draw charts responsively
453 1233 ChartBuilderChartsJs.prototype.resizeChart = function(){
@@ -497,8 +1277,49 @@
497 1277 ChartBuilderChartsJs.prototype.updateChartData = function(){
498 1278 var _this = this;
499 1279 var newData = _this.chartConvertData( _this.chartData );
500 1280
1281 + var settings = _this.chartSourceData.settings;
1282 + var nSettings = _this.configOptionsForCharts(settings);
1283 + var defaultColors = nSettings.sliceColorDefault || ['#36A2EB','#FF6384','#FF9F40','#FFCD56', '#4BC0C0','#0099c6','#dd4477','#66aa00', '#b82e2e','#316395','#994499','#22aa99', '#aaaa11','#6633cc','#e67300','#8b0707', '#651067','#329262','#5574a6','#3b3eac', '#b77322','#16d620','#b91383','#f4359e', '#9c5935','#a9c413','#2a778d','#668d1c', '#bea413','#0c5922','#743411'];
1284 +
1285 + var existingDatasets = _this.chartObject.data.datasets || [];
1286 + newData.dataSets = newData.dataSets.map((dataset, index) => {
1287 + var existingDataset = existingDatasets[index] || {};
1288 +
1289 + // Handle backgroundColor for pie charts (array of colors per data point)
1290 + if (_this.chartType === 'pie_chart' && Array.isArray(existingDataset.backgroundColor)) {
1291 + var newBgColor = [...existingDataset.backgroundColor];
1292 + for (var i = existingDataset.backgroundColor.length; i < dataset.data.length; i++) {
1293 + newBgColor[i] = nSettings.sliceColor?.[i] || defaultColors[i % defaultColors.length];
1294 + }
1295 + return {
1296 + ...dataset,
1297 + backgroundColor: newBgColor,
1298 + borderColor: existingDataset.borderColor || dataset.borderColor,
1299 + borderWidth: existingDataset.borderWidth !== undefined ? existingDataset.borderWidth : dataset.borderWidth
1300 + };
1301 + }
1302 +
1303 + // Handle backgroundColor for bar/line charts (single color per dataset)
1304 + var bgColor = existingDataset.backgroundColor;
1305 + var borderColor = existingDataset.borderColor;
1306 +
1307 + if (!bgColor) {
1308 + bgColor = defaultColors[index % defaultColors.length];
1309 + }
1310 + if (!borderColor) {
1311 + borderColor = bgColor;
1312 + }
1313 +
1314 + return {
1315 + ...dataset,
1316 + backgroundColor: bgColor,
1317 + borderColor: borderColor,
1318 + borderWidth: existingDataset.borderWidth !== undefined ? existingDataset.borderWidth : dataset.borderWidth
1319 + };
1320 + });
1321 +
501 1322 _this.chartObject.data = {
502 1323 ..._this.chartObject.data,
503 1324 labels: newData?.labels,
504 1325 datasets: newData?.dataSets,
@@ -504,8 +1325,52 @@
504 1325 datasets: newData?.dataSets,
505 1326 },
506 1327 _this.chartObject.update();
507 1328 }
1329 +
1330 + ChartBuilderChartsJs.prototype.getTooltipCallbacks = function(tooltipText, showColorCode) {
1331 + var _this = this;
1332 + if (showColorCode === 'checked' || showColorCode === true) {
1333 + return {
1334 + label: function(context) {
1335 + var color = context.dataset.backgroundColor[context.dataIndex];
1336 + return ' Color: ' + color;
1337 + }
1338 + };
1339 + } else {
1340 + switch(tooltipText) {
1341 + case 'percentage':
1342 + return {
1343 + label: function(context) {
1344 + var label = context.label || '';
1345 + var value = context.parsed || 0;
1346 + var total = context.chart._metasets[context.datasetIndex].total;
1347 + var percentage = ((value / total) * 100).toFixed(1) + '%';
1348 + return ' ' + label + ': ' + percentage;
1349 + }
1350 + };
1351 + case 'both':
1352 + return {
1353 + label: function(context) {
1354 + var label = context.label || '';
1355 + var value = context.parsed || 0;
1356 + var total = context.chart._metasets[context.datasetIndex].total;
1357 + var percentage = ((value / total) * 100).toFixed(1) + '%';
1358 + return ' ' + label + ': ' + value + ' (' + percentage + ')';
1359 + }
1360 + };
1361 + case 'value':
1362 + default:
1363 + return {
1364 + label: function(context) {
1365 + var label = context.label || '';
1366 + var value = context.parsed || 0;
1367 + return ' ' + label + ': ' + value;
1368 + }
1369 + };
1370 + }
1371 + }
1372 + };
508 1373
509 1374 ChartBuilderChartsJs.prototype.addChartDataRow = function (element){
510 1375 var _this = this;
511 1376 var content = '';