| 1 |
(function($) { |
| 2 |
'use strict'; |
| 3 |
function ChartBuilderGoogleCharts(element, options){ |
| 4 |
this.el = element; |
| 5 |
this.$el = $(element); |
| 6 |
this.ajaxAction = 'ays_chart_admin_ajax'; |
| 7 |
this.htmlClassPrefix = 'ays-chart-'; |
| 8 |
this.htmlNamePrefix = 'ays_'; |
| 9 |
this.dbOptions = undefined; |
| 10 |
this.chartSourceData = undefined; |
| 11 |
this.chartObj = undefined; |
| 12 |
this.chartOptions = null; |
| 13 |
this.chartData = null; |
| 14 |
this.chartTempData = null; |
| 15 |
this.chartType = 'pie_chart'; |
| 16 |
this.chartSourceType = 'google-charts'; |
| 17 |
|
| 18 |
this.chartSources = { |
| 19 |
'line_chart' : 'Line Chart', |
| 20 |
'bar_chart' : 'Bar Chart', |
| 21 |
'pie_chart' : 'Pie Chart', |
| 22 |
'column_chart' : 'Column Chart', |
| 23 |
'org_chart' : 'Org Chart', |
| 24 |
'donut_chart' : 'Donut Chart', |
| 25 |
} |
| 26 |
|
| 27 |
this.init(); |
| 28 |
|
| 29 |
return this; |
| 30 |
} |
| 31 |
|
| 32 |
ChartBuilderGoogleCharts.prototype.init = function() { |
| 33 |
var _this = this; |
| 34 |
_this.chartSourceData = window.ChartBuilderSourceData; |
| 35 |
|
| 36 |
_this.setEvents(); |
| 37 |
_this.initLibraries(); |
| 38 |
_this.setAccordionEvents(); |
| 39 |
|
| 40 |
_this.initDbImport(); |
| 41 |
_this.initQuizDBImport(); |
| 42 |
}; |
| 43 |
|
| 44 |
// Set events |
| 45 |
ChartBuilderGoogleCharts.prototype.setEvents = function(e){ |
| 46 |
var _this = this; |
| 47 |
|
| 48 |
_this.chartType = _this.chartSourceData.chartType; |
| 49 |
_this.chartSourceType = _this.chartSourceData.chartSourceType; |
| 50 |
_this.loadChartBySource(); |
| 51 |
_this.configureOptions(); |
| 52 |
|
| 53 |
/* == Tabulation == */ |
| 54 |
_this.$el.on('click', '.nav-tab-wrapper a.nav-tab' , _this.changeTabs); |
| 55 |
/* */ |
| 56 |
|
| 57 |
/* == Notifications dismiss button == */ |
| 58 |
_this.$el.on('click', '.notice-dismiss', function (e) { |
| 59 |
_this.changeCurrentUrl('status'); |
| 60 |
}); |
| 61 |
|
| 62 |
_this.$el.on('click', '.toggle_ddmenu' , _this.toggleDDmenu); |
| 63 |
/* */ |
| 64 |
|
| 65 |
/* Add Manual data */ |
| 66 |
_this.$el.on("click" , '.'+_this.htmlClassPrefix+'add-new-row-box', function(){ |
| 67 |
_this.addChartDataRow(); |
| 68 |
}); |
| 69 |
|
| 70 |
_this.$el.on("click" , '.'+_this.htmlClassPrefix+'add-new-column-box', function(){ |
| 71 |
_this.addChartDataColumn(); |
| 72 |
}); |
| 73 |
|
| 74 |
_this.$el.on('click', '.'+_this.htmlClassPrefix+'show-on-chart-bttn', function(e){ |
| 75 |
e.preventDefault(); |
| 76 |
if(_this.chartType != "org_chart" ) { |
| 77 |
_this.showOnChart(); |
| 78 |
} else { |
| 79 |
_this.orgTypeShowOnChart(); |
| 80 |
} |
| 81 |
}); |
| 82 |
|
| 83 |
/* */ |
| 84 |
|
| 85 |
/* Delete data */ |
| 86 |
_this.$el.on("click" , '.'+_this.htmlClassPrefix+'chart-source-data-remove-row', function(){ |
| 87 |
_this.deleteChartDataRow($(this)); |
| 88 |
_this.detectManualChange(); |
| 89 |
}); |
| 90 |
_this.$el.on("click" , '.'+_this.htmlClassPrefix+'chart-source-data-remove-col', function(){ |
| 91 |
_this.deleteChartDataColumn($(this)); |
| 92 |
_this.detectManualChange(); |
| 93 |
}); |
| 94 |
_this.$el.on('mouseenter', '.'+_this.htmlClassPrefix+'chart-source-data-remove-block', function() { |
| 95 |
$(this).find('path').css('fill', '#ff0000'); |
| 96 |
}); |
| 97 |
_this.$el.on('mouseleave', '.'+_this.htmlClassPrefix+'chart-source-data-remove-block', function() { |
| 98 |
$(this).find('path').css('fill', '#b8b8b8'); |
| 99 |
}); |
| 100 |
/* */ |
| 101 |
|
| 102 |
/* Save with Ctrl + S */ |
| 103 |
_this.$el.on('keydown', $(document), _this.quickSaveHotKeys); |
| 104 |
/* */ |
| 105 |
|
| 106 |
// Submit buttons disabling |
| 107 |
_this.$el.on('click', '.'+_this.htmlClassPrefix+'loader-banner', _this.submitOnce); |
| 108 |
/* */ |
| 109 |
|
| 110 |
// Disabling submit when press enter button on inputing |
| 111 |
$(document).on("keypress", '.ays-text-input', _this.keyBoardConfig.bind(_this)); |
| 112 |
/* */ |
| 113 |
|
| 114 |
// Modal close |
| 115 |
$(document).on('click', '.ays-close', function () { |
| 116 |
$(this).parents('.ays-modal').aysModal('hide'); |
| 117 |
}); |
| 118 |
|
| 119 |
// Changing source type to manual |
| 120 |
_this.$el.on('input', '.'+_this.htmlClassPrefix+'chart-source-data-content input', function () { |
| 121 |
_this.detectManualChange(); |
| 122 |
}); |
| 123 |
|
| 124 |
// Shortcode text for editor tooltip |
| 125 |
$(document).find('strong.ays-chart-shortcode-box').on('mouseleave', function(){ |
| 126 |
var _this = $(this); |
| 127 |
|
| 128 |
_this.attr('data-original-title', aysChartBuilderAdmin.clickForCopy); |
| 129 |
_this.attr("data-bs-original-title", aysChartBuilderAdmin.clickForCopy); |
| 130 |
_this.attr("title", aysChartBuilderAdmin.clickForCopy); |
| 131 |
}); |
| 132 |
|
| 133 |
// Quiz maker integration |
| 134 |
$(document).find('#'+_this.htmlClassPrefix+'select-quiz-maker-data-query').on('change', function () { |
| 135 |
var option = $(this).find('option:selected'); |
| 136 |
if (option.attr('is-pro') == "true") { |
| 137 |
$(this).find('option[value=""]').prop('selected', true); |
| 138 |
window.open('https://ays-pro.com/wordpress/chart-builder/', '_blank'); |
| 139 |
} else { |
| 140 |
_this.$el.find('.ays-chart-quiz-query-tooltip').attr('title', _this.chartSourceData.quiz_query_tooltips[this.value]); |
| 141 |
_this.$el.find('.ays-chart-quiz-query-tooltip').attr('data-bs-original-title', _this.chartSourceData.quiz_query_tooltips[this.value]); |
| 142 |
_this.quizMakerIntegrationConfig(); |
| 143 |
_this.toggleQuizSelect(this); |
| 144 |
} |
| 145 |
}); |
| 146 |
|
| 147 |
$(document).find('#'+_this.htmlClassPrefix+'select-quiz-maker-quiz').on('change', function () { |
| 148 |
_this.quizMakerIntegrationConfig(); |
| 149 |
}); |
| 150 |
|
| 151 |
$(window).on('load', function () { |
| 152 |
_this.toggleQuizSelect(); |
| 153 |
}); |
| 154 |
|
| 155 |
// Options configuration |
| 156 |
$(document).find('#'+_this.htmlClassPrefix+'option-haxis-slanted-text').on('change', function () { |
| 157 |
var angleOption = $(document).find('#'+_this.htmlClassPrefix+'option-haxis-slanted-text-angle').parents('.'+_this.htmlClassPrefix+'options-section'); |
| 158 |
if ($(this).val() !== 'false') { |
| 159 |
angleOption.removeClass('display_none'); |
| 160 |
} else { |
| 161 |
angleOption.addClass('display_none'); |
| 162 |
} |
| 163 |
}); |
| 164 |
|
| 165 |
_this.$el.find('.'+_this.htmlClassPrefix+'toggle-hidden-option').on('change', function () { |
| 166 |
// var animationOptions = _this.$el.find('.'+_this.htmlClassPrefix+'hidden-options-section'); |
| 167 |
var currentSettings = $(this).parents('.' + _this.htmlClassPrefix + 'settings-data-main-wrap') |
| 168 |
var hiddenSection = currentSettings.find('.' + _this.htmlClassPrefix + 'hidden-options-section'); |
| 169 |
var notHiddenSection = currentSettings.find('.' + _this.htmlClassPrefix + 'not-hidden-options-section'); |
| 170 |
|
| 171 |
if ($(this).is(':checked')) { |
| 172 |
hiddenSection.removeClass('display_none'); |
| 173 |
notHiddenSection.addClass('display_none'); |
| 174 |
} else { |
| 175 |
hiddenSection.addClass('display_none'); |
| 176 |
notHiddenSection.removeClass('display_none'); |
| 177 |
} |
| 178 |
}); |
| 179 |
|
| 180 |
_this.$el.on("click", '.'+_this.htmlClassPrefix+'chart-source-data-sort', function(){ |
| 181 |
_this.sortDataByColumn($(this)); |
| 182 |
_this.detectManualChange(); |
| 183 |
}); |
| 184 |
|
| 185 |
_this.$el.on("click", '.'+_this.htmlClassPrefix+'charts-change-type-type', function(){ |
| 186 |
_this.chartType = $(this).attr('data-type'); |
| 187 |
_this.changeChartType(); |
| 188 |
_this.$el.find('.'+_this.htmlClassPrefix+'charts-change-type-type').css('backgroundColor', '#e7e7e7'); |
| 189 |
$(this).css('backgroundColor', '#008cff63'); |
| 190 |
}); |
| 191 |
|
| 192 |
// Live preview |
| 193 |
_this.liveSettingsPreview(); |
| 194 |
} |
| 195 |
|
| 196 |
ChartBuilderGoogleCharts.prototype.liveSettingsPreview = function () { |
| 197 |
var _this = this; |
| 198 |
|
| 199 |
// title |
| 200 |
_this.$el.find('#ays-title').on('input', function () { |
| 201 |
_this.$el.find('.'+_this.htmlClassPrefix+'charts-title').text($(this).val()); |
| 202 |
}); |
| 203 |
|
| 204 |
// description |
| 205 |
_this.$el.find('#'+_this.htmlClassPrefix+'description').on('input', function () { |
| 206 |
_this.$el.find('.'+_this.htmlClassPrefix+'charts-description').text($(this).val()); |
| 207 |
}); |
| 208 |
|
| 209 |
// general settings |
| 210 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-width').on('input', function () { |
| 211 |
var format = _this.$el.find('#'+_this.htmlClassPrefix+'option-width-format').val() == '%' ? '%' : ''; |
| 212 |
_this.$el.find('.'+_this.htmlClassPrefix+'charts-main-container').css('width', $(this).val() + format); |
| 213 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 214 |
}); |
| 215 |
|
| 216 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-width-format').on('change', function () { |
| 217 |
var format = '%'; |
| 218 |
if ($(this).val() == 'px') { |
| 219 |
format = ''; |
| 220 |
} |
| 221 |
var value = _this.$el.find('#'+_this.htmlClassPrefix+'option-width').val(); |
| 222 |
_this.$el.find('.'+_this.htmlClassPrefix+'charts-main-container').css('width', value + format); |
| 223 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 224 |
}); |
| 225 |
|
| 226 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-position').on('change', function () { |
| 227 |
var value = $(this).val(); |
| 228 |
var val = ''; |
| 229 |
switch (value) { |
| 230 |
case 'center': |
| 231 |
val = 'auto'; |
| 232 |
break; |
| 233 |
case 'right': |
| 234 |
val = 'auto 0 auto auto'; |
| 235 |
break; |
| 236 |
case 'left': |
| 237 |
val = 'auto auto auto 0'; |
| 238 |
break; |
| 239 |
default: |
| 240 |
break; |
| 241 |
} |
| 242 |
_this.$el.find('.'+_this.htmlClassPrefix+'charts-main-container').css('margin', val); |
| 243 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 244 |
}); |
| 245 |
|
| 246 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-height').on('input', function () { |
| 247 |
var format = _this.$el.find('#'+_this.htmlClassPrefix+'option-height-format').val() == '%' ? '%' : ''; |
| 248 |
_this.$el.find('.'+_this.htmlClassPrefix+'charts-main-container').css('height', $(this).val() + format); |
| 249 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 250 |
}); |
| 251 |
|
| 252 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-height-format').on('change', function () { |
| 253 |
var format = ''; |
| 254 |
if ($(this).val() == '%') { |
| 255 |
format = '%'; |
| 256 |
} |
| 257 |
var value = _this.$el.find('#'+_this.htmlClassPrefix+'option-height').val(); |
| 258 |
_this.$el.find('.'+_this.htmlClassPrefix+'charts-main-container').css('height', value + format); |
| 259 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 260 |
}); |
| 261 |
|
| 262 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-font-size').on('input', function () { |
| 263 |
_this.chartOptions.fontSize = $(this).val(); |
| 264 |
_this.chartSourceData.settings.font_size = _this.chartOptions.fontSize; |
| 265 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 266 |
}); |
| 267 |
|
| 268 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-background-color').on('input', function () { |
| 269 |
var isTransparent = _this.$el.find('#'+_this.htmlClassPrefix+'option-transparent-background').is(':checked'); |
| 270 |
|
| 271 |
if (!isTransparent) { |
| 272 |
_this.chartOptions.backgroundColor.fill = $(this).val(); |
| 273 |
_this.chartSourceData.settings.background_color = _this.chartOptions.backgroundColor.fill; |
| 274 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 275 |
} |
| 276 |
}); |
| 277 |
|
| 278 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-transparent-background').on('change', function () { |
| 279 |
var bgColor = _this.$el.find('#'+_this.htmlClassPrefix+'option-background-color').val(); |
| 280 |
var chartBgColor = _this.$el.find('#'+_this.htmlClassPrefix+'option-chart-background-color').val(); |
| 281 |
|
| 282 |
_this.chartSourceData.settings.transparent_background = $(this).is(':checked') ? 'checked' : ''; |
| 283 |
_this.chartOptions.backgroundColor.fill = $(this).is(':checked') ? 'transparent' : bgColor; |
| 284 |
if (typeof _this.chartOptions.chartArea.backgroundColor !== 'undefined') { |
| 285 |
_this.chartOptions.chartArea.backgroundColor.fill = $(this).is(':checked') ? 'transparent' : chartBgColor; |
| 286 |
} |
| 287 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 288 |
}); |
| 289 |
|
| 290 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-chart-background-color').on('input', function () { |
| 291 |
var isTransparent = _this.$el.find('#'+_this.htmlClassPrefix+'option-transparent-background').is(':checked'); |
| 292 |
|
| 293 |
if (!isTransparent) { |
| 294 |
_this.chartOptions.chartArea.backgroundColor.fill = $(this).val(); |
| 295 |
_this.chartSourceData.settings.chart_background_color = _this.chartOptions.chartArea.backgroundColor.fill; |
| 296 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 297 |
} |
| 298 |
}); |
| 299 |
|
| 300 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-border-width').on('input', function () { |
| 301 |
_this.chartSourceData.settings.border_width = $(this).val(); |
| 302 |
_this.$el.find('.'+_this.htmlClassPrefix+'charts-main-container').css('border-width', $(this).val() + 'px'); |
| 303 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 304 |
}); |
| 305 |
|
| 306 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-border-color').on('input', function () { |
| 307 |
_this.chartSourceData.settings.border_color = $(this).val(); |
| 308 |
_this.$el.find('.'+_this.htmlClassPrefix+'charts-main-container').css('border-color', $(this).val()); |
| 309 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 310 |
}); |
| 311 |
|
| 312 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-border-radius').on('input', function () { |
| 313 |
_this.chartSourceData.settings.border_radius = $(this).val(); |
| 314 |
_this.$el.find('.'+_this.htmlClassPrefix+'charts-main-container').css('border-radius', $(this).val() + 'px'); |
| 315 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 316 |
}); |
| 317 |
|
| 318 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-border-style').on('change', function () { |
| 319 |
_this.chartSourceData.settings.border_style = $(this).val(); |
| 320 |
_this.$el.find('.'+_this.htmlClassPrefix+'charts-main-container').css('border-style', $(this).val()); |
| 321 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 322 |
}); |
| 323 |
|
| 324 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-border-width-with-title').on('input', function () { |
| 325 |
_this.chartSourceData.settings.border_width_with_title = $(this).val(); |
| 326 |
_this.$el.find('.'+_this.htmlClassPrefix+'container').css('border-width', $(this).val() + 'px'); |
| 327 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 328 |
}); |
| 329 |
|
| 330 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-border-radius-with-title').on('input', function () { |
| 331 |
_this.chartSourceData.settings.border_radius_with_title = $(this).val(); |
| 332 |
_this.$el.find('.'+_this.htmlClassPrefix+'container').css('border-radius', $(this).val() + 'px'); |
| 333 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 334 |
}); |
| 335 |
|
| 336 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-border-color-with-title').on('input', function () { |
| 337 |
_this.chartSourceData.settings.border_color_with_title = $(this).val(); |
| 338 |
_this.$el.find('.'+_this.htmlClassPrefix+'container').css('border-color', $(this).val()); |
| 339 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 340 |
}); |
| 341 |
|
| 342 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-border-style-with-title').on('change', function () { |
| 343 |
_this.chartSourceData.settings.border_style_with_title = $(this).val(); |
| 344 |
_this.$el.find('.'+_this.htmlClassPrefix+'container').css('border-style', $(this).val()); |
| 345 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 346 |
}); |
| 347 |
|
| 348 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-padding-outer').on('input', function () { |
| 349 |
_this.chartSourceData.settings.padding_outer = $(this).val(); |
| 350 |
_this.$el.find('.'+_this.htmlClassPrefix+'container').css('padding', $(this).val() + 'px'); |
| 351 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 352 |
}); |
| 353 |
|
| 354 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-chart-border-width').on('input', function () { |
| 355 |
_this.chartOptions.chartArea.backgroundColor.strokeWidth = $(this).val(); |
| 356 |
_this.chartSourceData.settings.chart_border_width = _this.chartOptions.chartArea.backgroundColor.strokeWidth; |
| 357 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 358 |
}); |
| 359 |
|
| 360 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-chart-border-color').on('input', function () { |
| 361 |
_this.chartOptions.chartArea.backgroundColor.stroke = $(this).val(); |
| 362 |
_this.chartSourceData.settings.chart_border_color = _this.chartOptions.chartArea.backgroundColor.stroke; |
| 363 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 364 |
}); |
| 365 |
|
| 366 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-box-shadow').on('change', function () { |
| 367 |
if ($(this).is(':checked')) { |
| 368 |
_this.$el.find('.'+_this.htmlClassPrefix+'charts-main-container').css('box-shadow', '2px 2px 10px 2px ' + _this.chartSourceData.settings.border_color); |
| 369 |
} else { |
| 370 |
_this.$el.find('.'+_this.htmlClassPrefix+'charts-main-container').css('box-shadow', 'unset'); |
| 371 |
} |
| 372 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 373 |
}); |
| 374 |
|
| 375 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-box-shadow-color').on('input', function () { |
| 376 |
if (_this.$el.find('#'+_this.htmlClassPrefix+'option-box-shadow').is(':checked')) { |
| 377 |
_this.chartSourceData.settings.box_shadow_color = $(this).val(); |
| 378 |
_this.$el.find('.'+_this.htmlClassPrefix+'charts-main-container').css('box-shadow', '2px 2px 10px 2px ' + _this.chartSourceData.settings.box_shadow_color); |
| 379 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 380 |
} |
| 381 |
}); |
| 382 |
|
| 383 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-chart-left-margin').on('input', function () { |
| 384 |
_this.chartOptions.chartArea.left = $(this).val() === '' ? 'auto' : +$(this).val(); |
| 385 |
_this.chartSourceData.settings.chart_left_margin = _this.chartOptions.chartArea.left; |
| 386 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 387 |
}); |
| 388 |
|
| 389 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-chart-right-margin').on('input', function () { |
| 390 |
_this.chartOptions.chartArea.right = $(this).val() === '' ? 'auto' : +$(this).val(); |
| 391 |
_this.chartSourceData.settings.chart_right_margin = _this.chartOptions.chartArea.right; |
| 392 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 393 |
}); |
| 394 |
|
| 395 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-chart-top-margin').on('input', function () { |
| 396 |
_this.chartOptions.chartArea.top = $(this).val() === '' ? 'auto' : +$(this).val(); |
| 397 |
_this.chartSourceData.settings.chart_top_margin = _this.chartOptions.chartArea.top; |
| 398 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 399 |
}); |
| 400 |
|
| 401 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-chart-bottom-margin').on('input', function () { |
| 402 |
_this.chartOptions.chartArea.bottom = $(this).val() === '' ? 'auto' : +$(this).val(); |
| 403 |
_this.chartSourceData.settings.chart_bottom_margin = _this.chartOptions.chartArea.bottom; |
| 404 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 405 |
}); |
| 406 |
|
| 407 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-enable-interactivity').on('change', function () { |
| 408 |
_this.chartOptions.enableInteractivity = $(this).is(':checked'); |
| 409 |
_this.chartSourceData.settings.enable_interactivity = _this.chartOptions.enableInteractivity ? 'checked' : ''; |
| 410 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 411 |
}); |
| 412 |
|
| 413 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-maximized-view').on('change', function () { |
| 414 |
_this.chartOptions.theme = $(this).is(':checked') ? 'maximized' : null; |
| 415 |
_this.chartSourceData.settings.maximized_view = $(this).is(':checked') ? 'checked' : ''; |
| 416 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 417 |
}); |
| 418 |
|
| 419 |
// tooltip settings |
| 420 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-tooltip-trigger').on('change', function () { |
| 421 |
_this.chartOptions.tooltip.trigger = $(this).val(); |
| 422 |
_this.chartSourceData.settings.tooltip_trigger = _this.chartOptions.tooltip.trigger; |
| 423 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 424 |
}); |
| 425 |
|
| 426 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-show-color-code').on('change', function () { |
| 427 |
_this.chartOptions.tooltip.showColorCode = $(this).is(':checked'); |
| 428 |
_this.chartSourceData.settings.show_color_code = _this.chartOptions.tooltip.showColorCode ? 'checked' : ''; |
| 429 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 430 |
}); |
| 431 |
|
| 432 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-tooltip-text-color').on('input', function () { |
| 433 |
_this.chartOptions.tooltip.textStyle.color = $(this).val(); |
| 434 |
_this.chartSourceData.settings.tooltip_text_color = _this.chartOptions.tooltip.textStyle.color; |
| 435 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 436 |
}); |
| 437 |
|
| 438 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-tooltip-font-size').on('input', function () { |
| 439 |
_this.chartOptions.tooltip.textStyle.fontSize = $(this).val(); |
| 440 |
_this.chartSourceData.settings.tooltip_font_size = _this.chartOptions.tooltip.textStyle.fontSize; |
| 441 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 442 |
}); |
| 443 |
|
| 444 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-tooltip-italic').on('change', function () { |
| 445 |
_this.chartOptions.tooltip.textStyle.italic = $(this).is(':checked'); |
| 446 |
_this.chartSourceData.settings.tooltip_italic = _this.chartOptions.tooltip.textStyle.italic ? 'checked' : ''; |
| 447 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 448 |
}); |
| 449 |
|
| 450 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-tooltip-bold').on('change', function () { |
| 451 |
_this.chartOptions.tooltip.textStyle.bold = $(this).val(); |
| 452 |
_this.chartSourceData.settings.tooltip_bold = _this.chartOptions.tooltip.textStyle.bold ? 'checked' : ''; |
| 453 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 454 |
}); |
| 455 |
|
| 456 |
// legend settings |
| 457 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-legend-position').on('change', function () { |
| 458 |
_this.chartOptions.legend.position = $(this).val(); |
| 459 |
_this.chartSourceData.settings.legend_position = _this.chartOptions.legend.position; |
| 460 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 461 |
}); |
| 462 |
|
| 463 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-legend-alignment').on('change', function () { |
| 464 |
_this.chartOptions.legend.alignment = $(this).val(); |
| 465 |
_this.chartSourceData.settings.legend_alignment = _this.chartOptions.legend.alignment; |
| 466 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 467 |
}); |
| 468 |
|
| 469 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-legend-font-color').on('input', function () { |
| 470 |
_this.chartOptions.legend.textStyle.color = $(this).val(); |
| 471 |
_this.chartSourceData.settings.legend_font_color = _this.chartOptions.legend.textStyle.color; |
| 472 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 473 |
}); |
| 474 |
|
| 475 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-legend-font-size').on('input', function () { |
| 476 |
_this.chartOptions.legend.textStyle.fontSize = $(this).val(); |
| 477 |
_this.chartSourceData.settings.legend_font_size = _this.chartOptions.legend.textStyle.fontSize; |
| 478 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 479 |
}); |
| 480 |
|
| 481 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-legend-italic').on('change', function () { |
| 482 |
_this.chartOptions.legend.textStyle.italic = $(this).is(':checked'); |
| 483 |
_this.chartSourceData.settings.legend_italic = _this.chartOptions.legend.textStyle.italic ? 'checked' : ''; |
| 484 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 485 |
}); |
| 486 |
|
| 487 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-legend-bold').on('change', function () { |
| 488 |
_this.chartOptions.legend.textStyle.bold = $(this).is(':checked'); |
| 489 |
_this.chartSourceData.settings.legend_bold = _this.chartOptions.legend.textStyle.bold ? 'checked' : ''; |
| 490 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 491 |
}); |
| 492 |
|
| 493 |
// horizontal axis settings |
| 494 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-haxis-title').on('input', function () { |
| 495 |
_this.chartOptions.hAxis.title = $(this).val(); |
| 496 |
_this.chartSourceData.settings.haxis_title = _this.chartOptions.hAxis.title; |
| 497 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 498 |
}); |
| 499 |
|
| 500 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-haxis-text-position').on('change', function () { |
| 501 |
_this.chartOptions.hAxis.textPosition = $(this).val(); |
| 502 |
_this.chartSourceData.settings.haxis_text_position = _this.chartOptions.hAxis.textPosition; |
| 503 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 504 |
}); |
| 505 |
|
| 506 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-haxis-text-direction').on('change', function () { |
| 507 |
_this.chartOptions.hAxis.direction = $(this).is(':checked') ? -1 : 1; |
| 508 |
_this.chartSourceData.settings.haxis_text_direction = _this.chartOptions.hAxis.direction; |
| 509 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 510 |
}); |
| 511 |
|
| 512 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-haxis-text-color').on('input', function () { |
| 513 |
_this.chartOptions.hAxis.textStyle.color = $(this).val(); |
| 514 |
_this.chartSourceData.settings.haxis_text_color = _this.chartOptions.hAxis.textStyle.color; |
| 515 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 516 |
}); |
| 517 |
|
| 518 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-haxis-baseline-color').on('input', function () { |
| 519 |
_this.chartOptions.hAxis.baselineColor = $(this).val(); |
| 520 |
_this.chartSourceData.settings.haxis_baseline_color = _this.chartOptions.hAxis.baselineColor; |
| 521 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 522 |
}); |
| 523 |
|
| 524 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-haxis-text-font-size').on('input', function () { |
| 525 |
_this.chartOptions.hAxis.textStyle.fontSize = $(this).val(); |
| 526 |
_this.chartSourceData.settings.haxis_text_font_size = _this.chartOptions.hAxis.textStyle.fontSize; |
| 527 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 528 |
}); |
| 529 |
|
| 530 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-haxis-slanted-text').on('change', function () { |
| 531 |
_this.chartOptions.hAxis.slantedText = $(this).val(); |
| 532 |
_this.chartSourceData.settings.haxis_slanted_text = _this.chartOptions.hAxis.slantedText; |
| 533 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 534 |
}); |
| 535 |
|
| 536 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-haxis-slanted-text-angle').on('input', function () { |
| 537 |
_this.chartOptions.hAxis.slantedTextAngle = $(this).val() != 0 ? $(this).val() : 30; |
| 538 |
_this.chartSourceData.settings.haxis_slanted_text_angle = _this.chartOptions.hAxis.slantedTextAngle; |
| 539 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 540 |
}); |
| 541 |
|
| 542 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-haxis-show-text-every').on('input', function () { |
| 543 |
_this.chartOptions.hAxis.showTextEvery = $(this).val() != 0 ? $(this).val() : 'automatic'; |
| 544 |
_this.chartSourceData.settings.haxis_show_text_every = $(this).val(); |
| 545 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 546 |
}); |
| 547 |
|
| 548 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-haxis-format').on('change', function () { |
| 549 |
_this.chartOptions.hAxis.format = $(this).val(); |
| 550 |
_this.chartSourceData.settings.haxis_format = _this.chartOptions.hAxis.format; |
| 551 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 552 |
}); |
| 553 |
|
| 554 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-haxis-label-font-size').on('input', function () { |
| 555 |
_this.chartOptions.hAxis.titleTextStyle.fontSize = $(this).val(); |
| 556 |
_this.chartSourceData.settings.haxis_label_font_size = _this.chartOptions.hAxis.titleTextStyle.fontSize; |
| 557 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 558 |
}); |
| 559 |
|
| 560 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-haxis-italic').on('change', function () { |
| 561 |
_this.chartOptions.hAxis.textStyle.italic = $(this).is(':checked'); |
| 562 |
_this.chartSourceData.settings.haxis_italic = _this.chartOptions.hAxis.textStyle.italic ? 'checked' : ''; |
| 563 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 564 |
}); |
| 565 |
|
| 566 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-haxis-bold').on('change', function () { |
| 567 |
_this.chartOptions.hAxis.textStyle.bold = $(this).is(':checked'); |
| 568 |
_this.chartSourceData.settings.haxis_bold = _this.chartOptions.hAxis.textStyle.bold ? 'checked' : ''; |
| 569 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 570 |
}); |
| 571 |
|
| 572 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-haxis-title-italic').on('change', function () { |
| 573 |
_this.chartOptions.hAxis.titleTextStyle.italic = $(this).is(':checked'); |
| 574 |
_this.chartSourceData.settings.haxis_title_italic = _this.chartOptions.hAxis.titleTextStyle.italic ? 'checked' : ''; |
| 575 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 576 |
}); |
| 577 |
|
| 578 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-haxis-title-bold').on('change', function () { |
| 579 |
_this.chartOptions.hAxis.titleTextStyle.bold = $(this).is(':checked'); |
| 580 |
_this.chartSourceData.settings.haxis_title_bold = _this.chartOptions.hAxis.titleTextStyle.bold ? 'checked' : ''; |
| 581 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 582 |
}); |
| 583 |
|
| 584 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-haxis-label-color').on('input', function () { |
| 585 |
_this.chartOptions.hAxis.titleTextStyle.color = $(this).val(); |
| 586 |
_this.chartSourceData.settings.haxis_label_color = _this.chartOptions.hAxis.titleTextStyle.color; |
| 587 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 588 |
}); |
| 589 |
|
| 590 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-haxis-max-value').on('input', function () { |
| 591 |
_this.chartOptions.hAxis.viewWindow.max = $(this).val(); |
| 592 |
_this.chartSourceData.settings.haxis_max_value = _this.chartOptions.hAxis.viewWindow.max; |
| 593 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 594 |
}); |
| 595 |
|
| 596 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-haxis-min-value').on('input', function () { |
| 597 |
_this.chartOptions.hAxis.viewWindow.min = $(this).val(); |
| 598 |
_this.chartSourceData.settings.haxis_min_value = _this.chartOptions.hAxis.viewWindow.min; |
| 599 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 600 |
}); |
| 601 |
|
| 602 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-haxis-gridlines-count').on('input', function () { |
| 603 |
_this.chartOptions.hAxis.gridlines.count = $(this).val(); |
| 604 |
_this.chartSourceData.settings.haxis_gridlines_count = _this.chartOptions.hAxis.gridlines.count; |
| 605 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 606 |
}); |
| 607 |
|
| 608 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-haxis-gridlines-color').on('input', function () { |
| 609 |
_this.chartOptions.hAxis.gridlines.color = $(this).val(); |
| 610 |
_this.chartSourceData.settings.haxis_gridlines_color = _this.chartOptions.hAxis.gridlines.color; |
| 611 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 612 |
}); |
| 613 |
|
| 614 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-haxis-minor-gridlines-color').on('input', function () { |
| 615 |
_this.chartOptions.hAxis.minorGridlines.color = $(this).val(); |
| 616 |
_this.chartSourceData.settings.haxis_minor_gridlines_color = _this.chartOptions.hAxis.minorGridlines.color; |
| 617 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 618 |
}); |
| 619 |
|
| 620 |
// vertical axis settings |
| 621 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-vaxis-title').on('input', function () { |
| 622 |
_this.chartOptions.vAxis.title = $(this).val(); |
| 623 |
_this.chartSourceData.settings.vaxis_title = _this.chartOptions.vAxis.title; |
| 624 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 625 |
}); |
| 626 |
|
| 627 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-vaxis-text-position').on('change', function () { |
| 628 |
_this.chartOptions.vAxis.textPosition = $(this).val(); |
| 629 |
_this.chartSourceData.settings.vaxis_text_position = _this.chartOptions.vAxis.textPosition; |
| 630 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 631 |
}); |
| 632 |
|
| 633 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-vaxis-text-direction').on('change', function () { |
| 634 |
_this.chartOptions.vAxis.direction = $(this).is(':checked') ? -1 : 1; |
| 635 |
_this.chartSourceData.settings.vaxis_text_direction = _this.chartOptions.vAxis.direction; |
| 636 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 637 |
}); |
| 638 |
|
| 639 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-vaxis-text-color').on('input', function () { |
| 640 |
_this.chartOptions.vAxis.textStyle.color = $(this).val(); |
| 641 |
_this.chartSourceData.settings.vaxis_text_color = _this.chartOptions.vAxis.textStyle.color; |
| 642 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 643 |
}); |
| 644 |
|
| 645 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-vaxis-baseline-color').on('input', function () { |
| 646 |
_this.chartOptions.vAxis.baselineColor = $(this).val(); |
| 647 |
_this.chartSourceData.settings.vaxis_baseline_color = _this.chartOptions.vAxis.baselineColor; |
| 648 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 649 |
}); |
| 650 |
|
| 651 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-vaxis-text-font-size').on('input', function () { |
| 652 |
_this.chartOptions.vAxis.textStyle.fontSize = $(this).val(); |
| 653 |
_this.chartSourceData.settings.vaxis_text_font_size = _this.chartOptions.vAxis.textStyle.fontSize; |
| 654 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 655 |
}); |
| 656 |
|
| 657 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-vaxis-format').on('change', function () { |
| 658 |
_this.chartOptions.vAxis.format = $(this).val(); |
| 659 |
_this.chartSourceData.settings.vaxis_format = _this.chartOptions.vAxis.format; |
| 660 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 661 |
}); |
| 662 |
|
| 663 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-vaxis-label-font-size').on('input', function () { |
| 664 |
_this.chartOptions.vAxis.titleTextStyle.fontSize = $(this).val(); |
| 665 |
_this.chartSourceData.settings.vaxis_label_font_size = _this.chartOptions.vAxis.titleTextStyle.fontSize; |
| 666 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 667 |
}); |
| 668 |
|
| 669 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-vaxis-italic').on('change', function () { |
| 670 |
_this.chartOptions.vAxis.textStyle.italic = $(this).is(':checked'); |
| 671 |
_this.chartSourceData.settings.vaxis_italic = _this.chartOptions.vAxis.textStyle.italic ? 'checked' : ''; |
| 672 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 673 |
}); |
| 674 |
|
| 675 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-vaxis-bold').on('change', function () { |
| 676 |
_this.chartOptions.vAxis.textStyle.bold = $(this).is(':checked'); |
| 677 |
_this.chartSourceData.settings.vaxis_bold = _this.chartOptions.vAxis.textStyle.bold ? 'checked' : ''; |
| 678 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 679 |
}); |
| 680 |
|
| 681 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-vaxis-title-italic').on('change', function () { |
| 682 |
_this.chartOptions.vAxis.titleTextStyle.italic = $(this).is(':checked'); |
| 683 |
_this.chartSourceData.settings.vaxis_title_italic = _this.chartOptions.vAxis.titleTextStyle.italic ? 'checked' : ''; |
| 684 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 685 |
}); |
| 686 |
|
| 687 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-vaxis-title-bold').on('change', function () { |
| 688 |
_this.chartOptions.vAxis.titleTextStyle.bold = $(this).is(':checked'); |
| 689 |
_this.chartSourceData.settings.vaxis_title_bold = _this.chartOptions.vAxis.titleTextStyle.bold ? 'checked' : ''; |
| 690 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 691 |
}); |
| 692 |
|
| 693 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-vaxis-label-color').on('input', function () { |
| 694 |
_this.chartOptions.vAxis.titleTextStyle.color = $(this).val(); |
| 695 |
_this.chartSourceData.settings.vaxis_label_color = _this.chartOptions.vAxis.titleTextStyle.color; |
| 696 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 697 |
}); |
| 698 |
|
| 699 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-vaxis-max-value').on('input', function () { |
| 700 |
_this.chartOptions.vAxis.viewWindow.max = $(this).val(); |
| 701 |
_this.chartSourceData.settings.vaxis_max_value = _this.chartOptions.vAxis.viewWindow.max; |
| 702 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 703 |
}); |
| 704 |
|
| 705 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-vaxis-min-value').on('input', function () { |
| 706 |
_this.chartOptions.vAxis.viewWindow.min = $(this).val(); |
| 707 |
_this.chartSourceData.settings.vaxis_min_value = _this.chartOptions.vAxis.viewWindow.min; |
| 708 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 709 |
}); |
| 710 |
|
| 711 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-vaxis-gridlines-count').on('input', function () { |
| 712 |
_this.chartOptions.vAxis.gridlines.count = $(this).val(); |
| 713 |
_this.chartSourceData.settings.vaxis_gridlines_count = _this.chartOptions.vAxis.gridlines.count; |
| 714 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 715 |
}); |
| 716 |
|
| 717 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-vaxis-gridlines-color').on('input', function () { |
| 718 |
_this.chartOptions.vAxis.gridlines.color = $(this).val(); |
| 719 |
_this.chartSourceData.settings.vaxis_gridlines_color = _this.chartOptions.vAxis.gridlines.color; |
| 720 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 721 |
}); |
| 722 |
|
| 723 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-vaxis-minor-gridlines-color').on('input', function () { |
| 724 |
_this.chartOptions.vAxis.minorGridlines.color = $(this).val(); |
| 725 |
_this.chartSourceData.settings.vaxis_minor_gridlines_color = _this.chartOptions.vAxis.minorGridlines.color; |
| 726 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 727 |
}); |
| 728 |
|
| 729 |
// animation settings |
| 730 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-enable-animation').on('change', function () { |
| 731 |
if ($(this).is(':checked')) { |
| 732 |
_this.chartOptions.animation = { |
| 733 |
startup: _this.$el.find('#'+_this.htmlClassPrefix+'option-animation-startup').is(':checked'), |
| 734 |
duration: _this.$el.find('#'+_this.htmlClassPrefix+'option-animation-duration').val(), |
| 735 |
easing: _this.$el.find('#'+_this.htmlClassPrefix+'option-animation-easing').val(), |
| 736 |
} |
| 737 |
_this.chartSourceData.settings.enable_animation = 'checked'; |
| 738 |
} else { |
| 739 |
delete _this.chartOptions.animation; |
| 740 |
_this.chartSourceData.settings.enable_animation = ''; |
| 741 |
} |
| 742 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 743 |
}); |
| 744 |
|
| 745 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-animation-duration').on('input', function () { |
| 746 |
if (_this.$el.find('#'+_this.htmlClassPrefix+'option-enable-animation').is(':checked')) { |
| 747 |
_this.chartOptions.animation.duration = $(this).val(); |
| 748 |
_this.chartSourceData.settings.animation_duration = _this.chartOptions.animation.duration; |
| 749 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 750 |
} |
| 751 |
}); |
| 752 |
|
| 753 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-animation-startup').on('input', function () { |
| 754 |
if (_this.$el.find('#'+_this.htmlClassPrefix+'option-enable-animation').is(':checked')) { |
| 755 |
_this.chartOptions.animation.startup = $(this).is(':checked'); |
| 756 |
_this.chartSourceData.settings.animation_startup = _this.chartOptions.animation.startup ? 'checked' : ''; |
| 757 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 758 |
} |
| 759 |
}); |
| 760 |
|
| 761 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-animation-easing').on('input', function () { |
| 762 |
if (_this.$el.find('#'+_this.htmlClassPrefix+'option-enable-animation').is(':checked')) { |
| 763 |
_this.chartOptions.animation.easing = $(this).val(); |
| 764 |
_this.chartSourceData.settings.animation_easing = _this.chartOptions.animation.easing; |
| 765 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 766 |
} |
| 767 |
}); |
| 768 |
|
| 769 |
// advanced settings |
| 770 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-rotation-degree').on('input', function () { |
| 771 |
_this.chartOptions.pieStartAngle = $(this).val(); |
| 772 |
_this.chartSourceData.settings.rotation_degree = _this.chartOptions.pieStartAngle; |
| 773 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 774 |
}); |
| 775 |
|
| 776 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-reverse-categories').on('change', function () { |
| 777 |
_this.chartOptions.reverseCategories = $(this).is(':checked'); |
| 778 |
_this.chartSourceData.settings.reverse_categories = _this.chartOptions.reverseCategories ? 'checked' : ''; |
| 779 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 780 |
}); |
| 781 |
|
| 782 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-slice-border-color').on('input', function () { |
| 783 |
_this.chartOptions.pieSliceBorderColor = $(this).val(); |
| 784 |
_this.chartSourceData.settings.slice_border_color = _this.chartOptions.pieSliceBorderColor; |
| 785 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 786 |
}); |
| 787 |
|
| 788 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-slice-text').on('change', function () { |
| 789 |
_this.chartOptions.pieSliceText = $(this).val(); |
| 790 |
_this.chartSourceData.settings.slice_text = _this.chartOptions.pieSliceText; |
| 791 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 792 |
}); |
| 793 |
|
| 794 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-is-stacked').on('change', function () { |
| 795 |
_this.chartOptions.isStacked = $(this).is(':checked'); |
| 796 |
_this.chartSourceData.settings.is_stacked = _this.chartOptions.isStacked ? 'checked' : ''; |
| 797 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 798 |
}); |
| 799 |
|
| 800 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-focus-target').on('change', function () { |
| 801 |
_this.chartOptions.focusTarget = $(this).val(); |
| 802 |
_this.chartSourceData.settings.focus_target = _this.chartOptions.focusTarget; |
| 803 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 804 |
}); |
| 805 |
|
| 806 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-opacity').on('input', function () { |
| 807 |
_this.chartOptions.dataOpacity = $(this).val(); |
| 808 |
_this.chartSourceData.settings.opacity = _this.chartOptions.dataOpacity; |
| 809 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 810 |
}); |
| 811 |
|
| 812 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-tooltip-text').on('change', function () { |
| 813 |
_this.chartOptions.tooltip.text = $(this).val(); |
| 814 |
_this.chartSourceData.settings.tooltip_text = _this.chartOptions.tooltip.text; |
| 815 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 816 |
}); |
| 817 |
|
| 818 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-line-width').on('input', function () { |
| 819 |
_this.chartOptions.lineWidth = $(this).val(); |
| 820 |
_this.chartSourceData.settings.line_width = _this.chartOptions.lineWidth; |
| 821 |
|
| 822 |
_this.chartSourceData.settings.series_line_width.forEach((value, id) => { |
| 823 |
_this.chartOptions.series[id]["lineWidth"] = $(this).val(); |
| 824 |
_this.chartSourceData.settings.series_line_width[id] = $(this).val(); |
| 825 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-series-line-width-'+id).val($(this).val()); |
| 826 |
}); |
| 827 |
|
| 828 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 829 |
}); |
| 830 |
|
| 831 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-data-grouping-limit').on('input', function () { |
| 832 |
_this.chartOptions.sliceVisibilityThreshold = $(this).val()/100; |
| 833 |
_this.chartSourceData.settings.data_grouping_limit = $(this).val(); |
| 834 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 835 |
}); |
| 836 |
|
| 837 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-data-grouping-label').on('input', function () { |
| 838 |
_this.chartOptions.pieResidueSliceLabel = $(this).val(); |
| 839 |
_this.chartSourceData.settings.data_grouping_label = _this.chartOptions.pieResidueSliceLabel; |
| 840 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 841 |
}); |
| 842 |
|
| 843 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-data-grouping-color').on('input', function () { |
| 844 |
_this.chartOptions.pieResidueSliceColor = $(this).val(); |
| 845 |
_this.chartSourceData.settings.data_grouping_color = _this.chartOptions.pieResidueSliceColor; |
| 846 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 847 |
}); |
| 848 |
|
| 849 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-multiple-selection').on('change', function () { |
| 850 |
_this.chartOptions.selectionMode = $(this).is(':checked') ? 'multiple' : 'single'; |
| 851 |
_this.chartSourceData.settings.multiple_selection = $(this).is(':checked') ? 'checked' : ''; |
| 852 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 853 |
}); |
| 854 |
|
| 855 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-multiple-data-format').on('change', function () { |
| 856 |
_this.chartOptions.aggregationTarget = $(this).val(); |
| 857 |
_this.chartSourceData.settings.multiple_data_format = _this.chartOptions.aggregationTarget; |
| 858 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 859 |
}); |
| 860 |
|
| 861 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-point-shape').on('change', function () { |
| 862 |
_this.chartOptions.pointShape = $(this).val(); |
| 863 |
_this.chartSourceData.settings.point_shape = _this.chartOptions.pointShape; |
| 864 |
|
| 865 |
_this.chartSourceData.settings.series_point_shape.forEach((value, id) => { |
| 866 |
_this.chartOptions.series[id]["pointShape"] = $(this).val(); |
| 867 |
_this.chartSourceData.settings.series_point_shape[id] = $(this).val(); |
| 868 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-series-point-shape-'+id).val($(this).val()); |
| 869 |
}); |
| 870 |
|
| 871 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 872 |
}); |
| 873 |
|
| 874 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-point-size').on('input', function () { |
| 875 |
_this.chartOptions.pointSize = $(this).val(); |
| 876 |
_this.chartSourceData.settings.point_size = _this.chartOptions.pointSize; |
| 877 |
|
| 878 |
_this.chartSourceData.settings.series_point_size.forEach((value, id) => { |
| 879 |
_this.chartOptions.series[id]["pointSize"] = $(this).val(); |
| 880 |
_this.chartSourceData.settings.series_point_size[id] = $(this).val(); |
| 881 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-series-point-size-'+id).val($(this).val()); |
| 882 |
}); |
| 883 |
|
| 884 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 885 |
}); |
| 886 |
|
| 887 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-crosshair-trigger').on('change', function () { |
| 888 |
_this.chartOptions.crosshair.trigger = $(this).val(); |
| 889 |
_this.chartSourceData.settings.crosshair_trigger = _this.chartOptions.crosshair.trigger; |
| 890 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 891 |
}); |
| 892 |
|
| 893 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-crosshair-orientation').on('change', function () { |
| 894 |
_this.chartOptions.crosshair.orientation = $(this).val(); |
| 895 |
_this.chartSourceData.settings.crosshair_orientation = _this.chartOptions.crosshair.orientation; |
| 896 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 897 |
}); |
| 898 |
|
| 899 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-crosshair-opacity').on('input', function () { |
| 900 |
_this.chartOptions.crosshair.opacity = $(this).val(); |
| 901 |
_this.chartSourceData.settings.crosshair_opacity = _this.chartOptions.crosshair.opacity; |
| 902 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 903 |
}); |
| 904 |
|
| 905 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-dash-style').on('input', function () { |
| 906 |
_this.chartOptions.lineDashStyle = $(this).val() ? $(this).val().split(',') : null; |
| 907 |
_this.chartSourceData.settings.dash_style = _this.chartOptions.lineDashStyle.join(','); |
| 908 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 909 |
}); |
| 910 |
|
| 911 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-group-width').on('input', function () { |
| 912 |
var format = _this.$el.find('#'+_this.htmlClassPrefix+'option-group-width-format').val() == '%' ? '%' : ''; |
| 913 |
_this.chartOptions.bar.groupWidth = $(this).val() + format; |
| 914 |
_this.chartSourceData.settings.group_width = $(this).val(); |
| 915 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 916 |
}); |
| 917 |
|
| 918 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-group-width-format').on('change', function () { |
| 919 |
var format = '%'; |
| 920 |
if ($(this).val() == 'px') { |
| 921 |
format = ''; |
| 922 |
} |
| 923 |
var value = _this.$el.find('#'+_this.htmlClassPrefix+'option-group-width').val(); |
| 924 |
_this.chartOptions.bar.groupWidth = value + format; |
| 925 |
_this.chartSourceData.settings.group_width_format = format; |
| 926 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 927 |
}); |
| 928 |
|
| 929 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-orientation').on('change', function () { |
| 930 |
_this.chartOptions.orientation = $(this).is(':checked') ? 'vertical' : 'horizontal'; |
| 931 |
_this.chartSourceData.settings.orientation = $(this).is(':checked') ? 'checked' : ''; |
| 932 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 933 |
}); |
| 934 |
|
| 935 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-fill-nulls').on('change', function () { |
| 936 |
_this.chartOptions.interpolateNulls = $(this).is(':checked') ? 'true' : 'false'; |
| 937 |
_this.chartSourceData.settings.full_nulls = $(this).is(':checked') ? 'checked' : ''; |
| 938 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 939 |
}); |
| 940 |
|
| 941 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-donut-hole-size').on('input', function () { |
| 942 |
_this.chartOptions.pieHole = $(this).val(); |
| 943 |
_this.chartSourceData.settings.donut_hole_size = _this.chartOptions.pieHole; |
| 944 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 945 |
}); |
| 946 |
|
| 947 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-org-chart-font-size').on('change', function () { |
| 948 |
_this.chartOptions.size = $(this).val(); |
| 949 |
_this.chartSourceData.settings.org_chart_font_size = _this.chartOptions.size; |
| 950 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 951 |
}); |
| 952 |
|
| 953 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-allow-collapse').on('change', function () { |
| 954 |
_this.chartOptions.allowCollapse = $(this).is(':checked'); |
| 955 |
_this.chartSourceData.settings.allow_collapse = _this.chartOptions.allowCollapse; |
| 956 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 957 |
}); |
| 958 |
|
| 959 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-org-classname').on('input', function () { |
| 960 |
_this.chartOptions.nodeClass = $(this).val(); |
| 961 |
_this.chartSourceData.settings.org_classname = _this.chartOptions.nodeClass; |
| 962 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 963 |
}); |
| 964 |
|
| 965 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-org-node-background-color').on('input', function () { |
| 966 |
var orgClassname = _this.chartSourceData.settings.org_classname; |
| 967 |
_this.chartSourceData.settings.org_node_background_color = $(this).val(); |
| 968 |
if (orgClassname != '') { |
| 969 |
_this.setOrgChartCustomStyles(); |
| 970 |
} |
| 971 |
}); |
| 972 |
|
| 973 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-org-node-padding').on('input', function () { |
| 974 |
var orgClassname = _this.chartSourceData.settings.org_classname; |
| 975 |
_this.chartSourceData.settings.org_node_padding = $(this).val(); |
| 976 |
if (orgClassname != '') { |
| 977 |
_this.setOrgChartCustomStyles(); |
| 978 |
} |
| 979 |
}); |
| 980 |
|
| 981 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-org-node-border-radius').on('input', function () { |
| 982 |
var orgClassname = _this.chartSourceData.settings.org_classname; |
| 983 |
_this.chartSourceData.settings.org_node_border_radius = $(this).val(); |
| 984 |
if (orgClassname != '') { |
| 985 |
_this.setOrgChartCustomStyles(); |
| 986 |
} |
| 987 |
}); |
| 988 |
|
| 989 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-org-node-border-width').on('input', function () { |
| 990 |
var orgClassname = _this.chartSourceData.settings.org_classname; |
| 991 |
_this.chartSourceData.settings.org_node_border_width = $(this).val(); |
| 992 |
if (orgClassname != '') { |
| 993 |
_this.setOrgChartCustomStyles(); |
| 994 |
} |
| 995 |
}); |
| 996 |
|
| 997 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-org-node-border-color').on('input', function () { |
| 998 |
var orgClassname = _this.chartSourceData.settings.org_classname; |
| 999 |
_this.chartSourceData.settings.org_node_border_color = $(this).val(); |
| 1000 |
if (orgClassname != '') { |
| 1001 |
_this.setOrgChartCustomStyles(); |
| 1002 |
} |
| 1003 |
}); |
| 1004 |
|
| 1005 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-org-node-text-color').on('input', function () { |
| 1006 |
var orgClassname = _this.chartSourceData.settings.org_classname; |
| 1007 |
_this.chartSourceData.settings.org_node_text_color = $(this).val(); |
| 1008 |
if (orgClassname != '') { |
| 1009 |
_this.setOrgChartCustomStyles(); |
| 1010 |
} |
| 1011 |
}); |
| 1012 |
|
| 1013 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-org-node-text-font-size').on('input', function () { |
| 1014 |
var orgClassname = _this.chartSourceData.settings.org_classname; |
| 1015 |
_this.chartSourceData.settings.org_node_text_font_size = $(this).val(); |
| 1016 |
if (orgClassname != '') { |
| 1017 |
_this.setOrgChartCustomStyles(); |
| 1018 |
} |
| 1019 |
}); |
| 1020 |
|
| 1021 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-org-seslected-classname').on('input', function () { |
| 1022 |
_this.chartOptions.selectedNodeClass = $(this).val(); |
| 1023 |
_this.chartSourceData.settings.org_selected_classname = _this.chartOptions.selectedNodeClass; |
| 1024 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 1025 |
}); |
| 1026 |
|
| 1027 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-org-selected-node-background-color').on('input', function () { |
| 1028 |
var orgClassname = _this.chartSourceData.settings.org_selected_classname; |
| 1029 |
_this.chartSourceData.settings.org_selected_node_background_color = $(this).val(); |
| 1030 |
if (orgClassname != '') { |
| 1031 |
_this.setOrgChartCustomStyles(); |
| 1032 |
} |
| 1033 |
}); |
| 1034 |
|
| 1035 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-org-selected-node-text-color').on('input', function () { |
| 1036 |
var orgClassname = _this.chartSourceData.settings.org_selected_classname; |
| 1037 |
_this.chartSourceData.settings.org_selected_node_text_color = $(this).val(); |
| 1038 |
if (orgClassname != '') { |
| 1039 |
_this.setOrgChartCustomStyles(); |
| 1040 |
} |
| 1041 |
}); |
| 1042 |
|
| 1043 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-org-node-description-font-color').on('input', function () { |
| 1044 |
_this.chartSourceData.settings.org_node_description_font_color = $(this).val(); |
| 1045 |
_this.setOrgChartCustomStyles(); |
| 1046 |
}); |
| 1047 |
|
| 1048 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-org-node-description-font-size').on('input', function () { |
| 1049 |
_this.chartSourceData.settings.org_node_description_font_size = $(this).val(); |
| 1050 |
_this.setOrgChartCustomStyles(); |
| 1051 |
}); |
| 1052 |
|
| 1053 |
// Slices settings |
| 1054 |
_this.$el.find('.'+_this.htmlClassPrefix+'option-slice-color').on('input', function () { |
| 1055 |
var id = $(this).attr('data-slice-id'); |
| 1056 |
_this.chartOptions.slices[id].color = $(this).val(); |
| 1057 |
_this.chartSourceData.settings.slice_color[id] = $(this).val(); |
| 1058 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 1059 |
}); |
| 1060 |
|
| 1061 |
_this.$el.find('.'+_this.htmlClassPrefix+'option-slice-offset').on('input', function () { |
| 1062 |
var id = $(this).attr('data-slice-id'); |
| 1063 |
_this.chartOptions.slices[id].offset = $(this).val(); |
| 1064 |
_this.chartSourceData.settings.slice_offset[id] = $(this).val(); |
| 1065 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 1066 |
}); |
| 1067 |
|
| 1068 |
_this.$el.find('.'+_this.htmlClassPrefix+'option-slice-text-color').on('input', function () { |
| 1069 |
var id = $(this).attr('data-slice-id'); |
| 1070 |
_this.chartOptions.slices[id].textStyle.color = $(this).val(); |
| 1071 |
_this.chartSourceData.settings.slice_text_color[id] = $(this).val(); |
| 1072 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 1073 |
}); |
| 1074 |
|
| 1075 |
// Series settings |
| 1076 |
_this.$el.find('.'+_this.htmlClassPrefix+'option-series-color').on('input', function () { |
| 1077 |
if (!_this.$el.find('#'+_this.htmlClassPrefix+'option-enable-row-settings').is(':checked')) { |
| 1078 |
var id = $(this).attr('data-series-id'); |
| 1079 |
_this.chartOptions.series[id].color = $(this).val(); |
| 1080 |
_this.chartSourceData.settings.series_color[id] = $(this).val(); |
| 1081 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 1082 |
} |
| 1083 |
}); |
| 1084 |
|
| 1085 |
_this.$el.find('.'+_this.htmlClassPrefix+'option-series-visible-in-legend').on('input', function () { |
| 1086 |
if (_this.chartSourceData.source[0].length > 2) { |
| 1087 |
var id = $(this).attr('data-series-id'); |
| 1088 |
_this.chartOptions.series[id].visibleInLegend = $(this).is(':checked'); |
| 1089 |
_this.chartSourceData.settings.series_visible_in_legend[id] = $(this).val(); |
| 1090 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 1091 |
} |
| 1092 |
}); |
| 1093 |
|
| 1094 |
_this.$el.find('.'+_this.htmlClassPrefix+'option-series-line-width').on('input', function () { |
| 1095 |
if (!_this.$el.find('#'+_this.htmlClassPrefix+'option-enable-row-settings').is(':checked')) { |
| 1096 |
var id = $(this).attr('data-series-id'); |
| 1097 |
_this.chartOptions.series[id].lineWidth = $(this).val(); |
| 1098 |
_this.chartSourceData.settings.series_line_width[id] = $(this).val(); |
| 1099 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 1100 |
} |
| 1101 |
}); |
| 1102 |
|
| 1103 |
_this.$el.find('.'+_this.htmlClassPrefix+'option-series-point-size').on('input', function () { |
| 1104 |
if (!_this.$el.find('#'+_this.htmlClassPrefix+'option-enable-row-settings').is(':checked')) { |
| 1105 |
var id = $(this).attr('data-series-id'); |
| 1106 |
_this.chartOptions.series[id].pointSize = $(this).val(); |
| 1107 |
_this.chartSourceData.settings.series_point_size[id] = $(this).val(); |
| 1108 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 1109 |
} |
| 1110 |
}); |
| 1111 |
|
| 1112 |
_this.$el.find('.'+_this.htmlClassPrefix+'option-series-point-shape').on('change', function () { |
| 1113 |
if (!_this.$el.find('#'+_this.htmlClassPrefix+'option-enable-row-settings').is(':checked')) { |
| 1114 |
var id = $(this).attr('data-series-id'); |
| 1115 |
_this.chartOptions.series[id].pointShape = $(this).val(); |
| 1116 |
_this.chartSourceData.settings.series_point_shape[id] = $(this).val(); |
| 1117 |
_this.drawChartFunction(_this.chartData, _this.chartOptions); |
| 1118 |
} |
| 1119 |
}); |
| 1120 |
|
| 1121 |
// Rows settings |
| 1122 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-enable-row-settings').on('change', function () { |
| 1123 |
var getChartSource = _this.chartSourceData.source; |
| 1124 |
var dataTypes = _this.multiColumnChartConvertData( getChartSource ); |
| 1125 |
|
| 1126 |
if ($(this).is(':checked')) { |
| 1127 |
dataTypes = _this.setRowOptions(dataTypes, _this.chartSourceData.settings, false); |
| 1128 |
_this.chartSourceData.settings.enable_row_settings = 'checked'; |
| 1129 |
} else { |
| 1130 |
dataTypes = _this.removeRowOptions(dataTypes); |
| 1131 |
_this.chartSourceData.settings.enable_row_settings = ''; |
| 1132 |
} |
| 1133 |
|
| 1134 |
_this.chartData = google.visualization.arrayToDataTable(dataTypes); |
| 1135 |
_this.chartObj.draw(_this.chartData, _this.chartOptions); |
| 1136 |
}); |
| 1137 |
|
| 1138 |
_this.$el.find('.'+_this.htmlClassPrefix+'option-rows-color').on('input', function () { |
| 1139 |
if (_this.$el.find('#'+_this.htmlClassPrefix+'option-enable-row-settings').is(':checked')) { |
| 1140 |
var getChartSource = _this.chartSourceData.source; |
| 1141 |
var dataTypes = _this.multiColumnChartConvertData( getChartSource ); |
| 1142 |
|
| 1143 |
var id = $(this).attr('data-rows-id'); |
| 1144 |
_this.chartSourceData.settings.rows_color[id] = $(this).val(); |
| 1145 |
|
| 1146 |
dataTypes = _this.setRowOptions(dataTypes, _this.chartSourceData.settings, false); |
| 1147 |
|
| 1148 |
_this.chartData = google.visualization.arrayToDataTable(dataTypes); |
| 1149 |
|
| 1150 |
_this.chartObj.draw(_this.chartData, _this.chartOptions); |
| 1151 |
} |
| 1152 |
}); |
| 1153 |
|
| 1154 |
_this.$el.find('.'+_this.htmlClassPrefix+'option-rows-opacity').on('input', function () { |
| 1155 |
if (_this.$el.find('#'+_this.htmlClassPrefix+'option-enable-row-settings').is(':checked')) { |
| 1156 |
var getChartSource = _this.chartSourceData.source; |
| 1157 |
var dataTypes = _this.multiColumnChartConvertData( getChartSource ); |
| 1158 |
|
| 1159 |
var id = $(this).attr('data-rows-id'); |
| 1160 |
_this.chartSourceData.settings.rows_opacity[id] = $(this).val(); |
| 1161 |
|
| 1162 |
dataTypes = _this.setRowOptions(dataTypes, _this.chartSourceData.settings, false); |
| 1163 |
|
| 1164 |
_this.chartData = google.visualization.arrayToDataTable(dataTypes); |
| 1165 |
|
| 1166 |
_this.chartObj.draw(_this.chartData, _this.chartOptions); |
| 1167 |
} |
| 1168 |
}); |
| 1169 |
} |
| 1170 |
|
| 1171 |
ChartBuilderGoogleCharts.prototype.toggleQuizSelect = function (e) { |
| 1172 |
var _this = this; |
| 1173 |
|
| 1174 |
var select = $(document).find('#'+_this.htmlClassPrefix+'select-quiz-maker-data-query'); |
| 1175 |
var option = $(select).find('option:selected').val(); |
| 1176 |
var selectQuizSelect = $(document).find('.'+_this.htmlClassPrefix+'select-quiz-maker-quiz-container'); |
| 1177 |
|
| 1178 |
if (option == 'q1' || option == 'q3' || option == 'q6') { |
| 1179 |
selectQuizSelect.slideDown(); |
| 1180 |
} else { |
| 1181 |
selectQuizSelect.slideUp(); |
| 1182 |
} |
| 1183 |
} |
| 1184 |
|
| 1185 |
ChartBuilderGoogleCharts.prototype.quizMakerIntegrationConfig = function (e) { |
| 1186 |
var _this = this; |
| 1187 |
|
| 1188 |
var input = $(document).find('input[name="ays_source_type"]'); |
| 1189 |
if (input.val() !== 'quiz_maker') input.val('quiz_maker'); |
| 1190 |
|
| 1191 |
_this.$el.find('#ays-chart-quiz-maker-success').empty(); |
| 1192 |
_this.$el.find('#ays-chart-quiz-maker-error').empty(); |
| 1193 |
} |
| 1194 |
|
| 1195 |
ChartBuilderGoogleCharts.prototype.detectManualChange = function (e) { |
| 1196 |
var input = $(document).find('input[name="ays_source_type"]'); |
| 1197 |
if (input.val() !== 'manual') input.val('manual'); |
| 1198 |
} |
| 1199 |
|
| 1200 |
ChartBuilderGoogleCharts.prototype.keyBoardConfig = function(e) { |
| 1201 |
if (e.which == 13) { |
| 1202 |
if ($(document).find("#ays-charts-form-google-charts").length !== 0 || $(document).find("#ays-settings-form").length !== 0) { |
| 1203 |
var parent = $(e.target).parents('.ays-chart-chart-source-data-edit-block'); |
| 1204 |
var index = $(e.target).parents('.ays-chart-chart-source-data-input-box').index(); |
| 1205 |
index = parent.index() == 0 ? index - 1 : index - 2; |
| 1206 |
|
| 1207 |
if (e.shiftKey) { |
| 1208 |
var prevRow; |
| 1209 |
if (parent.prev('.ays-chart-chart-source-data-edit-block').length === 0) { |
| 1210 |
return false; |
| 1211 |
} |
| 1212 |
prevRow = parent.prev('.ays-chart-chart-source-data-edit-block'); |
| 1213 |
|
| 1214 |
prevRow.children('.ays-chart-chart-source-data-input-box').eq(index).find('.ays-text-input').focus(); |
| 1215 |
} else { |
| 1216 |
var nextRow; |
| 1217 |
if (parent.next('.ays-chart-chart-source-data-edit-block').length === 0) { |
| 1218 |
this.addChartDataRow(); |
| 1219 |
} |
| 1220 |
nextRow = parent.next('.ays-chart-chart-source-data-edit-block'); |
| 1221 |
|
| 1222 |
nextRow.children('.ays-chart-chart-source-data-input-box').eq(index).find('.ays-text-input').focus(); |
| 1223 |
} |
| 1224 |
|
| 1225 |
return false; |
| 1226 |
} |
| 1227 |
} |
| 1228 |
} |
| 1229 |
|
| 1230 |
ChartBuilderGoogleCharts.prototype.changeTabs = function(e){ |
| 1231 |
if(! $(this).hasClass('no-js')){ |
| 1232 |
var elemenetID = $(this).attr('href'); |
| 1233 |
var active_tab = $(this).attr('data-tab'); |
| 1234 |
$(document).find('.nav-tab-wrapper a.nav-tab').each(function () { |
| 1235 |
if ($(this).hasClass('nav-tab-active')) { |
| 1236 |
$(this).removeClass('nav-tab-active'); |
| 1237 |
} |
| 1238 |
}); |
| 1239 |
$(this).addClass('nav-tab-active'); |
| 1240 |
$(document).find('.ays-tab-content').each(function () { |
| 1241 |
$(this).removeClass('ays-tab-content-active'); |
| 1242 |
}); |
| 1243 |
$(document).find("[name='ays_chart_tab']").val(active_tab); |
| 1244 |
$('.ays-tab-content' + elemenetID).addClass('ays-tab-content-active'); |
| 1245 |
e.preventDefault(); |
| 1246 |
} |
| 1247 |
} |
| 1248 |
|
| 1249 |
ChartBuilderGoogleCharts.prototype.changeCurrentUrl = function(key){ |
| 1250 |
var linkModified = location.href.split('?')[1].split('&'); |
| 1251 |
for(var i = 0; i < linkModified.length; i++){ |
| 1252 |
if(linkModified[i].split("=")[0] == key){ |
| 1253 |
linkModified.splice(i, 1); |
| 1254 |
} |
| 1255 |
} |
| 1256 |
linkModified = linkModified.join('&'); |
| 1257 |
window.history.replaceState({}, document.title, '?'+linkModified); |
| 1258 |
} |
| 1259 |
|
| 1260 |
ChartBuilderGoogleCharts.prototype.toggleDDmenu = function(e){ |
| 1261 |
var ddmenu = $(this).next(); |
| 1262 |
var state = ddmenu.attr('data-expanded'); |
| 1263 |
switch (state) { |
| 1264 |
case 'true': |
| 1265 |
$(this).find('.ays_fa').css({ |
| 1266 |
transform: 'rotate(0deg)' |
| 1267 |
}); |
| 1268 |
ddmenu.attr('data-expanded', 'false'); |
| 1269 |
break; |
| 1270 |
case 'false': |
| 1271 |
$(this).find('.ays_fa').css({ |
| 1272 |
transform: 'rotate(90deg)' |
| 1273 |
}); |
| 1274 |
ddmenu.attr('data-expanded', 'true'); |
| 1275 |
break; |
| 1276 |
} |
| 1277 |
} |
| 1278 |
|
| 1279 |
ChartBuilderGoogleCharts.prototype.submitOnce = function(el) { |
| 1280 |
setTimeout(function() { |
| 1281 |
$(document).find('.ays-chart-loader-banner').attr('disabled', true); |
| 1282 |
}, 50); |
| 1283 |
|
| 1284 |
setTimeout(function() { |
| 1285 |
$(document).find('.ays-chart-loader-banner').attr('disabled', false); |
| 1286 |
}, 5000); |
| 1287 |
} |
| 1288 |
|
| 1289 |
// Load charts by given type main function |
| 1290 |
ChartBuilderGoogleCharts.prototype.initLibraries = function (){ |
| 1291 |
var _this = this; |
| 1292 |
|
| 1293 |
var googleSelect = _this.$el.find('.' + _this.htmlClassPrefix + 'google-sheet-select'); |
| 1294 |
googleSelect.select2(); |
| 1295 |
var fileTypeSelect = _this.$el.find('#' + _this.htmlClassPrefix + 'import-files-file-type'); |
| 1296 |
fileTypeSelect.select2(); |
| 1297 |
var quizQuerySelect = _this.$el.find('#' + _this.htmlClassPrefix + 'select-quiz-maker-data-query'); |
| 1298 |
quizQuerySelect.select2(); |
| 1299 |
var quizQuizSelect = _this.$el.find('#' + _this.htmlClassPrefix + 'select-quiz-maker-quiz'); |
| 1300 |
quizQuizSelect.select2(); |
| 1301 |
var woocommerceSelect = _this.$el.find('#' + _this.htmlClassPrefix + 'woocommerce-datas-select'); |
| 1302 |
woocommerceSelect.select2(); |
| 1303 |
|
| 1304 |
_this.$el.find('#ays-chart-option-create-author').select2({ |
| 1305 |
placeholder: aysChartBuilderAdmin.selectUser, |
| 1306 |
minimumInputLength: 1, |
| 1307 |
allowClear: true, |
| 1308 |
language: { |
| 1309 |
searching: function() { |
| 1310 |
return aysChartBuilderAdmin.searching; |
| 1311 |
}, |
| 1312 |
inputTooShort: function () { |
| 1313 |
return aysChartBuilderAdmin.pleaseEnterMore; |
| 1314 |
} |
| 1315 |
}, |
| 1316 |
ajax: { |
| 1317 |
url: ajaxurl, |
| 1318 |
dataType: 'json', |
| 1319 |
data: function (response) { |
| 1320 |
var checkedUsers = _this.$el.find('#ays-chart-option-create-author').val(); |
| 1321 |
return { |
| 1322 |
action: _this.ajaxAction, |
| 1323 |
function: window.aysChartBuilderChartSettings.ajax['actions']['author_user_search'], |
| 1324 |
security: window.aysChartBuilderChartSettings.ajax['nonces']['author_user_search'], |
| 1325 |
params: { |
| 1326 |
search: response.term, |
| 1327 |
val: checkedUsers |
| 1328 |
} |
| 1329 |
}; |
| 1330 |
} |
| 1331 |
} |
| 1332 |
}); |
| 1333 |
|
| 1334 |
_this.$el.find('.' + _this.htmlClassPrefix + 'chart-source-data-content').sortable({ |
| 1335 |
items: "> div." + _this.htmlClassPrefix + "chart-source-data-edit-block:not(:first)", |
| 1336 |
handle: "." + _this.htmlClassPrefix + "chart-source-data-move-row", |
| 1337 |
update: function (event, ui) { |
| 1338 |
_this.$el.find('div.' + _this.htmlClassPrefix + 'chart-source-data-edit-block:not(:first)').each(function (index) { |
| 1339 |
$(this).attr('data-source-id', index + 1); |
| 1340 |
$(this).find("input.ays-text-input").attr('name', 'ays_chart_source_data[' + (index + 1) + '][]') |
| 1341 |
}); |
| 1342 |
} |
| 1343 |
}); |
| 1344 |
} |
| 1345 |
|
| 1346 |
// Load charts by given type main function |
| 1347 |
ChartBuilderGoogleCharts.prototype.loadChartBySource = function(isChangedType = false){ |
| 1348 |
var _this = this; |
| 1349 |
|
| 1350 |
if( ! _this.chartType ){ |
| 1351 |
_this.chartType = _this.chartSourceData.chartType; |
| 1352 |
} |
| 1353 |
|
| 1354 |
if(typeof _this.chartType !== undefined && _this.chartType){ |
| 1355 |
switch (_this.chartType) { |
| 1356 |
case 'pie_chart': |
| 1357 |
_this.pieChartView(isChangedType); |
| 1358 |
break; |
| 1359 |
case 'bar_chart': |
| 1360 |
_this.barChartView(isChangedType); |
| 1361 |
break; |
| 1362 |
case 'column_chart': |
| 1363 |
_this.columnChartView(isChangedType); |
| 1364 |
break; |
| 1365 |
case 'line_chart': |
| 1366 |
_this.lineChartView(isChangedType); |
| 1367 |
break; |
| 1368 |
case 'org_chart': |
| 1369 |
_this.orgChartView(isChangedType); |
| 1370 |
break; |
| 1371 |
case 'donut_chart': |
| 1372 |
_this.donutChartView(isChangedType); |
| 1373 |
break; |
| 1374 |
default: |
| 1375 |
_this.pieChartView(isChangedType); |
| 1376 |
break; |
| 1377 |
} |
| 1378 |
} |
| 1379 |
} |
| 1380 |
|
| 1381 |
// Load chart by pie chart |
| 1382 |
ChartBuilderGoogleCharts.prototype.pieChartView = function(isChangedType){ |
| 1383 |
var _this = this; |
| 1384 |
var getChartSource = _this.chartSourceData.source; |
| 1385 |
|
| 1386 |
var dataTypes = _this.chartConvertData( getChartSource ); |
| 1387 |
|
| 1388 |
var settings = _this.chartSourceData.settings; |
| 1389 |
var nSettings = _this.configOptionsForCharts(settings); |
| 1390 |
|
| 1391 |
var userLocale = navigator.language || navigator.userLanguage || 'en'; |
| 1392 |
|
| 1393 |
/* == Google part == */ |
| 1394 |
google.charts.load('current', {'packages':['corechart'], 'language': userLocale}); |
| 1395 |
google.charts.setOnLoadCallback(drawChart); |
| 1396 |
|
| 1397 |
function drawChart() { |
| 1398 |
_this.chartData = isChangedType ? _this.chartData : google.visualization.arrayToDataTable( dataTypes ); |
| 1399 |
|
| 1400 |
_this.chartOptions = { |
| 1401 |
fontSize: nSettings.chartFontSize, |
| 1402 |
chartArea: { |
| 1403 |
left: nSettings.chartLeftMargin, |
| 1404 |
right: nSettings.chartRightMargin, |
| 1405 |
top: nSettings.chartTopMargin, |
| 1406 |
bottom: nSettings.chartBottomMargin, |
| 1407 |
}, |
| 1408 |
backgroundColor: { |
| 1409 |
fill: nSettings.backgroundColor, |
| 1410 |
// strokeWidth: nSettings.borderWidth, |
| 1411 |
// stroke: nSettings.borderColor |
| 1412 |
}, |
| 1413 |
enableInteractivity: nSettings.enableInteractivity, |
| 1414 |
legend: { |
| 1415 |
position: nSettings.legendPosition, |
| 1416 |
alignment: nSettings.legendAlignment, |
| 1417 |
textStyle: { |
| 1418 |
color: nSettings.legendColor, |
| 1419 |
fontSize: nSettings.legendFontSize, |
| 1420 |
italic: nSettings.legendItalicText, |
| 1421 |
bold: nSettings.legendBoldText, |
| 1422 |
} |
| 1423 |
}, |
| 1424 |
tooltip: { |
| 1425 |
trigger: nSettings.tooltipTrigger, |
| 1426 |
showColorCode: nSettings.showColorCode, |
| 1427 |
text: nSettings.tooltipText, |
| 1428 |
textStyle: { |
| 1429 |
color: nSettings.tooltipTextColor, |
| 1430 |
fontSize: nSettings.tooltipFontSize, |
| 1431 |
italic: nSettings.tooltipItalicText, |
| 1432 |
bold: nSettings.tooltipBoldText, |
| 1433 |
} |
| 1434 |
}, |
| 1435 |
pieStartAngle: nSettings.rotationDegree, |
| 1436 |
pieSliceBorderColor: nSettings.sliceBorderColor, |
| 1437 |
reverseCategories: nSettings.reverseCategories, |
| 1438 |
pieSliceText: nSettings.sliceText, |
| 1439 |
sliceVisibilityThreshold: nSettings.dataGroupingLimit, |
| 1440 |
pieResidueSliceLabel: nSettings.dataGroupingLabel, |
| 1441 |
pieResidueSliceColor: nSettings.dataGroupingColor, |
| 1442 |
slices: {} |
| 1443 |
}; |
| 1444 |
|
| 1445 |
for (var i = 0; i < dataTypes.length - 1; i++) { |
| 1446 |
_this.chartOptions.slices[i] = { |
| 1447 |
color: nSettings.sliceColor[i], |
| 1448 |
offset: typeof nSettings.sliceOffset[i] !== 'undefined' ? nSettings.sliceOffset[i] : 0, |
| 1449 |
textStyle: { |
| 1450 |
color: nSettings.sliceTextColor[i], |
| 1451 |
}, |
| 1452 |
} |
| 1453 |
} |
| 1454 |
|
| 1455 |
_this.chartObj = new google.visualization.PieChart( document.getElementById(_this.htmlClassPrefix + _this.chartType) ); |
| 1456 |
|
| 1457 |
_this.chartObj.draw( _this.chartData, _this.chartOptions ); |
| 1458 |
_this.resizeChart(); |
| 1459 |
} |
| 1460 |
/* */ |
| 1461 |
} |
| 1462 |
|
| 1463 |
// Load chart by bar chart |
| 1464 |
ChartBuilderGoogleCharts.prototype.barChartView = function(isChangedType){ |
| 1465 |
var _this = this; |
| 1466 |
var getChartSource = _this.chartSourceData.source; |
| 1467 |
var dataTypes = _this.multiColumnChartConvertData( getChartSource ); |
| 1468 |
|
| 1469 |
var settings = _this.chartSourceData.settings; |
| 1470 |
var nSettings = _this.configOptionsForCharts(settings); |
| 1471 |
|
| 1472 |
var userLocale = navigator.language || navigator.userLanguage || 'en'; |
| 1473 |
|
| 1474 |
/* == Google part == */ |
| 1475 |
google.charts.load('current', {'packages':['corechart'], 'language': userLocale}); |
| 1476 |
google.charts.setOnLoadCallback(drawChart); |
| 1477 |
|
| 1478 |
function drawChart() { |
| 1479 |
dataTypes = nSettings.enableRowSettings ? _this.setRowOptions(dataTypes, nSettings, true) : dataTypes; |
| 1480 |
|
| 1481 |
_this.chartData = isChangedType ? _this.chartData : google.visualization.arrayToDataTable(dataTypes); |
| 1482 |
|
| 1483 |
_this.chartOptions = { |
| 1484 |
fontSize: nSettings.chartFontSize, |
| 1485 |
backgroundColor: { |
| 1486 |
fill: nSettings.backgroundColor, |
| 1487 |
// strokeWidth: nSettings.borderWidth, |
| 1488 |
// stroke: nSettings.borderColor |
| 1489 |
}, |
| 1490 |
chartArea: { |
| 1491 |
backgroundColor: { |
| 1492 |
fill: nSettings.chartBackgroundColor, |
| 1493 |
stroke: nSettings.chartBorderColor, |
| 1494 |
strokeWidth: nSettings.chartBorderWidth |
| 1495 |
}, |
| 1496 |
left: nSettings.chartLeftMargin, |
| 1497 |
right: nSettings.chartRightMargin, |
| 1498 |
top: nSettings.chartTopMargin, |
| 1499 |
bottom: nSettings.chartBottomMargin, |
| 1500 |
}, |
| 1501 |
enableInteractivity: nSettings.enableInteractivity, |
| 1502 |
theme: nSettings.maximizedView, |
| 1503 |
legend: { |
| 1504 |
position: nSettings.legendPosition, |
| 1505 |
alignment: nSettings.legendAlignment, |
| 1506 |
textStyle: { |
| 1507 |
color: nSettings.legendColor, |
| 1508 |
fontSize: nSettings.legendFontSize, |
| 1509 |
italic: nSettings.legendItalicText, |
| 1510 |
bold: nSettings.legendBoldText, |
| 1511 |
} |
| 1512 |
}, |
| 1513 |
tooltip: { |
| 1514 |
trigger: nSettings.tooltipTrigger, |
| 1515 |
showColorCode: nSettings.showColorCode, |
| 1516 |
textStyle: { |
| 1517 |
color: nSettings.tooltipTextColor, |
| 1518 |
fontSize: nSettings.tooltipFontSize, |
| 1519 |
italic: nSettings.tooltipItalicText, |
| 1520 |
bold: nSettings.tooltipBoldText, |
| 1521 |
} |
| 1522 |
}, |
| 1523 |
hAxis: { |
| 1524 |
title: nSettings.hAxisTitle, |
| 1525 |
textPosition: nSettings.hAxisTextPosition, |
| 1526 |
direction: nSettings.hAxisDirection, |
| 1527 |
baselineColor: nSettings.hAxisBaselineColor, |
| 1528 |
textStyle: { |
| 1529 |
color: nSettings.hAxisTextColor, |
| 1530 |
fontSize: nSettings.hAxisTextFontSize, |
| 1531 |
italic: nSettings.hAxisItalicText, |
| 1532 |
bold: nSettings.hAxisBoldText, |
| 1533 |
}, |
| 1534 |
slantedText: nSettings.hAxisSlantedText, |
| 1535 |
slantedTextAngle: nSettings.hAxisSlantedTextAngle, |
| 1536 |
format: nSettings.hAxisFormat, |
| 1537 |
titleTextStyle: { |
| 1538 |
fontSize: nSettings.hAxisLabelFontSize, |
| 1539 |
color: nSettings.hAxisLabelColor, |
| 1540 |
italic: nSettings.hAxisItalicTitle, |
| 1541 |
bold: nSettings.hAxisBoldTitle, |
| 1542 |
}, |
| 1543 |
viewWindow: { |
| 1544 |
min: nSettings.hAxisMinValue, |
| 1545 |
max: nSettings.hAxisMaxValue, |
| 1546 |
}, |
| 1547 |
gridlines: { |
| 1548 |
count: nSettings.hAxisGridlinesCount, |
| 1549 |
color: nSettings.hAxisGridlinesColor, |
| 1550 |
}, |
| 1551 |
minorGridlines: { |
| 1552 |
color: nSettings.hAxisMinorGridlinesColor, |
| 1553 |
}, |
| 1554 |
}, |
| 1555 |
vAxis: { |
| 1556 |
title: nSettings.vAxisTitle, |
| 1557 |
textPosition: nSettings.vAxisTextPosition, |
| 1558 |
direction: nSettings.vAxisDirection, |
| 1559 |
baselineColor: nSettings.vAxisBaselineColor, |
| 1560 |
textStyle: { |
| 1561 |
color: nSettings.vAxisTextColor, |
| 1562 |
fontSize: nSettings.vAxisTextFontSize, |
| 1563 |
italic: nSettings.vAxisItalicText, |
| 1564 |
bold: nSettings.vAxisBoldText, |
| 1565 |
}, |
| 1566 |
format: nSettings.vAxisFormat, |
| 1567 |
titleTextStyle: { |
| 1568 |
fontSize: nSettings.vAxisLabelFontSize, |
| 1569 |
color: nSettings.vAxisLabelColor, |
| 1570 |
italic: nSettings.vAxisItalicTitle, |
| 1571 |
bold: nSettings.vAxisBoldTitle, |
| 1572 |
}, |
| 1573 |
viewWindow: { |
| 1574 |
min: nSettings.vAxisMinValue, |
| 1575 |
max: nSettings.vAxisMaxValue, |
| 1576 |
}, |
| 1577 |
gridlines: { |
| 1578 |
count: nSettings.vAxisGridlinesCount, |
| 1579 |
color: nSettings.vAxisGridlinesColor, |
| 1580 |
}, |
| 1581 |
minorGridlines: { |
| 1582 |
color: nSettings.vAxisMinorGridlinesColor, |
| 1583 |
}, |
| 1584 |
}, |
| 1585 |
focusTarget: nSettings.focusTarget, |
| 1586 |
isStacked: nSettings.isStacked, |
| 1587 |
dataOpacity: nSettings.opacity, |
| 1588 |
bar: { |
| 1589 |
groupWidth: nSettings.groupWidth |
| 1590 |
}, |
| 1591 |
series: {}, |
| 1592 |
}; |
| 1593 |
|
| 1594 |
var seriesRows = dataTypes[0].filter(item => typeof item === 'string'); |
| 1595 |
for (var i = 0; i < seriesRows.length - 1; i++) { |
| 1596 |
_this.chartOptions.series[i] = { |
| 1597 |
color: nSettings.seriesColor[i], |
| 1598 |
visibleInLegend: nSettings.seriesVisibleInLegend[i] == 'on' ? true : (typeof nSettings.seriesColor[i] !== 'undefined' ? false : true), |
| 1599 |
} |
| 1600 |
} |
| 1601 |
|
| 1602 |
if (nSettings.enableAnimation) { |
| 1603 |
_this.chartOptions.animation = { |
| 1604 |
startup: nSettings.animationStartup, |
| 1605 |
duration: nSettings.animationDuration, |
| 1606 |
easing: nSettings.animationEasing, |
| 1607 |
} |
| 1608 |
} |
| 1609 |
|
| 1610 |
_this.chartObj = new google.visualization.BarChart(document.getElementById(_this.htmlClassPrefix + _this.chartType)); |
| 1611 |
|
| 1612 |
_this.chartObj.draw( _this.chartData, _this.chartOptions ); |
| 1613 |
_this.resizeChart(); |
| 1614 |
} |
| 1615 |
/* */ |
| 1616 |
} |
| 1617 |
|
| 1618 |
// Load chart by column chart |
| 1619 |
ChartBuilderGoogleCharts.prototype.columnChartView = function(isChangedType){ |
| 1620 |
var _this = this; |
| 1621 |
var getChartSource = _this.chartSourceData.source; |
| 1622 |
|
| 1623 |
var dataTypes = _this.multiColumnChartConvertData( getChartSource ); |
| 1624 |
|
| 1625 |
var settings = _this.chartSourceData.settings; |
| 1626 |
var nSettings = _this.configOptionsForCharts(settings); |
| 1627 |
|
| 1628 |
var userLocale = navigator.language || navigator.userLanguage || 'en'; |
| 1629 |
|
| 1630 |
/* == Google part == */ |
| 1631 |
google.charts.load('current', {'packages':['corechart'], 'language': userLocale}); |
| 1632 |
google.charts.setOnLoadCallback(drawChart); |
| 1633 |
|
| 1634 |
function drawChart() { |
| 1635 |
dataTypes = nSettings.enableRowSettings ? _this.setRowOptions(dataTypes, nSettings, true) : dataTypes; |
| 1636 |
|
| 1637 |
_this.chartData = isChangedType ? _this.chartData : google.visualization.arrayToDataTable(dataTypes); |
| 1638 |
|
| 1639 |
_this.chartOptions = { |
| 1640 |
fontSize: nSettings.chartFontSize, |
| 1641 |
backgroundColor: { |
| 1642 |
fill: nSettings.backgroundColor, |
| 1643 |
// strokeWidth: nSettings.borderWidth, |
| 1644 |
// stroke: nSettings.borderColor |
| 1645 |
}, |
| 1646 |
chartArea: { |
| 1647 |
backgroundColor: { |
| 1648 |
fill: nSettings.chartBackgroundColor, |
| 1649 |
stroke: nSettings.chartBorderColor, |
| 1650 |
strokeWidth: nSettings.chartBorderWidth |
| 1651 |
}, |
| 1652 |
left: nSettings.chartLeftMargin, |
| 1653 |
right: nSettings.chartRightMargin, |
| 1654 |
top: nSettings.chartTopMargin, |
| 1655 |
bottom: nSettings.chartBottomMargin, |
| 1656 |
}, |
| 1657 |
enableInteractivity: nSettings.enableInteractivity, |
| 1658 |
theme: nSettings.maximizedView, |
| 1659 |
legend: { |
| 1660 |
position: nSettings.legendPosition, |
| 1661 |
alignment: nSettings.legendAlignment, |
| 1662 |
textStyle: { |
| 1663 |
color: nSettings.legendColor, |
| 1664 |
fontSize: nSettings.legendFontSize, |
| 1665 |
italic: nSettings.legendItalicText, |
| 1666 |
bold: nSettings.legendBoldText, |
| 1667 |
} |
| 1668 |
}, |
| 1669 |
tooltip: { |
| 1670 |
trigger: nSettings.tooltipTrigger, |
| 1671 |
showColorCode: nSettings.showColorCode, |
| 1672 |
textStyle: { |
| 1673 |
color: nSettings.tooltipTextColor, |
| 1674 |
fontSize: nSettings.tooltipFontSize, |
| 1675 |
italic: nSettings.tooltipItalicText, |
| 1676 |
bold: nSettings.tooltipBoldText, |
| 1677 |
} |
| 1678 |
}, |
| 1679 |
hAxis: { |
| 1680 |
title: nSettings.hAxisTitle, |
| 1681 |
textPosition: nSettings.hAxisTextPosition, |
| 1682 |
direction: nSettings.hAxisDirection, |
| 1683 |
baselineColor: nSettings.hAxisBaselineColor, |
| 1684 |
textStyle: { |
| 1685 |
color: nSettings.hAxisTextColor, |
| 1686 |
fontSize: nSettings.hAxisTextFontSize, |
| 1687 |
italic: nSettings.hAxisItalicText, |
| 1688 |
bold: nSettings.hAxisBoldText, |
| 1689 |
}, |
| 1690 |
slantedText: nSettings.hAxisSlantedText, |
| 1691 |
slantedTextAngle: nSettings.hAxisSlantedTextAngle, |
| 1692 |
format: nSettings.hAxisFormat, |
| 1693 |
titleTextStyle: { |
| 1694 |
fontSize: nSettings.hAxisLabelFontSize, |
| 1695 |
color: nSettings.hAxisLabelColor, |
| 1696 |
italic: nSettings.hAxisItalicTitle, |
| 1697 |
bold: nSettings.hAxisBoldTitle, |
| 1698 |
}, |
| 1699 |
viewWindow: { |
| 1700 |
min: nSettings.hAxisMinValue, |
| 1701 |
max: nSettings.hAxisMaxValue, |
| 1702 |
}, |
| 1703 |
gridlines: { |
| 1704 |
count: nSettings.hAxisGridlinesCount, |
| 1705 |
color: nSettings.hAxisGridlinesColor, |
| 1706 |
}, |
| 1707 |
minorGridlines: { |
| 1708 |
color: nSettings.hAxisMinorGridlinesColor, |
| 1709 |
}, |
| 1710 |
showTextEvery: nSettings.hAxisShowTextEvery |
| 1711 |
}, |
| 1712 |
vAxis: { |
| 1713 |
title: nSettings.vAxisTitle, |
| 1714 |
textPosition: nSettings.vAxisTextPosition, |
| 1715 |
direction: nSettings.vAxisDirection, |
| 1716 |
baselineColor: nSettings.vAxisBaselineColor, |
| 1717 |
textStyle: { |
| 1718 |
color: nSettings.vAxisTextColor, |
| 1719 |
fontSize: nSettings.vAxisTextFontSize, |
| 1720 |
italic: nSettings.vAxisItalicText, |
| 1721 |
bold: nSettings.vAxisBoldText, |
| 1722 |
}, |
| 1723 |
format: nSettings.vAxisFormat, |
| 1724 |
titleTextStyle: { |
| 1725 |
fontSize: nSettings.vAxisLabelFontSize, |
| 1726 |
color: nSettings.vAxisLabelColor, |
| 1727 |
italic: nSettings.vAxisItalicTitle, |
| 1728 |
bold: nSettings.vAxisBoldTitle, |
| 1729 |
}, |
| 1730 |
viewWindow: { |
| 1731 |
min: nSettings.vAxisMinValue, |
| 1732 |
max: nSettings.vAxisMaxValue, |
| 1733 |
}, |
| 1734 |
gridlines: { |
| 1735 |
count: nSettings.vAxisGridlinesCount, |
| 1736 |
color: nSettings.vAxisGridlinesColor, |
| 1737 |
}, |
| 1738 |
minorGridlines: { |
| 1739 |
color: nSettings.vAxisMinorGridlinesColor, |
| 1740 |
}, |
| 1741 |
}, |
| 1742 |
focusTarget: nSettings.focusTarget, |
| 1743 |
isStacked: nSettings.isStacked, |
| 1744 |
dataOpacity: nSettings.opacity, |
| 1745 |
bar: { |
| 1746 |
groupWidth: nSettings.groupWidth |
| 1747 |
}, |
| 1748 |
series: {}, |
| 1749 |
}; |
| 1750 |
|
| 1751 |
var seriesRows = dataTypes[0].filter(item => typeof item === 'string'); |
| 1752 |
for (var i = 0; i < seriesRows.length - 1; i++) { |
| 1753 |
_this.chartOptions.series[i] = { |
| 1754 |
color: nSettings.seriesColor[i], |
| 1755 |
visibleInLegend: nSettings.seriesVisibleInLegend[i] == 'on' ? true : (typeof nSettings.seriesColor[i] !== 'undefined' ? false : true), |
| 1756 |
} |
| 1757 |
} |
| 1758 |
|
| 1759 |
if (nSettings.enableAnimation) { |
| 1760 |
_this.chartOptions.animation = { |
| 1761 |
startup: nSettings.animationStartup, |
| 1762 |
duration: nSettings.animationDuration, |
| 1763 |
easing: nSettings.animationEasing, |
| 1764 |
} |
| 1765 |
} |
| 1766 |
|
| 1767 |
_this.chartObj = new google.visualization.ColumnChart(document.getElementById(_this.htmlClassPrefix + _this.chartType)); |
| 1768 |
|
| 1769 |
_this.chartObj.draw( _this.chartData, _this.chartOptions ); |
| 1770 |
_this.resizeChart(); |
| 1771 |
} |
| 1772 |
/* */ |
| 1773 |
} |
| 1774 |
|
| 1775 |
// Load chart by line chart |
| 1776 |
ChartBuilderGoogleCharts.prototype.lineChartView = function(isChangedType){ |
| 1777 |
var _this = this; |
| 1778 |
var getChartSource = _this.chartSourceData.source; |
| 1779 |
var dataTypes = _this.multiColumnChartConvertData(getChartSource); |
| 1780 |
|
| 1781 |
var settings = _this.chartSourceData.settings; |
| 1782 |
var nSettings = _this.configOptionsForCharts(settings); |
| 1783 |
|
| 1784 |
var userLocale = navigator.language || navigator.userLanguage || 'en'; |
| 1785 |
|
| 1786 |
/* == Google part == */ |
| 1787 |
google.charts.load('current', {'packages':['corechart'], 'language': userLocale}); |
| 1788 |
google.charts.setOnLoadCallback(drawChart); |
| 1789 |
|
| 1790 |
function drawChart() { |
| 1791 |
dataTypes = nSettings.enableRowSettings ? _this.setRowOptions(dataTypes, nSettings, true) : dataTypes; |
| 1792 |
|
| 1793 |
_this.chartData = isChangedType ? _this.chartData : google.visualization.arrayToDataTable(dataTypes); |
| 1794 |
|
| 1795 |
_this.chartOptions = { |
| 1796 |
fontSize: nSettings.chartFontSize, |
| 1797 |
backgroundColor: { |
| 1798 |
fill: nSettings.backgroundColor, |
| 1799 |
// strokeWidth: nSettings.borderWidth, |
| 1800 |
// stroke: nSettings.borderColor |
| 1801 |
}, |
| 1802 |
chartArea: { |
| 1803 |
backgroundColor: { |
| 1804 |
fill: nSettings.chartBackgroundColor, |
| 1805 |
stroke: nSettings.chartBorderColor, |
| 1806 |
strokeWidth: nSettings.chartBorderWidth |
| 1807 |
}, |
| 1808 |
left: nSettings.chartLeftMargin, |
| 1809 |
right: nSettings.chartRightMargin, |
| 1810 |
top: nSettings.chartTopMargin, |
| 1811 |
bottom: nSettings.chartBottomMargin, |
| 1812 |
}, |
| 1813 |
enableInteractivity: nSettings.enableInteractivity, |
| 1814 |
theme: nSettings.maximizedView, |
| 1815 |
legend: { |
| 1816 |
position: nSettings.legendPosition, |
| 1817 |
alignment: nSettings.legendAlignment, |
| 1818 |
textStyle: { |
| 1819 |
color: nSettings.legendColor, |
| 1820 |
fontSize: nSettings.legendFontSize, |
| 1821 |
italic: nSettings.legendItalicText, |
| 1822 |
bold: nSettings.legendBoldText, |
| 1823 |
} |
| 1824 |
}, |
| 1825 |
tooltip: { |
| 1826 |
trigger: nSettings.tooltipTrigger, |
| 1827 |
showColorCode: nSettings.showColorCode, |
| 1828 |
textStyle: { |
| 1829 |
color: nSettings.tooltipTextColor, |
| 1830 |
fontSize: nSettings.tooltipFontSize, |
| 1831 |
italic: nSettings.tooltipItalicText, |
| 1832 |
bold: nSettings.tooltipBoldText, |
| 1833 |
} |
| 1834 |
}, |
| 1835 |
hAxis: { |
| 1836 |
title: nSettings.hAxisTitle, |
| 1837 |
textPosition: nSettings.hAxisTextPosition, |
| 1838 |
direction: nSettings.hAxisDirection, |
| 1839 |
baselineColor: nSettings.hAxisBaselineColor, |
| 1840 |
textStyle: { |
| 1841 |
color: nSettings.hAxisTextColor, |
| 1842 |
fontSize: nSettings.hAxisTextFontSize, |
| 1843 |
italic: nSettings.hAxisItalicText, |
| 1844 |
bold: nSettings.hAxisBoldText, |
| 1845 |
}, |
| 1846 |
slantedText: nSettings.hAxisSlantedText, |
| 1847 |
slantedTextAngle: nSettings.hAxisSlantedTextAngle, |
| 1848 |
format: nSettings.hAxisFormat, |
| 1849 |
titleTextStyle: { |
| 1850 |
fontSize: nSettings.hAxisLabelFontSize, |
| 1851 |
color: nSettings.hAxisLabelColor, |
| 1852 |
italic: nSettings.hAxisItalicTitle, |
| 1853 |
bold: nSettings.hAxisBoldTitle, |
| 1854 |
}, |
| 1855 |
viewWindow: { |
| 1856 |
min: nSettings.hAxisMinValue, |
| 1857 |
max: nSettings.hAxisMaxValue, |
| 1858 |
}, |
| 1859 |
gridlines: { |
| 1860 |
count: nSettings.hAxisGridlinesCount, |
| 1861 |
color: nSettings.hAxisGridlinesColor, |
| 1862 |
}, |
| 1863 |
minorGridlines: { |
| 1864 |
color: nSettings.hAxisMinorGridlinesColor, |
| 1865 |
}, |
| 1866 |
showTextEvery: nSettings.hAxisShowTextEvery |
| 1867 |
}, |
| 1868 |
vAxis: { |
| 1869 |
title: nSettings.vAxisTitle, |
| 1870 |
textPosition: nSettings.vAxisTextPosition, |
| 1871 |
direction: nSettings.vAxisDirection, |
| 1872 |
baselineColor: nSettings.vAxisBaselineColor, |
| 1873 |
textStyle: { |
| 1874 |
color: nSettings.vAxisTextColor, |
| 1875 |
fontSize: nSettings.vAxisTextFontSize, |
| 1876 |
italic: nSettings.vAxisItalicText, |
| 1877 |
bold: nSettings.vAxisBoldText, |
| 1878 |
}, |
| 1879 |
format: nSettings.vAxisFormat, |
| 1880 |
titleTextStyle: { |
| 1881 |
fontSize: nSettings.vAxisLabelFontSize, |
| 1882 |
color: nSettings.vAxisLabelColor, |
| 1883 |
italic: nSettings.vAxisItalicTitle, |
| 1884 |
bold: nSettings.vAxisBoldTitle, |
| 1885 |
}, |
| 1886 |
viewWindow: { |
| 1887 |
min: nSettings.vAxisMinValue, |
| 1888 |
max: nSettings.vAxisMaxValue, |
| 1889 |
}, |
| 1890 |
gridlines: { |
| 1891 |
count: nSettings.vAxisGridlinesCount, |
| 1892 |
color: nSettings.vAxisGridlinesColor, |
| 1893 |
}, |
| 1894 |
minorGridlines: { |
| 1895 |
color: nSettings.vAxisMinorGridlinesColor, |
| 1896 |
}, |
| 1897 |
}, |
| 1898 |
crosshair: { |
| 1899 |
opacity: nSettings.crosshairOpacity, |
| 1900 |
orientation: nSettings.crosshairOrientation, |
| 1901 |
trigger: nSettings.crosshairTrigger, |
| 1902 |
}, |
| 1903 |
focusTarget: nSettings.focusTarget, |
| 1904 |
dataOpacity: nSettings.opacity, |
| 1905 |
lineWidth: nSettings.lineWidth, |
| 1906 |
selectionMode: nSettings.multipleSelection, |
| 1907 |
aggregationTarget: nSettings.multipleDataFormat, |
| 1908 |
pointShape: nSettings.pointShape, |
| 1909 |
pointSize: nSettings.pointSize, |
| 1910 |
orientation: nSettings.orientation, |
| 1911 |
interpolateNulls: nSettings.fillNulls, |
| 1912 |
lineDashStyle: nSettings.dashStyle, |
| 1913 |
series: {}, |
| 1914 |
}; |
| 1915 |
|
| 1916 |
var seriesRows = dataTypes[0].filter(item => typeof item === 'string'); |
| 1917 |
for (var i = 0; i < seriesRows.length - 1; i++) { |
| 1918 |
_this.chartOptions.series[i] = { |
| 1919 |
color: nSettings.seriesColor[i], |
| 1920 |
visibleInLegend: nSettings.seriesVisibleInLegend[i] == 'on' ? true : (typeof nSettings.seriesColor[i] !== 'undefined' ? false : true), |
| 1921 |
lineWidth: nSettings.seriesLineWidth[i], |
| 1922 |
pointSize: nSettings.seriesPointSize[i], |
| 1923 |
pointShape: nSettings.seriesPointShape[i], |
| 1924 |
} |
| 1925 |
} |
| 1926 |
|
| 1927 |
if (nSettings.enableAnimation) { |
| 1928 |
_this.chartOptions.animation = { |
| 1929 |
startup: nSettings.animationStartup, |
| 1930 |
duration: nSettings.animationDuration, |
| 1931 |
easing: nSettings.animationEasing, |
| 1932 |
} |
| 1933 |
} |
| 1934 |
|
| 1935 |
_this.chartObj = new google.visualization.LineChart(document.getElementById(_this.htmlClassPrefix + _this.chartType)); |
| 1936 |
|
| 1937 |
_this.chartObj.draw( _this.chartData, _this.chartOptions ); |
| 1938 |
_this.resizeChart(); |
| 1939 |
} |
| 1940 |
/* */ |
| 1941 |
} |
| 1942 |
|
| 1943 |
// Load chart by donut chart |
| 1944 |
ChartBuilderGoogleCharts.prototype.donutChartView = function(isChangedType){ |
| 1945 |
var _this = this; |
| 1946 |
var getChartSource = _this.chartSourceData.source; |
| 1947 |
var dataTypes = _this.chartConvertData( getChartSource ); |
| 1948 |
|
| 1949 |
var settings = _this.chartSourceData.settings; |
| 1950 |
var nSettings = _this.configOptionsForCharts(settings); |
| 1951 |
|
| 1952 |
var userLocale = navigator.language || navigator.userLanguage || 'en'; |
| 1953 |
|
| 1954 |
/* == Google part == */ |
| 1955 |
google.charts.load('current', {'packages':['corechart'], 'language': userLocale}); |
| 1956 |
google.charts.setOnLoadCallback(drawChart); |
| 1957 |
|
| 1958 |
function drawChart() { |
| 1959 |
_this.chartData = isChangedType ? _this.chartData : google.visualization.arrayToDataTable( dataTypes ); |
| 1960 |
|
| 1961 |
_this.chartOptions = { |
| 1962 |
fontSize: nSettings.chartFontSize, |
| 1963 |
chartArea: { |
| 1964 |
left: nSettings.chartLeftMargin, |
| 1965 |
right: nSettings.chartRightMargin, |
| 1966 |
top: nSettings.chartTopMargin, |
| 1967 |
bottom: nSettings.chartBottomMargin, |
| 1968 |
}, |
| 1969 |
backgroundColor: { |
| 1970 |
fill: nSettings.backgroundColor, |
| 1971 |
// strokeWidth: nSettings.borderWidth, |
| 1972 |
// stroke: nSettings.borderColor |
| 1973 |
}, |
| 1974 |
enableInteractivity: nSettings.enableInteractivity, |
| 1975 |
legend: { |
| 1976 |
position: nSettings.legendPosition, |
| 1977 |
alignment: nSettings.legendAlignment, |
| 1978 |
textStyle: { |
| 1979 |
color: nSettings.legendColor, |
| 1980 |
fontSize: nSettings.legendFontSize, |
| 1981 |
italic: nSettings.legendItalicText, |
| 1982 |
bold: nSettings.legendBoldText, |
| 1983 |
} |
| 1984 |
}, |
| 1985 |
tooltip: { |
| 1986 |
trigger: nSettings.tooltipTrigger, |
| 1987 |
showColorCode: nSettings.showColorCode, |
| 1988 |
text: nSettings.tooltipText, |
| 1989 |
textStyle: { |
| 1990 |
color: nSettings.tooltipTextColor, |
| 1991 |
fontSize: nSettings.tooltipFontSize, |
| 1992 |
italic: nSettings.tooltipItalicText, |
| 1993 |
bold: nSettings.tooltipBoldText, |
| 1994 |
} |
| 1995 |
}, |
| 1996 |
pieStartAngle: nSettings.rotationDegree, |
| 1997 |
pieSliceBorderColor: nSettings.sliceBorderColor, |
| 1998 |
reverseCategories: nSettings.reverseCategories, |
| 1999 |
pieSliceText: nSettings.sliceText, |
| 2000 |
sliceVisibilityThreshold: nSettings.dataGroupingLimit, |
| 2001 |
pieResidueSliceLabel: nSettings.dataGroupingLabel, |
| 2002 |
pieResidueSliceColor: nSettings.dataGroupingColor, |
| 2003 |
pieHole: nSettings.holeSize, |
| 2004 |
slices: {} |
| 2005 |
}; |
| 2006 |
|
| 2007 |
for (var i = 0; i < dataTypes.length - 1; i++) { |
| 2008 |
_this.chartOptions.slices[i] = { |
| 2009 |
color: nSettings.sliceColor[i], |
| 2010 |
offset: typeof nSettings.sliceOffset[i] !== 'undefined' ? nSettings.sliceOffset[i] : 0, |
| 2011 |
textStyle: { |
| 2012 |
color: nSettings.sliceTextColor[i], |
| 2013 |
}, |
| 2014 |
} |
| 2015 |
} |
| 2016 |
|
| 2017 |
_this.chartObj = new google.visualization.PieChart( document.getElementById(_this.htmlClassPrefix + _this.chartType) ); |
| 2018 |
|
| 2019 |
_this.chartObj.draw( _this.chartData, _this.chartOptions ); |
| 2020 |
_this.resizeChart(); |
| 2021 |
} |
| 2022 |
/* */ |
| 2023 |
} |
| 2024 |
|
| 2025 |
// Load chart by org chart |
| 2026 |
ChartBuilderGoogleCharts.prototype.orgChartView = function(isChangedType){ |
| 2027 |
var _this = this; |
| 2028 |
var getChartSource = _this.chartSourceData.source; |
| 2029 |
var dataTypes = _this.orgChartConvertData(getChartSource); |
| 2030 |
var treeData = _this.orgChartConvertDataForTreeManual(getChartSource); |
| 2031 |
|
| 2032 |
var settings = _this.chartSourceData.settings; |
| 2033 |
var nSettings = _this.configOptionsForCharts(settings); |
| 2034 |
|
| 2035 |
var userLocale = navigator.language || navigator.userLanguage || 'en'; |
| 2036 |
|
| 2037 |
/* == Google part == */ |
| 2038 |
google.charts.load('current', {'packages':['orgchart'], 'language': userLocale}); |
| 2039 |
google.charts.setOnLoadCallback(drawChart); |
| 2040 |
|
| 2041 |
function drawChart() { |
| 2042 |
_this.chartDataArray = isChangedType ? _this.chartDataArray : dataTypes; |
| 2043 |
_this.chartData = google.visualization.arrayToDataTable(_this.chartDataArray); |
| 2044 |
|
| 2045 |
var view = new google.visualization.DataView(_this.chartData); |
| 2046 |
view.setColumns([0, 1, 2]); |
| 2047 |
|
| 2048 |
_this.chartOptions = { |
| 2049 |
allowHtml: true, |
| 2050 |
size: nSettings.orgChartFontSize, |
| 2051 |
allowCollapse: nSettings.allowCollapse, |
| 2052 |
compactRows: true, |
| 2053 |
nodeClass: nSettings.orgClassname, |
| 2054 |
selectedNodeClass: nSettings.orgSelectedClassname, |
| 2055 |
}; |
| 2056 |
|
| 2057 |
_this.chartObj = new google.visualization.OrgChart(document.getElementById(_this.htmlClassPrefix + _this.chartType)); |
| 2058 |
|
| 2059 |
google.visualization.events.addListener(_this.chartObj, 'select', function () { |
| 2060 |
var selection = _this.chartObj.getSelection(); |
| 2061 |
if (selection.length > 0) { |
| 2062 |
if (_this.chartData.getValue(selection[0].row, 3) != '') { |
| 2063 |
window.open(_this.chartData.getValue(selection[0].row, 3), '_blank'); |
| 2064 |
} |
| 2065 |
} |
| 2066 |
}); |
| 2067 |
|
| 2068 |
google.visualization.events.addListener(_this.chartObj, 'collapse', function () { |
| 2069 |
_this.setOrgChartCustomStyles(); |
| 2070 |
}); |
| 2071 |
|
| 2072 |
_this.chartObj.draw( view, _this.chartOptions ); |
| 2073 |
_this.resizeChart(); |
| 2074 |
_this.setOrgChartCustomStyles(); |
| 2075 |
} |
| 2076 |
|
| 2077 |
_this.$el.on('click', '.google-visualization-orgchart-node-small, .google-visualization-orgchart-node-medium, .google-visualization-orgchart-node-large', function(e) { |
| 2078 |
if (nSettings.orgSelectedClassname !== '') { |
| 2079 |
_this.setOrgChartCustomStyles(); |
| 2080 |
} |
| 2081 |
}); |
| 2082 |
|
| 2083 |
var treeManualId = '#ays-chart-chart-source-data-edit-tree-content'; |
| 2084 |
var sortable = new TreeSortable({ |
| 2085 |
treeSelector: treeManualId, |
| 2086 |
}); |
| 2087 |
var $treeManual = $(treeManualId); |
| 2088 |
var $content = treeData.map(sortable.createBranch); |
| 2089 |
$treeManual.html($content); |
| 2090 |
sortable.run(); |
| 2091 |
|
| 2092 |
sortable.addListener('click', '.add-child', function (event, instance) { |
| 2093 |
instance.addChildBranch($(event.target), treeData); |
| 2094 |
}); |
| 2095 |
sortable.addListener('click', '.add-sibling', function (event, instance) { |
| 2096 |
instance.addSiblingBranch($(event.target), treeData); |
| 2097 |
}); |
| 2098 |
|
| 2099 |
sortable.addListener('click', '.remove-branch', function (event, instance) { |
| 2100 |
event.preventDefault(); |
| 2101 |
var confirm = window.confirm('Are you sure you want to delete this branch?'); |
| 2102 |
if (!confirm) { |
| 2103 |
return; |
| 2104 |
} |
| 2105 |
instance.removeBranch($(event.target)); |
| 2106 |
}); |
| 2107 |
|
| 2108 |
sortable.addListener('click', '.open-branch-options', function (event, instance) { |
| 2109 |
instance.openBranchOptions($(event.target)); |
| 2110 |
}) |
| 2111 |
|
| 2112 |
sortable.addListener('click', '.close-branch-options', function (event, instance) { |
| 2113 |
instance.closeBranchOptions($(event.target)); |
| 2114 |
}) |
| 2115 |
|
| 2116 |
sortable.addListener('click', '.change-branch-options', function (event, instance) { |
| 2117 |
instance.changeBranchOptions($(event.target)); |
| 2118 |
}) |
| 2119 |
|
| 2120 |
tippy('[data-tippy-content]'); |
| 2121 |
} |
| 2122 |
|
| 2123 |
/* |
| 2124 |
Configure all settings for all chart types |
| 2125 |
Getting settings for each chart type in respective function |
| 2126 |
*/ |
| 2127 |
ChartBuilderGoogleCharts.prototype.configOptionsForCharts = function (settings) { |
| 2128 |
var newSettings = {}; |
| 2129 |
|
| 2130 |
newSettings.chartFontSize = settings['font_size']; |
| 2131 |
newSettings.backgroundColor = settings['transparent_background'] && settings['transparent_background'] === 'checked' ? 'transparent' : settings['background_color']; |
| 2132 |
// newSettings.borderWidth = settings['border_width']; |
| 2133 |
// newSettings.borderColor = settings['border_color']; |
| 2134 |
newSettings.tooltipTrigger = settings['tooltip_trigger']; |
| 2135 |
newSettings.tooltipText = settings['tooltip_text']; |
| 2136 |
newSettings.showColorCode = (settings['show_color_code'] == 'checked') ? true : false; |
| 2137 |
newSettings.tooltipItalicText = (settings['tooltip_italic'] == 'checked') ? true : false; |
| 2138 |
newSettings.tooltipBoldText = settings['tooltip_bold']; |
| 2139 |
newSettings.legendItalicText = (settings['legend_italic'] == 'checked') ? true : false; |
| 2140 |
newSettings.legendBoldText = (settings['legend_bold'] == 'checked') ? true : false; |
| 2141 |
newSettings.tooltipTextColor = settings['tooltip_text_color']; |
| 2142 |
newSettings.tooltipFontSize = settings['tooltip_font_size']; |
| 2143 |
newSettings.legendPosition = settings['legend_position']; |
| 2144 |
newSettings.legendAlignment = settings['legend_alignment']; |
| 2145 |
newSettings.legendFontSize = settings['legend_font_size']; |
| 2146 |
newSettings.rotationDegree = settings['rotation_degree']; |
| 2147 |
newSettings.sliceBorderColor = settings['slice_border_color']; |
| 2148 |
newSettings.reverseCategories = (settings['reverse_categories'] == 'checked') ? true : false; |
| 2149 |
newSettings.sliceText = settings['slice_text']; |
| 2150 |
newSettings.legendColor = settings['legend_color']; |
| 2151 |
newSettings.dataGroupingLimit = settings['data_grouping_limit']/100; |
| 2152 |
newSettings.dataGroupingLabel = settings['data_grouping_label']; |
| 2153 |
newSettings.dataGroupingColor = settings['data_grouping_color']; |
| 2154 |
newSettings.sliceColor = settings['slice_color']; |
| 2155 |
newSettings.sliceOffset = settings['slice_offset']; |
| 2156 |
newSettings.sliceTextColor = settings['slice_text_color']; |
| 2157 |
newSettings.chartBackgroundColor = settings['transparent_background'] && settings['transparent_background'] === 'checked' ? 'transparent' : settings['chart_background_color']; |
| 2158 |
newSettings.chartBorderWidth = settings['chart_border_width']; |
| 2159 |
newSettings.chartBorderColor = settings['chart_border_color']; |
| 2160 |
newSettings.chartLeftMargin = settings['chart_left_margin_for_js']; |
| 2161 |
newSettings.chartRightMargin = settings['chart_right_margin_for_js']; |
| 2162 |
newSettings.chartTopMargin = settings['chart_top_margin_for_js']; |
| 2163 |
newSettings.chartBottomMargin = settings['chart_bottom_margin_for_js']; |
| 2164 |
newSettings.isStacked = (settings['is_stacked'] == 'checked') ? true : false; |
| 2165 |
newSettings.focusTarget = settings['focus_target']; |
| 2166 |
newSettings.groupWidthFormat = settings['group_width_format'] == '%' ? '%' : ''; |
| 2167 |
newSettings.groupWidth = settings['group_width'] + newSettings.groupWidthFormat; |
| 2168 |
newSettings.hAxisTitle = settings['haxis_title']; |
| 2169 |
newSettings.vAxisTitle = settings['vaxis_title']; |
| 2170 |
newSettings.hAxisLabelFontSize = settings['haxis_label_font_size']; |
| 2171 |
newSettings.vAxisLabelFontSize = settings['vaxis_label_font_size']; |
| 2172 |
newSettings.hAxisLabelColor = settings['haxis_label_color']; |
| 2173 |
newSettings.vAxisLabelColor = settings['vaxis_label_color']; |
| 2174 |
newSettings.hAxisTextPosition = settings['haxis_text_position']; |
| 2175 |
newSettings.vAxisTextPosition = settings['vaxis_text_position']; |
| 2176 |
newSettings.vAxisDirection = (settings['vaxis_direction'] == 'checked') ? -1 : 1; |
| 2177 |
newSettings.hAxisDirection = (settings['haxis_direction'] == 'checked') ? -1 : 1; |
| 2178 |
newSettings.hAxisTextColor = settings['haxis_text_color']; |
| 2179 |
newSettings.vAxisTextColor = settings['vaxis_text_color']; |
| 2180 |
newSettings.hAxisBaselineColor = settings['haxis_baseline_color']; |
| 2181 |
newSettings.vAxisBaselineColor = settings['vaxis_baseline_color']; |
| 2182 |
newSettings.hAxisTextFontSize = settings['haxis_text_font_size']; |
| 2183 |
newSettings.vAxisTextFontSize = settings['vaxis_text_font_size']; |
| 2184 |
newSettings.hAxisSlantedText = settings['haxis_slanted']; |
| 2185 |
newSettings.hAxisSlantedTextAngle = settings['haxis_slanted_text_angle']; |
| 2186 |
newSettings.hAxisShowTextEvery = settings['haxis_show_text_every']; |
| 2187 |
newSettings.vAxisFormat = settings['vaxis_format']; |
| 2188 |
newSettings.hAxisFormat = settings['haxis_format']; |
| 2189 |
newSettings.hAxisMinValue = settings['haxis_min_value']; |
| 2190 |
newSettings.hAxisMaxValue = settings['haxis_max_value']; |
| 2191 |
newSettings.vAxisMinValue = settings['vaxis_min_value']; |
| 2192 |
newSettings.vAxisMaxValue = settings['vaxis_max_value']; |
| 2193 |
newSettings.hAxisGridlinesCount = settings['haxis_gridlines_count']; |
| 2194 |
newSettings.hAxisGridlinesColor = settings['haxis_gridlines_color']; |
| 2195 |
newSettings.hAxisMinorGridlinesColor = settings['haxis_minor_gridlines_color']; |
| 2196 |
newSettings.vAxisGridlinesCount = settings['vaxis_gridlines_count']; |
| 2197 |
newSettings.vAxisGridlinesColor = settings['vaxis_gridlines_color']; |
| 2198 |
newSettings.vAxisMinorGridlinesColor = settings['vaxis_minor_gridlines_color']; |
| 2199 |
newSettings.hAxisItalicText = (settings['haxis_italic'] == 'checked') ? true : false; |
| 2200 |
newSettings.hAxisBoldText = (settings['haxis_bold'] == 'checked') ? true : false; |
| 2201 |
newSettings.vAxisItalicText = (settings['vaxis_italic'] == 'checked') ? true : false; |
| 2202 |
newSettings.vAxisBoldText = (settings['vaxis_bold'] == 'checked') ? true : false; |
| 2203 |
newSettings.hAxisItalicTitle = (settings['haxis_title_italic'] == 'checked') ? true : false; |
| 2204 |
newSettings.hAxisBoldTitle = (settings['haxis_title_bold'] == 'checked') ? true : false; |
| 2205 |
newSettings.vAxisItalicTitle = (settings['vaxis_title_italic'] == 'checked') ? true : false; |
| 2206 |
newSettings.vAxisBoldTitle = (settings['vaxis_title_bold'] == 'checked') ? true : false; |
| 2207 |
newSettings.opacity = settings['opacity']; |
| 2208 |
newSettings.enableInteractivity = (settings['enable_interactivity'] == 'checked') ? true : false; |
| 2209 |
newSettings.maximizedView = (settings['maximized_view'] == 'checked') ? 'maximized' : null; |
| 2210 |
newSettings.enableAnimation = (settings['enable_animation'] == 'checked') ? true : false; |
| 2211 |
newSettings.animationDuration = settings['animation_duration']; |
| 2212 |
newSettings.animationStartup = (settings['animation_startup'] == 'checked') ? true : false; |
| 2213 |
newSettings.animationEasing = settings['animation_easing']; |
| 2214 |
newSettings.seriesColor = settings['series_color']; |
| 2215 |
newSettings.seriesVisibleInLegend = settings['series_visible_in_legend']; |
| 2216 |
newSettings.seriesLineWidth = settings['series_line_width']; |
| 2217 |
newSettings.seriesPointSize = settings['series_point_size']; |
| 2218 |
newSettings.seriesPointShape = settings['series_point_shape']; |
| 2219 |
newSettings.enableRowSettings = (settings['enable_row_settings'] == 'checked') ? true : false; |
| 2220 |
newSettings.rowsColor = settings['rows_color']; |
| 2221 |
newSettings.rowsOpacity = settings['rows_opacity']; |
| 2222 |
newSettings.multipleSelection = (settings['multiple_selection'] == 'checked') ? 'multiple' : 'single'; |
| 2223 |
newSettings.multipleDataFormat = settings['multiple_data_format']; |
| 2224 |
newSettings.pointShape = settings['point_shape']; |
| 2225 |
newSettings.pointSize = settings['point_size']; |
| 2226 |
newSettings.lineWidth = settings['line_width']; |
| 2227 |
newSettings.crosshairTrigger = settings['crosshair_trigger']; |
| 2228 |
newSettings.crosshairOrientation = settings['crosshair_orientation']; |
| 2229 |
newSettings.crosshairOpacity = settings['crosshair_opacity']; |
| 2230 |
newSettings.dashStyle = settings['dash_style'] ? settings['dash_style'].split(',') : null; |
| 2231 |
newSettings.orientation = (settings['orientation'] == 'checked') ? 'vertical' : 'horizontal'; |
| 2232 |
newSettings.fillNulls = (settings['fill_nulls'] == 'checked') ? true : false; |
| 2233 |
newSettings.holeSize = settings['donut_hole_size']; |
| 2234 |
newSettings.orgChartFontSize = settings['org_chart_font_size']; |
| 2235 |
newSettings.allowCollapse = (settings['allow_collapse'] == 'checked') ? true : false; |
| 2236 |
newSettings.orgClassname = settings['org_classname']; |
| 2237 |
newSettings.orgSelectedClassname = settings['org_selected_classname']; |
| 2238 |
|
| 2239 |
return newSettings; |
| 2240 |
} |
| 2241 |
|
| 2242 |
ChartBuilderGoogleCharts.prototype.setRowOptions = function (data, options, isJS = true) { |
| 2243 |
var _this = this; |
| 2244 |
|
| 2245 |
if (data && data.length > 0) { |
| 2246 |
if (data[0] && data[0].length == 2) { |
| 2247 |
data[0].push({ role: 'style' }); |
| 2248 |
for (var i = 1; i < data.length; i++) { |
| 2249 |
var opts = []; |
| 2250 |
|
| 2251 |
var color = isJS ? options.rowsColor[i - 1] : options.rows_color[i - 1]; |
| 2252 |
opts.push(color ? 'color:'+color : ''); |
| 2253 |
|
| 2254 |
var opacity = isJS ? options.rowsOpacity[i - 1] : options.rows_opacity[i - 1]; |
| 2255 |
opts.push(opacity ? 'opacity:'+opacity : ''); |
| 2256 |
|
| 2257 |
|
| 2258 |
data[i].push(opts.join(';')); |
| 2259 |
} |
| 2260 |
} |
| 2261 |
} |
| 2262 |
|
| 2263 |
return data; |
| 2264 |
} |
| 2265 |
|
| 2266 |
ChartBuilderGoogleCharts.prototype.removeRowOptions = function (data) { |
| 2267 |
var _this = this; |
| 2268 |
|
| 2269 |
if (data && data.length > 0) { |
| 2270 |
if (data[0] && data[0].length == 2) { |
| 2271 |
for (var i = 0; i < data.length; i++) { |
| 2272 |
data[i].splice(2, 1); |
| 2273 |
} |
| 2274 |
} |
| 2275 |
} |
| 2276 |
|
| 2277 |
return data; |
| 2278 |
} |
| 2279 |
|
| 2280 |
// Detect window resize moment to draw charts responsively |
| 2281 |
ChartBuilderGoogleCharts.prototype.resizeChart = function(){ |
| 2282 |
var _this = this; |
| 2283 |
|
| 2284 |
//create trigger to resizeEnd event |
| 2285 |
$(window).resize(function() { |
| 2286 |
if(this.resizeTO) clearTimeout(this.resizeTO); |
| 2287 |
this.resizeTO = setTimeout(function() { |
| 2288 |
$(this).trigger('resizeEnd'); |
| 2289 |
}, 100); |
| 2290 |
}); |
| 2291 |
|
| 2292 |
//redraw graph when window resize is completed |
| 2293 |
$(window).on('resizeEnd', function() { |
| 2294 |
_this.drawChartFunction( _this.chartData, _this.chartOptions ); |
| 2295 |
}); |
| 2296 |
|
| 2297 |
} |
| 2298 |
|
| 2299 |
ChartBuilderGoogleCharts.prototype.setOrgChartCustomStyles = function () { |
| 2300 |
var _this = this; |
| 2301 |
|
| 2302 |
var orgClassname = _this.chartSourceData.settings.org_classname; |
| 2303 |
var bgColor = _this.chartSourceData.settings.org_node_background_color; |
| 2304 |
var padding = _this.chartSourceData.settings.org_node_padding; |
| 2305 |
var borderRadius = _this.chartSourceData.settings.org_node_border_radius; |
| 2306 |
var borderWidth = _this.chartSourceData.settings.org_node_border_width; |
| 2307 |
var borderColor = _this.chartSourceData.settings.org_node_border_color; |
| 2308 |
var textColor = _this.chartSourceData.settings.org_node_text_color; |
| 2309 |
var textSize = _this.chartSourceData.settings.org_node_text_font_size; |
| 2310 |
var descriptionColor = _this.chartSourceData.settings.org_node_description_font_color; |
| 2311 |
var descriptionSize = _this.chartSourceData.settings.org_node_description_font_size; |
| 2312 |
|
| 2313 |
var orgSelectedClassname = _this.chartSourceData.settings.org_selected_classname; |
| 2314 |
var selectedBgColor = _this.chartSourceData.settings.org_selected_node_background_color; |
| 2315 |
var selectedTextColor = _this.chartSourceData.settings.org_selected_node_text_color; |
| 2316 |
|
| 2317 |
if (orgClassname != '') { |
| 2318 |
var node = _this.$el.find('.' + orgClassname); |
| 2319 |
node.css({ |
| 2320 |
'background-color' : bgColor, |
| 2321 |
'padding' : padding + 'px', |
| 2322 |
'border-radius' : borderRadius + 'px', |
| 2323 |
'color' : textColor, |
| 2324 |
'font-size' : textSize + 'px', |
| 2325 |
'border' : 'none', |
| 2326 |
'outline' : borderWidth + 'px solid ' + borderColor, |
| 2327 |
}); |
| 2328 |
} |
| 2329 |
|
| 2330 |
if (orgSelectedClassname != '') { |
| 2331 |
var selectedNode = _this.$el.find('.' + orgSelectedClassname); |
| 2332 |
selectedNode.css({ |
| 2333 |
'background-color' : selectedBgColor, |
| 2334 |
// 'padding' : padding + 'px', |
| 2335 |
// 'border-radius' : borderRadius + 'px', |
| 2336 |
'color' : selectedTextColor, |
| 2337 |
// 'font-size' : textSize + 'px', |
| 2338 |
// 'border' : 'none', |
| 2339 |
// 'outline' : borderWidth + 'px solid ' + borderColor, |
| 2340 |
}); |
| 2341 |
} |
| 2342 |
|
| 2343 |
var description = _this.$el.find('.' + _this.htmlClassPrefix + 'org-chart-tree-description'); |
| 2344 |
description.css({ |
| 2345 |
'color' : descriptionColor, |
| 2346 |
'font-size' : descriptionSize + 'px', |
| 2347 |
}); |
| 2348 |
|
| 2349 |
// var image = _this.$el.find('.' + _this.htmlClassPrefix + 'org-chart-tree-image'); |
| 2350 |
} |
| 2351 |
|
| 2352 |
ChartBuilderGoogleCharts.prototype.chartConvertData = function( data ){ |
| 2353 |
var _this = this; |
| 2354 |
var dataTypes = []; |
| 2355 |
|
| 2356 |
// Collect data in new array for chart rendering |
| 2357 |
for ( var key in data ) { |
| 2358 |
if ( data.hasOwnProperty( key ) ) { |
| 2359 |
if (key == 0) { |
| 2360 |
if (data[key][0] != '' && data[key][1] != '') { |
| 2361 |
dataTypes.push([ |
| 2362 |
_this.htmlDecode(data[key][0]), _this.htmlDecode(data[key][1]) |
| 2363 |
]); |
| 2364 |
} |
| 2365 |
} else { |
| 2366 |
if (data[key][0] != '' && data[key][1] != '') { |
| 2367 |
dataTypes.push([ |
| 2368 |
_this.htmlDecode(data[key][0]), +(data[key][1]) |
| 2369 |
]); |
| 2370 |
} |
| 2371 |
} |
| 2372 |
} |
| 2373 |
} |
| 2374 |
|
| 2375 |
return dataTypes; |
| 2376 |
} |
| 2377 |
|
| 2378 |
// Converting chart data for multicolumn chart |
| 2379 |
ChartBuilderGoogleCharts.prototype.multiColumnChartConvertData = function( data ){ |
| 2380 |
var _this = this; |
| 2381 |
var dataTypes = []; |
| 2382 |
var titleRow = []; |
| 2383 |
|
| 2384 |
for (var key in data) { |
| 2385 |
var dataRow = []; |
| 2386 |
if (data.hasOwnProperty(key)) { |
| 2387 |
if (key == 0) { |
| 2388 |
for (var index in data[key]) { |
| 2389 |
if (data[key][index] != '') { |
| 2390 |
titleRow.push(_this.htmlDecode(data[key][index])); |
| 2391 |
} |
| 2392 |
} |
| 2393 |
dataTypes.push(titleRow); |
| 2394 |
} else { |
| 2395 |
for (var index in data[key]) { |
| 2396 |
if (data[key][index] != '') { |
| 2397 |
if (index == 0) { |
| 2398 |
dataRow.push(_this.htmlDecode(data[key][index])); |
| 2399 |
} else { |
| 2400 |
dataRow.push(+data[key][index]); |
| 2401 |
} |
| 2402 |
} |
| 2403 |
} |
| 2404 |
dataTypes.push(dataRow); |
| 2405 |
} |
| 2406 |
} |
| 2407 |
} |
| 2408 |
|
| 2409 |
return dataTypes; |
| 2410 |
} |
| 2411 |
|
| 2412 |
// Converting chart data for org chart type |
| 2413 |
ChartBuilderGoogleCharts.prototype.orgChartConvertData = function( data ){ |
| 2414 |
var _this = this; |
| 2415 |
var dataTypes = [['Name', 'Manager', 'Tooltip', 'Url']]; |
| 2416 |
// var name = ""; |
| 2417 |
// Collect data in new array for chart rendering |
| 2418 |
for ( var key in data ) { |
| 2419 |
if ( data.hasOwnProperty( key ) ) { |
| 2420 |
if (key != 0) { |
| 2421 |
var name = data[key][0]; |
| 2422 |
var description = data[key][1]; |
| 2423 |
var image = (data[key].length > 6) ? data[key][2] : ''; |
| 2424 |
var parent_name = (data[key].length > 6) ? data[key][3] : data[key][2]; |
| 2425 |
var tooltip = (data[key].length > 6) ? data[key][4] : data[key][3]; |
| 2426 |
var url = (data[key].length > 6) ? data[key][5] : ''; |
| 2427 |
|
| 2428 |
if (description) { |
| 2429 |
name += _this.orgChartFormatName(description); |
| 2430 |
} |
| 2431 |
if (image && image != '') { |
| 2432 |
name = _this.orgChartFormatImage(image) + name; |
| 2433 |
} |
| 2434 |
name = {'v': data[key][0], 'f': name}; |
| 2435 |
dataTypes.push([ |
| 2436 |
name, parent_name, tooltip, url |
| 2437 |
]); |
| 2438 |
} |
| 2439 |
} |
| 2440 |
} |
| 2441 |
|
| 2442 |
return dataTypes; |
| 2443 |
} |
| 2444 |
|
| 2445 |
ChartBuilderGoogleCharts.prototype.orgChartFormatName = function( description ){ |
| 2446 |
return `<div class="${this.htmlClassPrefix}org-chart-tree-description">${description}</div>`; |
| 2447 |
} |
| 2448 |
|
| 2449 |
ChartBuilderGoogleCharts.prototype.orgChartFormatImage = function( image ){ |
| 2450 |
return `<div class="${this.htmlClassPrefix}org-chart-tree-image"><img width="128px" src="${image}"></div>`; |
| 2451 |
} |
| 2452 |
|
| 2453 |
ChartBuilderGoogleCharts.prototype.orgChartConvertDataForTreeManual = function( source ){ |
| 2454 |
var _this = this; |
| 2455 |
var treeDataArr = []; |
| 2456 |
var ordering = _this.chartSourceData.source_ordering; |
| 2457 |
source = Object.assign({}, source); |
| 2458 |
if ( !$.isArray(source) ) { |
| 2459 |
for (var index in ordering) { |
| 2460 |
var key = (ordering[index]); |
| 2461 |
|
| 2462 |
var id = key; |
| 2463 |
var title = source[key][0]; |
| 2464 |
var description = source[key][1]; |
| 2465 |
var image = (source[key].length > 6) ? source[key][2] : ''; |
| 2466 |
var parent_name = (source[key].length > 6) ? source[key][3] : source[key][2]; |
| 2467 |
var tooltip = (source[key].length > 6) ? source[key][4] : source[key][3]; |
| 2468 |
var url = (source[key].length > 6) ? source[key][5] : ''; |
| 2469 |
var parent_id = (source[key].length > 6) ? source[key][6].toString() : source[key][4].toString(); |
| 2470 |
var level = (source[key].length > 6) ? source[key][7].toString() : source[key][5].toString(); |
| 2471 |
|
| 2472 |
// var ID = (source[0] == undefined) ? key : key + 1; |
| 2473 |
treeDataArr[index] = { |
| 2474 |
id: id, |
| 2475 |
parent_id: parent_id, |
| 2476 |
title: title, |
| 2477 |
level: level, |
| 2478 |
description: description, |
| 2479 |
image: image, |
| 2480 |
tooltip: tooltip, |
| 2481 |
url: url, |
| 2482 |
parent_name: parent_name |
| 2483 |
} |
| 2484 |
} |
| 2485 |
} |
| 2486 |
|
| 2487 |
return treeDataArr; |
| 2488 |
} |
| 2489 |
|
| 2490 |
// Update chart data and display immediately |
| 2491 |
ChartBuilderGoogleCharts.prototype.updateChartData = function( newData ){ |
| 2492 |
var _this = this; |
| 2493 |
_this.drawChartFunction( newData, _this.chartOptions ); |
| 2494 |
} |
| 2495 |
|
| 2496 |
ChartBuilderGoogleCharts.prototype.addChartDataRow = function (element){ |
| 2497 |
var _this = this; |
| 2498 |
// var deleteImageUrl = ChartBuilderSourceData.removeManualDataRow; |
| 2499 |
var content = ''; |
| 2500 |
|
| 2501 |
var addedTermsandConds = this.$el.find("."+this.htmlClassPrefix+"chart-source-data-edit-block"); |
| 2502 |
var addedTermsandCondsId = this.$el.find("."+this.htmlClassPrefix+"chart-source-data-edit-block:last-child"); |
| 2503 |
var dataId = addedTermsandConds.length >= 1 ? addedTermsandCondsId.data("sourceId") + 1 : 1; |
| 2504 |
var colCount = addedTermsandConds.first().children().length - 1; |
| 2505 |
|
| 2506 |
var termsCondsMessageAttrName = this.newTermsCondsMessageAttrName( this.htmlNamePrefix + 'chart_source_data' , dataId ); |
| 2507 |
|
| 2508 |
content += '<div class = "'+this.htmlClassPrefix+'chart-source-data-edit-block" data-source-id="' + dataId + '" >'; |
| 2509 |
content += '<div class="'+this.htmlClassPrefix+'chart-source-data-move-block '+this.htmlClassPrefix+'chart-source-data-move-row">'; |
| 2510 |
content += '<svg xmlns="http://www.w3.org/2000/svg" height="1em" viewBox="0 0 512 512"><path d="M278.6 9.4c-12.5-12.5-32.8-12.5-45.3 0l-64 64c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l9.4-9.4V224H109.3l9.4-9.4c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-64 64c-12.5 12.5-12.5 32.8 0 45.3l64 64c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3l-9.4-9.4H224V402.7l-9.4-9.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l64 64c12.5 12.5 32.8 12.5 45.3 0l64-64c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-9.4 9.4V288H402.7l-9.4 9.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l64-64c12.5-12.5 12.5-32.8 0-45.3l-64-64c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l9.4 9.4H288V109.3l9.4 9.4c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3l-64-64z" style="fill: #b8b8b8;" /></svg>'; |
| 2511 |
content += '</div>'; |
| 2512 |
content += '<div class="'+this.htmlClassPrefix+'icons-box '+this.htmlClassPrefix+'icons-remove-box">'; |
| 2513 |
content += '<svg class="'+this.htmlClassPrefix+'chart-source-data-remove-block '+this.htmlClassPrefix+'chart-source-data-remove-row" data-trigger="hover" data-bs-toggle="tooltip" title="Delete row" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><path d="M310.6 150.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L160 210.7 54.6 105.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L114.7 256 9.4 361.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L160 301.3 265.4 406.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L205.3 256 310.6 150.6z" style="fill: #b8b8b8;" /></svg>'; |
| 2514 |
content += '</div>'; |
| 2515 |
for (var i = 0; i < colCount; i++) { |
| 2516 |
if (i == 0) { |
| 2517 |
content += '<div class="'+this.htmlClassPrefix+'chart-source-data-input-box '+this.htmlClassPrefix+'chart-source-data-name-input-box" data-cell-id="'+i+'">'; |
| 2518 |
content += '<input type="text" class="ays-text-input form-control" name="' + termsCondsMessageAttrName + '">'; |
| 2519 |
content += '</div>'; |
| 2520 |
} else { |
| 2521 |
content += '<div class="'+this.htmlClassPrefix+'chart-source-data-input-box '+this.htmlClassPrefix+'chart-source-data-input-number" data-cell-id="'+i+'">'; |
| 2522 |
content += '<input type="number" class="ays-text-input form-control" name="' + termsCondsMessageAttrName + '" step="any">'; |
| 2523 |
content += '</div>'; |
| 2524 |
} |
| 2525 |
} |
| 2526 |
content += '</div>'; |
| 2527 |
|
| 2528 |
this.$el.find('.'+this.htmlClassPrefix+'chart-source-data-content').append(content); |
| 2529 |
$('[data-bs-toggle="tooltip"]').tooltip(); |
| 2530 |
} |
| 2531 |
|
| 2532 |
ChartBuilderGoogleCharts.prototype.addChartDataColumn = function (e){ |
| 2533 |
var _this = this; |
| 2534 |
|
| 2535 |
var rows = _this.$el.find("."+_this.htmlClassPrefix+"chart-source-data-content").children(); |
| 2536 |
var lastColId = +$(rows[0]).find('.'+_this.htmlClassPrefix+'chart-source-data-input-box:last-child').attr('data-cell-id'); |
| 2537 |
rows.each(function(key, row){ |
| 2538 |
var dataIDEach = row.getAttribute('data-source-id'); |
| 2539 |
var content = ''; |
| 2540 |
|
| 2541 |
if (key === 0) { |
| 2542 |
content += '<div class="'+_this.htmlClassPrefix+'chart-source-data-input-box ' +_this.htmlClassPrefix+'chart-source-title-box" data-cell-id="'+(lastColId+1)+'">'; |
| 2543 |
content += '<svg class="'+_this.htmlClassPrefix+'chart-source-data-remove-block '+_this.htmlClassPrefix+'chart-source-data-remove-col" data-trigger="hover" data-bs-toggle="tooltip" title="Delete column" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512" width="10px">'; |
| 2544 |
content += '<path d="M310.6 150.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L160 210.7 54.6 105.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L114.7 256 9.4 361.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L160 301.3 265.4 406.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L205.3 256 310.6 150.6z" style="fill: #b8b8b8;" />'; |
| 2545 |
content += '</svg>'; |
| 2546 |
|
| 2547 |
content += '<div class="' + _this.htmlClassPrefix + 'chart-source-data-titles-box-item">'; |
| 2548 |
content += '<input type="text" class="ays-text-input form-control ' + _this.htmlClassPrefix+'chart-source-title-input" name="' + _this.newTermsCondsMessageAttrName( _this.htmlNamePrefix + 'chart_source_data' , dataIDEach ) + '">'; |
| 2549 |
content += '<svg class="' + _this.htmlClassPrefix + 'chart-source-data-sort" data-sort-order="asc" xmlns="http://www.w3.org/2000/svg" height="1em" viewBox="0 0 320 512">'; |
| 2550 |
content += '<path d="M137.4 41.4c12.5-12.5 32.8-12.5 45.3 0l128 128c9.2 9.2 11.9 22.9 6.9 34.9s-16.6 19.8-29.6 19.8H32c-12.9 0-24.6-7.8-29.6-19.8s-2.2-25.7 6.9-34.9l128-128zm0 429.3l-128-128c-9.2-9.2-11.9-22.9-6.9-34.9s16.6-19.8 29.6-19.8H288c12.9 0 24.6 7.8 29.6 19.8s2.2 25.7-6.9 34.9l-128 128c-12.5 12.5-32.8 12.5-45.3 0z" style="fill: #b8b8b8;" />'; |
| 2551 |
content += '</svg>'; |
| 2552 |
content += '</div>' |
| 2553 |
content += '</div>'; |
| 2554 |
} else { |
| 2555 |
content += '<div class="'+_this.htmlClassPrefix+'chart-source-data-input-box ' +_this.htmlClassPrefix+'chart-source-data-input-number" data-cell-id="'+(lastColId+1)+'">'; |
| 2556 |
content += '<input type="number" class="ays-text-input form-control" name="' + _this.newTermsCondsMessageAttrName( _this.htmlNamePrefix + 'chart_source_data' , dataIDEach ) + '" step="any">'; |
| 2557 |
content += '</div>'; |
| 2558 |
} |
| 2559 |
|
| 2560 |
$(row).append(content); |
| 2561 |
$('[data-bs-toggle="tooltip"]').tooltip(); |
| 2562 |
}); |
| 2563 |
} |
| 2564 |
|
| 2565 |
ChartBuilderGoogleCharts.prototype.deleteChartDataRow = function (element){ |
| 2566 |
var _this = this; |
| 2567 |
|
| 2568 |
var rows = _this.$el.find("."+_this.htmlClassPrefix+"chart-source-data-content").children(); |
| 2569 |
if ((rows.length - 1) >= 2) { |
| 2570 |
var confirm = window.confirm(aysChartBuilderAdmin.confirmRowDelete); |
| 2571 |
if (confirm) { |
| 2572 |
var thisMainParent = element.parent().parent(); |
| 2573 |
thisMainParent.remove(); |
| 2574 |
} |
| 2575 |
} else { |
| 2576 |
alert(aysChartBuilderAdmin.minRowNotice); |
| 2577 |
} |
| 2578 |
|
| 2579 |
element.blur(); |
| 2580 |
element.tooltip('hide'); |
| 2581 |
} |
| 2582 |
|
| 2583 |
ChartBuilderGoogleCharts.prototype.deleteChartDataColumn = function (element){ |
| 2584 |
var _this = this; |
| 2585 |
|
| 2586 |
var rows = _this.$el.find("."+_this.htmlClassPrefix+"chart-source-data-content").children(); |
| 2587 |
if (rows.eq(1).children('.ays-chart-chart-source-data-input-number').length >= 2) { |
| 2588 |
var confirm = window.confirm(aysChartBuilderAdmin.confirmColDelete); |
| 2589 |
if (confirm) { |
| 2590 |
var parent = element.parents('.ays-chart-chart-source-title-box'); |
| 2591 |
var index = _this.returnIndexOfEl(parent); |
| 2592 |
rows.each(function(key, row){ |
| 2593 |
var dataRow = $(row).find('.ays-chart-chart-source-data-input-box:not("ays-chart-chart-source-data-name-input-box")'); |
| 2594 |
$(dataRow).each(function(ind, cell){ |
| 2595 |
if (ind == index) { |
| 2596 |
$(cell).remove(); |
| 2597 |
} |
| 2598 |
}); |
| 2599 |
}); |
| 2600 |
} |
| 2601 |
} else { |
| 2602 |
alert(aysChartBuilderAdmin.minColNotice); |
| 2603 |
} |
| 2604 |
|
| 2605 |
element.blur(); |
| 2606 |
element.tooltip('hide'); |
| 2607 |
} |
| 2608 |
|
| 2609 |
ChartBuilderGoogleCharts.prototype.sortDataByColumn = function (el) { |
| 2610 |
var _this = this; |
| 2611 |
|
| 2612 |
var sortingOrder = el.attr('data-sort-order'); |
| 2613 |
var colFirst = el.parents('.'+_this.htmlClassPrefix+'chart-source-data-input-box'); |
| 2614 |
var colIndex = colFirst.attr('data-cell-id'); |
| 2615 |
var colList = colFirst.parents('.'+_this.htmlClassPrefix+'chart-source-data-content').find('.'+_this.htmlClassPrefix+'chart-source-data-input-box[data-cell-id="'+colIndex+'"] input.ays-text-input'); |
| 2616 |
|
| 2617 |
var sorted = {}; |
| 2618 |
colList.each(function(key, input){ |
| 2619 |
if (key !== 0) { |
| 2620 |
var rowIndex = $(input).parents('.'+_this.htmlClassPrefix+'chart-source-data-edit-block').attr('data-source-id'); |
| 2621 |
sorted[rowIndex] = +input.value |
| 2622 |
} |
| 2623 |
}); |
| 2624 |
|
| 2625 |
if (sortingOrder === 'asc') { |
| 2626 |
sorted = _this.sortDataAsc(sorted); |
| 2627 |
el.attr('data-sort-order', 'desc'); |
| 2628 |
} else if (sortingOrder === 'desc') { |
| 2629 |
sorted = _this.sortDataDesc(sorted); |
| 2630 |
el.attr('data-sort-order', 'asc'); |
| 2631 |
} else { |
| 2632 |
sorted = _this.sortDataAsc(sorted); |
| 2633 |
el.attr('data-sort-order', 'desc'); |
| 2634 |
} |
| 2635 |
|
| 2636 |
var container = _this.$el.find('.'+_this.htmlClassPrefix+'chart-source-data-content'); |
| 2637 |
var newContainer = []; |
| 2638 |
sorted.forEach((index, newIndex) => { |
| 2639 |
var row = container.find("."+_this.htmlClassPrefix+"chart-source-data-edit-block[data-source-id='"+index+"']"); |
| 2640 |
var inputs = row.find('input.ays-text-input'); |
| 2641 |
var inputName = _this.newTermsCondsMessageAttrName(_this.htmlNamePrefix + 'chart_source_data', newIndex + 1); |
| 2642 |
|
| 2643 |
$(inputs).each(function (inputIndex, input) { |
| 2644 |
input.setAttribute('name', inputName); |
| 2645 |
}); |
| 2646 |
|
| 2647 |
newContainer.push(row); |
| 2648 |
}); |
| 2649 |
sorted.forEach((index, newIndex) => { |
| 2650 |
var row = container.find("."+_this.htmlClassPrefix+"chart-source-data-edit-block[data-source-id='"+index+"']"); |
| 2651 |
newContainer.push(row); |
| 2652 |
}); |
| 2653 |
|
| 2654 |
container.innerHTML = ''; |
| 2655 |
newContainer.forEach(row => { |
| 2656 |
container.append(row); |
| 2657 |
}); |
| 2658 |
|
| 2659 |
var rows = container.find("."+_this.htmlClassPrefix+"chart-source-data-edit-block"); |
| 2660 |
for (var i = 0; i < rows.length; i++) { |
| 2661 |
$(rows[i]).attr('data-source-id', i); |
| 2662 |
} |
| 2663 |
} |
| 2664 |
|
| 2665 |
ChartBuilderGoogleCharts.prototype.sortDataAsc = function (data) { |
| 2666 |
return Object.keys(data).sort(function (a, b) {return data[a] - data[b]}); |
| 2667 |
} |
| 2668 |
|
| 2669 |
ChartBuilderGoogleCharts.prototype.sortDataDesc = function (data) { |
| 2670 |
return Object.keys(data).sort(function (a, b) {return data[b] - data[a]}); |
| 2671 |
} |
| 2672 |
|
| 2673 |
ChartBuilderGoogleCharts.prototype.returnIndexOfEl = function (element){ |
| 2674 |
var i = 0; |
| 2675 |
var elements = element.parent().find('.ays-chart-chart-source-title-box'); |
| 2676 |
elements.each(function(key, cell){ |
| 2677 |
if ($(cell).is(element)) { |
| 2678 |
i = key; |
| 2679 |
} |
| 2680 |
}); |
| 2681 |
return i; |
| 2682 |
} |
| 2683 |
|
| 2684 |
ChartBuilderGoogleCharts.prototype.configureOptions = function() { |
| 2685 |
var _this = this; |
| 2686 |
|
| 2687 |
_this.$el.find('.ays-chart-chart-source-title-box').eq(0).find('.ays-chart-chart-source-data-remove-block').css('visibility', 'hidden'); |
| 2688 |
|
| 2689 |
var removeCols = _this.$el.find('.ays-chart-chart-source-title-box').find('.ays-chart-chart-source-data-remove-block'); |
| 2690 |
if (_this.chartType === 'pie_chart') { |
| 2691 |
removeCols.css('visibility', 'hidden'); |
| 2692 |
} |
| 2693 |
|
| 2694 |
var options = _this.$el.find('.cb-changable-opt'); |
| 2695 |
var typeOptions = _this.$el.find('.cb-'+_this.chartType+'-opt'); |
| 2696 |
options.addClass('display_none'); |
| 2697 |
typeOptions.removeClass('display_none'); |
| 2698 |
|
| 2699 |
var manualTabs = _this.$el.find('.cb-changable-manual:not(.cb-'+_this.chartType+'-manual)'); |
| 2700 |
var typeManualTab = _this.$el.find('.cb-'+_this.chartType+'-manual'); |
| 2701 |
manualTabs.remove(); |
| 2702 |
typeManualTab.removeClass('display_none'); |
| 2703 |
|
| 2704 |
var tabs = _this.$el.find('.cb-changable-tab:not(.cb-'+_this.chartType+'-tab)').parents('fieldset.ays-accordion-options-container'); |
| 2705 |
var currentTabs = _this.$el.find('.cb-'+_this.chartType+'-tab').parents('fieldset.ays-accordion-options-container'); |
| 2706 |
tabs.addClass('display_none'); |
| 2707 |
currentTabs.removeClass('display_none'); |
| 2708 |
} |
| 2709 |
|
| 2710 |
ChartBuilderGoogleCharts.prototype.changeChartType = function () { |
| 2711 |
var _this = this; |
| 2712 |
|
| 2713 |
_this.$el.find('#'+_this.htmlClassPrefix+'option-chart-type').val(_this.chartType); |
| 2714 |
_this.$el.find('.'+_this.htmlClassPrefix+'type-info-box-text-changeable').text(_this.chartSources[_this.chartType]); |
| 2715 |
_this.$el.find('.'+_this.htmlClassPrefix+'nav-tab-chart.nav-tab[data-tab="tab4"]').text(_this.chartSourceData.chartTypesNames[_this.chartType]+" settings"); |
| 2716 |
_this.$el.find('.'+_this.htmlClassPrefix+'advanced-settings .ays-accordion-options-container:first-child legend.ays-accordion-options-header span').text(_this.chartSourceData.chartTypesNames[_this.chartType]+" settings"); |
| 2717 |
_this.$el.find('.'+_this.htmlClassPrefix+'charts-main-container').attr('id' , _this.htmlClassPrefix+_this.chartType); |
| 2718 |
|
| 2719 |
_this.configureOptions(); |
| 2720 |
_this.loadChartBySource(true); |
| 2721 |
} |
| 2722 |
|
| 2723 |
ChartBuilderGoogleCharts.prototype.newTermsCondsMessageAttrName = function (termCondName, termCondId){ |
| 2724 |
var _this = this; |
| 2725 |
return termCondName + '['+ termCondId +'][]'; |
| 2726 |
} |
| 2727 |
|
| 2728 |
ChartBuilderGoogleCharts.prototype.setAccordionEvents = function(e){ |
| 2729 |
var _this = this; |
| 2730 |
|
| 2731 |
_this.$el.on('click', '.ays-accordion-options-header', function(e){ |
| 2732 |
_this.openCloseAccordion(e, _this); |
| 2733 |
}); |
| 2734 |
|
| 2735 |
_this.$el.on('click', '.ays-slices-accordion-options-header', function(e){ |
| 2736 |
_this.openCloseAccordion(e, _this, '-slices'); |
| 2737 |
}); |
| 2738 |
|
| 2739 |
_this.$el.on('click', '.ays-series-accordion-options-header', function(e){ |
| 2740 |
_this.openCloseAccordion(e, _this, '-series'); |
| 2741 |
}); |
| 2742 |
|
| 2743 |
_this.$el.on('click', '.ays-rows-accordion-options-header', function(e){ |
| 2744 |
_this.openCloseAccordion(e, _this, '-rows'); |
| 2745 |
}); |
| 2746 |
} |
| 2747 |
|
| 2748 |
ChartBuilderGoogleCharts.prototype.openCloseAccordion = function(e, _this, contType = ""){ |
| 2749 |
var container = $(e.target).parents('.ays' + contType + '-accordion-options-container'); |
| 2750 |
var parent = (contType != "") ? container.parents('.ays-chart' + contType + '-settings') : _this.$el.find('#' + container.parents('.ays-tab-content').attr('id') + ' .ays-accordions-container').eq(0); |
| 2751 |
var index = (contType != "") ? container.index() : -1; |
| 2752 |
|
| 2753 |
if( container.attr('data-collapsed') === 'true' ){ |
| 2754 |
_this.closeAllAccordions( parent, contType, index ); |
| 2755 |
setTimeout(() => { |
| 2756 |
container.find('.ays' + contType + '-accordion-options-content').slideDown(); |
| 2757 |
container.attr('data-collapsed', 'false'); |
| 2758 |
container.find('.ays' + contType + '-accordion-options-header .ays' + contType + '-accordion-arrow').find('path').css('fill', '#008cff'); |
| 2759 |
container.find('.ays' + contType + '-accordion-options-header .ays' + contType + '-accordion-arrow').removeClass('ays' + contType + '-accordion-arrow-right').addClass('ays' + contType + '-accordion-arrow-down'); |
| 2760 |
}, 150); |
| 2761 |
}else{ |
| 2762 |
setTimeout(() => { |
| 2763 |
container.find('.ays' + contType + '-accordion-options-content').slideUp(); |
| 2764 |
container.attr('data-collapsed', 'true'); |
| 2765 |
container.find('.ays' + contType + '-accordion-options-header .ays' + contType + '-accordion-arrow').find('path').css('fill', '#c4c4c4'); |
| 2766 |
container.find('.ays' + contType + '-accordion-options-header .ays' + contType + '-accordion-arrow').removeClass('ays' + contType + '-accordion-arrow-down').addClass('ays' + contType + '-accordion-arrow-right'); |
| 2767 |
}, 150); |
| 2768 |
} |
| 2769 |
} |
| 2770 |
|
| 2771 |
ChartBuilderGoogleCharts.prototype.closeAllAccordions = function( container, contType, index ){ |
| 2772 |
var _this = this; |
| 2773 |
|
| 2774 |
container.find('.ays' + contType + '-accordion-options-container').each(function (i){ |
| 2775 |
var $this = $(this); |
| 2776 |
if (i != index) { |
| 2777 |
setTimeout(() => { |
| 2778 |
$this.find('.ays' + contType + '-accordion-options-content').slideUp(); |
| 2779 |
$this.attr('data-collapsed', 'true'); |
| 2780 |
$this.find('.ays' + contType + '-accordion-options-header .ays' + contType + '-accordion-arrow').find('path').css('fill', '#c4c4c4'); |
| 2781 |
$this.find('.ays' + contType + '-accordion-options-header .ays' + contType + '-accordion-arrow').removeClass('ays' + contType + '-accordion-arrow-down').addClass('ays' + contType + '-accordion-arrow-right'); |
| 2782 |
}, 150); |
| 2783 |
} |
| 2784 |
}); |
| 2785 |
} |
| 2786 |
|
| 2787 |
ChartBuilderGoogleCharts.prototype.initDbImportComponent = function(){ |
| 2788 |
var _this = this; |
| 2789 |
var table_columns = window.aysChartBuilderChartSettings.db_query.tables; |
| 2790 |
var code_mirror = wp.CodeMirror || CodeMirror; |
| 2791 |
var cm = code_mirror.fromTextArea(_this.$el.find('.ays-chart-db-query').get(0), { |
| 2792 |
value: _this.$el.find('.ays-chart-db-query').val(), |
| 2793 |
autofocus: false, |
| 2794 |
mode: 'text/x-mysql', |
| 2795 |
lineWrapping: true, |
| 2796 |
dragDrop: false, |
| 2797 |
matchBrackets: true, |
| 2798 |
autoCloseBrackets: true, |
| 2799 |
extraKeys: {"Ctrl-Space": "autocomplete"}, |
| 2800 |
hintOptions: { tables: table_columns } |
| 2801 |
}); |
| 2802 |
cm = code_mirror.fromTextArea(_this.$el.find('.ays-chart-external-db-query').get(0), { |
| 2803 |
value: _this.$el.find('.ays-chart-external-db-query').val(), |
| 2804 |
autofocus: false, |
| 2805 |
mode: 'text/x-mysql', |
| 2806 |
lineWrapping: true, |
| 2807 |
dragDrop: false, |
| 2808 |
matchBrackets: true, |
| 2809 |
autoCloseBrackets: true, |
| 2810 |
extraKeys: {"Ctrl-Space": "autocomplete"} |
| 2811 |
}); |
| 2812 |
|
| 2813 |
|
| 2814 |
// force refresh so that the query shows on first time load. Otherwise you have to click on the editor for it to show. |
| 2815 |
_this.$el.on('ays-chart:db:query:focus', function(event, data){ |
| 2816 |
cm.refresh(); |
| 2817 |
}); |
| 2818 |
|
| 2819 |
// cm.focus(); |
| 2820 |
|
| 2821 |
// update text area. |
| 2822 |
cm.on('inputRead', function(x, y){ |
| 2823 |
cm.save(); |
| 2824 |
}); |
| 2825 |
|
| 2826 |
// backspace and delete do not register so the text box does not get empty if the entire query is deleted |
| 2827 |
// from the editor. Let's force this. |
| 2828 |
_this.$el.on('ays-chart:db:query:update', function(event, data){ |
| 2829 |
cm.save(); |
| 2830 |
}); |
| 2831 |
|
| 2832 |
// clear the editor. |
| 2833 |
_this.$el.on('ays-chart:db:query:setvalue', function(event, data){ |
| 2834 |
cm.setValue(data.value); |
| 2835 |
cm.clearHistory(); |
| 2836 |
cm.refresh(); |
| 2837 |
}); |
| 2838 |
|
| 2839 |
// set an option at runtime? |
| 2840 |
_this.$el.on('ays-chart:db:query:changeoption', function(event, data){ |
| 2841 |
cm.setOption(data.name, data.value); |
| 2842 |
}); |
| 2843 |
} |
| 2844 |
|
| 2845 |
ChartBuilderGoogleCharts.prototype.initDbImport = function(){ |
| 2846 |
var _this = this; |
| 2847 |
_this.initDbImportComponent(); |
| 2848 |
} |
| 2849 |
|
| 2850 |
ChartBuilderGoogleCharts.prototype.initQuizDBImport = function(){ |
| 2851 |
var _this = this; |
| 2852 |
|
| 2853 |
_this.$el.find('#ays-chart-quiz-maker-fetch').on('click', function(e){ |
| 2854 |
e.preventDefault(); |
| 2855 |
|
| 2856 |
var select_query = $(document).find('#'+_this.htmlClassPrefix+'select-quiz-maker-data-query').val(); |
| 2857 |
if (select_query == "") { |
| 2858 |
return; |
| 2859 |
} |
| 2860 |
|
| 2861 |
_this.fetchQuizData( true ); |
| 2862 |
}); |
| 2863 |
|
| 2864 |
_this.$el.find('#ays-chart-quiz-maker-show-on-chart').on( 'click', function(e){ |
| 2865 |
e.preventDefault(); |
| 2866 |
|
| 2867 |
var select_query = $(document).find('#'+_this.htmlClassPrefix+'select-quiz-maker-data-query').val(); |
| 2868 |
if (select_query == "") { |
| 2869 |
return; |
| 2870 |
} |
| 2871 |
|
| 2872 |
if( _this.chartTempData ){ |
| 2873 |
_this.$el.find('#ays-chart-quiz-maker-success').empty(); |
| 2874 |
_this.$el.find('#ays-chart-quiz-maker-error').empty(); |
| 2875 |
if (_this.chartType == 'line_chart' || _this.chartType == 'bar_chart' || _this.chartType == 'column_chart') { |
| 2876 |
_this.chartTempData = _this.multiColumnChartConvertData( _this.chartTempData ); |
| 2877 |
} else if (_this.chartType == 'org_chart') { |
| 2878 |
_this.chartTempData = _this.orgChartConvertData( _this.chartTempData ); |
| 2879 |
} else { |
| 2880 |
_this.chartTempData = _this.chartConvertData( _this.chartTempData ); |
| 2881 |
} |
| 2882 |
_this.chartData = window.google.visualization.arrayToDataTable( _this.chartTempData ); |
| 2883 |
|
| 2884 |
_this.updateChartData( _this.chartData ); |
| 2885 |
|
| 2886 |
_this.chartTempData = null; |
| 2887 |
}else{ |
| 2888 |
_this.fetchQuizData( false, true ); |
| 2889 |
} |
| 2890 |
|
| 2891 |
}); |
| 2892 |
|
| 2893 |
_this.$el.find('#ays-chart-quiz-maker-save').on( 'click', function(e){ |
| 2894 |
e.preventDefault(); |
| 2895 |
|
| 2896 |
var select_query = $(document).find('#'+_this.htmlClassPrefix+'select-quiz-maker-data-query').val(); |
| 2897 |
if (select_query == "") { |
| 2898 |
return; |
| 2899 |
} |
| 2900 |
|
| 2901 |
_this.$el.find('#ays-chart-quiz-maker-success').empty(); |
| 2902 |
_this.$el.find('#ays-chart-quiz-maker-error').empty(); |
| 2903 |
|
| 2904 |
var chart_id = $(document).find('.' + _this.htmlClassPrefix + 'chart-id').val(); |
| 2905 |
var query = $(document).find('#'+_this.htmlClassPrefix+'select-quiz-maker-data-query').find('option:selected').val(); |
| 2906 |
var selectQuizSelectDisplay = $(document).find('.'+_this.htmlClassPrefix+'select-quiz-maker-quiz-container').css('display'); |
| 2907 |
var quizID = null; |
| 2908 |
if (selectQuizSelectDisplay != 'none') { |
| 2909 |
quizID = $(document).find('#'+_this.htmlClassPrefix+'select-quiz-maker-quiz').find('option:selected').val(); |
| 2910 |
if (quizID == 0) { |
| 2911 |
_this.$el.find('#ays-chart-quiz-maker-error').html( 'Please select a quiz.' ); |
| 2912 |
return; |
| 2913 |
} |
| 2914 |
} |
| 2915 |
|
| 2916 |
// submit only if a query has been provided. |
| 2917 |
if( query.length > 0 ){ |
| 2918 |
_this.startAjax( _this.$el.find('#ays-chart-quiz-maker-form') ); |
| 2919 |
|
| 2920 |
$.ajax({ |
| 2921 |
url: ajaxurl, |
| 2922 |
method: 'post', |
| 2923 |
dataType: 'json', |
| 2924 |
data: { |
| 2925 |
'action': _this.ajaxAction, |
| 2926 |
'function': window.aysChartBuilderChartSettings.ajax['actions']['quiz_maker_save_data'], |
| 2927 |
'security': window.aysChartBuilderChartSettings.ajax['nonces']['quiz_maker_save_data'], |
| 2928 |
'params': { |
| 2929 |
query: query, |
| 2930 |
quizID: quizID, |
| 2931 |
chart_id: chart_id, |
| 2932 |
} |
| 2933 |
}, |
| 2934 |
success: function( response ){ |
| 2935 |
if( response.success ){ |
| 2936 |
_this.$el.find('#ays-chart-quiz-maker-success').html( response.data.msg ); |
| 2937 |
_this.$el.find('input[name="' + _this.htmlNamePrefix + 'source_type"]').val('quiz_maker'); |
| 2938 |
}else{ |
| 2939 |
_this.$el.find('#ays-chart-quiz-maker-error').html( response.data.msg ); |
| 2940 |
_this.$el.find('input[name="' + _this.htmlNamePrefix + 'source_type"]').val('manual'); |
| 2941 |
} |
| 2942 |
}, |
| 2943 |
complete: function(){ |
| 2944 |
_this.endAjax( _this.$el.find('#ays-chart-quiz-maker-form') ); |
| 2945 |
} |
| 2946 |
}); |
| 2947 |
}else{ |
| 2948 |
_this.$el.find('#ays-chart-quiz-maker-form').unlock(); |
| 2949 |
_this.$el.find('input[name="' + _this.htmlNamePrefix + 'source_type"]').val('manual'); |
| 2950 |
} |
| 2951 |
}); |
| 2952 |
|
| 2953 |
$(document).on('ays-chart:modal:close', function (){ |
| 2954 |
_this.chartTempData = null; |
| 2955 |
}); |
| 2956 |
} |
| 2957 |
|
| 2958 |
ChartBuilderGoogleCharts.prototype.fetchQuizData = function( openModal = false, showOnChart = false ){ |
| 2959 |
var _this = this; |
| 2960 |
_this.$el.trigger('ays-chart:db:query:update', {}); |
| 2961 |
|
| 2962 |
var chart_id = $(document).find('.' + _this.htmlClassPrefix + 'chart-id').val(); |
| 2963 |
var query = $(document).find('#'+_this.htmlClassPrefix+'select-quiz-maker-data-query').find('option:selected').val(); |
| 2964 |
var selectQuizSelectDisplay = $(document).find('.'+_this.htmlClassPrefix+'select-quiz-maker-quiz-container').css('display'); |
| 2965 |
var quizID = null; |
| 2966 |
if (selectQuizSelectDisplay != 'none') { |
| 2967 |
quizID = $(document).find('#'+_this.htmlClassPrefix+'select-quiz-maker-quiz').find('option:selected').val(); |
| 2968 |
if (quizID == 0) { |
| 2969 |
_this.$el.find('#ays-chart-quiz-maker-error').html( 'Please select a quiz.' ); |
| 2970 |
return; |
| 2971 |
} |
| 2972 |
} |
| 2973 |
|
| 2974 |
if (query.length == 0) { |
| 2975 |
return; |
| 2976 |
} |
| 2977 |
|
| 2978 |
_this.startAjax( _this.$el.find('#ays-chart-quiz-maker-form') ); |
| 2979 |
|
| 2980 |
var modal = $(document).find('#ays-chart-db-query-results'); |
| 2981 |
|
| 2982 |
_this.$el.find('.db-wizard-results').empty(); |
| 2983 |
_this.$el.find('#ays-chart-quiz-maker-success').empty(); |
| 2984 |
_this.$el.find('#ays-chart-quiz-maker-error').empty(); |
| 2985 |
|
| 2986 |
$.ajax({ |
| 2987 |
url: ajaxurl, |
| 2988 |
method: 'post', |
| 2989 |
dataType: 'json', |
| 2990 |
data: { |
| 2991 |
'action': _this.ajaxAction, |
| 2992 |
'function': window.aysChartBuilderChartSettings.ajax['actions']['quiz_maker_get_data'], |
| 2993 |
'security': window.aysChartBuilderChartSettings.ajax['nonces']['quiz_maker_get_data'], |
| 2994 |
'params': { |
| 2995 |
query: query, |
| 2996 |
quizID: quizID, |
| 2997 |
chart_id: chart_id, |
| 2998 |
} |
| 2999 |
}, |
| 3000 |
success: function( response ){ |
| 3001 |
if( response.success ){ |
| 3002 |
modal.find('.db-wizard-results').html( response.data.table ); |
| 3003 |
modal.find('#results').DataTable({ |
| 3004 |
"paging": true |
| 3005 |
}); |
| 3006 |
modal.find('#results').parent().addClass('ays-db-results-wrap'); |
| 3007 |
|
| 3008 |
if( openModal === true ) { |
| 3009 |
modal.aysModal('show'); |
| 3010 |
} |
| 3011 |
|
| 3012 |
_this.chartTempData = response.data.data ? response.data.data : null; |
| 3013 |
|
| 3014 |
if( showOnChart === true ) { |
| 3015 |
if (_this.chartType == 'line_chart' || _this.chartType == 'bar_chart' || _this.chartType == 'column_chart') { |
| 3016 |
_this.chartTempData = _this.multiColumnChartConvertData( _this.chartTempData ); |
| 3017 |
} else if (_this.chartType == 'org_chart') { |
| 3018 |
_this.chartTempData = _this.orgChartConvertData( _this.chartTempData ); |
| 3019 |
} else { |
| 3020 |
_this.chartTempData = _this.chartConvertData( _this.chartTempData ); |
| 3021 |
} |
| 3022 |
_this.chartData = window.google.visualization.arrayToDataTable(_this.chartTempData); |
| 3023 |
|
| 3024 |
_this.updateChartData(_this.chartData); |
| 3025 |
|
| 3026 |
_this.chartTempData = null; |
| 3027 |
} |
| 3028 |
}else{ |
| 3029 |
modal.find('ays-close').trigger('click'); |
| 3030 |
_this.$el.find('#ays-chart-quiz-maker-error').html( response.data.msg ); |
| 3031 |
_this.$el.find('input[name="' + _this.htmlNamePrefix + 'source_type"]').val('manual'); |
| 3032 |
} |
| 3033 |
}, |
| 3034 |
complete: function(){ |
| 3035 |
_this.endAjax( _this.$el.find('#ays-chart-quiz-maker-form') ); |
| 3036 |
} |
| 3037 |
}); |
| 3038 |
} |
| 3039 |
|
| 3040 |
ChartBuilderGoogleCharts.prototype.startAjax = function( element ){ |
| 3041 |
element.lock(); |
| 3042 |
} |
| 3043 |
|
| 3044 |
ChartBuilderGoogleCharts.prototype.endAjax = function( element ){ |
| 3045 |
element.unlock(); |
| 3046 |
} |
| 3047 |
|
| 3048 |
ChartBuilderGoogleCharts.prototype.quickSaveHotKeys = function() { |
| 3049 |
$(document).on('keydown', function(e){ |
| 3050 |
var saveButton = $(document).find('input#ays-button-apply'); |
| 3051 |
if ( saveButton.length > 0 ) { |
| 3052 |
if (!(e.which == 83 && e.ctrlKey) && !(e.which == 19)){ |
| 3053 |
return true; |
| 3054 |
} |
| 3055 |
saveButton.trigger("click"); |
| 3056 |
e.preventDefault(); |
| 3057 |
return false; |
| 3058 |
} |
| 3059 |
}); |
| 3060 |
} |
| 3061 |
|
| 3062 |
// Manual data preview button |
| 3063 |
ChartBuilderGoogleCharts.prototype.showOnChart = function () { |
| 3064 |
var _this = this; |
| 3065 |
|
| 3066 |
var lastId = $(document).find(".ays-chart-chart-source-data-edit-block:last-child").attr('data-source-id'); |
| 3067 |
var chartData = []; |
| 3068 |
|
| 3069 |
var rowTitles = $(document).find('.ays-chart-chart-source-data-name-input-box'); |
| 3070 |
rowTitles.each(function(key, el) { |
| 3071 |
var value = $(el).find('input').val(); |
| 3072 |
if ( value == '' ) { |
| 3073 |
$(el).find('input').val('Option'); |
| 3074 |
} |
| 3075 |
}); |
| 3076 |
|
| 3077 |
var form = $(document).find("#ays-charts-form-google-charts"); |
| 3078 |
var data = form.serializeFormJSON(); |
| 3079 |
|
| 3080 |
for (var i = 0; i <= lastId; i++) { |
| 3081 |
if (data['ays_chart_source_data['+i+'][]'] !== undefined) { |
| 3082 |
var dataRow = data['ays_chart_source_data['+i+'][]']; |
| 3083 |
var filteredRow = []; |
| 3084 |
for (var key = 0; key < dataRow.length; key++) { |
| 3085 |
var value = dataRow[key]; |
| 3086 |
if (value != '') { |
| 3087 |
filteredRow.push(value); |
| 3088 |
} else { |
| 3089 |
if (i == 0) { |
| 3090 |
filteredRow.push('Title'+key); |
| 3091 |
} else { |
| 3092 |
filteredRow.push('0'); |
| 3093 |
} |
| 3094 |
} |
| 3095 |
} |
| 3096 |
if (filteredRow.length != 0) { |
| 3097 |
chartData.push(filteredRow); |
| 3098 |
} |
| 3099 |
} |
| 3100 |
} |
| 3101 |
if (_this.chartType == 'line_chart' || _this.chartType == 'bar_chart' || _this.chartType == 'column_chart') { |
| 3102 |
_this.chartTempData = _this.multiColumnChartConvertData( chartData ); |
| 3103 |
} else { |
| 3104 |
_this.chartTempData = _this.chartConvertData( chartData ); |
| 3105 |
} |
| 3106 |
|
| 3107 |
_this.chartTempData = _this.chartSourceData.settings.enableRowSettings ? _this.setRowOptions(_this.chartTempData, _this.chartSourceData.settings, false) : _this.chartTempData; |
| 3108 |
|
| 3109 |
_this.chartData = window.google.visualization.arrayToDataTable( _this.chartTempData ); |
| 3110 |
|
| 3111 |
_this.updateChartData( _this.chartData ); |
| 3112 |
|
| 3113 |
_this.chartTempData = null; |
| 3114 |
} |
| 3115 |
|
| 3116 |
ChartBuilderGoogleCharts.prototype.orgTypeShowOnChart = function () { |
| 3117 |
var _this = this; |
| 3118 |
|
| 3119 |
var form = _this.$el.find("#ays-charts-form-google-charts"); |
| 3120 |
var data = form.serializeFormJSON(); |
| 3121 |
var allBranches = _this.$el.find(".tree-branch"); |
| 3122 |
var treeManual = _this.$el.find("#ays-chart-chart-source-data-edit-tree-content"); |
| 3123 |
|
| 3124 |
var chartData = {}; |
| 3125 |
allBranches.each(function() { |
| 3126 |
var branchId = $(this).attr("data-id") |
| 3127 |
var changedName = $(this).find(".ays-chart-org-chart-name-" + branchId).val(); |
| 3128 |
var changedDescription = $(this).find(".ays-chart-org-chart-description-" + branchId).val(); |
| 3129 |
var changedImage = $(this).find(".ays-chart-org-chart-image-" + branchId).val(); |
| 3130 |
var changedParentName = $(this).find(".ays-chart-org-chart-parent-name").val(); |
| 3131 |
var changedTooltip = $(this).find(".ays-chart-org-chart-tooltip-" + branchId).val(); |
| 3132 |
var changedUrl = $(this).find(".ays-chart-org-chart-url-" + branchId).val(); |
| 3133 |
var changedParentId = $(this).find(".ays-chart-org-chart-parent").val(); |
| 3134 |
|
| 3135 |
var changedLevel = $(this).find(".ays-chart-org-chart-level").val(); |
| 3136 |
|
| 3137 |
chartData[branchId] = [changedName, changedDescription, changedImage, changedParentName, changedTooltip, changedUrl, changedParentId, changedLevel] |
| 3138 |
}) |
| 3139 |
|
| 3140 |
_this.chartData = _this.orgChartConvertData( chartData ); |
| 3141 |
_this.chartTempData = _this.chartData; |
| 3142 |
_this.chartData = window.google.visualization.arrayToDataTable( _this.chartData ); |
| 3143 |
_this.updateChartData( _this.chartData ); |
| 3144 |
chartData = null; |
| 3145 |
} |
| 3146 |
|
| 3147 |
ChartBuilderGoogleCharts.prototype.htmlDecode = function (input) { |
| 3148 |
if (!input) return input; |
| 3149 |
|
| 3150 |
var e = document.createElement('div'); |
| 3151 |
e.innerHTML = input; |
| 3152 |
return e.childNodes[0].nodeValue; |
| 3153 |
} |
| 3154 |
|
| 3155 |
ChartBuilderGoogleCharts.prototype.drawChartFunction = function (source, options) { |
| 3156 |
var _this = this; |
| 3157 |
|
| 3158 |
var view = new google.visualization.DataView(source); |
| 3159 |
_this.chartData = source; |
| 3160 |
|
| 3161 |
if (_this.chartType == 'org_chart') { |
| 3162 |
view.setColumns([0, 1, 2]); |
| 3163 |
} |
| 3164 |
|
| 3165 |
_this.chartObj.draw(view, options); |
| 3166 |
|
| 3167 |
if (_this.chartType == 'org_chart') { |
| 3168 |
_this.setOrgChartCustomStyles(); |
| 3169 |
} |
| 3170 |
} |
| 3171 |
|
| 3172 |
$.fn.ChartBuilderGoogleChartsMain = function(options) { |
| 3173 |
return this.each(function() { |
| 3174 |
if (!$.data(this, 'ChartBuilderGoogleChartsMain')) { |
| 3175 |
$.data(this, 'ChartBuilderGoogleChartsMain', new ChartBuilderGoogleCharts(this, options)); |
| 3176 |
} else { |
| 3177 |
try { |
| 3178 |
$(this).data('ChartBuilderGoogleChartsMain').init(); |
| 3179 |
} catch (err) { |
| 3180 |
console.error('ChartBuilderGoogleChartsMain has not initiated properly'); |
| 3181 |
} |
| 3182 |
} |
| 3183 |
}); |
| 3184 |
}; |
| 3185 |
$(document).find('#ays-charts-form-google-charts').ChartBuilderGoogleChartsMain(); |
| 3186 |
|
| 3187 |
})(jQuery); |
| 3188 |
|
| 3189 |
(function ($) { |
| 3190 |
|
| 3191 |
$.fn.serializeFormJSON = function () { |
| 3192 |
let o = {}, |
| 3193 |
a = this.serializeArray(); |
| 3194 |
$.each(a, function () { |
| 3195 |
if (o[this.name]) { |
| 3196 |
if (!o[this.name].push) { |
| 3197 |
o[this.name] = [o[this.name]]; |
| 3198 |
} |
| 3199 |
o[this.name].push(this.value || ''); |
| 3200 |
} else { |
| 3201 |
o[this.name] = this.value || ''; |
| 3202 |
} |
| 3203 |
}); |
| 3204 |
return o; |
| 3205 |
}; |
| 3206 |
|
| 3207 |
$.fn.lock = function () { |
| 3208 |
$(this).each(function () { |
| 3209 |
var $this = $(this); |
| 3210 |
var position = $this.css('position'); |
| 3211 |
|
| 3212 |
if (!position) { |
| 3213 |
position = 'static'; |
| 3214 |
} |
| 3215 |
|
| 3216 |
switch (position) { |
| 3217 |
case 'absolute': |
| 3218 |
case 'relative': |
| 3219 |
break; |
| 3220 |
default: |
| 3221 |
$this.css('position', 'relative'); |
| 3222 |
break; |
| 3223 |
} |
| 3224 |
$this.data('position', position); |
| 3225 |
|
| 3226 |
var width = $this.width(), |
| 3227 |
height = $this.height(); |
| 3228 |
|
| 3229 |
var locker = $('<div class="locker"></div>'); |
| 3230 |
locker.width(width).height(height); |
| 3231 |
|
| 3232 |
var loader = $('<div class="locker-loader"></div>'); |
| 3233 |
loader.width(width).height(height); |
| 3234 |
|
| 3235 |
locker.append(loader); |
| 3236 |
$this.append(locker); |
| 3237 |
$(window).resize(function () { |
| 3238 |
$this.find('.locker,.locker-loader').width($this.width()).height($this.height()); |
| 3239 |
}); |
| 3240 |
}); |
| 3241 |
|
| 3242 |
return $(this); |
| 3243 |
}; |
| 3244 |
|
| 3245 |
$.fn.unlock = function () { |
| 3246 |
$(this).each(function () { |
| 3247 |
$(this).find('.locker').remove(); |
| 3248 |
$(this).css('position', $(this).data('position')); |
| 3249 |
}); |
| 3250 |
|
| 3251 |
return $(this); |
| 3252 |
}; |
| 3253 |
})(jQuery); |