public void GroupAllData(Every period, DiagramMode currentDiagramMode)
 {
     GroupAllData(period);
     if (currentDiagramMode == DiagramMode.BarVertical100)
     {
         StackAllData();
     }
 }
Beispiel #2
0
 public DiagramHintCreator(DiagramData allDiagramData, SortedList <DateTime, List <double> > currentSeriesUnitedData,
                           Every groupInterval, DiagramMode diagramMode, DiagramDrawingCalculator diagramDrawingCalculator)
 {
     _allDiagramData           = allDiagramData;
     _currentSeriesUnitedData  = currentSeriesUnitedData;
     _groupInterval            = groupInterval;
     _diagramMode              = diagramMode;
     _diagramDrawingCalculator = diagramDrawingCalculator;
 }
        private void ChangeDiagramForNewStyle(DiagramMode newDiagramMode)
        {
            DiagramMode     = newDiagramMode;
            AllSeriesUnited = new DiagramDataSeriesUnited(AllDiagramData);
            AllSeriesUnited.StackAllData(newDiagramMode, GroupInterval);

            ExtractDataBetweenLimits();
            DiagramDataExtremums = CurrentSeriesUnited.FindDataExtremums(DiagramMode);
            Draw();
        }
 public void StackAllData(DiagramMode newDiagramMode, Every currentGroupInterval)
 {
     if (currentGroupInterval != GroupInterval)
     {
         GroupAllData(currentGroupInterval);
     }
     if (newDiagramMode == DiagramMode.BarVertical100)
     {
         StackAllData();
     }
 }
Beispiel #5
0
        public DrawingImage Draw(DiagramDataSeriesUnited diagramData, DiagramDataExtremums diagramDataExtremums,
                                 DiagramDrawingCalculator diagramDrawingCalculator, DiagramMode diagramMode, Every groupInterval)
        {
            _diagramData = diagramData;
            _extremums   = diagramDataExtremums;
            _diagramDrawingCalculator = diagramDrawingCalculator;
            _diagramMode   = diagramMode;
            _groupInterval = groupInterval;

            var drawingGroup = new DrawingGroup();

            drawingGroup.Children.Add(FullDiagramBackground(_diagramDrawingCalculator));
            drawingGroup.Children.Add(DiagramRegionBackground(_diagramDrawingCalculator));

            drawingGroup.Children.Add(HorizontalAxes(_diagramDrawingCalculator));
            drawingGroup.Children.Add(VerticalGridLines(_diagramDrawingCalculator));

            drawingGroup.Children.Add(XAxisDashes(Dock.Top, _diagramDrawingCalculator));
            drawingGroup.Children.Add(XAxisDashes(Dock.Bottom, _diagramDrawingCalculator));
            drawingGroup.Children.Add(XAxisMarkers(Dock.Top, _diagramDrawingCalculator));
            drawingGroup.Children.Add(XAxisMarkers(Dock.Bottom, _diagramDrawingCalculator));

            drawingGroup.Children.Add(VerticalAxes(_diagramDrawingCalculator));

            drawingGroup.Children.Add(YAxisDashes(Dock.Left, _diagramDrawingCalculator));
            drawingGroup.Children.Add(YAxisMarkers(Dock.Left, _diagramDrawingCalculator));
            drawingGroup.Children.Add(YAxisDashes(Dock.Right, _diagramDrawingCalculator));
            drawingGroup.Children.Add(YAxisMarkers(Dock.Right, _diagramDrawingCalculator));

            drawingGroup.Children.Add(HorizontalGridLines(_diagramDrawingCalculator));

            if (_diagramMode == DiagramMode.BarVertical || _diagramMode == DiagramMode.BarVertical100)
            {
                BarVerticalDiagram(_diagramDrawingCalculator, ref drawingGroup);
            }
            if (_diagramMode == DiagramMode.Lines)
            {
                for (var j = 0; j < _diagramData.SeriesCount; j++)
                {
                    drawingGroup.Children.Add(OneSeriesLine(_diagramDrawingCalculator, j));
                }
            }
            if (_diagramMode == DiagramMode.SeparateLines)
            {
                drawingGroup.Children.Add(OneSeriesLine(_diagramDrawingCalculator, diagramData.ActiveLine));
            }

            return(new DrawingImage(drawingGroup));
        }
        /// <summary>
        /// Action performed when comboBoxDiagramMode's selected index changed.
        /// Reset diagramMode and dataTimePickerDiagramDuration.CustomFormat.
        /// If mode is "yearly", the CustomFormat will be set to "yyyy", or it
        /// will be "yyyy-MM".
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="e">E.</param>
        private void ComboBoxDiagramMode_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (comboBoxDiagramMode.SelectedIndex)
            {
            case 1:
                diagramMode = DiagramMode.Yearly;
                // Automatically change DateTimePickerFormat.
                dateTimePickerDiagramDuration.CustomFormat = "yyyy";
                break;

            default:
                diagramMode = DiagramMode.Monthly;
                // Automatically change DateTimePickerFormat.
                dateTimePickerDiagramDuration.CustomFormat = "yyyy-MM";
                break;
            }
        }
        public DiagramDataExtremums FindDataExtremums(DiagramMode diagramMode)
        {
            var dataExtremums = new DiagramDataExtremums();

            dataExtremums.MinDate = DiagramData.ElementAt(0).Key;
            dataExtremums.MaxDate = DiagramData.Last().Key;

            switch (diagramMode)
            {
            case DiagramMode.SeparateLines:
                // экстремумы определяются по одной, активной сейчас линии
                dataExtremums.MinValue = double.PositiveInfinity;
                dataExtremums.MaxValue = Double.NegativeInfinity;
                foreach (var day in DiagramData)
                {
                    if (day.Value[ActiveLine] < dataExtremums.MinValue)
                    {
                        dataExtremums.MinValue = day.Value[ActiveLine];
                    }
                    if (day.Value[ActiveLine] > dataExtremums.MaxValue)
                    {
                        dataExtremums.MaxValue = day.Value[ActiveLine];
                    }
                }
                break;

            case DiagramMode.Lines:
            case DiagramMode.BarHorizontal:
                // это вариант , когда столбцы разных серий стоят рядом
                dataExtremums.MinValue = DiagramData.Values.Min(l => l.Min());
                dataExtremums.MaxValue = DiagramData.Values.Max(l => l.Max());
                break;

            case DiagramMode.BarVertical:
                // ряд серий отрицательные, либо даже просто значение отрицательное в положительной серии
                dataExtremums.MinValue = dataExtremums.MaxValue = 0;
                foreach (var day in DiagramData)
                {
                    var plus  = day.Value.Where(values => values > 0).Sum();
                    var minus = day.Value.Where(values => values < 0).Sum();
                    if (plus > dataExtremums.MaxValue)
                    {
                        dataExtremums.MaxValue = plus;
                    }
                    if (minus < dataExtremums.MinValue)
                    {
                        dataExtremums.MinValue = minus;
                    }
                }
                break;

            case DiagramMode.BarVertical100:
                dataExtremums.MinValue = 0;
                dataExtremums.MaxValue = 100;
                break;
            }

            if ((int)diagramMode < 100)
            {
                if (dataExtremums.MaxValue > 0 && dataExtremums.MinValue > 0)
                {
                    dataExtremums.MinValue = 0;
                }
                if (dataExtremums.MaxValue < 0 && dataExtremums.MinValue < 0)
                {
                    dataExtremums.MaxValue = 0;
                }
            }

            return(dataExtremums);
        }