示例#1
0
        public BarChartGenerator(SplittedGanttChartModel model)
        {
            _chart = new Chart(1000, 300, 50);
            _chart.AddElement(new BottomBorder(_chart.InnerArea));
            _chart.AddElement(new LeftBorder(_chart.InnerArea));
            var chartAreaSplitted = new ChartAreaSplitted(_chart.InnerArea);

            foreach (var chartStringModel in model.ChartStrings)
            {
                var chartString = chartAreaSplitted.CreateString(chartAreaSplitted.Height / model.ChartStrings.Count);
                _chart.AddElement(new BottomBorder(chartString));
                var captionY = new CaptionY(chartString)
                {
                    Caption = chartStringModel.StartChartTime.Hour + " час."
                };
                _chart.AddElement(captionY);
                var en  = model.Graphs.First().Intervals.Where(i => (i.StartTime >= chartStringModel.StartChartTime) && (i.StartTime <= chartStringModel.EndChartTime));
                var bar = new Bar(chartString, new GraphParameters(0), new Scale(70, chartString.Width))
                {
                    Sections = new[]
                    {
                        new BarSectionData()
                        {
                            Name = "Труб", SectionNum = 0, Value = en.Where(i => i.Level == 0).Count()
                        },
                        new BarSectionData()
                        {
                            Name = "Образцов", SectionNum = 1, Value = en.Where(i => i.Level == 1).Count()
                        },
                        new BarSectionData()
                        {
                            Name = "Повторов", SectionNum = 2, Value = en.Where(i => i.Level == 2).Count()
                        }
                    },
                    Bottom = chartString.Bottom,
                };
                var barCaption = new BarCaption(chartString, bar, bar.Sections[0].Value.ToString() + '/' + bar.Sections.Sum(s => s.Value).ToString());
                _chart.AddElement(bar);
                _chart.AddElement(barCaption);
            }
        }
示例#2
0
        public HistogramGenerator(SplittedGanttChartModel model)
        {
            _chart = new Chart(1000, 300, 50);
            _chart.AddElement(new BottomBorder(_chart.InnerArea));
            _chart.AddElement(new LeftBorder(_chart.InnerArea));
            var      chartAreaSplitted = new ChartAreaSplitted(_chart.InnerArea);
            Interval oldInterval       = null;

            foreach (var chartString in model.ChartStrings)
            {
                var chartString1 = chartAreaSplitted.CreateString(chartAreaSplitted.Height / model.ChartStrings.Count);
                _chart.AddElement(new BottomBorder(chartString1));
                var timeChartArea = new TimeChartArea(chartString1);
                var captionY      = new CaptionY(chartString1)
                {
                    Caption = chartString.StartChartTime.Hour + " час."
                };
                _chart.AddElement(captionY);

                foreach (IntervalDefectoscope interval in model.Graphs.First().Intervals.Where(i => (i.StartTime >= chartString.StartChartTime) && (i.StartTime <= chartString.EndChartTime)).OrderBy(i => i.StartTime))
                {
                    int value = (oldInterval == null) ? 0 : (int)(oldInterval.Duration.TotalSeconds / 60 / (interval.StartTime - oldInterval.StartTime).TotalHours);
                    var x     = Convert.ToInt32(chartString.GetStartCoord(interval) * timeChartArea.PixelPerSecond);
                    var bar   = new VerticalBar(timeChartArea)
                    {
                        X = x, Value = value
                    };
                    var point = new HistogramPoint(timeChartArea)
                    {
                        X = x, Value = interval.EstimatedSpeed
                    };
                    _chart.AddElement(point);
                    _chart.AddElement(bar);
                    oldInterval = interval;
                }
            }
        }