function selectHistogram(this, rowId)
    %% SELECTHISTOGRAM function publishes data to select histogram in
    % visualization section of FPT GUI
    
    %   Copyright 2016-2020 The MathWorks, Inc.
    
    if ~isempty(this.VisualizerEngine.TableData)
        matchingIndex  = this.VisualizerEngine.getRowIndexForId(rowId);
        
        if matchingIndex > 0
            % If index to select is outside of StartIndex:EndIndex,
            % histogram widget should be re-rendered using new data. Move
            % canvas if required.
            if (matchingIndex < this.VisualizerEngine.StartIndex) || (matchingIndex > this.VisualizerEngine.EndIndex)
                % Selecting a row in spreadsheet may require the visualizer to
                % fetch visualizer new data outside the one it has selected
                if (matchingIndex - this.VisualizerEngine.StartIndex) == -1
                    % If you select the left most histogram, select it in
                    % the spreadsheet, and go up a row the Visualizer should
                    % show the 20 (DataThreshold) previous selection and
                    % have the last histogram selected. If going back the
                    % DataThreashold amount returns a non-positive index,
                    % set the start index to 1
                    newStartPosition = max(this.VisualizerEngine.StartIndex - this.VisualizerEngine.DataThreshold, 1);
                else
                    % Otherwise, use the selected row index as the start of the
                    % visualizer
                    newStartPosition  = matchingIndex;
                end
                
                this.sendDataForCanvasMove(struct('NewCanvasPosition', newStartPosition));
            end
            
            % Histogram to be selected is within StartIndex:EndIndex
            publishedIndex = matchingIndex - this.VisualizerEngine.StartIndex + 1;
        else
            % Index is not found
            publishedIndex = -1;
        end
        
        message.publish(this.PublishSelectHistogramChannel, struct('SignalIdx', publishedIndex, 'Run', this.VisualizerEngine.RunName));
        this.LastUsedChannel = this.PublishSelectHistogramChannel;
        this.LastUsedData = publishedIndex;
    end
end
