<commit_before>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

pvc.BaseChart
.add({
    _updateSelectionSuspendCount: 0,
    _lastSelectedDatums: null,

    /**
     * Clears any selections and, if necessary,
     * re-renders the parts of the chart that show selected marks.
     *
     * @type undefined
     * @virtual
     */
    clearSelections: function() {
        if(this.data.owner.clearSelected()) this.updateSelections();
        return this;
    },

    _updatingSelections: function(method, context) {
        this._suspendSelectionUpdate();

        try     { method.call(context || this);  }
        finally { this._resumeSelectionUpdate(); }
    },

    _suspendSelectionUpdate: function() {
        if(this === this.root) this._updateSelectionSuspendCount++;
        else                   this.root._suspendSelectionUpdate();
    },

    _resumeSelectionUpdate: function() {
        if(this === this.root) {
            if(this._updateSelectionSuspendCount > 0 && !(--this._updateSelectionSuspendCount))
                this.updateSelections();
        } else {
            this.root._resumeSelectionUpdate();
        }
    },

    /**
     * Re-renders the parts of a chart that react to interaction.
     * @returns {pvc.visual.Chart} The chart instance.
     */
    renderInteractive: function() {
        this.useTextMeasureCache(function() { 
            this.basePanel.renderInteractive(); 
        }, this);
        return this;
    },

    /**
     * Resizes and re-renders a chart given its new dimensions.
     * @param {number} [width]  The new width of the chart. Ignored when undefined.
     * @param {number} [height] The new height of the chart. Ignored when undefined.
     * @returns {pvc.visual.Chart} The chart instance.
     */
    renderResize: function(width, height) {
        if(width  !== undefined) this.options.width  = width;
        if(height !== undefined) this.options.height = height;

        return this.render(true, true, false);
    },

    /**
     * Processes any changed selections and, optionally,
     * re-renders the parts of the chart that show marks.
     *
     * @param {object} [keyArgs] Optional keyword arguments.
     * @param {boolean} [keyArgs.render=true] Indicates if a render should be performed after processing
     * the changed selections.
     * @type undefined
     * @virtual
     */
    updateSelections: function(keyArgs) {
        if(this === this.root) {
            if(this._inUpdateSelections || this._updateSelectionSuspendCount) return this;

            var selectedChangedDatumMap = this._calcSelectedChangedDatums();
            if(!selectedChangedDatumMap) return this;

            pvc.removeTipsyLegends();

            // Reentry control
            this._inUpdateSelections = true;
            try {
                // Fire action
                var action = this.options.selectionChangedAction;
                if(action) {
                    // Can change selection further...although it's probably
                    // better to do that in userSelectionAction, called
                    // before chosen datums' selected state is actually affected.
                    var selectedDatums = this.data.selectedDatums(),
                        selectedChangedDatums = selectedChangedDatumMap.values();
                    action.call(
                        this.basePanel.context(),
                        selectedDatums,
                        selectedChangedDatums);
                }

                // Rendering afterwards allows the action to change the selection in between
                if(def.get(keyArgs, 'render', true))
                    this.useTextMeasureCache(function() { this.basePanel.renderInteractive(); }, this);
            } finally {
                this._inUpdateSelections = false;
            }
        } else {
            this.root.updateSelections();<commit_msg>[CLEANUP] Args not being passed through.<commit_after>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

pvc.BaseChart
.add({
    _updateSelectionSuspendCount: 0,
    _lastSelectedDatums: null,

    /**
     * Clears any selections and, if necessary,
     * re-renders the parts of the chart that show selected marks.
     *
     * @type undefined
     * @virtual
     */
    clearSelections: function() {
        if(this.data.owner.clearSelected()) this.updateSelections();
        return this;
    },

    _updatingSelections: function(method, context) {
        this._suspendSelectionUpdate();

        try     { method.call(context || this);  }
        finally { this._resumeSelectionUpdate(); }
    },

    _suspendSelectionUpdate: function() {
        if(this === this.root) this._updateSelectionSuspendCount++;
        else                   this.root._suspendSelectionUpdate();
    },

    _resumeSelectionUpdate: function() {
        if(this === this.root) {
            if(this._updateSelectionSuspendCount > 0 && !(--this._updateSelectionSuspendCount))
                this.updateSelections();
        } else {
            this.root._resumeSelectionUpdate();
        }
    },

    /**
     * Re-renders the parts of a chart that react to interaction.
     * @returns {pvc.visual.Chart} The chart instance.
     */
    renderInteractive: function() {
        this.useTextMeasureCache(function() { 
            this.basePanel.renderInteractive(); 
        }, this);
        return this;
    },

    /**
     * Resizes and re-renders a chart given its new dimensions.
     * @param {number} [width]  The new width of the chart. Ignored when undefined.
     * @param {number} [height] The new height of the chart. Ignored when undefined.
     * @returns {pvc.visual.Chart} The chart instance.
     */
    renderResize: function(width, height) {
        if(width  !== undefined) this.options.width  = width;
        if(height !== undefined) this.options.height = height;

        return this.render(true, true, false);
    },

    /**
     * Processes any changed selections and, optionally,
     * re-renders the parts of the chart that show marks.
     *
     * @param {object} [keyArgs] Optional keyword arguments.
     * @param {boolean} [keyArgs.render=true] Indicates if a render should be performed after processing
     * the changed selections.
     * @type undefined
     * @virtual
     */
    updateSelections: function(keyArgs) {
        if(this === this.root) {
            if(this._inUpdateSelections || this._updateSelectionSuspendCount) return this;

            var selectedChangedDatumMap = this._calcSelectedChangedDatums();
            if(!selectedChangedDatumMap) return this;

            pvc.removeTipsyLegends();

            // Reentry control
            this._inUpdateSelections = true;
            try {
                // Fire action
                var action = this.options.selectionChangedAction;
                if(action) {
                    // Can change selection further...although it's probably
                    // better to do that in userSelectionAction, called
                    // before chosen datums' selected state is actually affected.
                    var selectedDatums = this.data.selectedDatums(),
                        selectedChangedDatums = selectedChangedDatumMap.values();
                    action.call(
                        this.basePanel.context(),
                        selectedDatums,
                        selectedChangedDatums);
                }

                // Rendering afterwards allows the action to change the selection in between
                if(def.get(keyArgs, 'render', true))
                    this.useTextMeasureCache(function() { this.basePanel.renderInteractive(); }, this);
            } finally {
                this._inUpdateSelections = false;
            }
        } else {
            this.root.updateSelections(keyArgs);
{'fraction_non_alphanumeric': 0.09796468857282982, 'fraction_numerical': 0.0014713094654242277, 'mean_word_length': 1.9977949283351708, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '3743199', 'n_tokens_mistral': 2137, 'n_tokens_neox': 2052, 'n_words': 572}