Ejemplo n.º 1
0
        public LeftTurnGapAnalysisChart(LeftTurnGapAnalysisOptions options, Signal signal, Approach approach,
                                        List <Controller_Event_Log> events, int opposingPhase, DateTime startDate, DateTime endDate, string detectionType)
        {
            _signal        = signal;
            _options       = options;
            _approach      = approach;
            _events        = events;
            _opposingPhase = opposingPhase;
            _startDate     = startDate;
            _endDate       = endDate;
            _detectionType = detectionType;

            options.Y2AxisMax   = 100;
            options.Y2AxisTitle = $"% Of Gap Time > {options.TrendLineGapThreshold} seconds";

            Chart = ChartFactory.CreateDefaultChartNoX2Axis(options);
            SetChartTitle(Chart, options, signal, approach, detectionType);
            ChartFactory.SetImageProperties(Chart);

            Chart.ChartAreas[0].AxisY.Title        = "# Gaps";
            Chart.ChartAreas[0].AxisY.IntervalType = DateTimeIntervalType.Auto;
            Chart.ChartAreas[0].AxisY.Interval     = 20;

            AddDataToChart();
        }
Ejemplo n.º 2
0
        public RedLightMonitorChart(DateTime graphStartDate, DateTime graphEndDate,
                                    RLMSignalPhase signalPhase, int binSize,
                                    string location, string region, string yAxisMax, string yAxis2Max,
                                    bool showVolume, bool showPlanStatistics)
        {
            double y = 0;
            var    extendedDirection = string.Empty;
            var    movementType      = "Phase";

            if (signalPhase.Approach.IsProtectedPhaseOverlap)
            {
                movementType = "Overlap";
            }


            //Gets direction for the title
            switch (signalPhase.Approach.DirectionType.Description)
            {
            case "SB":
                extendedDirection = "Southbound";
                break;

            case "NB":
                extendedDirection = "Northbound";
                break;

            default:
                extendedDirection = signalPhase.Approach.DirectionType.Description;
                break;
            }

            //Set the chart properties
            ChartFactory.SetImageProperties(chart);
            chart.BorderSkin.SkinStyle   = BorderSkinStyle.Raised;
            chart.BorderSkin.BorderColor = Color.Black;
            chart.BorderSkin.BorderWidth = 1;


            //Set the chart title
            chart.Titles.Add(location + "Signal " + signalPhase.Approach.SignalID + " "
                             + movementType + ": " + signalPhase.Approach.ProtectedPhaseNumber +
                             " " + extendedDirection + "\n" + graphStartDate.ToString("f") +
                             " - " + graphEndDate.ToString("f"));

            //Create the chart legend
            var chartLegend = new Legend();

            chartLegend.Name    = "MainLegend";
            chartLegend.Docking = Docking.Left;
            chart.Legends.Add(chartLegend);


            //Create the chart area
            var chartArea = new ChartArea();

            chartArea.Name = "ChartArea1";
            if (double.TryParse(yAxisMax, out y))
            {
                chartArea.AxisY.Maximum = y;
            }
            else
            {
                chartArea.AxisY.Maximum = 60;
            }
            chartArea.AxisY.Minimum   = 0;
            chartArea.AxisY.Title     = "Volume (Vehicles Per Hour)";
            chartArea.AxisY.Interval  = 500;
            chartArea.AxisY2.Title    = "Percent AoR";
            chartArea.AxisY2.Maximum  = 100;
            chartArea.AxisY2.Interval = 10;
            chartArea.AxisY2.Enabled  = AxisEnabled.True;


            chartArea.AxisX.Title             = "Time (Hour of Day)";
            chartArea.AxisX.Interval          = 1;
            chartArea.AxisX.IntervalType      = DateTimeIntervalType.Hours;
            chartArea.AxisX.LabelStyle.Format = "HH";

            chartArea.AxisX2.Enabled = AxisEnabled.True;
            chartArea.AxisX2.MajorTickMark.Enabled = true;
            chartArea.AxisX2.IntervalType          = DateTimeIntervalType.Hours;
            chartArea.AxisX2.LabelStyle.Format     = "HH";
            chartArea.AxisX2.LabelAutoFitStyle     = LabelAutoFitStyles.None;
            chartArea.AxisX2.Interval = 1;

            chart.ChartAreas.Add(chartArea);


            //Add the point series

            var AoRSeries = new Series();

            AoRSeries.ChartType       = SeriesChartType.Line;
            AoRSeries.BorderDashStyle = ChartDashStyle.Dash;
            AoRSeries.Color           = Color.Red;
            AoRSeries.Name            = "Arrivals on Red";
            AoRSeries.XValueType      = ChartValueType.DateTime;

            var TVSeries = new Series();

            TVSeries.ChartType       = SeriesChartType.Line;
            TVSeries.BorderDashStyle = ChartDashStyle.Dash;
            TVSeries.Color           = Color.Black;
            TVSeries.Name            = "Total Vehicles";
            TVSeries.XValueType      = ChartValueType.DateTime;

            var PARSeries = new Series();

            PARSeries.ChartType   = SeriesChartType.Line;
            PARSeries.Color       = Color.Red;
            PARSeries.Name        = "Percent Arrivals on Red";
            PARSeries.BorderWidth = 2;
            PARSeries.XValueType  = ChartValueType.DateTime;
            PARSeries.YAxisType   = AxisType.Secondary;


            var pointSeries = new Series();

            pointSeries.ChartType         = SeriesChartType.Point;
            pointSeries.Color             = Color.White;
            pointSeries.Name              = "Posts";
            pointSeries.XValueType        = ChartValueType.DateTime;
            pointSeries.IsVisibleInLegend = false;


            chart.Series.Add(pointSeries);
            chart.Series.Add(AoRSeries);
            chart.Series.Add(PARSeries);
            chart.Series.Add(TVSeries);


            //Add points at the start and and of the x axis to ensure
            //the graph covers the entire period selected by the user
            //whether there is data or not
            chart.Series["Posts"].Points.AddXY(graphStartDate, 0);
            chart.Series["Posts"].Points.AddXY(graphEndDate, 0);

            AddDataToChart(chart, signalPhase, graphStartDate, graphEndDate, binSize, signalPhase.Approach.SignalID,
                           region, showVolume, false);
            SetPlanStrips(signalPhase.Plans.PlanList, chart, graphStartDate, showPlanStatistics);
        }
Ejemplo n.º 3
0
        public ArriveOnRedChart(AoROptions options, SignalPhase signalPhase)
        {
            Options = options;
            var reportTimespan = Options.EndDate - Options.StartDate;

            //Set the chart properties
            ChartFactory.SetImageProperties(chart);

            //Create the chart legend
            var chartLegend = new Legend();

            chartLegend.Name    = "MainLegend";
            chartLegend.Docking = Docking.Left;
            chart.Legends.Add(chartLegend);


            //Create the chart area
            var chartArea = new ChartArea();

            chartArea.Name = "ChartArea1";
            if (Options.YAxisMax != null)
            {
                chartArea.AxisY.Maximum = Options.YAxisMax.Value;
            }

            chartArea.AxisY.Minimum   = 0;
            chartArea.AxisY.Title     = "Volume (Vehicles Per Hour)";
            chartArea.AxisY.Interval  = 500;
            chartArea.AxisY2.Title    = "Percent AoR";
            chartArea.AxisY2.Maximum  = 100;
            chartArea.AxisY2.Interval = 10;
            chartArea.AxisY2.Enabled  = AxisEnabled.True;


            chartArea.AxisX.Title              = "Time (Hour of Day)";
            chartArea.AxisX.IntervalType       = DateTimeIntervalType.Hours;
            chartArea.AxisX.LabelStyle.Format  = "HH";
            chartArea.AxisX2.LabelStyle.Format = "HH";
            if (reportTimespan.Days < 1)
            {
                if (reportTimespan.Hours > 1)
                {
                    chartArea.AxisX2.Interval = 1;
                    chartArea.AxisX.Interval  = 1;
                }
                else
                {
                    chartArea.AxisX.LabelStyle.Format  = "HH:mm";
                    chartArea.AxisX2.LabelStyle.Format = "HH:mm";
                }
            }
            chartArea.AxisX2.Enabled = AxisEnabled.True;
            chartArea.AxisX2.MajorTickMark.Enabled = true;
            chartArea.AxisX2.IntervalType          = DateTimeIntervalType.Hours;
            chartArea.AxisX2.LabelAutoFitStyle     = LabelAutoFitStyles.None;

            chart.ChartAreas.Add(chartArea);


            //Add the point series

            var AoRSeries = new Series();

            AoRSeries.ChartType       = SeriesChartType.Line;
            AoRSeries.BorderDashStyle = ChartDashStyle.Dash;
            AoRSeries.Color           = Color.Red;
            AoRSeries.Name            = "Arrivals on Red";
            AoRSeries.XValueType      = ChartValueType.DateTime;

            var TVSeries = new Series();

            TVSeries.ChartType       = SeriesChartType.Line;
            TVSeries.BorderDashStyle = ChartDashStyle.Dash;
            TVSeries.Color           = Color.Black;
            TVSeries.Name            = "Total Vehicles";
            TVSeries.XValueType      = ChartValueType.DateTime;

            var PARSeries = new Series();

            PARSeries.ChartType   = SeriesChartType.Line;
            PARSeries.Color       = Color.Red;
            PARSeries.Name        = "Percent Arrivals on Red";
            PARSeries.BorderWidth = 2;
            PARSeries.XValueType  = ChartValueType.DateTime;
            PARSeries.YAxisType   = AxisType.Secondary;


            var pointSeries = new Series();

            pointSeries.ChartType         = SeriesChartType.Point;
            pointSeries.Color             = Color.White;
            pointSeries.Name              = "Posts";
            pointSeries.XValueType        = ChartValueType.DateTime;
            pointSeries.IsVisibleInLegend = false;


            chart.Series.Add(pointSeries);
            chart.Series.Add(AoRSeries);
            chart.Series.Add(PARSeries);
            chart.Series.Add(TVSeries);


            //Add points at the start and and of the x axis to ensure
            //the graph covers the entire period selected by the user
            //whether there is data or not
            chart.Series["Posts"].Points.AddXY(Options.StartDate, 0);
            chart.Series["Posts"].Points.AddXY(Options.EndDate, 0);

            AddDataToChart(chart, signalPhase);
            SetPlanStrips(signalPhase.Plans, chart, Options.StartDate, Options.ShowPlanStatistics);
        }
Ejemplo n.º 4
0
        public DelayChart(ApproachDelayOptions options, SignalPhase signalPhase)
        {
            Options = options;
            //Set the chart properties
            Chart = ChartFactory.CreateDefaultChart(options);
            ChartFactory.SetImageProperties(Chart);


            //Create the chart legend
            var chartLegend = new Legend();

            chartLegend.Name    = "MainLegend";
            chartLegend.Docking = Docking.Left;
            Chart.Legends.Add(chartLegend);



            //Primary Y axis (delay per vehicle)
            if (Options.ShowDelayPerVehicle)
            {
                if (Options.YAxisMax != null)
                {
                    Chart.ChartAreas[0].AxisY.Maximum = Options.YAxisMax.Value;
                }
                Chart.ChartAreas[0].AxisY.Minimum = 0;
                Chart.ChartAreas[0].AxisY.Enabled = AxisEnabled.True;
                Chart.ChartAreas[0].AxisY.MajorTickMark.Enabled = true;
                Chart.ChartAreas[0].AxisY.MajorGrid.Enabled     = true;
                Chart.ChartAreas[0].AxisY.Interval       = 5;
                Chart.ChartAreas[0].AxisY.TitleForeColor = Color.Blue;
                Chart.ChartAreas[0].AxisY.Title          = "Delay Per Vehicle (Seconds) ";
            }

            //secondary y axis (total delay)
            if (Options.ShowDelayPerVehicle)
            {
                if (Options.Y2AxisMax != null && Options.Y2AxisMax > 0)
                {
                    Chart.ChartAreas[0].AxisY2.Maximum = Options.Y2AxisMax.Value;
                }
                else
                {
                    Chart.ChartAreas[0].AxisY2.Maximum = 10;
                }
                Chart.ChartAreas[0].AxisY2.Minimum = 0;
                Chart.ChartAreas[0].AxisY2.Enabled = AxisEnabled.True;
                Chart.ChartAreas[0].AxisY2.MajorTickMark.Enabled = true;
                Chart.ChartAreas[0].AxisY2.MajorGrid.Enabled     = false;
                Chart.ChartAreas[0].AxisY2.Interval       = 5;
                Chart.ChartAreas[0].AxisY2.Title          = "Delay per Hour (hrs) ";
                Chart.ChartAreas[0].AxisY2.TitleForeColor = Color.Red;
            }

            //Add the point series

            var delayPerVehicleSeries = new Series();

            delayPerVehicleSeries.ChartType  = SeriesChartType.Line;
            delayPerVehicleSeries.Color      = Color.Blue;
            delayPerVehicleSeries.Name       = "Approach Delay Per Vehicle";
            delayPerVehicleSeries.YAxisType  = AxisType.Primary;
            delayPerVehicleSeries.XValueType = ChartValueType.DateTime;

            var delaySeries = new Series();

            delaySeries.ChartType  = SeriesChartType.Line;
            delaySeries.Color      = Color.Red;
            delaySeries.Name       = "Approach Delay";
            delaySeries.YAxisType  = AxisType.Secondary;
            delaySeries.XValueType = ChartValueType.DateTime;


            var pointSeries = new Series();

            pointSeries.ChartType         = SeriesChartType.Point;
            pointSeries.Color             = Color.White;
            pointSeries.Name              = "Posts";
            pointSeries.XValueType        = ChartValueType.DateTime;
            pointSeries.IsVisibleInLegend = false;


            Chart.Series.Add(pointSeries);
            Chart.Series.Add(delaySeries);
            Chart.Series.Add(delayPerVehicleSeries);


            //Add points at the start and and of the x axis to ensure
            //the graph covers the entire period selected by the user
            //whether there is data or not
            Chart.Series["Posts"].Points.AddXY(Options.StartDate, 0);
            Chart.Series["Posts"].Points.AddXY(Options.EndDate, 0);

            AddDataToChart(Chart, signalPhase, Options.SelectedBinSize, Options.ShowTotalDelayPerHour,
                           Options.ShowDelayPerVehicle);
            if (Options.ShowPlanStatistics)
            {
                SetPlanStrips(signalPhase.Plans, Chart, Options.StartDate, Options.ShowPlanStatistics);
            }
        }
Ejemplo n.º 5
0
        public ArriveOnRedChart(AoROptions options, SignalPhase signalPhase)
        {
            Options = options;
            Chart   = ChartFactory.CreateDefaultChart(options);
            //Set the chart properties
            ChartFactory.SetImageProperties(Chart);

            //Create the chart legend
            var chartLegend = new Legend();

            chartLegend.Name    = "MainLegend";
            chartLegend.Docking = Docking.Left;
            Chart.Legends.Add(chartLegend);

            if (Options.YAxisMax != null)
            {
                Chart.ChartAreas[0].AxisY.Maximum = Options.YAxisMax.Value;
            }

            Chart.ChartAreas[0].AxisY.Minimum   = 0;
            Chart.ChartAreas[0].AxisY.Title     = "Volume (Vehicles Per Hour)";
            Chart.ChartAreas[0].AxisY.Interval  = 500;
            Chart.ChartAreas[0].AxisY2.Title    = "Percent AoR";
            Chart.ChartAreas[0].AxisY2.Maximum  = 100;
            Chart.ChartAreas[0].AxisY2.Interval = 10;
            Chart.ChartAreas[0].AxisY2.Enabled  = AxisEnabled.True;


            //Add the point series

            var AoRSeries = new Series();

            AoRSeries.ChartType       = SeriesChartType.Line;
            AoRSeries.BorderDashStyle = ChartDashStyle.Dash;
            AoRSeries.Color           = Color.Red;
            AoRSeries.Name            = "Arrivals on Red";
            AoRSeries.XValueType      = ChartValueType.DateTime;

            var TVSeries = new Series();

            TVSeries.ChartType       = SeriesChartType.Line;
            TVSeries.BorderDashStyle = ChartDashStyle.Dash;
            TVSeries.Color           = Color.Black;
            TVSeries.Name            = "Total Vehicles";
            TVSeries.XValueType      = ChartValueType.DateTime;

            var PARSeries = new Series();

            PARSeries.ChartType   = SeriesChartType.Line;
            PARSeries.Color       = Color.Red;
            PARSeries.Name        = "Percent Arrivals on Red";
            PARSeries.BorderWidth = 2;
            PARSeries.XValueType  = ChartValueType.DateTime;
            PARSeries.YAxisType   = AxisType.Secondary;


            var pointSeries = new Series();

            pointSeries.ChartType         = SeriesChartType.Point;
            pointSeries.Color             = Color.White;
            pointSeries.Name              = "Posts";
            pointSeries.XValueType        = ChartValueType.DateTime;
            pointSeries.IsVisibleInLegend = false;


            Chart.Series.Add(pointSeries);
            Chart.Series.Add(AoRSeries);
            Chart.Series.Add(PARSeries);
            Chart.Series.Add(TVSeries);


            //Add points at the start and and of the x axis to ensure
            //the graph covers the entire period selected by the user
            //whether there is data or not
            Chart.Series["Posts"].Points.AddXY(Options.StartDate, 0);
            Chart.Series["Posts"].Points.AddXY(Options.EndDate, 0);

            AddDataToChart(Chart, signalPhase);
            SetPlanStrips(signalPhase.Plans, Chart, Options.StartDate, Options.ShowPlanStatistics);
        }
Ejemplo n.º 6
0
        /// <summary>
        ///     Gets a new chart for the pcd Diagram
        /// </summary>
        /// <param name="graphStartDate"></param>
        /// <param name="graphEndDate"></param>
        /// <param name="signalId"></param>
        /// <param name="phase"></param>
        /// <param name="direction"></param>
        /// <param name="location"></param>
        /// <returns></returns>
        private Chart GetNewChart(DateTime graphStartDate, DateTime graphEndDate, string signalId,
                                  int phase, string direction, string location, bool isOverlap, double y1AxisMaximum,
                                  double y2AxisMaximum, bool showVolume, int dotSize)
        {
            var chart             = new Chart();
            var extendedDirection = string.Empty;
            var movementType      = "Phase";

            if (isOverlap)
            {
                movementType = "Overlap";
            }


            //Gets direction for the title
            switch (direction)
            {
            case "SB":
                extendedDirection = "Southbound";
                break;

            case "NB":
                extendedDirection = "Northbound";
                break;

            default:
                extendedDirection = direction;
                break;
            }

            //Set the chart properties
            ChartFactory.SetImageProperties(chart);

            //Set the chart title
            var title = new Title();

            title.Text = location + "Signal " + signalId + " "
                         + movementType + ": " + phase +
                         " " + extendedDirection + "\n" + graphStartDate.ToString("f") +
                         " - " + graphEndDate.ToString("f");
            title.Font = new Font(FontFamily.GenericSansSerif, 20);
            chart.Titles.Add(title);

            //Create the chart legend
            //Legend chartLegend = new Legend();
            //chartLegend.Name = "MainLegend";
            ////chartLegend.LegendStyle = LegendStyle.Table;
            //chartLegend.Docking = Docking.Left;
            //chartLegend.CustomItems.Add(Color.Blue, "AoG - Arrival On Green");
            //chartLegend.CustomItems.Add(Color.Blue, "GT - Green Time");
            //chartLegend.CustomItems.Add(Color.Maroon, "PR - Platoon Ratio");
            ////LegendCellColumn a = new LegendCellColumn();
            ////a.ColumnType = LegendCellColumnType.Text;
            ////a.Text = "test";
            ////chartLegend.CellColumns.Add(a);
            //chart.Legends.Add(chartLegend);


            //Create the chart area
            var chartArea = new ChartArea();

            chartArea.Name                    = "ChartArea1";
            chartArea.AxisY.Maximum           = y1AxisMaximum;
            chartArea.AxisY.Minimum           = 0;
            chartArea.AxisY.Title             = "Cycle Time (Seconds) ";
            chartArea.AxisY.TitleFont         = new Font(FontFamily.GenericSansSerif, 20);
            chartArea.AxisY.LabelAutoFitStyle = LabelAutoFitStyles.None;
            chartArea.AxisY.LabelStyle.Font   = new Font(FontFamily.GenericSansSerif, 20);

            if (showVolume)
            {
                chartArea.AxisY2.Enabled = AxisEnabled.True;
                chartArea.AxisY2.MajorTickMark.Enabled = true;
                chartArea.AxisY2.MajorGrid.Enabled     = false;
                chartArea.AxisY2.IntervalType          = DateTimeIntervalType.Number;
                chartArea.AxisY2.Interval = 500;
                chartArea.AxisY2.Maximum  = y2AxisMaximum;
                chartArea.AxisY2.Title    = "Volume Per Hour ";
            }

            chartArea.AxisX.Title             = "Time (Hour of Day)";
            chartArea.AxisX.TitleFont         = new Font(FontFamily.GenericSansSerif, 20);
            chartArea.AxisX.Interval          = 1;
            chartArea.AxisX.IntervalType      = DateTimeIntervalType.Hours;
            chartArea.AxisX.LabelStyle.Format = "HH";
            chartArea.AxisX.LabelAutoFitStyle = LabelAutoFitStyles.None;
            chartArea.AxisX.LabelStyle.Font   = new Font(FontFamily.GenericSansSerif, 20);

            //chartArea.AxisX.Minimum = 0;

            chartArea.AxisX2.Enabled = AxisEnabled.True;
            chartArea.AxisX2.MajorTickMark.Enabled = true;
            chartArea.AxisX2.IntervalType          = DateTimeIntervalType.Hours;
            chartArea.AxisX2.LabelStyle.Format     = "HH";
            chartArea.AxisX2.LabelAutoFitStyle     = LabelAutoFitStyles.None;
            chartArea.AxisX2.Interval        = 1;
            chartArea.AxisX2.LabelStyle.Font = new Font(FontFamily.GenericSansSerif, 20);
            //chartArea.AxisX.Minimum = 0;

            chart.ChartAreas.Add(chartArea);

            //Add the point series
            var pointSeries = new Series();

            pointSeries.ChartType  = SeriesChartType.Point;
            pointSeries.Color      = Color.Black;
            pointSeries.Name       = "Detector Activation";
            pointSeries.XValueType = ChartValueType.DateTime;
            pointSeries.MarkerSize = dotSize;
            chart.Series.Add(pointSeries);

            //Add the green series
            var greenSeries = new Series();

            greenSeries.ChartType   = SeriesChartType.Line;
            greenSeries.Color       = Color.DarkGreen;
            greenSeries.Name        = "Change to Green";
            greenSeries.XValueType  = ChartValueType.DateTime;
            greenSeries.BorderWidth = 1;
            chart.Series.Add(greenSeries);

            //Add the yellow series
            var yellowSeries = new Series();

            yellowSeries.ChartType  = SeriesChartType.Line;
            yellowSeries.Color      = Color.Yellow;
            yellowSeries.Name       = "Change to Yellow";
            yellowSeries.XValueType = ChartValueType.DateTime;
            chart.Series.Add(yellowSeries);

            //Add the red series
            var redSeries = new Series();

            redSeries.ChartType  = SeriesChartType.Line;
            redSeries.Color      = Color.Red;
            redSeries.Name       = "Change to Red";
            redSeries.XValueType = ChartValueType.DateTime;
            chart.Series.Add(redSeries);

            //Add the red series
            var volumeSeries = new Series();

            volumeSeries.ChartType  = SeriesChartType.Line;
            volumeSeries.Color      = Color.Black;
            volumeSeries.Name       = "Volume Per Hour";
            volumeSeries.XValueType = ChartValueType.DateTime;
            volumeSeries.YAxisType  = AxisType.Secondary;
            chart.Series.Add(volumeSeries);


            //Add points at the start and and of the x axis to ensure
            //the graph covers the entire period selected by the user
            //whether there is data or not
            chart.Series["Detector Activation"].Points.AddXY(graphStartDate, 0);
            chart.Series["Detector Activation"].Points.AddXY(graphEndDate, 0);
            return(chart);
        }
Ejemplo n.º 7
0
        private void GetNewResultsChart()
        {
            var chart = new Chart();

            //Set the chart properties
            ChartFactory.SetImageProperties(chart);
            chart.ImageStorageMode = ImageStorageMode.UseImageLocation;

            //Set the chart title
            var title = new Title();

            title.Text = "Max Arrivals On Green By Second";
            title.Font = new Font(FontFamily.GenericSansSerif, 20);
            chart.Titles.Add(title);

            //Create the chart legend
            var chartLegend = new Legend();

            chartLegend.Name = "MainLegend";
            //chartLegend.LegendStyle = LegendStyle.Table;
            chartLegend.Docking = Docking.Left;
            //chartLegend.CustomItems.Add(Color.Blue, "AoG - Arrival On Green");
            //chartLegend.CustomItems.Add(Color.Blue, "GT - Green Time");
            //chartLegend.CustomItems.Add(Color.Maroon, "PR - Platoon Ratio");
            //LegendCellColumn a = new LegendCellColumn();
            //a.ColumnType = LegendCellColumnType.Text;
            //a.Text = "test";
            //chartLegend.CellColumns.Add(a);
            chart.Legends.Add(chartLegend);


            //Create the chart area
            var chartArea = new ChartArea();

            chartArea.Name                    = "ChartArea1";
            chartArea.AxisY.Minimum           = 0;
            chartArea.AxisY.Title             = "Arrivals On Green";
            chartArea.AxisY.TitleFont         = new Font(FontFamily.GenericSansSerif, 20);
            chartArea.AxisY.LabelAutoFitStyle = LabelAutoFitStyles.None;
            chartArea.AxisY.LabelStyle.Font   = new Font(FontFamily.GenericSansSerif, 20);


            chartArea.AxisX.Minimum           = 0;
            chartArea.AxisX.Title             = "Adjustment(seconds)";
            chartArea.AxisX.TitleFont         = new Font(FontFamily.GenericSansSerif, 20);
            chartArea.AxisX.Interval          = 10;
            chartArea.AxisX.LabelAutoFitStyle = LabelAutoFitStyles.None;
            chartArea.AxisX.LabelStyle.Font   = new Font(FontFamily.GenericSansSerif, 20);

            chart.ChartAreas.Add(chartArea);

            //Add the line series
            var lineSeries = new Series();

            lineSeries.ChartType   = SeriesChartType.Line;
            lineSeries.Color       = Color.Black;
            lineSeries.Name        = "Total AOG";
            lineSeries.XValueType  = ChartValueType.Int32;
            lineSeries.BorderWidth = 5;
            chart.Series.Add(lineSeries);

            foreach (var d in ResultsGraph)
            {
                chart.Series["Total AOG"].Points.AddXY(
                    d.Key,
                    d.Value);
            }

            //Add the line series
            var downstreamLineSeries = new Series();

            downstreamLineSeries.ChartType   = SeriesChartType.Line;
            downstreamLineSeries.Color       = Color.Blue;
            downstreamLineSeries.Name        = "Downstream AOG";
            downstreamLineSeries.XValueType  = ChartValueType.Int32;
            downstreamLineSeries.BorderWidth = 3;
            chart.Series.Add(downstreamLineSeries);

            foreach (var d in DownstreamResultsGraph)
            {
                chart.Series["Downstream AOG"].Points.AddXY(
                    d.Key,
                    d.Value);
            }

            //Add the line series
            var upstreamLineSeries = new Series();

            upstreamLineSeries.ChartType   = SeriesChartType.Line;
            upstreamLineSeries.Color       = Color.Green;
            upstreamLineSeries.Name        = "Upstream AOG";
            upstreamLineSeries.XValueType  = ChartValueType.Int32;
            upstreamLineSeries.BorderWidth = 3;
            chart.Series.Add(upstreamLineSeries);

            foreach (var d in UpstreamResultsGraph)
            {
                chart.Series["Upstream AOG"].Points.AddXY(
                    d.Key,
                    d.Value);
            }

            var chartName = "LinkPivot-" + SignalApproach.SignalID + SignalApproach.DirectionType.Abbreviation +
                            DownSignalApproach.SignalID + DownSignalApproach.DirectionType.Abbreviation +
                            DateTime.Now.Day +
                            DateTime.Now.Hour +
                            DateTime.Now.Minute +
                            DateTime.Now.Second +
                            ".jpg";
            var settingsRepository = MOE.Common.Models.Repositories.ApplicationSettingsRepositoryFactory.Create();
            var settings           = settingsRepository.GetGeneralSettings();

            chart.SaveImage(settings.ImagePath + chartName,
                            ChartImageFormat.Jpeg);
            ResultChartLocation = settings.ImageUrl + chartName;
        }
Ejemplo n.º 8
0
        public DelayChart(ApproachDelayOptions options, SignalPhase signalPhase)
        {
            Options = options;
            var reportTimespan    = Options.EndDate - Options.StartDate;
            var extendedDirection = signalPhase.Approach.DirectionType.Description;

            //Set the chart properties
            ChartFactory.SetImageProperties(chart);


            //Create the chart legend
            var chartLegend = new Legend();

            chartLegend.Name    = "MainLegend";
            chartLegend.Docking = Docking.Left;
            chart.Legends.Add(chartLegend);


            //Create the chart area
            var chartArea = new ChartArea();

            chartArea.Name = "ChartArea1";

            //Primary Y axis (delay per vehicle)
            if (Options.ShowDelayPerVehicle)
            {
                if (Options.YAxisMax != null)
                {
                    chartArea.AxisY.Maximum = Options.YAxisMax.Value;
                }
                chartArea.AxisY.Minimum = 0;
                chartArea.AxisY.Enabled = AxisEnabled.True;
                chartArea.AxisY.MajorTickMark.Enabled = true;
                chartArea.AxisY.MajorGrid.Enabled     = true;
                chartArea.AxisY.Interval       = 5;
                chartArea.AxisY.TitleForeColor = Color.Blue;
                chartArea.AxisY.Title          = "Delay Per Vehicle (Seconds) ";
            }

            //secondary y axis (total delay)
            if (Options.ShowDelayPerVehicle)
            {
                if (Options.Y2AxisMax != null && Options.Y2AxisMax > 0)
                {
                    chartArea.AxisY2.Maximum = Options.Y2AxisMax.Value;
                }
                else
                {
                    chartArea.AxisY2.Maximum = 10;
                }
                chartArea.AxisY2.Minimum = 0;
                chartArea.AxisY2.Enabled = AxisEnabled.True;
                chartArea.AxisY2.MajorTickMark.Enabled = true;
                chartArea.AxisY2.MajorGrid.Enabled     = false;
                chartArea.AxisY2.Interval       = 5;
                chartArea.AxisY2.Title          = "Delay per Hour (hrs) ";
                chartArea.AxisY2.TitleForeColor = Color.Red;
            }

            chartArea.AxisX.Title              = "Time (Hour of Day)";
            chartArea.AxisX.IntervalType       = DateTimeIntervalType.Hours;
            chartArea.AxisX.LabelStyle.Format  = "HH";
            chartArea.AxisX2.LabelStyle.Format = "HH";
            if (reportTimespan.Days < 1)
            {
                if (reportTimespan.Hours > 1)
                {
                    chartArea.AxisX2.Interval = 1;
                    chartArea.AxisX.Interval  = 1;
                }
                else
                {
                    chartArea.AxisX.LabelStyle.Format  = "HH:mm";
                    chartArea.AxisX2.LabelStyle.Format = "HH:mm";
                }
            }
            chartArea.AxisX2.Enabled = AxisEnabled.True;
            chartArea.AxisX2.MajorTickMark.Enabled = true;
            chartArea.AxisX2.IntervalType          = DateTimeIntervalType.Hours;
            chartArea.AxisX2.LabelAutoFitStyle     = LabelAutoFitStyles.None;

            chart.ChartAreas.Add(chartArea);


            //Add the point series

            var delayPerVehicleSeries = new Series();

            delayPerVehicleSeries.ChartType  = SeriesChartType.Line;
            delayPerVehicleSeries.Color      = Color.Blue;
            delayPerVehicleSeries.Name       = "Approach Delay Per Vehicle";
            delayPerVehicleSeries.YAxisType  = AxisType.Primary;
            delayPerVehicleSeries.XValueType = ChartValueType.DateTime;

            var delaySeries = new Series();

            delaySeries.ChartType  = SeriesChartType.Line;
            delaySeries.Color      = Color.Red;
            delaySeries.Name       = "Approach Delay";
            delaySeries.YAxisType  = AxisType.Secondary;
            delaySeries.XValueType = ChartValueType.DateTime;


            var pointSeries = new Series();

            pointSeries.ChartType         = SeriesChartType.Point;
            pointSeries.Color             = Color.White;
            pointSeries.Name              = "Posts";
            pointSeries.XValueType        = ChartValueType.DateTime;
            pointSeries.IsVisibleInLegend = false;


            chart.Series.Add(pointSeries);
            chart.Series.Add(delaySeries);
            chart.Series.Add(delayPerVehicleSeries);


            //Add points at the start and and of the x axis to ensure
            //the graph covers the entire period selected by the user
            //whether there is data or not
            chart.Series["Posts"].Points.AddXY(Options.StartDate, 0);
            chart.Series["Posts"].Points.AddXY(Options.EndDate, 0);

            AddDataToChart(chart, signalPhase, Options.SelectedBinSize, Options.ShowTotalDelayPerHour,
                           Options.ShowDelayPerVehicle);
            if (Options.ShowPlanStatistics)
            {
                SetPlanStrips(signalPhase.Plans, chart, Options.StartDate, Options.ShowPlanStatistics);
            }
        }
Ejemplo n.º 9
0
        public Chart GetChart(RLMSignalPhase signalPhase, YellowAndRedOptions options)
        {
            Options = options;
            var chart          = new Chart();
            var reportTimespan = Options.EndDate - Options.StartDate;


            //Set the chart properties
            ChartFactory.SetImageProperties(chart);
            chart.ImageStorageMode = ImageStorageMode.UseImageLocation;
            SetChartTitle(chart, signalPhase);

            //Create the chart legend
            var chartLegend = new Legend();

            chartLegend.Name = "MainLegend";
            chart.Legends.Add(chartLegend);


            //Create the chart area
            var chartArea = new ChartArea();

            chartArea.Name = "ChartArea1";
            if (Options.YAxisMax != null)
            {
                chartArea.AxisY.Maximum = Options.YAxisMax.Value;
            }
            chartArea.AxisY.Minimum = 0;
            chartArea.AxisY.Title   = "Yellow Red Time (Seconds) ";
            chartArea.AxisY.MinorTickMark.Enabled = true;
            chartArea.AxisY.MajorTickMark.Enabled = true;
            chartArea.AxisY.MajorGrid.Interval    = 5;
            chartArea.AxisY.MinorGrid.Interval    = 1;
            chartArea.AxisX.Title              = "Time (Hour of Day)";
            chartArea.AxisX.IntervalType       = DateTimeIntervalType.Hours;
            chartArea.AxisX.LabelStyle.Format  = "HH";
            chartArea.AxisX2.LabelStyle.Format = "HH";
            chartArea.AxisX.MajorGrid.Enabled  = true;
            if (reportTimespan.Days < 1)
            {
                if (reportTimespan.Hours > 1)
                {
                    chartArea.AxisX2.Interval = 1;
                    chartArea.AxisX.Interval  = 1;
                }
                else
                {
                    chartArea.AxisX.LabelStyle.Format  = "HH:mm";
                    chartArea.AxisX2.LabelStyle.Format = "HH:mm";
                }
            }
            //chartArea.AxisX.Minimum = 0;

            chartArea.AxisX2.Enabled = AxisEnabled.True;
            chartArea.AxisX2.MajorTickMark.Enabled = true;

            chartArea.AxisX2.IntervalType      = DateTimeIntervalType.Hours;
            chartArea.AxisX2.LabelAutoFitStyle = LabelAutoFitStyles.None;
            //chartArea.AxisX.Minimum = 0;

            chart.ChartAreas.Add(chartArea);

            var yelowish   = Color.FromArgb(245, 237, 127);
            var blueish    = Color.FromArgb(128, 10, 117, 182);
            var greenish   = Color.FromArgb(64, 177, 14);
            var tanish     = Color.FromArgb(220, 138, 78);
            var whiteish   = Color.FromArgb(243, 240, 235);
            var redish     = Color.FromArgb(128, 255, 0, 0);
            var darkRedish = Color.FromArgb(196, 222, 2, 2);
            //Color redish = Color.FromArgb(163, 60, 62);

            //Add the red series
            var redSeries = new Series();

            redSeries.ChartType = SeriesChartType.Area;
            redSeries.Color     = redish;
            //redSeries.BackGradientStyle = GradientStyle.VerticalCenter;
            redSeries.Name       = "Red";
            redSeries.XValueType = ChartValueType.DateTime;

            chart.Series.Add(redSeries);

            //Add the yellow series
            var redClearanceSeries = new Series();

            redClearanceSeries.ChartType  = SeriesChartType.Area;
            redClearanceSeries.Color      = darkRedish;
            redClearanceSeries.Name       = "Red Clearance";
            redClearanceSeries.XValueType = ChartValueType.DateTime;
            chart.Series.Add(redClearanceSeries);

            //Add the green series
            var yellowClearanceSeries = new Series();

            yellowClearanceSeries.ChartType = SeriesChartType.Area;
            yellowClearanceSeries.Color     = yelowish;
            //yellowClearanceSeries.BackGradientStyle = GradientStyle.DiagonalLeft;
            yellowClearanceSeries.BackSecondaryColor = yelowish;
            yellowClearanceSeries.Name       = "Yellow Clearance";
            yellowClearanceSeries.XValueType = ChartValueType.DateTime;
            chart.Series.Add(yellowClearanceSeries);

            //Add the point series
            var pointSeries = new Series();

            pointSeries.ChartType  = SeriesChartType.Point;
            pointSeries.Color      = Color.Black;
            pointSeries.Name       = "Detector Activation";
            pointSeries.XValueType = ChartValueType.DateTime;
            pointSeries.MarkerSize = 3;
            chart.Series.Add(pointSeries);


            //Add points at the start and and of the x axis to ensure
            //the graph covers the entire period selected by the user
            //whether there is data or not
            chart.Series["Detector Activation"].Points.AddXY(Options.StartDate, 0);
            chart.Series["Detector Activation"].Points.AddXY(Options.EndDate, 0);

            AddDataToChart(chart, signalPhase);
            return(chart);
        }