Ejemplo n.º 1
0
 public ApproachVolumeChart(ApproachVolumeOptions options, ApproachVolume approachVolume, Models.DirectionType direction1, Models.DirectionType direction2)
 {
     MetricInfo = new MetricInfo();
     Options    = options;
     Chart      = ChartFactory.CreateApproachVolumeChart(options, approachVolume);
     AddDataToChart(approachVolume, options);
 }
Ejemplo n.º 2
0
 protected void AddDataToChart(ApproachVolume approachVolume, ApproachVolumeOptions options)
 {
     AddDetectionTypeTitle(approachVolume);
     AddPrimaryDirectionSeries(approachVolume);
     AddOpposingDirectionSeries(approachVolume);
     AddCombindedDirectionSeries(approachVolume);
     AddDFactorSeries(approachVolume, options);
 }
Ejemplo n.º 3
0
 private void AddDetectionTypeTitle(ApproachVolume approachVolume)
 {
     if (approachVolume.Detectors.Count > 0)
     {
         Models.Detector d = approachVolume.Detectors.FirstOrDefault();
         if (d.DistanceFromStopBar != null && d.DistanceFromStopBar > 0)
         {
             Chart.Titles.Add(ChartTitleFactory.GetTitle(d.DetectionHardware.Name + " located " + d.DistanceFromStopBar +
                                                         "ft. upstream of the stop bar"));
         }
         else
         {
             Chart.Titles.Add(ChartTitleFactory.GetTitle(d.DetectionHardware.Name + " at stop bar"));
         }
     }
 }
Ejemplo n.º 4
0
        public static Chart CreateApproachVolumeChart(ApproachVolumeOptions options, ApproachVolume.ApproachVolume approachVolume)
        {
            Chart chart = new Chart();

            SetImageProperties(chart);
            chart.Titles.Add(ChartTitleFactory.GetChartName(options.MetricTypeID));
            chart.Titles.Add(ChartTitleFactory.GetSignalLocationAndDateRange(options.SignalID, options.StartDate, options.EndDate));
            chart.Titles.Add(ChartTitleFactory.GetBoldTitle(approachVolume.PrimaryDirection.Description + " and " + approachVolume.OpposingDirection.Description + " Approaches"));
            Legend chartLegend = new Legend();

            chartLegend.Name    = "MainLegend";
            chartLegend.Docking = Docking.Left;
            chart.Legends.Add(chartLegend);
            chart.ChartAreas.Add(CreateChartArea(options));
            CustomizeChartAreaForApproachVolume(chart, options);
            return(chart);
        }
Ejemplo n.º 5
0
 private void AddCombindedDirectionSeries(ApproachVolume approachVolume)
 {
     if (approachVolume.CombinedDirectionsVolumes.Items.Count > 0 && Options.ShowTotalVolume)
     {
         Series CombinedVolumeSeries = new Series();
         CombinedVolumeSeries.ChartType   = SeriesChartType.Line;
         CombinedVolumeSeries.Color       = Color.Black;
         CombinedVolumeSeries.Name        = "Combined Volume";
         CombinedVolumeSeries.XValueType  = ChartValueType.DateTime;
         CombinedVolumeSeries.BorderWidth = 2;
         foreach (Volume v in approachVolume.CombinedDirectionsVolumes.Items)
         {
             CombinedVolumeSeries.Points.AddXY(v.XAxis.ToOADate(), v.YAxis);
         }
         Chart.Series.Add(CombinedVolumeSeries);
     }
 }
Ejemplo n.º 6
0
 private void AddPrimaryDirectionSeries(ApproachVolume approachVolume)
 {
     if (approachVolume.PrimaryDirectionVolume.Items.Count > 0)
     {
         if ((Options.ShowNbEbVolume && (approachVolume.PrimaryDirection.Description == "Northbound" || approachVolume.PrimaryDirection.Description == "Eastbound")) ||
             (Options.ShowSbWbVolume && (approachVolume.PrimaryDirection.Description == "Southbound" || approachVolume.PrimaryDirection.Description == "Westbound")))
         {
             Series D1Series = new Series();
             D1Series.ChartType   = SeriesChartType.Line;
             D1Series.Color       = Color.Blue;
             D1Series.Name        = approachVolume.PrimaryDirection.Description;
             D1Series.BorderWidth = 2;
             D1Series.XValueType  = ChartValueType.DateTime;
             foreach (Volume v in approachVolume.PrimaryDirectionVolume.Items)
             {
                 D1Series.Points.AddXY(v.XAxis.ToOADate(), v.YAxis);
             }
             Chart.Series.Add(D1Series);
         }
     }
 }
Ejemplo n.º 7
0
        private void AddDFactorSeries(ApproachVolume approachVolume, ApproachVolumeOptions options)
        {
            if (options.ShowDirectionalSplits)
            {
                Series d1DfactorSeries = new Series();
                d1DfactorSeries.ChartType       = SeriesChartType.Line;
                d1DfactorSeries.Name            = approachVolume.PrimaryDirection.Description + " D-Factor";
                d1DfactorSeries.XValueType      = ChartValueType.DateTime;
                d1DfactorSeries.YValueType      = ChartValueType.Double;
                d1DfactorSeries.YAxisType       = AxisType.Secondary;
                d1DfactorSeries.BorderDashStyle = ChartDashStyle.Dash;
                d1DfactorSeries.Color           = Color.Blue;

                Series d2DfactorSeries = new Series();
                d2DfactorSeries.ChartType       = SeriesChartType.Line;
                d2DfactorSeries.Name            = approachVolume.OpposingDirection.Description + " D-Factor";
                d2DfactorSeries.XValueType      = ChartValueType.DateTime;
                d2DfactorSeries.YValueType      = ChartValueType.Double;
                d2DfactorSeries.YAxisType       = AxisType.Secondary;
                d2DfactorSeries.Color           = Color.Red;
                d2DfactorSeries.BorderDashStyle = ChartDashStyle.Dash;

                for (int i = 0; i < approachVolume.PrimaryDirectionVolume.Items.Count; i++)
                {
                    var    primaryBin        = approachVolume.PrimaryDirectionVolume.Items[i];
                    var    opposingBin       = approachVolume.OpposingDirectionVolume.Items[i];
                    var    combinedBin       = approachVolume.CombinedDirectionsVolumes.Items[i];
                    double direction1DFactor = Convert.ToDouble(primaryBin.YAxis) /
                                               (Convert.ToDouble(opposingBin.YAxis) +
                                                Convert.ToDouble(combinedBin.YAxis));
                    d1DfactorSeries.Points.AddXY(primaryBin.StartTime.ToOADate(), direction1DFactor);
                    d2DfactorSeries.Points.AddXY(primaryBin.StartTime.ToOADate(), Convert.ToDouble(opposingBin.YAxis) / (Convert.ToDouble(primaryBin.YAxis) + Convert.ToDouble(combinedBin.YAxis)));
                }
                Chart.Series.Add(d1DfactorSeries);
                Chart.Series.Add(d2DfactorSeries);
            }
        }