<commit_before>/* Copyright 2015 Bloomberg Finance L.P.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

define(["widgets/js/manager", "widgets/js/widget", "d3", "base/js/utils"], function(WidgetManager, widget, d3, utils) {
    var Mark = widget.WidgetView.extend({
        render: function() {
            this.parent = this.options.parent;
            this.uuid = utils.uuid();
            var scale_creation_promise = this.set_scale_models();
            this.model.on("scales_updated", this.set_scale_models, this);

            this.colors = this.model.get("colors");

            this.el = d3.select(document.createElementNS(d3.ns.prefix.svg, "g"));
            if(this.options.clip_id && this.model.get("apply_clip")) {
                this.el.attr("clip-path", "url(#" + this.options.clip_id + ")");
            }

            this.help_text = this.model.get("help_text");
            this.div = d3.select("body").append("div")
              .attr("class", "tooltip")
              .style("opacity", 0);

            this.bisect = d3.bisector(function(d) { return d; }).left;
            this.el.style("display", (this.model.get("visible") ? "inline" : "none"));
            return scale_creation_promise;
        },
        set_scale_models: function() {
            // first, if this.scales was already defined, unregister from the
            // old ones.
            for (var key in this.scales) {
                this.stopListening(this.scales[key]);
            }

            this.scales = {};

            var scale_models = this.model.get("scales");
            var that = this;
            var scale_promises = {};
            _.each(scale_models, function(model, key) {
                scale_promises[key] = that.create_child_view(model);
            });
            return utils.resolve_promises_dict(scale_promises).then(function(scales) {
                that.scales = scales;
                that.set_positional_scales();
                that.initialize_additional_scales();
                that.set_ranges();
                that.draw();
            });
        },
        set_positional_scales: function() {
            // Positional scales are special in that they trigger a full redraw
            // when their domain is changed.
            // This should be overloaded in specific mark implementation.
        },
        initialize_additional_scales: function() {<commit_msg>set_scale_models -> set_scale_views<commit_after>/* Copyright 2015 Bloomberg Finance L.P.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

define(["widgets/js/manager", "widgets/js/widget", "d3", "base/js/utils"], function(WidgetManager, widget, d3, utils) {
    var Mark = widget.WidgetView.extend({
        render: function() {
            this.parent = this.options.parent;
            this.uuid = utils.uuid();
            var scale_creation_promise = this.set_scale_views();
            this.model.on("scales_updated", this.set_scale_views, this);

            this.colors = this.model.get("colors");

            this.el = d3.select(document.createElementNS(d3.ns.prefix.svg, "g"));
            if(this.options.clip_id && this.model.get("apply_clip")) {
                this.el.attr("clip-path", "url(#" + this.options.clip_id + ")");
            }

            this.help_text = this.model.get("help_text");
            this.div = d3.select("body").append("div")
              .attr("class", "tooltip")
              .style("opacity", 0);

            this.bisect = d3.bisector(function(d) { return d; }).left;
            this.el.style("display", (this.model.get("visible") ? "inline" : "none"));
            return scale_creation_promise;
        },
        set_scale_views: function() {
            // first, if this.scales was already defined, unregister from the
            // old ones.
            for (var key in this.scales) {
                this.stopListening(this.scales[key]);
            }

            this.scales = {};

            var scale_models = this.model.get("scales");
            var that = this;
            var scale_promises = {};
            _.each(scale_models, function(model, key) {
                scale_promises[key] = that.create_child_view(model);
            });
            return utils.resolve_promises_dict(scale_promises).then(function(scales) {
                that.scales = scales;
                that.set_positional_scales();
                that.initialize_additional_scales();
                that.set_ranges();
                that.draw();
            });
        },
        set_positional_scales: function() {
            // Positional scales are special in that they trigger a full redraw
            // when their domain is changed.
            // This should be overloaded in specific mark implementation.
        },
        initialize_additional_scales: function() {
{'fraction_non_alphanumeric': 0.11913295784263526, 'fraction_numerical': 0.005120327700972862, 'mean_word_length': 2.1336898395721926, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1430877', 'n_tokens_mistral': 1619, 'n_tokens_neox': 1544, 'n_words': 411}