PageSourceSearch

https://ed-data.org/Scripts/eddata/profile/chart.js?v=yi6mgkpOB9Rp2Jil4wAkbr5so2Rr82n2wMo4XCCagso

js ed-data.org collected 2026-09-24 21:12:08 UTC 38,681 bytes, 739 lines download raw bytes

1var eddata;
2(function (eddata) {
3    let chartErrorType;
4    (function (chartErrorType) {
5        chartErrorType[chartErrorType["NETWORK"] = 0] = "NETWORK";
6        chartErrorType[chartErrorType["NO_VALID_DATA"] = 1] = "NO_VALID_DATA";
7        chartErrorType[chartErrorType["PROCESSING"] = 2] = "PROCESSING";
8    })(chartErrorType = eddata.chartErrorType || (eddata.chartErrorType = {}));
9    class chartData {
10        constructor(_labels, _datasets, _totalNumbers) {
11            this.labels = _labels;
12            this.datasets = _datasets;
13            this.totalNumbers = _totalNumbers;
14        }
15    }
16    class chartDataset {
17        constructor(_label, _color) {
18            this.label = _label;
19            this.color = _color;
20            this.data = new Array();
21        }
22        addDataPoint(_dataPoint) {
23            this.data.push(_dataPoint);
24        }
25    }
26    class chart {
27        constructor(config) {
28            this.sharingSnapshotSelector = "#temp-sharing-holding-chart";
29            this.colors = ["58,74,95", "200,123,55", "191,103,138", "88,112,52", "88,113,149", "239,165,67", "114,147,67", "125,172,203", "173,79,37", "151,187,99", "149,71,101", "239,155,188", "172,48,60", "197,84,95", "252,147,160"];
30            this.config = config;
31            this.packeryContainerId = config.packeryContainerId;
32            this.isShowingDataView = false;
33            chart.windowWidth = window.innerWidth;
34            chart.windowHeight = window.innerHeight;
35            this.load();
36        }
37        load(typeToLoad, callBack) {
38            var isReplacingChart = false;
39            this.drillinFilter = this.chartSecondDrillIn == undefined ? "" : this.chartSecondDrillIn.val();
40            var sharableFilter = $("#temp-sharing-holding-chart").attr("data-second-drillinfilter");
41            if (this.config.isForShareableLayout && sharableFilter !== "")
42                this.drillinFilter = sharableFilter;
43            if (typeToLoad) {
44                if (this.config.type !== typeToLoad) {
45                    isReplacingChart = true;
46                    this.drillinFilter = "";
47                }
48                else if (this.drillinFilter !== "")
49                    isReplacingChart = true;
50            }
51            if (isReplacingChart) {
52                if (!this.containerDiv) {
53                    if (this.config.error && typeof this.config.error === 'function')
54                        this.config.error(chartErrorType.PROCESSING, "Error - Cannot flip a chart if the primary chart was never loaded!");
55                    return;
56                }
57                this.config.type = typeToLoad;
58            }
59            var needsTabsScript = true;
60            if ($(".state-info").attr("data-state-config")) {
61                this.stateConfig = $.parseJSON($(".state-info").attr("data-state-config"));
62                if (this.stateConfig.ChartType == this.config.type) {
63                    this.drillinFilter = this.stateConfig.DrillInFilter;
64                }
65            }
66            var cds = eddata_entityCds;
67            if ((this.packeryContainerId == "#packeryContainer-4-18" || this.packeryContainerId == "#packeryContainer-5-19" || this.packeryContainerId == "#packeryContainer-5-20") && eddata_entityType === "State") {
68                cds = "00-11111-0000000";
69            }
70            $.ajax({
71                url: '/Chart/Generate/' + cds + '/' + this.config.yearStart + '/' + this.config.yearEnd + '/' + this.config.type,
72                cache: true,
73                type: 'GET',
74                data: {
75                    drillinfilter: this.drillinFilter
76                },
77                contentType: 'application/html; charset=utf-8',
78                dataType: "html",
79                timeout: 15000,
80                success: (data) => {
81                    this.containerDiv = $(data);
82                    if (this.chartContainerId == undefined)
83                        this.chartContainerId = "#" + this.containerDiv[0].id;
84                    this.initialDataTableDiv = this.containerDiv.find(".table-div").html();
85                    this.kind = this.containerDiv.attr("data-kind");
86                    this.scaleHeaders = JSON.parse(this.containerDiv.attr("data-scale-header"));
87                    this.scaleHeaderToUse = this.scaleHeaders[0];
88                    this.scaleStartsFromZero = this.containerDiv.attr("data-scale-starts-from-zero") === 'true';
89                    this.optionsLabel = this.containerDiv.find(".subchart-options-select").attr("data-options-label");
90                    this.scaleOverride = this.containerDiv.attr("data-scale-override") ? $.parseJSON(this.containerDiv.attr("data-scale-override")) : null;
91                    this.showChartWithNoData = this.containerDiv.attr("data-show-chart-with-nodata") ? this.containerDiv.attr("data-show-chart-with-nodata") === 'true' : false;
92                    if (!this.parseChartData()) {
93                        $(this.packeryContainerId).trigger('invalidatedItem', [this.config.type]);
94                        $(this.packeryContainerId).trigger('addedItem', []);
95                        var msg = "No valid data was found for chart type '" + this.config.type + "'. Chart won't be displayed";
96                        console.log(msg);
97                        if (this.config.error && typeof this.config.error === 'function')
98                            this.config.error(chartErrorType.NO_VALID_DATA, msg);
99                        return false;
100                    }
101                    if (this.config.isForShareableLayout) {
102                        this.config.created(this);
103                        return;
104                    }
105                    this.name = $(this.containerDiv).find('.chartContent h1').text().trim();
106                    this.notes = $(this.containerDiv).find('.chart-notes').text().trim();
107                    this.chartMultiSelect = $(this.containerDiv).find('.subchart-options-select');
108                    this.chartSecondDrillIn = $(this.containerDiv).find('.subchart-options-seconddrillin');
109                    if ($(this.containerDiv).find('.chart-entity-name').text().trim() == "")
110                        $(this.containerDiv).find('.chart-entity-name').html(eddata_entityName);
111                    if (eddata_entityCds === "00-00000-0000000")
112                        $(this.containerDiv).find('.chartContent h3').hide();
113                    if ($(".state-info").attr("data-state-config")) {
114                        this.stateConfig = $.parseJSON($(".state-info").attr("data-state-config"));
115                        if (this.isDrillInOf(this.stateConfig.ChartType) || this.stateConfig.ChartType == this.config.type) {
116                            if (this.stateConfig.ChartType != this.config.type) {
117                                this.load(this.stateConfig.ChartType);
118                            }
119                            this.isShowingDataView = this.stateConfig.IsDataTableVisible;
120                            if (this.stateConfig.DataYear.toString() != this.config.yearEnd)
121                                $.notify("Note that the ending period being displayed is not what was originally shared", "warn");
122                            if (this.stateConfig.ChartType == this.config.type)
123                                $(".state-info").detach();
124                        }
125                        else
126                            this.stateConfig = undefined;
127                    }
128                    var uiClik = true;
129                    this.chartMultiSelect.multiselect({
130                        selectedText: this.optionsLabel ? this.optionsLabel : "Select options",
131                        noneSelectedText: this.optionsLabel ? this.optionsLabel : "Select options",
132                        uncheckAll: () => {
133                            this.refreshChart();
134                        },
135                        checkAll: () => {
136                            this.refreshChart();
137                        },
138                        click: (event, ui) => {
139                            if (uiClik) {
140                                this.refreshChart(ui.value, () => {
141                                    $(this.packeryContainerId).trigger('changedChartView', this.containerDiv);
142                                });
143                            }
144                        },
145                        open: (event, ui) => {
146                            $('.ui-multiselect-checkboxes label').eq(0).removeClass('ui-state-hover');
147                        },
148                        create: () => {
149                            if (this.stateConfig) {
150                                var views = [];
151                                this.chartMultiSelect.find('optgroup[label="View"] option').each((idx, el) => {
152                                    views.push($(el).text());
153                                });
154                                uiClik = false;
155                                this.chartMultiSelect.multiselect("widget").find(":checkbox").parent().find('span').each((idx, el) => {
156                                    if ($.inArray($(el).text(), this.stateConfig.SelectedFilters) < 0 && $.inArray($(el).text(), views) < 0) {
157                                        $(el).parent().find("input").click();
158                                    }
159                                });
160                                this.hideLegendsForUnselectedOptions();
161                                uiClik = true;
162                            }
163                            $(".ui-widget li.view-option").filter((idx, el) => { return $(el).text() == this.containerDiv.find(".chartContent header h1").text(); }).addClass("selected");
164                        },
165                        header: this.chartMultiSelect.find('option').length > 1,
166                        height: "auto",
167                        minWidth: this.containerDiv.find(".switch-candy").length >
167 0 && this.containerDiv.find(".chart-image-wide").length == 0 ? 185 : 225,
168                        position: ({
169                            my: "left top",
170                            at: "left bottom",
171                            collision: 'flipfit',
172                            within: window
173                        })
174                    });
175                    this.chartMultiSelect.multiselect("checkAll");
176                    this.chartSecondDrillIn.change((el) => {
177                        this.chartSecondDrillIn = $(el.target);
178                        var filterOptions = this.getSelectedOptions();
179                        this.load(this.config.type, () => this.selectoptionsSecondDrillIn(filterOptions));
180                    });
181                    $(this.containerDiv).find('.menu label').click((el) => {
182                        $(el.target).parent().tooltip("hide");
183                        this.containerDiv.find('.chart-data').toggle();
184                        this.isShowingDataView = !this.isShowingDataView;
185                        this.handleDatatable();
186                        this.containerDiv.resize();
187                    });
188                    if (this.containerDiv.find('.chart-data-row td 
188span.hidden').toArray().every((val) => {
189                        return $(val).text().trim() == "N/A";
190                    }))
191                        this.containerDiv.find(".switch-candy").hide();
192                    else {
193                        var showingSinglePctLine;
194                        this.containerDiv.find(".view-toggle-action").click((ev) => {
195                            this.containerDiv.find(".view-toggle").toggleClass("hidden");
196                            this.containerDiv.find(".switch-candy span>span").toggleClass("sw-off");
197                            if (this.parseChartData(false)) {
198                                this.scaleHeaderToUse = (this.scaleHeaderToUse == this.scaleHeaders[0])
199                                    ? this.scaleHeaders[1]
200                                    : this.scaleHeaders[0];
201                                this.render(this.getChartJSDefinition(), this.getSelectedOptions());
202                                this.deselectStateIfCount();
203                            }
204                            this.config.SelectedView = (this.scaleHeaderToUse.indexOf("Percent") >= 0) ? "Percent" : "Count";
205                            if (showingSinglePctLine) {
206                                this.containerDiv.find(".chart-data .chart-data-row").addClass("hidden");
207                                showingSinglePctLine = false;
208                            }
209                            if (this.containerDiv.find(".chart-data .chart-data-row").hasClass("hidden") && this.containerDiv.find(".chart-data tfoot").hasClass("hidden") && !showingSinglePctLine) {
210                                this.containerDiv.find(".chart-data .chart-data-row").removeClass("hidden");
211                                showingSinglePctLine = true;
212                            }
213                            this.adjustNotesHeightIfExpandedView();
214                        });
215                    }
216                    $(window).resize(() => {
217                        if (window.innerHeight !== chart.windowHeight || window.innerWidth !== chart.windowWidth) {
218                            chart.windowWidth = window.innerWidth;
219                            chart.windowHeight = window.innerHeight;
220                            this.handleDatatable();
221                        }
222                    });
223                    if (isReplacingChart) {
224                        $(this.chartContainerId).empty();
225                        this.containerDiv.children().each((idx, el) => {
226                            $(el).appendTo($(this.chartContainerId));
227                        });
228                        this.containerDiv = $(this.chartContainerId);
229                        setTimeout(() => {
230                            $(this.containerDiv).trigger("adjustCanvasHeight");
231                        }, 100);
232                    }
233                    else {
234                        if ($("#temp-canvas-holding").length > 0)
235                            $("#temp-canvas-holding").append(this.containerDiv);
236                        else
237                            $("#temp-sharing-holding-chart").append(this.containerDiv);
238                        $(this.packeryContainerId).trigger('addedItem', [this.containerDiv[0]]);
239                    }
240                    eddata.glossary.Factory.rebindElementLinks(this.containerDiv);
241                    this.containerDiv.find("[data-toggle='tooltip']").tooltip();
242                    this.handleDatatable(true);
243                    this.applyReadMore();
244                    this.render(this.getChartJSDefinition(), this.get
244SelectedOptions());
245                    this.deselectStateIfCount();
246                    if (this.containerDiv.find(".togglemenu").length > 0)
247                        this.containerDiv.find(".chart-tab-content").css("max-width", (this.containerDiv.find(".chart-canvas").css("width") + 12));
248                    this.adjustNotesHeightIfExpandedView();
249                    if (this.isShowingDataView)
250                        this.containerDiv.find('.chart-data').show();
251                    else
252                        this.containerDiv.find('.chart-data').hide();
253                    if (eddata.share) {
254                        new eddata.share(this);
255                    }
256                    this.containerDiv.resize(() => {
257                        $(this.packeryContainerId).trigger('changedItem', [this.containerDiv[0]]);
258                    });
259                    this.containerDiv.on('adjustCanvasHeight', (e) => {
260                        var buffer = this.containerDiv.innerHeight() - this.containerDiv.find(".chart-image").innerHeight();
261                        if (buffer > 0) {
262                            var canvasSize = parseInt(this.containerDiv.find(".chart-canvas").attr("height"), 10);
263                            this.containerDiv.find(".chart-canvas").attr("height", (canvasSize + buffer));
264                            this.refreshChart();
265                        }
266                    });
267                    if (this.drillinFilter == undefined || this.drillinFilter == "") {
268                        this.chartSecondDrillIn.prop("selectedIndex", 0);
269                    }
270                    else {
271                        this.chartSecondDrillIn.val(this.drillinFilter);
272                    }
273                    if (this.config.created && typeof this.config.created === 'function')
274                        this.config.created(this);
275                    if (typeof callBack === 'function')
276                        callBack();
277                },
278                error: (xhr, status, error) => {
279                    $(this.packeryContainerId).trigger('invalidatedItem', [this.config.type]);
280                    $(this.packeryContainerId).trigger('addedItem', []);
281                    if (this.config.error && typeof this.config.error === 'function')
282                        this.config.error(chartErrorType.NETWORK, status);
283                    eddata.errorManager.notifyAndLog({ eventOrMessage: xhr.status + " " + error, source: "chart.js", location: "load()" });
284                    $.notify("Sorry, there was a problem!");
285                }
286            }).done(() => {
287                var offSwitch = this.containerDiv.find(".sw-off").html();
288                if (this.stateConfig && this.stateConfig.SelectedView === "Percent" && offSwitch === "%") {
289                    this.containerDiv.find(".view-toggle-action").click();
290                }
291                else if (this.stateConfig && this.stateConfig.SelectedView === "Count" && offSwitch === "#") {
292                    this.containerDiv.find(".view-toggle-action").click();
293                }
294            });
295            if (this.packeryContainerId == "#packeryContainer-5-20" && eddata_entityType === "State") {
296                eddata_entityCds = "00-00000-0000000";
297            }
298        }
299        deselectStateIfCount() {
300            this.chartMultiSelect.multiselect("widget").find(":checkbox").parent().find('span').each((idx, el) => {
301                if ($(el).text() == "State") {
302                    if ($(el).parent().find("input:checked").length > 0) {
303                        if (this.containerDiv.find(".switch-candy span>span").not(".sw-off").text() == "#") {
304                            $(el).parent().find("input").click();
305                            this.hideLegendsForUnselectedOptions();
306                        }
307                    }
308                    else {
309                        if (this.containerDiv.find(".switch-candy span>span").not(".sw-off").text() == "%") {
310                            $(el).parent().find("input").click();
311                            this.hideLegendsForUnselectedOptions();
312                        }
313                    }
314                }
315            });
316        }
317        adjustNotesHeightIfExpandedView() {
318            if (this.containerDiv.find(".togglemenu").length == 0) {
319                var notesHeight = this.containerDiv.find(".chartBorder").height() - this.containerDiv.find(".chart
319-data").height() - 30;
320                this.containerDiv.find(".chart-tab-content").css("min-height", notesHeight);
321            }
322        }
323        isDrillInOf(chartType) {
324            var is = false;
325            this.containerDiv.find(".subchart-options-select option").each(function () {
326                var value = $(this).val();
327                if (value == chartType) {
328                    is = true;
329                    return false;
330                }
331            });
332            return is != false;
333        }
334        applyReadMore() {
335            let self = this;
336            this.containerDiv.find("footer .chart-notes").css("transition", "height 85ms");
337            this.containerDiv.find("footer .chart-notes").readmore({
338                collapsedHeight: 75,
339                moreLink: '<a href="#"> Read More <a>',
340                blockCSS: 'overflow:hidden',
341                afterToggle: function () {
342                    self.containerDiv.resize();
343                }
344            });
345            this.containerDiv.find("footer .nav-link:eq(0)").click(() => {
346                setTimeout(() => {
347                    this.containerDiv.find("footer .chart-notes").readmore({
348                        collapsedHeight: 80,
349                        moreLink: '<a href="#"> Read More <a>',
350                        blockCSS: 'overflow:hidden',
351                        afterToggle: function () {
352                            self.containerDiv.resize();
353                        }
354                    });
355                }, 0);
356            });
357            this.containerDiv.find("footer .nav-link:eq(1)").click(() => {
358                this.containerDiv.find("footer .chart-notes").readmore("destroy");
359                self.containerDiv.resize();
360            });
361        }
362        handleDatatable(isInitializing) {
363        }
364        getChartJSDefinition() {
365            var randomColor = function () { return Math.round(Math.random() * 300).toString() + "," + Math.round(Math.random() * 300).toString() + "," + Math.round(Math.random() * 300).toString(); };
366            var chartDatasets = [];
367            var colorIdx = 0;
368            this.data.datasets.forEach((ds) => {
369                if (ds == null)
370                    return null;
371                var counts = [];
372                ds.data.forEach((d) => {
373                    counts.push(d);
374                });
375                var colorToUse;
376                if (colorIdx >= this.colors.length) {
377                    colorToUse = randomColor();
378                    this.colors.push(colorToUse);
379                }
380                else {
381                    colorToUse = ds.color || this.colors[colorIdx];
382                }
383                var datasetItem = {
384                    label: ds.label,
385                    backgroundColor: "rgba(" + colorToUse + ",1)",
386                    borderColor: "rgba(" + colorToUse + ",1)",
387                    fillColor: "rgba(" + colorToUse + ",1)",
388                    fill: false,
389                    lineTension: 0,
390                    data: counts
391                };
392                chartDatasets.push(datasetItem);
393                colorIdx++;
394            });
395            if (this.data.labels.length == 1)
396                this.data.labels.push("");
397            return {
398                labels: this.data.labels,
399                datasets: (this.kind == "0") ? chartDatasets.reverse() : chartDatasets,
400                responsive: true,
401                legendTemplate: "<ul class=\"<%=name%>-legend\"><% for (var i=0; i<datasets.length; i++){%><li style=\"background-color:<%=datasets[i].fillColor%>\"><span ></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>",
402                multiTooltipTemplate: "<%= datasetLabel %>: <%= value %>"
403            };
404        }
405        refreshChart(selectedOption, callBack) {
406            if (selectedOption && selectedOption !== this.config.type && selectedOption.lastIndexOf("opt-", 0) !== 0) {
407                this.load(selectedOption, callBack);
408            }
409            else {
410                this.hideLegendsForUnselectedOptions();
411                this.render(this.getChartJSDefinition(), this.get
411SelectedOptions());
412            }
413        }
414        hideLegendsForUnselectedOptions() {
415            var selOptions = this.getSelectedOptions();
416            this.containerDiv.find(".legend li").css("display", "inline-block");
417            if (selOptions.length > 0) {
418                this.containerDiv.find(".legend li").each((idx, el) => {
419                    if ($.inArray($(el).text().trim(), selOptions) < 0)
420                        $(el).css("display", "none");
421                });
422            }
423        }
424        getSelectedOptions() {
425            var selectedDs = [];
426            if (this.chartMultiSelect && this.chartMultiSelect.multiselect) {
427                var selItems = this.chartMultiSelect.multiselect("getChecked");
428                for (var i = 0; i < selItems.length; i++) {
429                    if (selItems[i].value.lastIndexOf("opt-", 0) === 0) {
430                        selectedDs.push($(this.containerDiv).find('.subchart-options-select option[value="' + selItems[i].value + '"]').text());
431                    }
432                }
433            }
434            else {
435                var filters = $("[data-filters]").attr("data-filters");
436                if (filters.length > 0)
437                    selectedDs = $.parseJSON($("[data-filters]").attr("data-filters"));
438            }
439            return selectedDs;
440        }
441        selectoptionsSecondDrillIn(filterChartOptions) {
442            var views = [];
443            this.chartMultiSelect.find('optgroup[label="View"] option').each((idx, el) => {
444                views.push($(el).text());
445            });
446            this.chartMultiSelect.multiselect("widget").find(":checkbox").parent().find('span').each((idx, el) => {
447                if ($.inArray($(el).text(), filterChartOptions) < 0 && $.inArray($(el).text(), views) < 0) {
448                    $(el).parent().find("input").click();
449                }
450            });
451        }
452        render(chartJSData, selectedDataSets, paramCanvas) {
453            var canvas = paramCanvas == undefined ? ($(this.containerDiv).find('.chart-canvas')[0]) : paramCanvas;
454            var ctx = canvas.getContext("2d");
455            var chartDs = [];
456            if (selectedDataSets && selectedDataSets.length > 0) {
457                chartJSData.datasets.forEach((ds) => {
458                    if (selectedDataSets.indexOf(ds.label) > -1) {
459                        chartDs.push(ds);
460                    }
461                });
462            }
463            else {
464                chartDs = chartJSData.datasets;
465            }
466            if (this.canvasChart && !paramCanvas)
467                this.canvasChart.destroy();
468            var chartData = {
469                labels: chartJSData.labels,
470                datasets: chartDs,
471            };
472            var reverseLegend = (this.kind == "0") ? true : false;
473            var chartOption = {
474                plugins: { legend: false },
475                legendCallback: function (chart) {
476                    var text = [];
477                    text.push('<ul class="legend">');
478                    if (reverseLegend) {
479                        for (var i = chart.data.datasets.length - 1; i >= 0; i--) {
480                            text.push('<li style="display: inline-block;" data-index="' + i + '">');
481                            text.push('<span style="width:0%;" class="legendbar"></span>');
482                            text.push('<h5 class="li-legend">');
483                            text.push('<i class="icon-align-justify" style="background-color:' + chart.data.datasets[i].borderColor + '"></i>');
484                            text.push(chart.data.datasets[i].label);
485                            text.push('</h5>');
486                            text.push('</li>');
487                        }
488                    }
489                    else {
490                        for (var i = 0; i < chart.data.datasets.length; i++) {
491                            text.push('<li style="display: inline-block;" data-index="' + i + '">');
492                            text.push('<span style="width:0%;" class="legendbar"></span>');
493                            text.push('<h5 class="li-legend">');
494                            text.push('<i class="icon-align-justify" style="background-color:' + chart.data.datasets[i].borderColor + '"></i>');
495                            text.push(chart.data.datasets[i].label);
496                            text.push('</h5>');
497                            text.push('</li>');
498                        }
499                    }
500                    text.push('</ul>');
501                    return text.join("");
502                },
503                tooltips: {
504                    mode: 'point',
505                },
506                animation: {
507                    duration: 0
508                },
509                scales: {
510                    x: {
511                        stacked: false,
512                        grid: {
513                            display: true,
514                            drawOnChartArea: true,
515                            drawTicks: true,
516                        },
517                        ticks: {
518                            fontSize: 16,
519                            fontColor: '#000000'
520                        }
521                    },
522                    y: {
523                        stacked: false,
524                        grid: {
525                            display: true,
526                            drawOnChartArea: true,
527                            drawTicks: true,
528                        },
529                        position: "left",
530                        beginAtZero: this.scaleStartsFromZero,
531                        title: {
532                            display: true,
533                            fontSize: 16,
534                            padding: 2,
535                            fontColor: '#000000',
536                            text: this.scaleHeaderToUse ? this.scaleHeaderToUse : undefined,
537                        },
538                        ticks: {
539                            fontSize: 16,
540                            fontColor: '#000000',
541                            stepSize: this.scaleOverride ? this.scaleOverride.StepIncrement : null,
542                            suggestedMin: this.scaleOverride ? this.scaleOverride.StartingValue : null,
543                            callback: function (value, index, values) {
544                                return value.toLocaleString();
545                            }
546                        }
547                    }
548                }
549            };
550            switch (this.kind) {
551                case "0":
552                    chartOption.scales.x.stacked = true;
553                    chartOption.scales.y.stacked = true;
554                    break;
555                case "1":
556                    break;
557                case "2":
558                    break;
559            }
560            Chart.defaults.font.size = 16;
561            var canvasChart = new Chart(ctx, {
562                type: (this.kind == "1") ? 'line' : 'bar',
563                data: chartData,
564                options: chartOption
565            });
566            var chartLegendCtrl = ($(this.containerDiv).find('.chart-legend')[0]);
567            if ($(chartLegendCtrl).length) {
568            }
569            if (!paramCanvas) {
570                this.canvasChart = canvasChart;
571                this.colorLegends(this.containerDiv, chartDs);
572            }
573            else {
574                if (this.config.isForShareableLayout)
575                    this.colorLegends($("body"), chartDs);
576                else
577                    eddata.share.shareChartJSObject = canvasChart;
578            }
579        }
580        colorLegends(container, chartDs) {
581            container.find('.legend h5').each((idx, el) => {
582                for (var idx2 = 0; idx2 < chartDs.length; idx2++) {
583                    if ($(el).text().trim() == chartDs[idx2].label.trim()) {
584                        $(el).find("i").css("background-color", chartDs[idx2].backgroundColor);
585                        break;
586                    }
587                }
588            });
589        }
590        parseChartData(parseHiddenTable) {
591            var _datasets = [];
592            var _labels = [];
593            var _totals = [];
594            this.containerDiv.find('.chart-data-header th').each((idx, el) => {
595                var label = $(el).text().trim();
596                if ($(el).attr("data-tag") !== "label") {
597                    _labels.push(label);
598                }
599            });
600            var ds;
601            var grandTotalMinus1 = -1;
602            this.containerDiv.find('.chart-data-row td').each((idx, el) => {
603                var _data = "";
604                if ($(el).find("span").length > 0)
605                    if (parseHiddenTable) {
606                        if ($(el).find("span.hidden").length > 0)
607                            _data = $(el).find("span.hidden").text().trim();
608                        else
609                            _data = "N/A";
610                    }
611                    else
612                        _data = $(el).find("span").not(".hidden").text().trim();
613                else
614                    _data = $(el).text().trim();
615                if ($(el).attr("data-tag") === "label") {
616                    if (ds) {
617                        _datasets.push(ds);
618                    }
619                    ds = new chartDataset(_data, $(el).attr("data-color"));
620                }
621                else {
622                    if (_data != "N/A")
623                        grandTotalMinus1 = 0;
624                    var numData = _data.replace(/,/g, '').replace(/%/g, '');
625                    ds.addDataPoint(numData);
626                    if (this.isNumeric(numData))
627                        grandTotalMinus1 += parseInt(numData);
628                }
629            });
630            _datasets.push(ds);
631            this.containerDiv.find('.chart-data-total td').each((idx, el) => {
632                var total = $(el).text().trim().replace(/,/g, '');
633                if (this.isNumeric(total.replace(/,/g, '')))
634                    _totals.push(parseInt(total.replace(/,/g, '')));
635                else if (total.toLowerCase() !== "total")
636                    _totals.push(total);
637            });
638            if (grandTotalMinus1 < 0)
639                if (parseHiddenTable == null) {
640                    return this.parseChartData(true);
641                }
642                else if (!this.showChartWithNoData)
643                    return false;
644            this.data = new chartData(_labels, _datasets, _totals);
645            return true;
646        }
647        refresh(scaleHeader) {
648            if (scaleHeader)
649                this.scaleHeaderToUse = scaleHeader;
650            this.refreshChart();
651        }
652        getChartJSCanvas() {
653            return this.canvasChart;
654        }
655        doesContainStateInfo() {
656            return this.stateConfig != undefined;
657        }
658        isNumeric(n) {
659            return !isNaN(parseFloat(n)) && isFinite(n);
660        }
661        getStateConfig() {
662            return {
663                ChartType: this.config.type,
664                IsDataTableVisible: this.isShowingDataView,
665                SelectedFilters: this.getSelectedOptions(),
666                DataYear: parseInt(this.config.yearEnd),
667                SectionNbr: this.config.sectionNbr,
668                DrillInFilter: this.drillinFilter,
669                SelectedView: this.config.SelectedView,
670                IsAltSectionView: this.config.sectionNbr == eddata.SectionType.FINANCE_ALL_REV_AND_EXP ||
671                    this.config.sectionNbr == eddata.SectionType.FINANCE_GENERAL_FUND_EXP ||
672                    this.config.sectionNbr == eddata.SectionType.FINANCE_GENERAL_FUND_REV
673            };
674        }
675        getTypeForChart() {
676            return this.config.type;
677        }
678        preSharingProcessing() {
679            var tempCanvasSelector = this.sharingSnapshotSelector + " .chart-canvas2";
680            var buffer = $(this.sharingSnapshotSelector).find(".info-box-inner").innerHeight() - $(this.sharingSnapshotSelector).find(".info-box-inner div:first").innerHeight();
681            var canvas = ($(this.sharingSnapshotSelector + " .chart-canvas2")[0]);
682            canvas.height = Math.max((150 + buffer), 300);
683            $(this.sharingSnapshotSelector).outerWidth($(this.sharingSnapshotSelector).outerHeight() * 1.91);
684            canvas.width = $(this.sharingSnapshotSelector).find(".chart-canvas2").parent().width();
685            if (this.config.SelectedView == "Percent") {
686                this.parseChartData(true);
687                this.scaleHeaderToUse = this.scaleHeaders[1].includes("Percent") ? this.scaleHeaders[1] : this.scaleHeaders[0];
688            }
689            else if (this.config.SelectedView == "Count") {
690                this.parseChartData(true);
691                this.scaleHeaderToUse = this.scaleHeaders[1].includes("Number") ? this.scaleHeaders[1] : this.scaleHeaders[0];
692            }
693            this.render(this.getChartJSDefinition(), this.getSelectedOptions(), ($(tempCanvasSelector)[0]));
694        }
695        getDiv() {
696            return this.containerDiv;
697        }
698        getDataAsCSV() {
699            var lines = "";
700            var _labels = this.data.labels;
701            var sep = "|";
702            this.data.datasets.forEach((ds) => {
703                if (lines != "")
704                    lines += '\r\n';
705                var line = "";
706                line += ds.label;
707                ds.data.forEach((d) => {
708                    line += sep + d;
709                });
710                lines += line;
711            });
712            lines += '\r\n';
713            if (this.data.datasets.length == 1 && this.data.totalNumbers.length > 0)
714                lines = "";
715            var result = sep + _labels.join(sep) + '\r\n' + lines;
716            if (this.data.totalNumbers.length > 0)
717                result += "Total " + this.name + sep + this.data.totalNumbers.join(sep);
718            return { worksheets: [{ data: result }], separator: sep };
719        }
720        getShareDescriptionImage() {
721            return this.containerDiv.find(".share-class").attr("data-share-description-image");
722        }
723        getShareDescription() {
724            return this.containerDiv.find(".share-class").attr("data-share-description");
725        }
726        getItemName() {
727            return this.name;
728        }
729        getEntityName() {
730            return this.containerDiv.find(".chart-entity-name").text().trim();
731        }
732        getItemLegendAsJquery() {
733            if (this.containerDiv.find(".chart-legend").length)
734                return this.containerDiv.find(".legend").clone();
735        }
736    }
737    eddata.chart = chart;
738})(eddata || (eddata = {}));
739//# sourceMappingURL=chart.js.map

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.