<commit_before>/*global define, amplify, console*/
define([
        'jquery',
        'underscore',
        'fx-c-c/config/creators/highcharts_template',
        //'highcharts-export',
        //'highcharts-export-csv',
        'amplify'
    ],
    function ($, _, baseConfig) {

        'use strict';

        var defaultOptions = {

                s: {
                    CONTENT: '[data-role="content"]'
                },

                // TODO: handle multilanguage?
                noData: "<div>No data available</div>"

            };

        function HightchartCreator(config) {

            this.o = $.extend(true, {}, defaultOptions, config);

            this.o.hightchart_template = baseConfig;

            return this;
        }

        HightchartCreator.prototype._validateInput = function () {

            this.o.errors = {};

            //Container
            if (!this.o.hasOwnProperty("container")) {
                this.o.errors.container = "'container' attribute not present.";
            }

            if ($(this.o.container).find(this.o.s.CONTENT) === 0) {
                this.o.errors.container = "'container' is not a valid HTML element.";
            }

            return (Object.keys(this.o.errors).length === 0);
        };

        HightchartCreator.prototype._mergeConfiguration= function(config) {

            if (this.o.chartObj && this.o.chartObj.yAxis && config.chartObj && config.chartObj.yAxis && Array.isArray( config.chartObj.yAxis)) {

                var yAxis = $.extend(true, {}, this.o.chartObj.yAxis);

                for (var i = 0; i < config.chartObj.yAxis.length; i++) {
                    config.chartObj.yAxis[i] = $.extend(true, config.chartObj.yAxis[i], yAxis);
                }

            }

            $.extend(true, this.o, config);

        };

        HightchartCreator.prototype.render = function (config) {

            this._mergeConfiguration(config);

            if (this._validateInput() === true) {

                //Init chart container
                this.$container = $(this.o.container).find(this.o.s.CONTENT);

                if (this._validateSeries() === true) {

                    // create chart
                    this._createChart();

                }else {
                    this.noDataAvailable();
                }
            } else {
                console.error(this.o.errors);
                throw new Error("FENIX hightchart_creator has not a valid configuration");
            }
        };

        HightchartCreator.prototype._createChart = function () {

            this.o.config = $.extend(true, {}, baseConfig, this.o.chartObj);
            this.$container.highcharts(this.o.config);
        };

        HightchartCreator.prototype._onValidateDataError = function () {
            this._showConfigurationForm();
        };

        HightchartCreator.prototype._createConfiguration = function () {
            this.o.config = $.extend(true, {}, baseConfig, this.o.chartObj);
        };

        HightchartCreator.prototype._validateSeries = function() {

            for(var i=0; i < this.o.chartObj.series.length; i++) {
                for(var j=0; j < this.o.chartObj.series[i].data.length; j++) {
                    if (this.o.chartObj.series[i].data[j] !== null) {
                        return true;
                    }
                }
            }

            return false;
        };

        HightchartCreator.prototype.reflow = function () {

            if (typeof this.$container !== 'undefined' && this.$chartRendered) {
                this.$container.highcharts().reflow();
                return true;
            }
        };

        HightchartCreator.prototype.noDataAvailable = function (conf) {

            if (conf.container) {
                //Init chart container
                this.$container = $(conf.container).find(this.o.s.CONTENT);
            }
            this.$container.html(this.o.noData);
        };

        HightchartCreator.prototype.destroy = function () {
            this.o.$container.highcharts().destroy();
        };

        return HightchartCreator;
    });<commit_msg>BUG FIX: destroy chart fixed<commit_after>/*global define, amplify, console*/
define([
        'jquery',
        'underscore',
        'fx-c-c/config/creators/highcharts_template',
        //'highcharts-export',
        //'highcharts-export-csv',
        'amplify'
    ],
    function ($, _, baseConfig) {

        'use strict';

        var defaultOptions = {

                s: {
                    CONTENT: '[data-role="content"]'
                },

                // TODO: handle multilanguage?
                noData: "<div>No data available</div>"

            };

        function HightchartCreator(config) {

            this.o = $.extend(true, {}, defaultOptions, config);

            this.o.hightchart_template = baseConfig;

            return this;
        }

        HightchartCreator.prototype._validateInput = function () {

            this.o.errors = {};

            //Container
            if (!this.o.hasOwnProperty("container")) {
                this.o.errors.container = "'container' attribute not present.";
            }

            if ($(this.o.container).find(this.o.s.CONTENT) === 0) {
                this.o.errors.container = "'container' is not a valid HTML element.";
            }

            return (Object.keys(this.o.errors).length === 0);
        };

        HightchartCreator.prototype._mergeConfiguration= function(config) {

            if (this.o.chartObj && this.o.chartObj.yAxis && config.chartObj && config.chartObj.yAxis && Array.isArray( config.chartObj.yAxis)) {

                var yAxis = $.extend(true, {}, this.o.chartObj.yAxis);

                for (var i = 0; i < config.chartObj.yAxis.length; i++) {
                    config.chartObj.yAxis[i] = $.extend(true, config.chartObj.yAxis[i], yAxis);
                }

            }

            $.extend(true, this.o, config);

        };

        HightchartCreator.prototype.render = function (config) {

            this._mergeConfiguration(config);

            if (this._validateInput() === true) {

                //Init chart container
                this.$container = $(this.o.container).find(this.o.s.CONTENT);

                if (this._validateSeries() === true) {

                    // create chart
                    this._createChart();

                }else {
                    this.noDataAvailable();
                }
            } else {
                console.error(this.o.errors);
                throw new Error("FENIX hightchart_creator has not a valid configuration");
            }
        };

        HightchartCreator.prototype._createChart = function () {

            this.o.config = $.extend(true, {}, baseConfig, this.o.chartObj);
            this.$container.highcharts(this.o.config);
        };

        HightchartCreator.prototype._onValidateDataError = function () {
            this._showConfigurationForm();
        };

        HightchartCreator.prototype._createConfiguration = function () {
            this.o.config = $.extend(true, {}, baseConfig, this.o.chartObj);
        };

        HightchartCreator.prototype._validateSeries = function() {

            for(var i=0; i < this.o.chartObj.series.length; i++) {
                for(var j=0; j < this.o.chartObj.series[i].data.length; j++) {
                    if (this.o.chartObj.series[i].data[j] !== null) {
                        return true;
                    }
                }
            }

            return false;
        };

        HightchartCreator.prototype.reflow = function () {

            if (typeof this.$container !== 'undefined' && this.$chartRendered) {
                this.$container.highcharts().reflow();
                return true;
            }
        };

        HightchartCreator.prototype.noDataAvailable = function (conf) {

            if (conf.container) {
                //Init chart container
                this.$container = $(conf.container).find(this.o.s.CONTENT);
            }
            this.$container.html(this.o.noData);
        };

        HightchartCreator.prototype.destroy = function () {

            this.o.container.find( this.o.s.CONTENT).highcharts().destroy();
        };

        return HightchartCreator;
    });
{'fraction_non_alphanumeric': 0.13238997481712436, 'fraction_numerical': 0.001199184554502938, 'mean_word_length': 1.5434583714547119, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3614274', 'n_tokens_mistral': 2338, 'n_tokens_neox': 2170, 'n_words': 367}