https://www.abcwua.org/wp-content/plugins/wp-table-manager/app/site/assets/js/dropchart.js?ver=4.2.2
1function wptm_drawChart() { 2 var defaultConfig = { "dataUsing": "row", 3 "switchDataUsing": true, 4 "useFirstRowAsGraph": true, 5 "useFirstRowAsLabels": false, 6 "width": 500, "height": 375, 7 "scaleShowGridLines": false 8 }; 9 10 function formatSymbols(resultCalc, decimal_count, thousand_symbols, decimal_symbols, symbol_position, value_unit) { 11 decimal_count = parseInt(decimal_count); 12 if (typeof resultCalc === 'undefined') { 13 return; 14 } 15 var negative = resultCalc < 0 ? "-" : "", 16 i = parseInt(resultCalc = Math.abs(+resultCalc || 0).toFixed(decimal_count), 10) + "", 17 j = (j = i.length) > 3 ? j % 3 : 0; 18 19 resultCalc = (j ? i.substr(0, j) + thousand_symbols : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thousand_symbols) + (decimal_count ? decimal_symbols + Math.abs(resultCalc - i).toFixed(decimal_count).slice(2) : ""); 20 21 resultCalc = Number(symbol_position) === 0 22 ? ((negative === "-") ? negative + value_unit : value_unit) + resultCalc 23 : negative + resultCalc + ' ' + value_unit; 24 25 return resultCalc; 26 }; 27 28 if (typeof DropCharts === "undefined") { 29 var DropCharts = typeof window.DropCharts !== "undefined" ? window.DropCharts : []; 30 } 31 32 jQuery(".chartContainer.wptm").each(function () { 33 var id_chart = jQuery(this).data('id-chart'); 34 35 var DropCharts1 = DropCharts.filter(element => typeof element !== 'undefined' && element.id == id_chart); 36 37 if (jQuery(this).find('canvas').length > 0 && typeof DropCharts1 !== 'undefined') { 38 if (!jQuery(this).hasClass('chartActive') 39 && (jQuery(".vc_editor").length < 1 40 || (jQuery(".vc_editor").length > 0 && typeof jQuery(this).parents('.vc_wptm_chart_shortcode').data('model-id') !== 'undefined') 41 )//fix re_render in divi and elementor(add later) 42 ) { 43 let $canvas = jQuery(this).find('canvas') 44 let randomId = $canvas.data('random_id') 45 46 var DropChart 47 if (!randomId) { 48 DropChart = DropCharts1[DropCharts1.length - 1] 49 } else { 50 let DropCharts2 = DropCharts1.filter(element => typeof element !== 'undefined' && element.random_id == randomId) 51 DropChart = DropCharts2[0] 52 } 53 54 if (!DropChart || DropChart.length < 1) { 55 return false; 56 } 57 58 DropCharts1 = DropCharts1.map(function (chart) { 59 if (typeof chart.chart !== 'undefined' && typeof chart.random_id !== 'undefined') { 60 if (jQuery('.canvasWraper').find('canvas[data-random_id="' + chart.random_id + '"]').length < 1) { 61 chart.chart.destroy(); 62 } else { 63 return chart 64 } 65 } else { 66 return chart 67 } 68 }) 69 70 console.log(DropCharts, DropChart.config) 71 72 DropChart.config.plugins = {}; 73 DropChart.config.plugins.tooltip = { 74 enabled: true, callbacks: { 75 label: function (tooltipItems) { 76 var labelTitle = ''; 77 var label = ''; 78 var data = tooltipItems.chart.config._config.data; 79 var type = tooltipItems.chart.config._config.type; 80 var useFirstRowAsGraph = tooltipItems.chart.config._config?.options?.useFirstRowAsGraph || false; 81 if (data.useFirstRowAsLabels) { 82 switch (type) { 83 case 'polarArea': 84 labelTitle += data.labels[tooltipItems.dataIndex]; 85 if (!useFirstRowAsGraph) { 86 label += data.datasets[tooltipItems.datasetIndex].label 87 } 88 if (label) { 89 label += ': '; 90 } 91 break; 92 case 'pie': 93 case 'doughnut': 94 if (tooltipItems.label !== '') { 95 labelTitle += tooltipItems.label; 96 } else { 97 labelTitle += data.labels[tooltipItems.dataIndex]; 98 } 99 if (!useFirstRowAsGraph) { 100 label += data.datasets[tooltipItems.datasetIndex].label 101 } 102 if (label) { 103 label += ': '; 104 } 105 break; 106 case 'bar': 107 case 'radar': 108 case 'line': 109 default: 110 if (!useFirstRowAsGraph) { 111 if (data.datasets.length > 1) { 112 label = data.datasets[tooltipItems.datasetIndex].label || ''; 113 } 114 if (label) { 115 label += ': '; 116 } 117 } 118 break; 119 } 120 } 121 122 if (tooltipItems.raw !== 0) { 123 if (typeof tooltipItems.dataset.dataForTooltip !== 'undefined' && typeof tooltipItems.dataset.dataForTooltip[tooltipItems.dataIndex] !== 'undefined') { 124 label += tooltipItems.dataset.dataForTooltip[tooltipItems.dataIndex]; 125 } else { 126 label += tooltipItems.dataset.data[tooltipItems.dataIndex]; 127 } 128 } else { 129 label += '0' 130 } 131 return labelTitle !== '' ? [labelTitle, label] : label; 132 } 133 } 134 }; 135 136 var chartConfig = jQuery.extend({},defaultConfig, DropChart.config); 137 chartConfig.scaleBeginAtZero = false;
138 chartConfig.responsive = false; 139 //set labels for axes 140 DropChart.data.useFirstRowAsLabels = chartConfig.useFirstRowAsLabels; 141 if (typeof chartConfig.scales !== 'undefined') { 142 delete chartConfig.scales; 143 } 144 145 let scales = null 146 if (chartConfig.stepSize && chartConfig.stepSize > 0) 147 scales = {ticks: {stepSize: chartConfig.stepSize}} 148 149 if (chartConfig.minY && chartConfig.minY >= 0) 150 scales = scales !== null ? {...scales, ...{min: parseFloat(chartConfig.minY)}} : {min: parseFloat(chartConfig.minY)} 151 152 if (chartConfig.legend_display === false) 153 chartConfig.plugins.legend = {display: false} 154 155 let responsive = jQuery(this).find('canvas').data('responsive') 156 let aspectRatio = jQuery(this).find('canvas').data('aspect_ratio') 157 if (responsive === 1) { 158 chartConfig.responsive = true 159 chartConfig.aspectRatio = aspectRatio 160 } 161 162 var ctx = $canvas.get(0).getContext("2d"); 163 164 switch (DropChart.type) { 165 case 'PolarArea': 166 DropChart.chart = new wptmChart(ctx, { 167 type: 'polarArea', 168 data: DropChart.data, 169 options: chartConfig 170 }); 171 break; 172 case 'Pie': 173 DropChart.chart = new wptmChart(ctx, { 174 type: 'pie', 175 data: DropChart.data, 176 options: chartConfig 177 }); 178 break; 179 case 'Doughnut': 180 DropChart.chart = new wptmChart(ctx, { 181 type: 'doughnut', 182 data: DropChart.data, 183 options: chartConfig 184 }); 185 break; 186 case 'Bar': 187 if (scales !== null) { 188 chartConfig.scales = {y: scales} 189 chartConfig.scales.y.afterBuildTicks = function(axis) { 190 if (scales.ticks?.stepSize > 0 && axis.ticks[1].value - axis.ticks[0].value < axis.ticks[2].value - axis.ticks[1].value) { 191 axis.ticks = axis.ticks.map(function (tick) { 192 let newStep = tick.value 193 if (axis.start < tick.value) { 194 let newStep1 = Math.floor((tick.value - axis.start)/ scales.ticks.stepSize) 195 newStep = axis.start + (newStep1 + 1) * scales.ticks.stepSize 196 } 197 tick.value = newStep 198 return tick 199 }); 200 } 201 } 202 } 203 DropChart.chart = new wptmChart(ctx, { 204 type: 'bar', 205 data: DropChart.data, 206 options: chartConfig 207 }); 208 break; 209 case 'Radar': 210 DropChart.chart = new wptmChart(ctx, { 211 type: 'radar', 212 data: DropChart.data, 213 options: chartConfig 214 }); 215 break; 216 case 'Line': 217 default: 218 219 if (scales !== null) { 220 chartConfig.scales = {y: scales} 221 chartConfig.scales.y.afterBuildTicks = function(axis) { 222 if (scales.ticks?.stepSize > 0 && axis.ticks[1].value - axis.ticks[0].value < axis.ticks[2].value - axis.ticks[1].value) { 223 axis.ticks = axis.ticks.map(function (tick) { 224 let newStep = tick.value 225 if (axis.start < tick.value) { 226 let newStep1 = Math.floor((tick.value - axis.start)/ scales.ticks.stepSize) 227 newStep = axis.start + (newStep1 + 1) * scales.ticks.stepSize 228 } 229 tick.value = newStep 230 return tick 231 }); 232 } 233 } 234 } 235 chartConfig.cubicInterpolationMode = 'default'; 236 chartConfig.tension = 0.3; 237 DropChart.chart = new wptmChart(ctx, { 238 type: 'line', 239 data: DropChart.data, 240 options: chartConfig 241 }); 242 break; 243 } 244 jQuery(this).addClass('chartActive'); 245 } 246 } 247 }); 248} 249 250jQuery(document).ready(function(){ 251 if (typeof DropCharts !== 'undefined') { 252 wptm_drawChart(); 253 } 254}); 255 256function wptm_render_chart (id_table) { 257 // if (!jQuery('div#chartContainer' + id_table).hasClass('chartActive')) { 258 wptm_drawChart(); 259 // } 260};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.