/// <summary>
        /// Opens data visualizer with the detected <see cref="Observation"/>s.
        /// </summary>
        private void OpenDataVisualizer()
        {
            if (_dataVisualizerOpened)
            {
                return;
            }

            _dataVisualizerOpened = true;

            var allDataPoints = new List <Dictionary <Category, int> >();
            var allCategories = new HashSet <Category>();

            foreach (var imageEntry in InputImageEntries)
            {
                UpdateCategoryColors(imageEntry);
                var dataPoints = new Dictionary <Category, int>();
                foreach (var observation in imageEntry.Observations)
                {
                    if (dataPoints.ContainsKey(observation.Category))
                    {
                        dataPoints[observation.Category]++;
                    }
                    else
                    {
                        dataPoints.Add(observation.Category, 1);
                    }

                    allCategories.Add(observation.Category);
                }
                allDataPoints.Add(dataPoints);
            }

            _dataVisualizer = new BarChartSeries(allDataPoints, allCategories);
            _dataVisualizer.Update(allCategories.Where(category => SidebarController.CheckboxState[category]),
                                   new Category[] { }, View);

            ThumbnailViewHeight = Constants.TimeLineScrollViewHeight + Constants.BarChartSeriesStackViewHeight +
                                  Constants.LegendHeight;

            _timeLineScrollView.Frame = new CGRect(Constants.Origin,
                                                   View.Frame.Height - Constants.ResultsToolBarHeight - ThumbnailViewHeight + Constants.LegendHeight,
                                                   View.Frame.Width, ThumbnailViewHeight);

            CalculateScaledDimensions(InputImageEntry.Image);
            ImageView.Frame = new CGRect(0, 0, ImgWidth, ImgHeight);

            UpdateScrollViewDimensions();

            UpdateBoundingBoxes();

            var barChartsTopConstraint = NSLayoutConstraint.Create(_dataVisualizer.Chart, NSLayoutAttribute.Top,
                                                                   NSLayoutRelation.Equal, _timeLineScrollView, NSLayoutAttribute.Top, 1f, 0f);
            var barChartsLeadingConstraint = NSLayoutConstraint.Create(_dataVisualizer.Chart, NSLayoutAttribute.Leading,
                                                                       NSLayoutRelation.Equal, _timeLineScrollView, NSLayoutAttribute.Leading, 1f, 0f);

            _timeLineScrollView.AddSubview(_dataVisualizer.Chart);
            _timeLineScrollView.AddConstraints(new[]
            {
                barChartsTopConstraint,
                barChartsLeadingConstraint
            });

            _thumbnailStackView.Frame = new CGRect(Constants.Origin,
                                                   Constants.BarChartSeriesStackViewHeight,
                                                   Constants.TotalThumbnailWidth * InputImageEntries.Count,
                                                   Constants.ThumbnailHeight);

            _subHeadingStackView.Frame = new CGRect(Constants.Origin,
                                                    Constants.BarChartSeriesStackViewHeight,
                                                    Constants.TotalThumbnailWidth * InputImageEntries.Count,
                                                    Constants.SubheadingViewHeight);

            _legendScrollView = new UIScrollView(new CGRect(0, 0, View.Frame.Width, Constants.LegendHeight))
            {
                ContentSize            = new CGSize(_dataVisualizer.Legend.Frame.Width, Constants.LegendHeight),
                BackgroundColor        = Constants.LegendViewColour,
                UserInteractionEnabled = true,
                ScrollEnabled          = true
            };

            _legendView = new UIView(new CGRect(Constants.Origin,
                                                View.Frame.Height - Constants.ResultsToolBarHeight - ThumbnailViewHeight,
                                                View.Frame.Width, Constants.LegendHeight))
            {
                BackgroundColor        = Constants.LegendViewColour,
                UserInteractionEnabled = true
            };

            View.AddSubview(_legendView);

            var legendLeadingConstraint = NSLayoutConstraint.Create(_dataVisualizer.Legend,
                                                                    NSLayoutAttribute.LeadingMargin, NSLayoutRelation.Equal, _legendScrollView,
                                                                    NSLayoutAttribute.LeadingMargin, 1f, 0f);
            var legendCenterYConstraint = NSLayoutConstraint.Create(_dataVisualizer.Legend, NSLayoutAttribute.CenterY,
                                                                    NSLayoutRelation.Equal, _legendScrollView, NSLayoutAttribute.CenterY, 1f, 0f);

            _legendScrollView.AddSubview(_dataVisualizer.Legend);
            _legendScrollView.AddConstraints(new[]
            {
                legendLeadingConstraint,
                legendCenterYConstraint
            });

            _dataVisualizerCloseButton = new UIButton(UIButtonType.System)
            {
                TintColor = Constants.CloseBtnColor
            };
            _dataVisualizerCloseButton.SetImage(new UIImage(Constants.CloseBtnImage), UIControlState.Normal);
            _dataVisualizerCloseButton.SizeToFit();

            _dataVisualizerCloseButton.Frame = new CGRect(
                View.Frame.Width - _dataVisualizerCloseButton.Frame.Width - Constants.CloseButtonMargin,
                (Constants.LegendHeight - _dataVisualizerCloseButton.Frame.Height) / 2,
                _dataVisualizerCloseButton.Frame.Width,
                _dataVisualizerCloseButton.Frame.Height);

            ConfigureDataVisualizeCloseButtonAccessibilityAttribute(_dataVisualizerCloseButton);

            _legendScrollView.Frame = new CGRect(0, 0,
                                                 View.Frame.Width - _dataVisualizerCloseButton.Frame.Width - Constants.CloseButtonMargin * 2,
                                                 Constants.LegendHeight);

            _legendView.AddSubview(_legendScrollView);
            _legendView.AddSubview(_dataVisualizerCloseButton);

            _dataVisualizerCloseButton.TouchUpInside += DataVisualizerCloseButton_TouchUpInside;

            _legendScrollView.BringSubviewToFront(_dataVisualizerCloseButton);
        }