public HistogramBinsViewModel(GroupedExposuresHistogram groupedExposuresHistogram)
        {
            if (groupedExposuresHistogram == null) throw new ArgumentNullException("groupedExposuresHistogram");
            PressureViewModel = new FourAxisSeriesViewModel
            {
                BottomAxis =
                {
                    Visibility = Visibility.Visible,
                    AxisTicks = new ObservableList<DataAxisTick>(),
                    AxisType = AxisType.Enumerated,
                    Label = string.Format("Peak pressure per ping (±{0:0}dB) [dB re: 1 µPa]", groupedExposuresHistogram.BinWidth / 2)
                },
                LeftAxis =
                {
                    Visibility = Visibility.Visible,
                    AxisType = AxisType.Linear,
                    Label = "Exposure count",
                },
                TopAxis = { Visibility = Visibility.Collapsed },
                RightAxis = { Visibility = Visibility.Collapsed },
                PlotTitle = groupedExposuresHistogram.GroupName,
            };

            EnergyViewModel = new FourAxisSeriesViewModel
            {
                BottomAxis =
                {
                    Visibility = Visibility.Visible,
                    AxisTicks = new ObservableList<DataAxisTick>(),
                    AxisType = AxisType.Enumerated,
                    Label = string.Format("Sound exposure level per ping (±{0:0}dB) [dB re: 1 µPa²•s]", groupedExposuresHistogram.BinWidth / 2)
                },
                LeftAxis =
                {
                    Visibility = Visibility.Visible,
                    AxisType = AxisType.Linear,
                    Label = "Exposure count",
                },
                TopAxis = { Visibility = Visibility.Collapsed },
                RightAxis = { Visibility = Visibility.Collapsed },
                PlotTitle = groupedExposuresHistogram.GroupName,
            };

            PressureViewModel.BottomAxis.AxisTicks.Add(new DataAxisTick(-1, null, false));
            EnergyViewModel.BottomAxis.AxisTicks.Add(new DataAxisTick(-1, null, false));
            for (var binIndex = 0; binIndex < groupedExposuresHistogram.BinNames.Length; binIndex++)
            {
                PressureViewModel.BottomAxis.AxisTicks.Add(new DataAxisTick(binIndex, groupedExposuresHistogram.BinNames[binIndex], false));
                EnergyViewModel.BottomAxis.AxisTicks.Add(new DataAxisTick(binIndex, groupedExposuresHistogram.BinNames[binIndex], false));
            }
            PressureViewModel.BottomAxis.AxisTicks.Add(new DataAxisTick(groupedExposuresHistogram.BinNames.Length, null, false));
            EnergyViewModel.BottomAxis.AxisTicks.Add(new DataAxisTick(groupedExposuresHistogram.BinNames.Length, null, false));

            PressureViewModel.DataSeriesCollection.Add(groupedExposuresHistogram.GroupedBarSeriesViewModels[0]);
            EnergyViewModel.DataSeriesCollection.Add(groupedExposuresHistogram.GroupedBarSeriesViewModels[1]);

            PressureViewModel.LeftAxis.VisibleRange.Update(.9, 100);
            PressureViewModel.BottomAxis.DataRange.Update(-1, 12);
            EnergyViewModel.LeftAxis.VisibleRange.Update(.9, 100);
            EnergyViewModel.BottomAxis.DataRange.Update(-1, 12);

            //var barSeries = new StackedBarSeriesViewModel();
            //HistogramBinCollection.CollectionChanged += HistogramBinsCollectionChanged;
        }
 public virtual void Expose(ActorExposureRecord exposureRecord)
 {
     if (GroupDescriptions == null || GroupDescriptions.Count < GroupLevel) throw new InvalidOperationException("There is no GroupDescription defined for this grouping level");
     var groupDescription = GroupDescriptions[GroupLevel];
     if (groupDescription.RecordToKey == null) throw new InvalidOperationException("RecordToKey cannot be null for the current grouping level");
     if (groupDescription.GroupName == null) throw new InvalidOperationException("GroupName cannot be null for the current grouping level");
     if (groupDescription.RecordFilter != null && (!groupDescription.RecordFilter(exposureRecord))) return;
     var key = groupDescription.RecordToKey(exposureRecord);
     IGroupedExposures value;
     if (!_groupedExposures.TryGetValue(key, out value))
     {
         if (GroupDescriptions.Count > (GroupLevel + 2))
             value = new GroupedExposures(HistogramSource, LowBinValue, BinWidth, BinCount, GroupLevel + 1)
             {
                 GroupName = groupDescription.GroupName(exposureRecord),
                 GroupDescriptions = GroupDescriptions
             };
         else
             value = new GroupedExposuresHistogram(HistogramSource, LowBinValue, BinWidth, BinCount, GroupLevel + 1)
             {
                 GroupName = groupDescription.GroupName(exposureRecord),
                 GroupDescriptions = GroupDescriptions
             };
         if (_groupedExposures.TryAdd(key, value))
         {
             Debug.WriteLine(string.Format("Adding group {0} at level {1}", groupDescription.GroupName(exposureRecord), GroupLevel));
             Groups.Add(value);
         }
         else if (!_groupedExposures.TryGetValue(key, out value)) throw new ApplicationException("Could not add new exposure group");
     }
     value.Expose(exposureRecord);
 }