public static PlotModel IntervalBarSeries()
        {
            var model = new PlotModel { Title = "IntervalBarSeries", LegendPlacement = LegendPlacement.Outside };

            var s1 = new IntervalBarSeries { Title = "IntervalBarSeries 1" };
            s1.Items.Add(new IntervalBarItem { Start = 6, End = 8 });
            s1.Items.Add(new IntervalBarItem { Start = 4, End = 8 });
            s1.Items.Add(new IntervalBarItem { Start = 5, End = 11 });
            s1.Items.Add(new IntervalBarItem { Start = 4, End = 12 });
            model.Series.Add(s1);
            var s2 = new IntervalBarSeries { Title = "IntervalBarSeries 2" };
            s2.Items.Add(new IntervalBarItem { Start = 8, End = 9 });
            s2.Items.Add(new IntervalBarItem { Start = 8, End = 10 });
            s2.Items.Add(new IntervalBarItem { Start = 11, End = 12 });
            s2.Items.Add(new IntervalBarItem { Start = 12, End = 12.5 });
            model.Series.Add(s2);

            var categoryAxis = new CategoryAxis { Position = AxisPosition.Left };
            categoryAxis.Labels.Add("Activity A");
            categoryAxis.Labels.Add("Activity B");
            categoryAxis.Labels.Add("Activity C");
            categoryAxis.Labels.Add("Activity D");
            var valueAxis = new LinearAxis { Position = AxisPosition.Bottom, MinimumPadding = 0.1, MaximumPadding = 0.1 };
            model.Axes.Add(categoryAxis);
            model.Axes.Add(valueAxis);
            return model;
        }
Beispiel #2
0
        public SubsequenceViewModel(ObservableCollection <Event> primaryEvents)
        {
            Plot = new PlotModel
            {
                Axes =
                {
                    new DateTimeAxis
                    {
                        Position     = AxisPosition.Top,
                        StringFormat = "HH:mm:ss.FFFFF"
                    },
                    (categoryAxis = new CategoryAxis
                    {
                        Position = AxisPosition.Left
                    })
                },
                Series =
                {
                    (series = new IntervalBarSeries())
                }
            };

            Controller = new PlotController();
            Controller.UnbindMouseDown(OxyMouseButton.Left);
            Controller.BindMouseDown(OxyMouseButton.Left,
                                     new DelegateViewCommand <OxyMouseDownEventArgs>(OnPlotEdit));

            Events = primaryEvents;
            Events.CollectionChanged += (o, e) =>
            {
                RebuildPlotData();
            };

            RebuildPlotData();
        }
        public static PlotModel IntervalBarSeries()
        {
            var model = new PlotModel("IntervalBarSeries")
            {
                LegendPlacement = LegendPlacement.Outside
            };

            var s1 = new IntervalBarSeries {
                Title = "IntervalBarSeries 1"
            };

            s1.Items.Add(new IntervalBarItem {
                Start = 6, End = 8
            });
            s1.Items.Add(new IntervalBarItem {
                Start = 4, End = 8
            });
            s1.Items.Add(new IntervalBarItem {
                Start = 5, End = 11
            });
            s1.Items.Add(new IntervalBarItem {
                Start = 4, End = 12
            });
            model.Series.Add(s1);
            var s2 = new IntervalBarSeries {
                Title = "IntervalBarSeries 2"
            };

            s2.Items.Add(new IntervalBarItem {
                Start = 8, End = 9
            });
            s2.Items.Add(new IntervalBarItem {
                Start = 8, End = 10
            });
            s2.Items.Add(new IntervalBarItem {
                Start = 11, End = 12
            });
            s2.Items.Add(new IntervalBarItem {
                Start = 12, End = 12.5
            });
            model.Series.Add(s2);

            var categoryAxis = new CategoryAxis {
                Position = AxisPosition.Left
            };

            categoryAxis.Labels.Add("Activity A");
            categoryAxis.Labels.Add("Activity B");
            categoryAxis.Labels.Add("Activity C");
            categoryAxis.Labels.Add("Activity D");
            var valueAxis = new LinearAxis(AxisPosition.Bottom)
            {
                MinimumPadding = 0.1, MaximumPadding = 0.1
            };

            model.Axes.Add(categoryAxis);
            model.Axes.Add(valueAxis);
            return(model);
        }
 public void InitializeAIntervalBarSeries(bool isAnim = false)
 {
     intervalBarSeries = new IntervalBarSeries
     {
         LabelMargin = 0,
         BarWidth    = 0.75,
         StrokeColor = OxyColors.Transparent,
     };
     intervalBarSeries.Selectable = !isAnim;
 }
        public static List<DataItemViewModel> CreateIntervallItems(DiagramViewModel parentViewModel, IEnumerable<DataItem> dataItems, int index, IntervalBarSeries intervalBarSeries)
        {
            List<DataItemViewModel> viewModels = new List<DataItemViewModel>();
            foreach (var item in dataItems)
            {
                viewModels.Add(new DataItemViewModel(parentViewModel, item, index, intervalBarSeries));
            }

            return viewModels;
        }
 public DataItemViewModel(DiagramViewModel parentViewModel, DataItem data, int index, IntervalBarSeries intervallBarSeries)
 {
     this.dataViewModels = new List<DataItemViewModel>();
     this.ParentViewModel = parentViewModel;
     this.Data = data;
     this.Index = index;
     this.intervallBarSeries = intervallBarSeries;
     this.Data.PropertyChanged += this.Data_PropertyChanged;
     this.Data.Children.CollectionChanged += this.Children_CollectionChanged;
     this.CreateView();
 }
 public DataItemViewModel(DiagramViewModel parentViewModel, DataItem data, int index, IntervalBarSeries intervallBarSeries)
 {
     this.dataViewModels                   = new List <DataItemViewModel>();
     this.ParentViewModel                  = parentViewModel;
     this.Data                             = data;
     this.Index                            = index;
     this.intervallBarSeries               = intervallBarSeries;
     this.Data.PropertyChanged            += this.Data_PropertyChanged;
     this.Data.Children.CollectionChanged += this.Children_CollectionChanged;
     this.CreateView();
 }
Beispiel #8
0
        Task RenderIntervalBar(Series plot)
        {
            var intervalBarSeries = new IntervalBarSeries();

            foreach (var item in plot.Data)
            {
                intervalBarSeries.Items.Add(new IntervalBarItem(item.Start, item.End, item.Title));
            }
            OxyplotModel.Series.Add(intervalBarSeries);

            return(Task.CompletedTask);
        }
        /// <summary>
        /// Will perform a coverage plot
        /// </summary>
        /// <param name="theProtein">The PatternTools Fasta Item</param>
        /// <param name="peptides">A List of Tuples were the first item is a list of positions were this peptide aligns with the protein, the second item is the peptide sequence</param>
        public void Plot(FastaItem theProtein, List <Tuple <List <int>, string> > peptides)
        {
            peptides.Sort((a, b) => a.Item1[0].CompareTo(b.Item1[0]));

            PlotModel MyModel = new PlotModel();

            MyModel.Title = theProtein.SequenceIdentifier;

            MyModel.IsLegendVisible = false;


            IntervalBarSeries intervalBarSeriesProtein = new IntervalBarSeries();

            intervalBarSeriesProtein.Title = theProtein.SequenceIdentifier;
            intervalBarSeriesProtein.Items.Add(new IntervalBarItem(0, theProtein.Sequence.Length));


            var categoryAxis1 = new CategoryAxis();

            categoryAxis1.Position = AxisPosition.Left;
            categoryAxis1.Labels.Add(theProtein.SequenceIdentifier);

            MyModel.Series.Add(intervalBarSeriesProtein);

            IntervalBarSeries intervalBarSeriesPeptide = new IntervalBarSeries();

            //Lets insert a blank entry so that the first peptide appears in the first row
            intervalBarSeriesPeptide.FillColor = OxyColors.AliceBlue;
            intervalBarSeriesPeptide.Items.Add(new IntervalBarItem(0, 0));

            foreach (Tuple <List <int>, string> peptide in peptides)
            {
                foreach (int index in peptide.Item1)
                {
                    categoryAxis1.Labels.Add(peptide.Item2);
                    intervalBarSeriesPeptide.Title = peptide.Item2;
                    intervalBarSeriesPeptide.Items.Add(new IntervalBarItem(index, index + peptide.Item2.Length));

                    //And one series to show the coverage on the protein
                    IntervalBarSeries intervalBarSeriesPeptideProtein = new IntervalBarSeries();
                    intervalBarSeriesPeptideProtein.FillColor = OxyColors.AliceBlue;
                    intervalBarSeriesPeptideProtein.Items.Add(new IntervalBarItem(index, index + peptide.Item2.Length));
                    MyModel.Series.Add(intervalBarSeriesPeptideProtein);
                }
            }

            MyModel.Series.Add(intervalBarSeriesPeptide);

            MyModel.Axes.Add(categoryAxis1);

            MyPlot.Model = MyModel;
        }
Beispiel #10
0
        public MainWindowModel()
        {
            FAMA.AP.DataLayer.DbBarSeries dataBarSeries = new FAMA.AP.DataLayer.DbBarSeries();

            dataBarSeries.Selectalldata();


            PlotModel = new PlotModel {
                Title = ""
            };
            // var PlotModel = new PlotModel();

            PlotModel.Title           = "";
            PlotModel.LegendPlacement = LegendPlacement.Outside;
            var categoryAxis1 = new CategoryAxis();

            categoryAxis1.MinorStep = 1;
            categoryAxis1.Position  = AxisPosition.Left;
            categoryAxis1.Labels.Add("Activity A");
            categoryAxis1.Labels.Add("Activity B");
            categoryAxis1.Labels.Add("Activity C");
            categoryAxis1.Labels.Add("Activity D");
            //categoryAxis1.ActualLabels.Add("Activity A");
            //categoryAxis1.ActualLabels.Add("Activity B");
            //categoryAxis1.ActualLabels.Add("Activity C");
            //categoryAxis1.ActualLabels.Add("Activity D");
            PlotModel.Axes.Add(categoryAxis1);



            var linearAxis1 = new LinearAxis();

            linearAxis1.MaximumPadding = 0.1;
            linearAxis1.MinimumPadding = 0.1;
            linearAxis1.Position       = AxisPosition.Bottom;
            linearAxis1.IsAxisVisible  = false;
            PlotModel.Axes.Add(linearAxis1);


            var intervalBarSeries1 = new IntervalBarSeries();

            intervalBarSeries1.Title = "";
            intervalBarSeries1.Items.Add(new IntervalBarItem(6, 8));
            intervalBarSeries1.Items.Add(new IntervalBarItem(4, 8));
            intervalBarSeries1.Items.Add(new IntervalBarItem(5, 11));
            intervalBarSeries1.Items.Add(new IntervalBarItem(4, 12));
            intervalBarSeries1.FillColor         = OxyColors.LightBlue;
            intervalBarSeries1.LabelFormatString = "{0},{1}";

            PlotModel.Series.Add(intervalBarSeries1);
        }
 public CategoryNode(string name)
 {
     this.Name     = name;
     this.Children = new List <CategoryNode>();
     Series        = new IntervalBarSeries()
     {
         Title           = name,
         StrokeThickness = 1.5,
         StrokeColor     = OxyColors.Gray,
         FillColor       = OxyColor.FromArgb(255, 16, 16, 16),
         BarWidth        = 1.0,
         ToolTip         = name
     };
 }
        private void CreateView()
        {
            CategoryAxis categoryAxis1 = this.ParentViewModel.Model.Axes[0] as CategoryAxis;
            categoryAxis1.Labels.Add("Project " + this.Project.ID);

            this.lifeTimeLine = new LineSeries();
            this.lifeTimeLine.Color = OxyColor.FromArgb(255, 0, 120, 0);
            this.lifeTimeLine.Points.Add(new DataPoint(Axis.ToDouble(this.Project.StartPoint), this.Index));
            this.lifeTimeLine.Points.Add(new DataPoint(Axis.ToDouble(this.Project.EndPoint), this.Index));
            this.ParentViewModel.Model.Series.Add(this.lifeTimeLine);

            this.intervallBarSeries = new IntervalBarSeries();
            dataViewModels.AddRange(DataItemViewModel.CreateIntervallItems(this.ParentViewModel, this.Project.Data, this.Index, this.intervallBarSeries));
            this.ParentViewModel.Model.Series.Add(this.intervallBarSeries);
        }
        private void CreateView()
        {
            CategoryAxis categoryAxis1 = this.ParentViewModel.Model.Axes[0] as CategoryAxis;

            categoryAxis1.Labels.Add("Project " + this.Project.ID);

            this.lifeTimeLine       = new LineSeries();
            this.lifeTimeLine.Color = OxyColor.FromArgb(255, 0, 120, 0);
            this.lifeTimeLine.Points.Add(new DataPoint(Axis.ToDouble(this.Project.StartPoint), this.Index));
            this.lifeTimeLine.Points.Add(new DataPoint(Axis.ToDouble(this.Project.EndPoint), this.Index));
            this.ParentViewModel.Model.Series.Add(this.lifeTimeLine);

            this.intervallBarSeries = new IntervalBarSeries();
            dataViewModels.AddRange(DataItemViewModel.CreateIntervallItems(this.ParentViewModel, this.Project.Data, this.Index, this.intervallBarSeries));
            this.ParentViewModel.Model.Series.Add(this.intervallBarSeries);
        }
        // #ToDO Improve Performance by pulling all Points at once and combining as necessary
        private void UpdateChart()
        {
            m_plotModel      = new PlotModel();
            m_plotController = new PlotController();

            m_plotModel.Title = "Event Time Line";

            DateTimeAxis tAxis = new DateTimeAxis()
            {
                Minimum = DateTimeAxis.ToDouble(m_start),
                Maximum = DateTimeAxis.ToDouble(m_end)
            };

            tAxis.AxisChanged += AxisChanged;

            CategoryAxis categoryAxis = new CategoryAxis {
                Position = AxisPosition.Left
            };

            int i = 0;

            foreach (IReader reader in m_readers)
            {
                IEnumerable <AdaptEvent> evt = reader.GetEvents(m_start, m_end);

                categoryAxis.Labels.Add(reader.Signal.Device + " - " + reader.Signal.Name);

                IntervalBarSeries s1 = new IntervalBarSeries();
                s1.Items.AddRange(evt.Select(e => new IntervalBarItem {
                    Start         = DateTimeAxis.ToDouble(e.Timestamp),
                    End           = DateTimeAxis.ToDouble(e.Timestamp + (long)e.Value),
                    CategoryIndex = i
                }));

                m_plotModel.Series.Add(s1);

                i++;
            }

            m_plotModel.Axes.Add(categoryAxis);
            m_plotModel.Axes.Add(tAxis);

            OnPropertyChanged(nameof(PlotModel));
            OnPropertyChanged(nameof(PlotController));
        }
        private static PlotModel CreateModel()
        {
            var model = new PlotModel {
                LegendPlacement = LegendPlacement.Outside
            };
            var valueAxis = new LinearAxis {
                Position = AxisPosition.Bottom, MinimumPadding = 0.1, MaximumPadding = 0.1
            };
            var categoryAxis = new CategoryAxis {
                Position = AxisPosition.Left
            };
            var series = new IntervalBarSeries();

            model.Axes.Add(categoryAxis);
            model.Axes.Add(valueAxis);
            model.Series.Add(series);
            return(model);
        }
Beispiel #16
0
        private PlotModel CreateIntervalSeries()
        {
            var plotModel = new PlotModel {
                Title = "Bar Plot"
            };

            plotModel.Axes.Add(new CategoryAxis
            {
                Position    = AxisPosition.Left,
                ItemsSource = new[] {
                    "Col 1", "Col2", "Col 3", "Col4"
                }
            });
            plotModel.Axes.Add(new LinearAxis {
                Position = AxisPosition.Bottom
            });

            var series1 = new IntervalBarSeries();
            var x       = new ColumnItem(6.0);

            series1.Items.Add(new IntervalBarItem(1, 10)
            {
                Color = OxyColor.FromRgb(200, 0, 0), Title = "Series 1"
            });
            series1.Items.Add(new IntervalBarItem(11, 20)
            {
                Color = OxyColor.FromRgb(0, 200, 0), Title = "Series 2"
            });
            series1.Items.Add(new IntervalBarItem(21, 30)
            {
                Color = OxyColor.FromRgb(0, 0, 200), Title = "Series 3"
            });
            series1.Items.Add(new IntervalBarItem(35, 40)
            {
                Color = OxyColor.FromRgb(0, 200, 200), Title = "Series 4"
            });
            plotModel.Series.Add(series1);

            return(plotModel);
        }
Beispiel #17
0
        private static void PitchAndLyric()
        {
            float[] samples;
            int     rate;

            using (var wavReader = new WaveFileReader(Path.Combine(CommonUtils.GetTrainingDataDirectory(), "校歌 2018-01-17 15-10-46.wav")))
            {
                var provider = wavReader.ToSampleProvider().ToMono();
                rate = provider.WaveFormat.SampleRate;

                samples = new float[wavReader.SampleCount];
                for (var readSamples = 0; readSamples < samples.Length;)
                {
                    var count = provider.Read(samples, readSamples, samples.Length - readSamples);
                    if (count == 0)
                    {
                        break;
                    }
                    readSamples += count;
                }
            }

            const int analysisUnit    = 4096; // 4096 サンプルを 1 まとまりとする
            const int vowelWindowSize = 2048;
            const int pitchWindowSize = 1024;

            var classifier          = PrepareVowelClassifier();
            var series              = new IntervalBarSeries();
            var secsPerAnalysisUnit = (double)analysisUnit / rate;
            var analysisUnitCount   = samples.Length / analysisUnit;

            for (var i = 0; i < analysisUnitCount; i++)
            {
                var startIndex = analysisUnit * i;
                var endIndex   = startIndex + analysisUnit;

                var maxPower = 0f;
                for (var j = startIndex + 1; j < endIndex - 1; j++)
                {
                    if (samples[j] > maxPower)
                    {
                        maxPower = samples[j];
                    }
                }

                // 音量小さすぎ
                if (maxPower < 0.15)
                {
                    continue;
                }

                // 512 ずつずらしながら母音認識
                var vowelCandidates = new int[(int)VowelType.Other + 1];
                for (var offset = startIndex; offset <= endIndex - vowelWindowSize; offset += 512)
                {
                    vowelCandidates[(int)classifier.Decide(new ReadOnlySpan <float>(samples, offset, vowelWindowSize), rate)]++;
                }

                var vowelCandidate = default(VowelType?);
                var maxNumOfVotes  = 0;
                for (var j = 0; j < vowelCandidates.Length; j++)
                {
                    if (vowelCandidates[j] > maxNumOfVotes)
                    {
                        maxNumOfVotes  = vowelCandidates[j];
                        vowelCandidate = (VowelType)j;
                    }
                    else if (vowelCandidates[j] == maxNumOfVotes)
                    {
                        vowelCandidate = null;
                    }
                }

                // 母音が定まらなかったので、終了
                if (!vowelCandidate.HasValue || vowelCandidate.Value == VowelType.Other)
                {
                    continue;
                }

                // 512 ずつずらしながらピッチ検出
                const int pitchOffsetDelta = 512;
                var       basicFreqs       = new List <double>(analysisUnit / pitchOffsetDelta);
                for (var offset = startIndex; offset <= endIndex - pitchWindowSize; offset += pitchOffsetDelta)
                {
                    var f = McLeodPitchMethod.EstimateFundamentalFrequency(
                        rate,
                        new ReadOnlySpan <float>(samples, offset, pitchWindowSize)
                        );

                    if (f.HasValue)
                    {
                        basicFreqs.Add(f.Value);
                    }
                }

                // ピッチ検出に失敗したので終了
                if (basicFreqs.Count == 0)
                {
                    continue;
                }

                basicFreqs.Sort();
                var basicFreq = basicFreqs[basicFreqs.Count / 2]; // 中央値
                var noteNum   = CommonUtils.HzToMidiNote(basicFreq);

                var plotItem = new IntervalBarItem()
                {
                    Start         = secsPerAnalysisUnit * i,
                    End           = secsPerAnalysisUnit * (i + 1),
                    Title         = vowelCandidate.ToString(),
                    CategoryIndex = noteNum
                };

                var items = series.Items;
                if (items.Count > 0)
                {
                    var lastItem = items[items.Count - 1];
                    if (lastItem.End == plotItem.Start &&
                        lastItem.CategoryIndex == plotItem.CategoryIndex &&
                        lastItem.Title == plotItem.Title)
                    {
                        // マージできる
                        lastItem.End = plotItem.End;
                        continue;
                    }
                }

                items.Add(plotItem);
            }

            var categoryAxis = new CategoryAxis()
            {
                Position = AxisPosition.Left
            };
            var noteNames = new[] { "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" };

            for (var i = 0; i <= 127; i++)
            {
                categoryAxis.Labels.Add(noteNames[i % 12] + (i / 12).ToString(CultureInfo.InvariantCulture));
            }

            ShowPlot(new PlotModel()
            {
                Title  = "ピッチと母音",
                Axes   = { categoryAxis },
                Series = { series }
            });
        }
Beispiel #18
0
        //bool showXAxis = true, showYAxix = true, isZoomable = true, isMovable = true;
        //IPlotType chart;
        //public bool ShowXAxis
        //{
        //    get => showXAxis;
        //    set
        //    {
        //        if (showXAxis == value) return;
        //        showXAxis = value;
        //    }
        //}
        //public bool ShowYAxix
        //{
        //    get => showYAxix;
        //    set
        //    {
        //        if (showYAxix == value) return;
        //        showYAxix = value;
        //    }
        //}
        //public bool IsZoomable
        //{
        //    get => isZoomable;
        //    set
        //    {
        //        if (isZoomable == value) return;
        //        isZoomable = value;
        //    }
        //}
        //public bool IsMovable
        //{
        //    get => isMovable;
        //    set
        //    {
        //        if (isMovable == value) return;
        //        isMovable = value;
        //    }
        //}

        public async Task Add(PlotModel plotModel)
        {
            this.oxyplotModel       = new OxyPlot.PlotModel();
            this.oxyplotModel.Title = plotModel.Title;
            foreach (var chart in plotModel.Series)
            {
                if (chart is TwoColorArea) //it should be placed before Area if clause
                {
                    var twoColorAreaSeries = new TwoColorAreaSeries
                    {
                        Color  = ChartColor.CastToOxyColor(((TwoColorArea)chart).Color),
                        Color2 = ChartColor.CastToOxyColor(((TwoColorArea)chart).Color2),
                        Limit  = ((TwoColorArea)chart).Limit
                    };
                    foreach (var item in ((TwoColorArea)chart).Data)
                    {
                        twoColorAreaSeries.Points.Add(item);
                    }
                    this.oxyplotModel.Series.Add(twoColorAreaSeries);
                }
                else if (chart is Area)
                {
                    var areaSeries = new AreaSeries();
                    foreach (var point in ((Area)chart).Data)
                    {
                        areaSeries.Points.Add(point);
                    }
                    this.oxyplotModel.Series.Add(areaSeries);
                }
                else if (chart is TwoColorLine)//it should be placed before line if clause
                {
                    var twoColorLineSeries = new TwoColorLineSeries
                    {
                        Color  = ChartColor.CastToOxyColor(((TwoColorLine)chart).Color),
                        Color2 = ChartColor.CastToOxyColor(((TwoColorLine)chart).Color2),
                        Limit  = ((TwoColorLine)chart).Limit
                    };
                    foreach (var item in ((TwoColorLine)chart).Data)
                    {
                        twoColorLineSeries.Points.Add(item);
                    }
                    this.oxyplotModel.Series.Add(twoColorLineSeries);
                }
                else if (chart is Line)
                {
                    var lineSeries = new LineSeries
                    {
                        MarkerType   = MarkerType.Circle,
                        MarkerSize   = 4,
                        MarkerStroke = OxyColors.White
                    };

                    foreach (var point in ((Line)chart).Data)
                    {
                        lineSeries.Points.Add(point);
                    }
                    this.oxyplotModel.Series.Add(lineSeries);
                }
                else if (chart is Pie)
                {
                    var pieSeries = new PieSeries();
                    foreach (var slice in ((Pie)chart).Data)
                    {
                        pieSeries.Slices.Add(slice);
                    }
                    this.oxyplotModel.Series.Add(pieSeries);
                }
                else if (chart is Bar)
                {
                    var barSeries = new BarSeries();
                    foreach (var item in ((Bar)chart).Data)
                    {
                        barSeries.Items.Add(item);
                    }
                    this.oxyplotModel.Series.Add(barSeries);
                }
                else if (chart is ErrorColumn)
                {
                    var errorColumn = new ErrorColumnSeries();
                    foreach (ErrorColumnItem item in ((ErrorColumn)chart).Data)
                    {
                        errorColumn.Items.Add((OxyPlot.Series.ErrorColumnItem)item);
                    }
                    this.oxyplotModel.Series.Add(errorColumn);
                }
                else if (chart is Column)
                {
                    var barSeries = new ColumnSeries();
                    foreach (var item in ((Column)chart).Data)
                    {
                        barSeries.Items.Add(item);
                    }
                    this.oxyplotModel.Series.Add(barSeries);
                }
                else if (chart is Box)
                {
                    var boxSeries = new BoxPlotSeries();
                    foreach (var item in ((Box)chart).Data)
                    {
                        boxSeries.Items.Add(item);
                    }
                    this.oxyplotModel.Series.Add(boxSeries);
                }
                else if (chart is Contour)
                {
                    var contourSeries = new ContourSeries
                    {
                        Data = ((Contour)chart).Data,
                        ColumnCoordinates = ((Contour)chart).ColumnCoordinates,
                        RowCoordinates    = ((Contour)chart).RowCoordinates
                    };
                    this.oxyplotModel.Series.Add(contourSeries);
                }
                else if (chart is RectangleBar)
                {
                    var rectangleBarSeries = new RectangleBarSeries
                    {
                        Title = ((RectangleBar)chart).Title
                    };
                    foreach (var item in ((RectangleBar)chart).Data)
                    {
                        rectangleBarSeries.Items.Add(item);
                    }
                    this.oxyplotModel.Series.Add(rectangleBarSeries);
                }
                else if (chart is CandleStick)
                {
                    var candleStickSeries = new CandleStickSeries();
                    foreach (var item in ((CandleStick)chart).Data)
                    {
                        candleStickSeries.Items.Add(item);
                    }
                    this.oxyplotModel.Series.Add(candleStickSeries);
                }
                else if (chart is HeatMap)
                {
                    var heatMapSeries = new HeatMapSeries()
                    {
                        Data         = ((HeatMap)chart).Data,
                        X0           = ((HeatMap)chart).X0,
                        X1           = ((HeatMap)chart).X1,
                        Y0           = ((HeatMap)chart).Y0,
                        Y1           = ((HeatMap)chart).Y1,
                        Interpolate  = ((HeatMap)chart).Interpolate,
                        RenderMethod = ((HeatMap)chart).RenderMethod
                    };
                    this.oxyplotModel.Series.Add(heatMapSeries);
                }
                else if (chart is HighLow)
                {
                    var highLowSeries = new HighLowSeries();
                    foreach (var item in ((HighLow)chart).Data)
                    {
                        highLowSeries.Items.Add(item);
                    }
                    this.oxyplotModel.Series.Add(highLowSeries);
                }
                else if (chart is IntervalBar)
                {
                    var intervalBarSeries = new IntervalBarSeries();
                    foreach (var item in ((IntervalBar)chart).Data)
                    {
                        intervalBarSeries.Items.Add(item);
                    }
                    this.oxyplotModel.Series.Add(intervalBarSeries);
                }
                else if (chart is Scatter)
                {
                    var scatterSeries = new ScatterSeries();
                    foreach (var item in ((Scatter)chart).Data)
                    {
                        scatterSeries.Points.Add(item);
                    }
                    this.oxyplotModel.Series.Add(scatterSeries);
                }
            }
            foreach (var axis in plotModel.Axes)
            {
                this.oxyplotModel.Axes.Add(axis);
            }
        }
Beispiel #19
0
        private void RefreshGraph()
        {
            if (_plot == null || _categoryAxis == null)
            {
                return;
            }

            _plot.Series.Clear();
            _plot.LegendPlacement   = LegendPlacement.Outside;
            _plot.LegendPosition    = LegendPosition.BottomCenter;
            _plot.LegendOrientation = LegendOrientation.Horizontal;
            _categoryAxis.Labels.Clear();
            _categoryAxis.Labels.Add("Person Profile");
            var personSeries = new IntervalBarSeries {
                Title = "Person"
            };

            const double personstart = 0;
            double       personEnd   = 0;

            if (Presenter.ThisAffordance.PersonProfile != null)
            {
                personEnd = Presenter.ThisAffordance.PersonProfile.Duration.TotalMinutes;
            }

            personSeries.Items.Add(new IntervalBarItem(personstart, personEnd));
            _plot.Series.Add(personSeries);
            // Build the Chart
            // Get a reference to the GraphPane

            var minSeries = new IntervalBarSeries {
                Title = "Minimum"
            };

            minSeries.Items.Add(new IntervalBarItem(0, 0));
            var bodySeries = new IntervalBarSeries {
                Title = "Always"
            };

            bodySeries.Items.Add(new IntervalBarItem(0, 0));
            var maxSeries = new IntervalBarSeries {
                Title = "Maximum"
            };

            maxSeries.Items.Add(new IntervalBarItem(0, 0));

            var sim   = Presenter.Sim;
            var count = 0;

            count++;
            var aff = Presenter.ThisAffordance;

            if (aff == null)
            {
                throw new LPGException("Affordance was null");
            }

            foreach (var affordanceDevice in aff.AffordanceDevices)
            {
                if (affordanceDevice.Device.AssignableDeviceType == AssignableDeviceType.DeviceActionGroup)
                {
                    var minStartTime = new Dictionary <VLoadType, double>();
                    var maxStartTime = new Dictionary <VLoadType, double>();
                    var minEndTime   = new Dictionary <VLoadType, double>();
                    var maxEndTime   = new Dictionary <VLoadType, double>();
                    var dag          = (DeviceActionGroup)affordanceDevice.Device;
                    foreach (var device in dag.GetDeviceActions(sim.DeviceActions.It))
                    {
                        foreach (var actionProfile in device.Profiles)
                        {
                            var start = (double)actionProfile.TimeOffset + (double)affordanceDevice.TimeOffset;
                            if (!minStartTime.ContainsKey(actionProfile.VLoadType))
                            {
                                minStartTime.Add(actionProfile.VLoadType, start);
                            }
                            else if (minStartTime[actionProfile.VLoadType] > start)
                            {
                                minStartTime[actionProfile.VLoadType] = start;
                            }

                            if (!maxStartTime.ContainsKey(actionProfile.VLoadType))
                            {
                                maxStartTime.Add(actionProfile.VLoadType, start);
                            }
                            else if (maxStartTime[actionProfile.VLoadType] < start)
                            {
                                maxStartTime[actionProfile.VLoadType] = start;
                            }

                            var maxstart = maxStartTime[actionProfile.VLoadType];
                            var length   = actionProfile.Timeprofile.Duration.TotalMinutes;
                            var end      = maxstart + length;
                            if (!minEndTime.ContainsKey(actionProfile.VLoadType))
                            {
                                minEndTime.Add(actionProfile.VLoadType, end);
                            }
                            else if (minEndTime[actionProfile.VLoadType] > end)
                            {
                                minEndTime[actionProfile.VLoadType] = end;
                            }

                            if (!maxEndTime.ContainsKey(actionProfile.VLoadType))
                            {
                                maxEndTime.Add(actionProfile.VLoadType, end);
                            }
                            else if (maxEndTime[actionProfile.VLoadType] < end)
                            {
                                maxEndTime[actionProfile.VLoadType] = end;
                            }
                        }
                    }

                    foreach (var vLoadType in minStartTime.Keys)
                    {
                        minSeries.Items.Add(new IntervalBarItem(minStartTime[vLoadType], maxStartTime[vLoadType]));
                        bodySeries.Items.Add(new IntervalBarItem(maxStartTime[vLoadType], minEndTime[vLoadType]));
                        maxSeries.Items.Add(new IntervalBarItem(minEndTime[vLoadType], maxEndTime[vLoadType]));
                        _categoryAxis.Labels.Add(affordanceDevice.Name + " - " + vLoadType.PrettyName);
                        count++;
                    }
                }

                if (affordanceDevice.Device.AssignableDeviceType == AssignableDeviceType.DeviceCategory)
                {
                    var start = (double)affordanceDevice.TimeOffset;
                    var end   = affordanceDevice.TimeProfile.Duration.TotalMinutes;
                    bodySeries.Items.Add(new IntervalBarItem(start, end));
                    _categoryAxis.Labels.Add(affordanceDevice.Name + " - " + affordanceDevice.LoadType?.PrettyName);
                    count++;
                }

                if (affordanceDevice.Device.AssignableDeviceType == AssignableDeviceType.Device)
                {
                    var start = (double)affordanceDevice.TimeOffset;
                    var end   = start + affordanceDevice.TimeProfile.Duration.TotalMinutes;
                    bodySeries.Items.Add(new IntervalBarItem(start, end));
                    _categoryAxis.Labels.Add(affordanceDevice.Name + " - " + affordanceDevice.LoadType.PrettyName);
                    count++;
                }

                if (affordanceDevice.Device.AssignableDeviceType == AssignableDeviceType.DeviceAction)
                {
                    var da = (DeviceAction)affordanceDevice.Device;
                    foreach (var realDeviceLoadType in da.Profiles)
                    {
                        var start = (double)affordanceDevice.TimeOffset;
                        var end   = start + realDeviceLoadType.Timeprofile.Duration.TotalMinutes;
                        bodySeries.Items.Add(new IntervalBarItem(start, end));
                        _categoryAxis.Labels.Add(
                            affordanceDevice.Name + " - " + realDeviceLoadType.VLoadType.PrettyName);
                        count++;
                    }
                }
            }

            DeviceGrid.RowDefinitions[2].Height = new GridLength(count * 30 + 50);
            _plot.Series.Add(minSeries);
            _plot.Series.Add(bodySeries);
            _plot.Series.Add(maxSeries);
            _plot.InvalidatePlot(true);
        }
        public static List <DataItemViewModel> CreateIntervallItems(DiagramViewModel parentViewModel, IEnumerable <DataItem> dataItems, int index, IntervalBarSeries intervalBarSeries)
        {
            List <DataItemViewModel> viewModels = new List <DataItemViewModel>();

            foreach (var item in dataItems)
            {
                viewModels.Add(new DataItemViewModel(parentViewModel, item, index, intervalBarSeries));
            }

            return(viewModels);
        }
Beispiel #21
0
        public static PlotModel IntervalBarSeries()
        {
            var plotModel1 = new PlotModel();

            plotModel1.LegendPlacement = LegendPlacement.Outside;
            plotModel1.Title           = "IntervalBarSeries";
            var categoryAxis1 = new CategoryAxis();

            categoryAxis1.MinorStep = 1;
            categoryAxis1.Position  = AxisPosition.Left;

            categoryAxis1.Labels.Add("Activity A");
            categoryAxis1.Labels.Add("Activity B");
            categoryAxis1.Labels.Add("Activity C");
            categoryAxis1.Labels.Add("Activity D");

            //categoryAxis1.ActualLabels.Add("Activity A");
            //categoryAxis1.ActualLabels.Add("Activity B");
            //categoryAxis1.ActualLabels.Add("Activity C");
            //categoryAxis1.ActualLabels.Add("Activity D");
            plotModel1.Axes.Add(categoryAxis1);
            var linearAxis1 = new LinearAxis();

            linearAxis1.MaximumPadding = 0.1;
            linearAxis1.MinimumPadding = 0.1;
            linearAxis1.Position       = AxisPosition.Bottom;
            plotModel1.Axes.Add(linearAxis1);

            AddProjectLifeTime(0, 6, 11, plotModel1);
            AddProjectLifeTime(1, 5, 10, plotModel1);
            AddProjectLifeTime(2, 8, 15, plotModel1);
            AddProjectLifeTime(3, 4, 20, plotModel1);

            //var intervalBarSeries1 = new IntervalBarSeries();
            //intervalBarSeries1.Title = "IntervalBarSeries 1";
            //intervalBarSeries1.Items.Add(new IntervalBarItem(6, 7));
            //intervalBarSeries1.Items.Add(new IntervalBarItem(4, 8));
            //intervalBarSeries1.Items.Add(new IntervalBarItem(5, 11));
            //intervalBarSeries1.Items.Add(new IntervalBarItem(4, 12));
            //plotModel1.Series.Add(intervalBarSeries1);
            //var intervalBarSeries2 = new IntervalBarSeries();
            //intervalBarSeries2.Title = "IntervalBarSeries 2";
            //intervalBarSeries2.Items.Add(new IntervalBarItem(8, 9));

            ////intervalBarSeries2.Items.Add(new IntervalBarItem(8, 10));
            ////intervalBarSeries2.Items.Add(new IntervalBarItem(11, 12));
            ////intervalBarSeries2.Items.Add(new IntervalBarItem(12, 12.5));
            //plotModel1.Series.Add(intervalBarSeries2);
            var intervalBarSeries3 = new IntervalBarSeries();

            intervalBarSeries3.Items.Add(new IntervalBarItem(9, 10)
            {
                Color = OxyColor.FromArgb(99, 120, 120, 120), CategoryIndex = 1
            });
            intervalBarSeries3.Items.Add(new IntervalBarItem(9.5, 9.8)
            {
                Color = OxyColor.FromArgb(99, 120, 120, 120), CategoryIndex = 1
            });
            plotModel1.Series.Add(intervalBarSeries3);

            var intervalBarSeries2 = new IntervalBarSeries();

            intervalBarSeries2.Items.Add(new IntervalBarItem(9, 10)
            {
                Color = OxyColor.FromArgb(99, 120, 120, 120), CategoryIndex = 3
            });
            intervalBarSeries2.Items.Add(new IntervalBarItem(9.5, 9.8)
            {
                Color = OxyColor.FromArgb(99, 120, 120, 120), CategoryIndex = 3
            });
            plotModel1.Series.Add(intervalBarSeries2);

            //intervalBarSeries2.Items.Add(new IntervalBarItem(11, 12));
            //intervalBarSeries2.Items.Add(new IntervalBarItem(12, 12.5));

            return(plotModel1);
        }
        public static PlotModel IntervalBarSeries()
        {
            var plotModel1 = new PlotModel();
            plotModel1.LegendPlacement = LegendPlacement.Outside;
            plotModel1.Title = "IntervalBarSeries";
            var categoryAxis1 = new CategoryAxis();
            categoryAxis1.MinorStep = 1;
            categoryAxis1.Position = AxisPosition.Left;

            categoryAxis1.Labels.Add("Activity A");
            categoryAxis1.Labels.Add("Activity B");
            categoryAxis1.Labels.Add("Activity C");
            categoryAxis1.Labels.Add("Activity D");

            //categoryAxis1.ActualLabels.Add("Activity A");
            //categoryAxis1.ActualLabels.Add("Activity B");
            //categoryAxis1.ActualLabels.Add("Activity C");
            //categoryAxis1.ActualLabels.Add("Activity D");
            plotModel1.Axes.Add(categoryAxis1);
            var linearAxis1 = new LinearAxis();
            linearAxis1.MaximumPadding = 0.1;
            linearAxis1.MinimumPadding = 0.1;
            linearAxis1.Position = AxisPosition.Bottom;
            plotModel1.Axes.Add(linearAxis1);

            AddProjectLifeTime(0, 6, 11, plotModel1);
            AddProjectLifeTime(1, 5, 10, plotModel1);
            AddProjectLifeTime(2, 8, 15, plotModel1);
            AddProjectLifeTime(3, 4, 20, plotModel1);

            //var intervalBarSeries1 = new IntervalBarSeries();
            //intervalBarSeries1.Title = "IntervalBarSeries 1";
            //intervalBarSeries1.Items.Add(new IntervalBarItem(6, 7));
            //intervalBarSeries1.Items.Add(new IntervalBarItem(4, 8));
            //intervalBarSeries1.Items.Add(new IntervalBarItem(5, 11));
            //intervalBarSeries1.Items.Add(new IntervalBarItem(4, 12));
            //plotModel1.Series.Add(intervalBarSeries1);
            //var intervalBarSeries2 = new IntervalBarSeries();
            //intervalBarSeries2.Title = "IntervalBarSeries 2";
            //intervalBarSeries2.Items.Add(new IntervalBarItem(8, 9));

            ////intervalBarSeries2.Items.Add(new IntervalBarItem(8, 10));
            ////intervalBarSeries2.Items.Add(new IntervalBarItem(11, 12));
            ////intervalBarSeries2.Items.Add(new IntervalBarItem(12, 12.5));
            //plotModel1.Series.Add(intervalBarSeries2);
            var intervalBarSeries3 = new IntervalBarSeries();
            intervalBarSeries3.Items.Add(new IntervalBarItem(9, 10) { Color = OxyColor.FromArgb(99, 120, 120, 120), CategoryIndex = 1 });
            intervalBarSeries3.Items.Add(new IntervalBarItem(9.5, 9.8) { Color = OxyColor.FromArgb(99, 120, 120, 120), CategoryIndex = 1 });
            plotModel1.Series.Add(intervalBarSeries3);

            var intervalBarSeries2 = new IntervalBarSeries();
            intervalBarSeries2.Items.Add(new IntervalBarItem(9, 10) { Color = OxyColor.FromArgb(99, 120, 120, 120), CategoryIndex = 3 });
            intervalBarSeries2.Items.Add(new IntervalBarItem(9.5, 9.8) { Color = OxyColor.FromArgb(99, 120, 120, 120), CategoryIndex = 3 });
            plotModel1.Series.Add(intervalBarSeries2);

            //intervalBarSeries2.Items.Add(new IntervalBarItem(11, 12));
            //intervalBarSeries2.Items.Add(new IntervalBarItem(12, 12.5));

            return plotModel1;
        }
        public void MakeIntervalBars([JetBrains.Annotations.NotNull] ResultFileEntry srcResultFileEntry, [JetBrains.Annotations.NotNull] string plotName, [JetBrains.Annotations.NotNull] DirectoryInfo basisPath,
                                     [ItemNotNull][JetBrains.Annotations.NotNull] List <Tuple <string, double> > consumption,
                                     [JetBrains.Annotations.NotNull] ChartTaggingSet taggingSet,
                                     [JetBrains.Annotations.NotNull] string newFileNameSuffix,
                                     bool showTitle,
                                     [JetBrains.Annotations.NotNull] GenericChartBase gcb, CalcOption sourceOption)
        {
            var fontsize = 48;

            if (consumption.Count <= 20)
            {
                fontsize = 22;
            }
            if (consumption.Count > 20 && consumption.Count <= 30)
            {
                fontsize = 16;
            }
            if (consumption.Count > 30 && consumption.Count <= 40)
            {
                fontsize = 14;
            }
            if (consumption.Count > 40 && consumption.Count <= 50)
            {
                fontsize = 12;
            }
            if (consumption.Count > 50)
            {
                fontsize = 10;
            }
            if (!Config.MakePDFCharts)
            {
                fontsize = (int)(fontsize * 0.8);
            }
            var unit       = "min";
            var xaxislabel = "Time Consumption in Percent";

            if (srcResultFileEntry.LoadTypeInformation != null)
            {
                var lti = srcResultFileEntry.LoadTypeInformation;
                if (!lti.ShowInCharts)
                {
                    return;
                }
                unit       = lti.UnitOfSum;
                xaxislabel = lti.Name + " in Percent";
            }
            consumption.Sort((x, y) => y.Item2.CompareTo(x.Item2));
            OxyPalette p;

            if (consumption.Count > 1)
            {
                if (taggingSet.Categories.Count > 1)
                {
                    p = OxyPalettes.HueDistinct(taggingSet.Categories.Count);
                }
                else
                {
                    p = OxyPalettes.Hue64;
                }
            }
            else
            {
                p = OxyPalettes.Hue64;
            }
            var plotModel1 = new PlotModel
            {
                LegendBorderThickness = 0,
                LegendOrientation     = LegendOrientation.Vertical,
                LegendPlacement       = LegendPlacement.Inside,
                LegendPosition        = LegendPosition.TopLeft,
                PlotAreaBorderColor   = OxyColors.White,
                LegendFontSize        = fontsize,
                LegendSymbolMargin    = 25
            };

            if (showTitle)
            {
                plotModel1.Title = plotName;
            }
            if (Config.MakePDFCharts)
            {
                plotModel1.DefaultFontSize = fontsize;
            }
            var ca = new CategoryAxis
            {
                Position       = AxisPosition.Left,
                GapWidth       = 0,
                MaximumPadding = 0.03,
                MajorTickSize  = 0
            };

            plotModel1.Axes.Add(ca);
            var la = new LinearAxis
            {
                Minimum        = 0,
                MinimumPadding = 0,
                Title          = ChartLocalizer.Get().GetTranslation(xaxislabel),
                Position       = AxisPosition.Bottom,
                MinorTickSize  = 0
            };

            plotModel1.Axes.Add(la);
            var caSub = new CategoryAxis
            {
                StartPosition = 0.5,
                EndPosition   = 1,
                Position      = AxisPosition.Left,
                Key           = "Sub",
                GapWidth      = 0.3,
                MajorTickSize = 0,
                MinorTickSize = 0
            };

            plotModel1.Axes.Add(caSub);
            double runningSum   = 0;
            var    row          = 0;
            var    sum          = consumption.Select(x => x.Item2).Sum();
            var    allBarSeries = new Dictionary <string, IntervalBarSeries>();
            var    ba           = new BarSeries
            {
                YAxisKey          = "Sub",
                LabelFormatString = "{0:N1} %"
            };

            foreach (var s in taggingSet.Categories)
            {
                caSub.Labels.Add(ChartLocalizer.Get().GetTranslation(s));
                var ibs = new IntervalBarSeries();
                // ibs.Title =
                var coloridx = taggingSet.GetCategoryIndexOfCategory(s);
                ibs.FillColor       = p.Colors[coloridx];
                ibs.StrokeThickness = 0;
                ibs.FontSize        = fontsize;
                allBarSeries.Add(s, ibs);
                double categorysum = 0;
                foreach (var tuple in consumption)
                {
                    if (taggingSet.AffordanceToCategories[tuple.Item1] == s)
                    {
                        categorysum += tuple.Item2;
                    }
                }
                var percent = categorysum / sum * 100;
                var bai     = new BarItem(percent)
                {
                    Color = p.Colors[coloridx]
                };
                ba.Items.Add(bai);
            }
            plotModel1.Series.Add(ba);
            foreach (var tuple in consumption)
            {
                var percentage = tuple.Item2 / sum * 100;
                var name       = ChartLocalizer.Get().GetTranslation(tuple.Item1.Trim());
                if (name.Length > 100)
                {
                    name = name.Substring(0, 97) + "...";
                }
                var textAnnotation1 = new TextAnnotation
                {
                    StrokeThickness = 0,
                    FontSize        = fontsize,
                    Padding         = new OxyThickness(10, 0, 10, 0)
                };
                var txtValue = tuple.Item2.ToString("N1", CultureInfo.CurrentCulture);
                if (srcResultFileEntry.LoadTypeInformation == null)
                {
                    var ts = TimeSpan.FromMinutes(tuple.Item2);
                    txtValue = ts.ToString();
                }
                textAnnotation1.Text = " " + name + " (" + txtValue + " " + unit + ", " +
                                       (tuple.Item2 / sum * 100).ToString("N1", CultureInfo.CurrentCulture) + " %)   ";
                if (runningSum < 50)
                {
                    textAnnotation1.TextHorizontalAlignment = HorizontalAlignment.Left;
                    textAnnotation1.TextPosition            = new DataPoint(runningSum + percentage, row - 0.6);
                }
                else
                {
                    textAnnotation1.TextPosition            = new DataPoint(runningSum, row - 0.5);
                    textAnnotation1.TextHorizontalAlignment = HorizontalAlignment.Right;
                }
                plotModel1.Annotations.Add(textAnnotation1);
                var item     = new IntervalBarItem(runningSum, runningSum + percentage);
                var category = taggingSet.AffordanceToCategories[tuple.Item1];
                allBarSeries[category].Items.Add(item);
                foreach (var pair in allBarSeries)
                {
                    if (pair.Key != category)
                    {
                        pair.Value.Items.Add(new IntervalBarItem(0, 0));
                    }
                }
                ca.Labels.Add(string.Empty);
                runningSum += percentage;
                row++;
            }
            foreach (var pair in allBarSeries)
            {
                plotModel1.Series.Add(pair.Value);
            }
            gcb.Save(plotModel1, plotName, srcResultFileEntry.FullFileName + newFileNameSuffix, basisPath, sourceOption); // ".interval"
        }
        private void AddBars([JetBrains.Annotations.NotNull] CalculationProfiler.ProgramPart part, int row, double offset, int fontsize,
                             [JetBrains.Annotations.NotNull] Dictionary <int, IntervalBarSeries> itemsByLevel, [JetBrains.Annotations.NotNull] OxyPalette palette, [JetBrains.Annotations.NotNull] PlotModel pm)
        {
            var runningsum = offset;

            for (var i = 0; i < part.Children.Count; i++)
            {
                var programPart = part.Children[i];
                AddBars(programPart, row + 1, runningsum, fontsize, itemsByLevel, palette, pm);
                runningsum += programPart.Duration2;
            }

            //bar
            var item = new IntervalBarItem(offset, offset + part.Duration2)
            {
                Color = palette.Colors[_parts.IndexOf(part)]
            };

            if (!itemsByLevel.ContainsKey(1))
            {
                var series = new IntervalBarSeries
                {
                    FontSize = fontsize
                };
                itemsByLevel.Add(1, series);
            }
            var ibs = new IntervalBarSeries();

            for (var i = 0; i < row; i++)
            {
                ibs.Items.Add(new IntervalBarItem(0, 0, ""));
            }
            ibs.StrokeThickness = 0.1;
            ibs.Items.Add(item);
            pm.Series.Add(ibs);
            //  item.Title = name;

            //annotation
            if (string.IsNullOrWhiteSpace(part.Key))
            {
                throw new LPGException("Empty profiler key");
            }
            var name = part.Key;

            if (name.Length > 100)
            {
                name = name.Substring(0, 97) + "...";
            }
            var textAnnotation1 = new TextAnnotation
            {
                StrokeThickness = 0,
                FontSize        = 6,
                Padding         = new OxyThickness(10, 0, 10, 0)
            };
            var txtValue = name + " - " + part.Duration2.ToString("N1", CultureInfo.InvariantCulture) + "s";

            textAnnotation1.Text = txtValue;

            textAnnotation1.TextHorizontalAlignment = HorizontalAlignment.Left;
            textAnnotation1.TextPosition            = new DataPoint(offset, row + GetOffset(row));

            pm.Annotations.Add(textAnnotation1);
        }