コード例 #1
0
        public void TestMonitor(string testId, string storeId, bool old = true)
        {
            if (!old)
            {
                TestData = new List <Series>();
            }
            highOptions.Point[] pt = new highOptions.Point[Warehouse[storeId].testRunList.Count];
            int    i        = 0;
            string testName = "";

            foreach (TestRun t in Warehouse[storeId].testRunList.Values)
            {
                testName = t.testList[testId].Name;
                pt[i]    = new DotNet.Highcharts.Options.Point();
                pt[i].Id = t.testList[testId].Id;

                if (t.testList[testId].Result == TestResult.Failed)
                {
                    pt[i].Y = 1;
                }
                else
                {
                    pt[i].Y = 0;
                }

                pt[i].X = GetDateInJsFormat(t.StartTime);
                i++;
            }
            try
            {
                Array.Sort(pt, delegate(DotNet.Highcharts.Options.Point pt1, DotNet.Highcharts.Options.Point pt2)
                {
                    return(pt1.X.ToString().CompareTo(pt2.X.ToString()));
                }
                           );
                TestData.Add(new Series {
                    Data = new Data(pt), Name = testName + ":" + storeId, PlotOptionsLine = new PlotOptionsLine {
                        AllowPointSelect = false, LineWidth = 2, ZIndex = -1
                    }
                });
            }
            catch (Exception e)
            {
                ViewBag.ErrorMessage = "Sorry, Error occurred";
            }
        }
コード例 #2
0
		public static Highcharts EmployeePieChart(this IEnumerable<DepartmentVM> departments, DepartmentChartGroupOption groupOption)
		{
			var dataPoints = new Point[0];

			switch (groupOption)
			{
				case DepartmentChartGroupOption.Department:
					var orderedDepartments = departments.OrderBy(x => x.Name).ToList();
					dataPoints = orderedDepartments.Select(x => new Point { Name = x.Name, Y = x.EmployeeCount }).ToArray();
					break;
				case DepartmentChartGroupOption.DepartmentGroup:
					var orderedGroups = departments.GroupBy(x => x.GroupName).OrderBy(x => x.Key).ToList();
					dataPoints = orderedGroups.Select(x => new Point { Name = x.Key, Y = x.Sum(y => y.EmployeeCount) }).ToArray();
					break;
			}

			return new Highcharts("department_employees") //this name becomes the div id, so it needs to be one word!!!
				.InitChart(new Chart { PlotShadow = false })
				.SetTitle(new Title { Text = "Departments" })
				.SetTooltip(new Tooltip { Formatter = "function() { return '<b>'+ this.point.name +'</b>: '+ this.y; }" }) //everything needs to be small case
				.SetPlotOptions(new PlotOptions
					{
						Pie = new PlotOptionsPie
							{
								AllowPointSelect = true,
								Cursor = Cursors.Pointer,
								DataLabels = new PlotOptionsPieDataLabels
									{
										Color = ColorTranslator.FromHtml("#000000"),
										ConnectorColor = ColorTranslator.FromHtml("#000000"),
										Formatter = "function() { return this.point.name; }"
									}
							}
					})
				.SetSeries(new Series
					{
						Type = ChartTypes.Pie,
						Name = "Browser share",
						Data = new Data(dataPoints)
					});
		}
コード例 #3
0
ファイル: HomeController.cs プロジェクト: key-core/BSTWeb
        public ActionResult Index()
        {
            var cicloAct = db.SP_MW_Ciclos_Act().First();

            ViewBag.Ciclo = cicloAct.NU_Ano.ToString() + cicloAct.NU_Ciclo.ToString();
            ViewBag.FEIni = cicloAct.FE_CicloIni.Day + "/" + cicloAct.FE_CicloIni.Month + "/" + cicloAct.FE_CicloIni.Year;
            ViewBag.FEFin = cicloAct.FE_CicloFin.Day + "/" + cicloAct.FE_CicloFin.Month + "/" + cicloAct.FE_CicloFin.Year;

            DateTime inicio    = DateTime.Now;
            DateTime fin       = new DateTime(cicloAct.FE_CicloFin.Year, cicloAct.FE_CicloFin.Month, cicloAct.FE_CicloFin.Day);
            TimeSpan restantes = (fin - inicio);

            if (restantes.Days < 0)
            {
                ViewBag.Restantes = 0;
            }
            else
            {
                ViewBag.Restantes = restantes.Days + 1;
            }
            ChartsModel model = new ChartsModel();

            model.Charts = new List <Highcharts>();

            string[] regiones = db.SP_MW_Dashboard_CoberturaPorReg().ToList()
                                .OrderBy(e => e.TX_Region)
                                .Select(c => c.TX_Region).ToArray();

            object[] valPuntos = db.SP_MW_Dashboard_CoberturaPorReg()
                                 .OrderBy(e => e.TX_Region)
                                 .Select(c => c.PCJFVRR.ToString()).ToArray();

            object[] valCoberturaMedica = db.SP_MW_Dashboard_CoberturaPorReg()
                                          .OrderBy(e => e.TX_Region)
                                          .Select(c => new object[]
            {
                c.PCJFVRR
            }).ToArray();

            object[] valCoberturaHospital = db.SP_MW_Dashboard_CoberturaPorReg()
                                            .OrderBy(e => e.TX_Region)
                                            .Select(c => new object[]
            {
                c.VisitadosHospital
            }).ToArray();

            object[] valCoberturaFarmacia = db.SP_MW_Dashboard_CoberturaPorReg()
                                            .OrderBy(e => e.TX_Region)
                                            .Select(c => new object[]
            {
                c.VisitadosFarmacia
            }).ToArray();


            List <Point> misPuntos = new List <Point>();
            int          i         = 0;

            foreach (object v in valPuntos)
            {
                Point punto = new Point
                {
                    Y = Convert.ToDouble(v),

                    Color = Color.FromName("colors[" + i + "]")
                };
                misPuntos.Add(punto);
                i++;
            }

            Highcharts chart1 = new DotNet.Highcharts.Highcharts("chart1")
                                .SetCredits(new Credits {
                Enabled = false
            })
                                .InitChart(new Chart {
                DefaultSeriesType = ChartTypes.Column, Height = 250
            })
                                .SetTitle(new Title {
                Text = "Coberturas"
            })
                                .SetYAxis(new YAxis
            {
                Title = new YAxisTitle
                {
                    Text = "(%) Porcentajes"
                }
            })
                                .SetXAxis(new XAxis
            {
                Title = new XAxisTitle
                {
                    Text = "Regiones"
                },
                Categories = regiones
            })
                                .SetSeries(new[] {
                new Series
                {
                    Name = "Cobertura Médica (Mix)",
                    Data = new Data(valCoberturaMedica)
                },

                new Series
                {
                    Name = "Cobertura Farmacias",
                    Data = new Data(valCoberturaFarmacia)
                },

                new Series
                {
                    Name = "Cobertura Hospitales",
                    Data = new Data(valCoberturaHospital)
                },
            });


            var valAltasBajas = db.SP_MW_Dashboard_AltasBajas().First();

            Highcharts chart3 = new Highcharts("chart3")
                                .SetCredits(new Credits {
                Enabled = false
            })
                                .InitChart(new Chart {
                Height = 200
            })
                                .SetTitle(new Title {
                Text = "Altas y Bajas"
            })
                                .SetTooltip(new Tooltip {
                Formatter = "function() { return '<b>'+ this.point.name +'</b>: '+ this.percentage +' %'; }"
            })
                                .SetTooltip(new Tooltip {
                Formatter = "TooltipFormatter"
            })
                                .SetXAxis(new XAxis {
                Categories = new[] { "Altas", "Bajas" }
            })
                                .AddJavascripFunction("TooltipFormatter",
                                                      @"var s;
                    if (this.point.name) { // the pie chart
                       s = ''+
                          this.point.name +': '+ this.y +'%';
                    } else {
                       s = ''+
                          'Médicos: '+ this.y;
                    }
                    return s;")
                                .SetLabels(new Labels
            {
                Items = new[]
                {
                    new LabelsItems
                    {
                        Html  = "% Altas y Bajas",
                        Style = "left: '165px', top: '8px', color: 'black'"
                    }
                }
            })
                                .SetYAxis(new YAxis
            {
                Title = new YAxisTitle
                {
                    Text = "Cantidad de Médicos"
                }
            })
                                .SetPlotOptions(new PlotOptions
            {
                Pie = new PlotOptionsPie
                {
                    Center       = new[] { new PercentageOrPixel(170), new PercentageOrPixel(40) },
                    Size         = new PercentageOrPixel(60),
                    ShowInLegend = false,
                    DataLabels   = new PlotOptionsPieDataLabels {
                        Enabled = false
                    }
                },
                Column = new PlotOptionsColumn
                {
                    ShowInLegend = false,
                    DataLabels   = new PlotOptionsColumnDataLabels {
                        Enabled = true
                    }
                }
            })
                                .SetSeries(new[]
            {
                new Series
                {
                    Type = ChartTypes.Column,
                    Data = new Data(new[] {
                        new Point
                        {
                            //Name = "Altas",
                            DataLabels = false,
                            Y          = valAltasBajas.NU_Altas,
                            Color      = Color.FromName("Highcharts.getOptions().colors[0]")
                        },
                        new Point
                        {
                            //Name = "Bajas",
                            DataLabels = false,
                            Y          = valAltasBajas.NU_Bajas,
                            Color      = Color.FromName("Highcharts.getOptions().colors[1]")
                        }
                    })
                },

                new Series
                {
                    Type = ChartTypes.Pie,
                    Name = "Total",
                    Data = new Data(new[]
                    {
                        new Point
                        {
                            Name  = "Altas",
                            Y     = Convert.ToDouble(valAltasBajas.NU_PRCAltas),
                            Color = Color.FromName("Highcharts.getOptions().colors[0]")
                        },
                        new Point
                        {
                            Name  = "Bajas",
                            Y     = Convert.ToDouble(valAltasBajas.NU_PRCBajas),
                            Color = Color.FromName("Highcharts.getOptions().colors[1]")
                        }
                    }
                                    )
                }
            });


            var valAVGFichas = db.SP_MW_Dashboard_PromedioFichas().First();

            //IMPORTANTE Para que el Angular Gauge funcione debe estar en el _Layout el script "highcharts-more.js"
            Highcharts chart4 = new Highcharts("chart4")
                                .SetCredits(new Credits {
                Enabled = false
            })
                                .InitChart(new Chart
            {
                Type = ChartTypes.Gauge,
                PlotBackgroundColor = null,
                PlotBackgroundImage = null,
                PlotBorderWidth     = 0,
                PlotShadow          = false,
                Height = 250
            })
                                .SetTitle(new Title {
                Text = "% de Fichas Llenas"
            })
                                .SetPane(new Pane
            {
                StartAngle = -150,
                EndAngle   = 120,
                Background = new[]
                {
                    new BackgroundObject
                    {
                        BackgroundColor = new BackColorOrGradient(new Gradient
                        {
                            LinearGradient = new[] { 0, 0, 0, 1 },
                            Stops          = new object[, ] {
                                { 0, "#FFF" }, { 1, "#333" }
                            }
                        }),
                        BorderWidth = new PercentageOrPixel(0),
                        OuterRadius = new PercentageOrPixel(109, true)
                    },
                    new BackgroundObject
                    {
                        BackgroundColor = new BackColorOrGradient(new Gradient
                        {
                            LinearGradient = new[] { 0, 0, 0, 1 },
                            Stops          = new object[, ] {
                                { 0, "#333" }, { 1, "#FFF" }
                            }
                        }),
                        BorderWidth = new PercentageOrPixel(1),
                        OuterRadius = new PercentageOrPixel(107, true)
                    },
                    new BackgroundObject(),
                    new BackgroundObject
                    {
                        BackgroundColor = new BackColorOrGradient(ColorTranslator.FromHtml("#DDD")),
                        BorderWidth     = new PercentageOrPixel(0),
                        OuterRadius     = new PercentageOrPixel(105, true),
                        InnerRadius     = new PercentageOrPixel(103, true)
                    }
                }
            })
                                .SetYAxis(new YAxis
            {
                Min = 0,
                Max = 100,

                //MinorTickInterval = "auto",
                MinorTickWidth    = 1,
                MinorTickLength   = 10,
                MinorTickPosition = TickPositions.Inside,
                MinorTickColor    = ColorTranslator.FromHtml("#666"),
                TickPixelInterval = 30,
                TickWidth         = 2,
                TickPosition      = TickPositions.Inside,
                TickLength        = 10,
                TickColor         = ColorTranslator.FromHtml("#666"),
                Labels            = new YAxisLabels
                {
                    Step = 2,
                    //Rotation = "auto"
                },
                Title = new YAxisTitle {
                    Text = "% Fichas"
                },
                PlotBands = new[]
                {
                    new YAxisPlotBands {
                        From = 0, To = 50, Color = ColorTranslator.FromHtml("#DF5353")
                    },
                    new YAxisPlotBands {
                        From = 50, To = 90, Color = ColorTranslator.FromHtml("#DDDF0D")
                    },
                    new YAxisPlotBands {
                        From = 90, To = 100, Color = ColorTranslator.FromHtml("#55BF3B")
                    }
                }
            })
                                .SetSeries(new Series
            {
                Name = "Valor",
                Data = new Data(new object[] { valAVGFichas.Value })
            });

            model.Charts.Add(chart1);
            //model.Charts.Add(chart2);
            model.Charts.Add(chart3);
            model.Charts.Add(chart4);

            return(View(model));
        }
コード例 #4
0
 public void StoreMonitor(string storeId, bool old = true)
 {
     if (!old)
     {
         StoreData = new List <Series>();
     }
     if (String.IsNullOrEmpty(storeId))
     {
         StoreData = new List <Series>();
         foreach (TrxDataStore v in Warehouse.Values)
         {
             DotNet.Highcharts.Options.Point[] pt = new DotNet.Highcharts.Options.Point[v.testRunList.Count];
             int i = 0;
             foreach (TestRun t in v.testRunList.Values)
             {
                 pt[i]      = new DotNet.Highcharts.Options.Point();
                 pt[i].Name = t.StartTime.ToString();
                 pt[i].Id   = t.Id;
                 pt[i].Y    = t.Failed;
                 pt[i].X    = GetDateInJsFormat(t.StartTime);
                 i++;
             }
             try
             {
                 Array.Sort(pt, delegate(DotNet.Highcharts.Options.Point pt1, DotNet.Highcharts.Options.Point pt2)
                 {
                     return(pt1.X.ToString().CompareTo(pt2.X.ToString()));
                 }
                            );
                 StoreData.Add(new Series {
                     Data = new Data(pt), Name = v.Id
                 });
             }
             catch (Exception e)
             {
                 ViewBag.ErrorMessage = "Sorry, Error occurred";
             }
         }
     }
     else
     {
         DotNet.Highcharts.Options.Point[] pt = new DotNet.Highcharts.Options.Point[Warehouse[storeId].testRunList.Count];
         int i = 0;
         foreach (TestRun testRun in Warehouse[storeId].testRunList.Values)
         {
             pt[i]      = new DotNet.Highcharts.Options.Point();
             pt[i].Name = testRun.StartTime.ToString();
             pt[i].Id   = testRun.Id;
             pt[i].Y    = testRun.Failed;
             pt[i].X    = this.GetDateInJsFormat(testRun.StartTime);
             i++;
         }
         try
         {
             Array.Sort(pt, delegate(DotNet.Highcharts.Options.Point pt1, DotNet.Highcharts.Options.Point pt2)
             {
                 return(pt1.X.ToString().CompareTo(pt2.X.ToString()));
             }
                        );
             StoreData.Add(new Series {
                 Data = new Data(pt), Name = Warehouse[storeId].Id
             });
         }
         catch (Exception e)
         {
             ViewBag.ErrorMessage = "Sorry, Error occurred";
         }
     }
     //Response.Redirect("/XMLUtilityV1/Display");
     //return this.Display();
 }
コード例 #5
0
 /// <summary>
 /// Builds the high chart for Throughput chart
 /// </summary>
 /// <param name="tpCurveClean">TP curve clean</param>
 /// <param name="tpCurveNoClean">TP curve no clean</param>
 /// <param name="isDashboard">IsDashboard flag</param>
 /// <returns>Returns the high chart</returns>
 private Highcharts plotTPData(Dictionary<DateTime, Tuple<int, double, string>> tpCurveClean, Dictionary<DateTime, Tuple<int, double, string>> tpCurveNoClean, bool isDashboard)
 {
     try
     {
         double cleanAverage = 0;
         double noCleanAverage = 0;
         double xaxisMinValue = 0.0;
         List<Point> lstPoints = new List<Point>();
         List<double> xseries = new List<double>();
         List<double> yseries = new List<double>();
         object[] chartdata1 = new object[tpCurveClean.Count];
         object[] chartdata2 = new object[tpCurveNoClean.Count];
         object[] chartdataAverageClean = new object[tpCurveClean.Count];
         object[] chartdataAveragenoClean = new object[tpCurveNoClean.Count];
         Point[] chartData_Point1 = new Point[tpCurveClean.Count];
         Point[] chartData_Point2 = new Point[tpCurveNoClean.Count];
         Point[] withrticleanaverage = new Point[tpCurveClean.Count + 1];
         int counter = 0;
         Number width, height;
         foreach (DateTime dateTime in tpCurveClean.Keys)
         {
             Tuple<int, double, string> tuple = tpCurveClean[dateTime];
             chartData_Point1[counter] = new Point();
             chartData_Point1[counter].X = tuple.Item1;
             chartData_Point1[counter].Y = tuple.Item2;
             chartdata1[counter] = tuple.Item2;
             xseries.Add(tuple.Item1);
             counter++;
         }
         Number? MaximumWeek = chartData_Point1 != null && chartData_Point1.Length > 0 ? chartData_Point1[chartdata1.Count() - 1].X : 0;
         cleanAverage = chartdata1.Length > 0 ? (chartdata1.Cast<double>()).ToArray().Average() : 0;
         counter = 0;
         if (isDashboard == true)
         {
             width = 500;
             height = 290;
         }
         else
         {
             width = 650;
             height = 300;
         }
         foreach (DateTime dateTime in tpCurveNoClean.Keys)
         {
             Tuple<int, double, string> tuple = tpCurveNoClean[dateTime];
             chartData_Point2[counter] = new Point();
             chartData_Point2[counter].X = tuple.Item1;
             chartData_Point2[counter].Y = tuple.Item2;
             chartdata2[counter] = tuple.Item2;
             counter++;
             if (tuple.Item3 == "Replace")
             {
                 lstPoints.Add(new Point() { X = tuple.Item1, Y = tuple.Item2 });
             }
         }
         noCleanAverage = chartdata2.Length > 0 ? chartdata2.Cast<double>().ToArray().Average() : 0;
         xaxisMinValue = xseries.Count > 0 ? xseries[0] - 1 : 0;
         Series withCleaning = new Series
         {
             Name = "WithCleaning",
             Data = new Data(chartData_Point1),
         };
         Series withoutCleaning = new Series
         {
             Name = "WithoutCleaning",
             Data = new Data(chartData_Point2),
         };
         Highcharts chart1 = new Highcharts("chart")
            .InitChart(new Chart { Width = width, Height = height, DefaultSeriesType = ChartTypes.Area, ZoomType = ZoomTypes.Xy, SpacingRight = 20 })
            .SetTitle(new Title { Text = "Throughput Forecast" })
            .SetTooltip(new Tooltip
            {
                HeaderFormat = "<b>Week :{point.x:.0f}</b><br>",
                PointFormat = "<b>{series.name}: {point.y:.2f}</b>",
                Enabled = true
            })
            .SetXAxis(new XAxis
            {
                Title = new XAxisTitle { Text = "Number of Weeks" },
                Type = AxisTypes.Linear,
                MinRange = xaxisMinValue,
                Min = xaxisMinValue,
                TickInterval = 50,
                Labels = new XAxisLabels { Formatter = "function() { return this.value;  }" }
            })
            .SetCredits(new Credits { Enabled = false })
            .SetLegend(new Legend
             {
                 BorderWidth = 1,
             })
            .SetYAxis(new YAxis
            {
                Title = new YAxisTitle { Text = "Throughput" },
                Labels = new YAxisLabels { Formatter = "function() { return this.value; }" }
            })
            .SetPlotOptions(new PlotOptions
            {
                Area = new PlotOptionsArea
                {
                    Marker = new PlotOptionsAreaMarker
                    {
                        Enabled = false,
                        Symbol = "circle",
                        Radius = 2,
                        States = new PlotOptionsAreaMarkerStates
                        {
                            Hover = new PlotOptionsAreaMarkerStatesHover { Enabled = true }
                        }
                    },
                    PointInterval = 1,
                    PointStart = new PointStart(xaxisMinValue)
                }
            })
            .SetSeries(new[] {  withoutCleaning, withCleaning,
            new Series
            {
                Name = "Replace",
                Type = ChartTypes.Scatter,
                Data = new Data(lstPoints.ToArray()),
                Color = Color.Blue
            },
            new Series
            {
                Name = "Without RTI Average Clean",
                Type = ChartTypes.Spline,
                Data = new Data(new[] { new Point
                                                {
                                                    X = xaxisMinValue,
                                                    Y = noCleanAverage,
                                                },
                                                new Point
                                                {
                                                    X = MaximumWeek,
                                                    Y = noCleanAverage,
                                                }
                                            }),
                Color = Color.Red,
                PlotOptionsSpline=new PlotOptionsSpline{DashStyle=DashStyles.ShortDash}
              },
              new Series
            {
                Name = "With RTI Average Clean",
                Type = ChartTypes.Spline,
                Data = new Data(new[] { new Point
                                                {
                                                    X = xaxisMinValue,
                                                    Y = cleanAverage,
                                                },
                                                new Point
                                                {
                                                    X = MaximumWeek,
                                                    Y = cleanAverage,
                                                }
                                            }),
                Color = Color.Green,
                PlotOptionsSpline=new PlotOptionsSpline{DashStyle=DashStyles.ShortDash}
              }
            }
         );
         return chart1;
     }
     catch (Exception)
     {
         throw;
     }
 }
コード例 #6
0
        /// <summary>
        /// Fetches the salt split chart data.
        /// </summary>
        /// <param name="numWeeks">The number weeks.</param>
        /// <param name="avgResinage">The average resin age.</param>
        /// <param name="startingSS">The starting system.</param>
        /// <param name="maxDegSS">The maximum deg system.</param>
        /// <param name="selectedTrain">The selected train.</param>
        /// <param name="CleaningEffectiveness">The cleaning effectiveness.</param>
        /// <param name="isDashboard">if set to <c>true</c> [is dashboard].</param>
        /// <returns></returns>
        private Highcharts FetchSaltSplitChartData(double numWeeks, double avgResinage, double startingSS, double maxDegSS, string selectedTrain, double CleaningEffectiveness, bool isDashboard)
        {
            try
            {
                Dictionary<double, double> currentSS = new Dictionary<double, double>();
                List<double> minimumSS = this.predictiveModelService.CalculateMinSaltSplit(Convert.ToInt64(this.Session["CustomerId"]), selectedTrain);
                double minimumSaltSplit = minimumSS[0];
                double dblResinAge;
                if (avgResinage == 0)
                {
                    dblResinAge = minimumSS[1];
                }
                else
                {
                    dblResinAge = avgResinage;
                }
                Number width, height;
                Dictionary<double, double> chartPoints = new Dictionary<double, double>();
                if (isDashboard == true)
                {
                    width = 500;
                    height = 290;
                }
                else
                {
                    width = 650;
                    height = 265;
                }
                chartPoints = this.predictiveModelService.ComputeDataPoints(numWeeks, startingSS, maxDegSS);
                Data data1 = new Data(new object[] { });
                int[] d = new int[chartPoints.Count];
                double pointstart;
                Point[] afterCleaningSS = new Point[1];
                Point[] currentSaltSplitPoints = new Point[1];
                Point[] chartdataPoints = new Point[chartPoints.Count];
                object[] minThresholdSeries = new object[chartPoints.Count];
                int i = 0;
                foreach (var item in chartPoints)
                {
                    chartdataPoints[i] = new Point();
                    chartdataPoints[i].X = item.Key;
                    chartdataPoints[i].Y = item.Value;
                    pointstart = Convert.ToDouble(chartPoints.Keys != null ? chartPoints.Keys.FirstOrDefault() : 0);
                    minThresholdSeries.SetValue(minimumSaltSplit, i);
                    i++;
                }
                Point point1 = new Point();
                Point point2 = new Point();
                currentSS = this.predictiveModelService.CurrentSSConditions(dblResinAge, CleaningEffectiveness, startingSS);
                this.currentSaltSplit = (currentSS != null && currentSS.Count > 0) ? currentSS.ElementAt(0).Value : 0;

                point1.X = (currentSS != null && currentSS.Count > 0) ? currentSS.ElementAt(0).Key : 0;
                point1.Y = (currentSS != null && currentSS.Count > 0) ? currentSS.ElementAt(0).Value : 0;
                afterCleaningSS[0] = point1;
                if (currentSS != null && currentSS.Count > 1)
                {
                    point2.X = currentSS.ElementAt(1).Key;
                    point2.Y = currentSS.ElementAt(1).Value;
                }
                currentSaltSplitPoints[0] = point2;
                Highcharts chart = new Highcharts("chart1")
                    .InitChart(new Chart { Width = width, Height = height, DefaultSeriesType = ChartTypes.Spline, ZoomType = ZoomTypes.Xy, SpacingRight = 30 })
                    .SetTitle(new Title { Text = "Salt Split Degradation" })
                    .SetCredits(new Credits { Enabled = false })
                    .SetTooltip(new Tooltip
                    {
                        HeaderFormat = "<b>{series.name}</b><br>",
                        PointFormat = "<b>Week :{point.x:.0f}<br> <b>Salt Split: {point.y:.2f}</b>"
                        ,
                        Enabled = true
                    })
                    .SetLegend(new Legend
                    {
                        BorderWidth = 1,
                    })
                    .SetXAxis(new XAxis
                    {
                        Type = AxisTypes.Linear,
                        MinRange = 0,
                        Max = numWeeks,
                        Title = new XAxisTitle { Text = "Number of Weeks" },
                        TickInterval = 50
                    })
                    .SetYAxis(new YAxis
                    {
                        Title = new YAxisTitle { Text = "Salt Split" },
                        Min = 0,
                        Max = 30,
                        StartOnTick = false,
                        EndOnTick = false,
                        TickInterval = 10,
                        PlotLines = new YAxisPlotLines[1] { new YAxisPlotLines { Value = minimumSaltSplit, Color = Color.Red, Width = 2, DashStyle = DashStyles.ShortDash,
                        Label = new YAxisPlotLinesLabel { Text = "MinimumSS For Demand=" + Math.Round(minimumSaltSplit, 2) + string.Empty } } }

                    })
                    .SetPlotOptions(new PlotOptions
                    {
                        Spline = new PlotOptionsSpline
                        {
                            LineWidth = 2,
                            Marker = new PlotOptionsSplineMarker
                            {
                                Enabled = false,
                                States = new PlotOptionsSplineMarkerStates
                                {
                                    Hover = new PlotOptionsSplineMarkerStatesHover
                                    {
                                        Enabled = true,
                                        Radius = 2
                                    }
                                }
                            },
                            Shadow = false,
                            States = new PlotOptionsSplineStates { Hover = new PlotOptionsSplineStatesHover { LineWidth = 1 } },
                            Point = new PlotOptionsSplinePoint()
                        }
                    })
                    .SetSeries(new[] { new Series{
                    Name = "Salt Split degradation",
                    Type = ChartTypes.Spline,
                    Data = new Data(chartdataPoints),
                    Color = Color.Green,

                },
                new Series
                {
                    Name = "Current SaltSplit",
                    Type = ChartTypes.Scatter,
                    Data = new Data(afterCleaningSS),
                    Color = Color.Blue
                },
                new Series
                {
                    Name = "After Cleaning SaltSplit",
                    Type = ChartTypes.Scatter,
                    Data = new Data(currentSaltSplitPoints),
                    Color = Color.DarkRed
                }
                });
                return chart;
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #7
0
		public static Highcharts EmployeeBarChart(this IEnumerable<DepartmentVM> departments, DepartmentChartGroupOption groupOption)
		{
			var categories = new string[0];
			var dataPoints = new Point[0];
			switch (groupOption)
			{
				case DepartmentChartGroupOption.Department:
					var orderedDepartments = departments.OrderBy(x => x.Name).ToList();
					categories = orderedDepartments.Select(x => x.Name).ToArray();
					dataPoints = orderedDepartments.Select(x => new Point { Name = x.Name, Y = x.EmployeeCount }).ToArray();
					break;
				case DepartmentChartGroupOption.DepartmentGroup:
					var orderedGroups = departments.GroupBy(x => x.GroupName).OrderBy(x => x.Key).ToList();
					categories = orderedGroups.Select(x => x.Key).ToArray();
					dataPoints = orderedGroups.Select(x => new Point { Name = x.Key, Y = x.Sum(y => y.EmployeeCount) }).ToArray();
					break;
			}

			return new Highcharts("departments") //this name becomes the div id, so it needs to be one word!!!
				.InitChart(new Chart { DefaultSeriesType = ChartTypes.Column })
				.SetXAxis(new XAxis { Categories = categories })
				.SetYAxis(new YAxis { Min = 0, Title = new YAxisTitle { Text = "Employees" } })
				.SetLegend(new Legend
					{
						Layout = Layouts.Vertical,
						Align = HorizontalAligns.Left,
						VerticalAlign = VerticalAligns.Top,
						X = 100,
						Y = 70,
						Floating = true,
						//BackgroundColor = ColorTranslator.FromHtml("#FFFFFF"),
						Shadow = true
					})
				.SetTooltip(new Tooltip { Formatter = @"function() { return ''+ this.x +': '+ this.y; }" })
				.SetPlotOptions(new PlotOptions
					{
						Column = new PlotOptionsColumn
							{
								PointPadding = 0.2,
								BorderWidth = 0
							}
					})
				.SetSeries(new Series
					{
						Name = "Employee count",
						Data = new Data(dataPoints)
					});

		}
コード例 #8
0
        /// <summary>
        /// Builds the high chart for Throughput chart
        /// </summary>
        /// <param name="tpCurveClean">TP curve clean</param>
        /// <param name="tpCurveNoClean">TP curve no clean</param>
        /// <param name="isDashboard">IsDashboard flag</param>
        /// <returns>Returns the high chart</returns>
        private Highcharts plotTPData(Dictionary<DateTime, Tuple<int, double, string>> tpCurveClean, Dictionary<DateTime, Tuple<int, double, string>> tpCurveNoClean, bool isDashboard)
        {
            try
            {
                double cleanAverage = 0;
                double noCleanAverage = 0;
                double xaxisMinValue = 0.0;
                double xaxisMaxValue = Convert.ToDouble(tpCurveClean.Last().Value.Item1);
                List<Point> replacePts = new List<Point>();
                List<Point> cleanedPts = new List<Point>();
                List<double> xseries = new List<double>();
                double[] chartdata1 = new double[tpCurveClean.Count];
                double[] chartdata2 = new double[tpCurveNoClean.Count];
                Point[] chartData_Point1 = new Point[tpCurveClean.Count];
                Point[] chartData_Point2 = new Point[tpCurveNoClean.Count];
                int counter = 0;
                Number width, height;
                foreach (DateTime dateTime in tpCurveClean.Keys)
                {
                    Tuple<int, double, string> tuple = tpCurveClean[dateTime];
                    chartData_Point1[counter] = new Point();
                    chartData_Point1[counter].X = tuple.Item1;
                    chartData_Point1[counter].Y = !double.IsInfinity(tuple.Item2) ? tuple.Item2 : 0;
                    chartdata1[counter] = !double.IsInfinity(tuple.Item2) ? tuple.Item2 : 0;
                    xseries.Add(tuple.Item1);
                    counter++;
                    if (tuple.Item3 == "Clean")
                    {
                        cleanedPts.Add(new Point() { X = tuple.Item1, Y = tuple.Item2 });
                    }
                }
                Number? MaximumWeek = chartData_Point1 != null && chartData_Point1.Length > 0 ? chartData_Point1[chartdata1.Count() - 1].X : 0;

                cleanAverage = chartdata1.Length > 0 ? chartdata1.Average() : 0;
                counter = 0;
                if (isDashboard == true)
                {
                    width = 500;
                    height = 290;
                }
                else
                {
                    width = 650;
                    height = 300;
                }
                foreach (DateTime dateTime in tpCurveNoClean.Keys)
                {
                    Tuple<int, double, string> tuple = tpCurveNoClean[dateTime];
                    chartData_Point2[counter] = new Point();
                    chartData_Point2[counter].X = tuple.Item1;
                    chartData_Point2[counter].Y = !double.IsInfinity(tuple.Item2) ? tuple.Item2 : 0;
                    chartdata2[counter] = !double.IsInfinity(tuple.Item2) ? tuple.Item2 : 0;
                    counter++;
                    if (tuple.Item3 == "Replace")
                    {
                        replacePts.Add(new Point() { X = tuple.Item1, Y = tuple.Item2 });
                    }
                }
                noCleanAverage = chartdata2.Length > 0 ? chartdata2.Average() : 0;
                xaxisMinValue = xseries.Count > 0 ? xseries[0] : 0;

                // Set up area color fill gradient parameters
                Gradient gradLine = new Gradient();
                int[] LinearGradient = new int[] { 0, 0, 0, 300 };
                gradLine.LinearGradient = LinearGradient;
                object[,] stops2 = new object[,] { { 0, "#F7EF9B" }, { 1, "#FFFFFF" } };
                gradLine.Stops = stops2;

                Series withCleaning = new Series
                {
                    Name = "With Cleaning",
                    Data = new Data(chartData_Point1),
                    PlotOptionsArea = new PlotOptionsArea
                    {
                        FillColor = new BackColorOrGradient(Color.FromArgb(30, 0, 128, 0)),
                        Color = Color.FromArgb(80, 153, 80)
                    }
                };

                Series withoutCleaning = new Series
                {
                    Name = "Without Cleaning",
                    Data = new Data(chartData_Point2),
                    PlotOptionsArea = new PlotOptionsArea
                    {
                        FillColor = new BackColorOrGradient(gradLine),
                        Color = System.Drawing.Color.Goldenrod
                    }
                };
                Highcharts chart1 = new Highcharts("chart")
                    .SetOptions(new GlobalOptions
                    {
                        Lang = new DotNet.Highcharts.Helpers.Lang { ThousandsSep = ",", DecimalPoint = "." }
                    })
                   .InitChart(new Chart { Width = width, Height = height, DefaultSeriesType = ChartTypes.Area, ZoomType = ZoomTypes.X, SpacingRight = 20 })
                   .SetTitle(new Title { Text = "Throughput Forecast" })
                   .SetTooltip(new Tooltip
                   {
                       HeaderFormat = "<b>Week: {point.x:.0f}</b><br>",
                       //PointFormat = "<b><span style=\"color:this.data.marker.fillcolor\">{series.name}: {point.y:,.2f}</b></span><br>",

                       // Use javascript function to control the tool tip coloring, to add a week number display, and to add thousands place seperartors
                       Formatter = @"function() {var s = [];var X = '';$.each(this.points, function(index,point){if((index%2)==0){s.push('<span style=""color:#E6B800;font-weight:bold;"">'+ point.series.name + ' : <span>' + '<b style=""font-weight:bold;"">' + point.y.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, "","") + '</b>');}else{s.push('<span style=""color:#509950;font-weight:bold;"">'+ point.series.name + ' : <span>' + '<b style=""font-weight:bold;"">' + point.y.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, "","") + '</b>');}X = point.x;});var header = '<span style=""font-weight:bold;"">Week: ' + X.toString() + '<span>';  s.splice(0, 0, header); var temp1 = s[1];var temp2 = s[2];s[1] = temp2;s[2] = temp1;if(s.length >= 5){temp1 = s[4];temp2 = s[3];s[4] = temp2;s[3] = temp1;}return s.join('<br>');}",
                       Enabled = true,
                       Shared = true
                   })
                   .SetXAxis(new XAxis
                   {
                       Title = new XAxisTitle { Text = "Number of Weeks" },
                       Type = AxisTypes.Linear,
                       MinRange = 0,
                       Min = xaxisMinValue,
                       Max = xaxisMaxValue,
                       TickInterval = 20,
                       Labels = new XAxisLabels { Formatter = "function() { return this.value;  }" }
                   })
                   .SetCredits(new Credits { Enabled = false })
                   .SetLegend(new Legend
                    {
                        BorderWidth = 1,
                    })
                   .SetYAxis(new YAxis
                   {
                       Title = new YAxisTitle { Text = "Throughput" },
                       Labels = new YAxisLabels { Formatter = "function() { return this.value; }" }
                   })
                   .SetPlotOptions(new PlotOptions
                   {
                       Area = new PlotOptionsArea
                       {
                           Marker = new PlotOptionsAreaMarker
                           {
                               Enabled = false,
                               Symbol = "circle",
                               Radius = 2,
                               States = new PlotOptionsAreaMarkerStates
                               {
                                   Hover = new PlotOptionsAreaMarkerStatesHover { Enabled = true }
                               }
                           },
                           PointInterval = 1,
                           PointStart = new PointStart(xaxisMinValue),
                       }
                   })
                   .SetSeries(new[] {  withoutCleaning, withCleaning,
                   new Series
                   {
                       Name = "Replace",
                       Type = ChartTypes.Scatter,
                       Data = new Data(replacePts.ToArray()),
                       Color = Color.Blue,
                   },
                   new Series
                   {
                       Name = "Clean",
                       Type = ChartTypes.Scatter,
                       Data = new Data(cleanedPts.ToArray()),
                       Color = Color.Red
                   },
                   new Series
                   {
                       Name = "Without Cleaning Average",
                       Type = ChartTypes.Spline,
                       Data = new Data(new[] { new Point
                                                       {
                                                           X = xaxisMinValue,
                                                           Y = noCleanAverage,
                                                       },
                                                       new Point
                                                       {
                                                           X = MaximumWeek,
                                                           Y = noCleanAverage,
                                                       }
                                                   }),
                       Color = Color.Goldenrod
            ,
                       PlotOptionsSpline=new PlotOptionsSpline
                       {
                           DashStyle=DashStyles.ShortDash,
                           LineWidth=1,
                           Marker = new PlotOptionsSplineMarker{Enabled = false},
                       }
                     },
                     new Series
                   {
                       Name = "With Cleaning Average",
                       Type = ChartTypes.Spline,
                       Data = new Data(new[] { new Point
                                                       {
                                                           X = xaxisMinValue,
                                                           Y = cleanAverage,
                                                       },
                                                       new Point
                                                       {
                                                           X = MaximumWeek,
                                                           Y = cleanAverage,
                                                       }
                                                   }),
                       Color = Color.ForestGreen,
                       PlotOptionsSpline=new PlotOptionsSpline
                       {
                           DashStyle=DashStyles.ShortDash,
                           LineWidth=1,
                           Marker = new PlotOptionsSplineMarker{Enabled = false}
                       }
                     }
                   }
                );
                return chart1;
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #9
0
        /// <summary>
        /// Builds the high chart for Throughput chart
        /// </summary>
        /// <param name="tpCurveClean">TP curve clean</param>
        /// <param name="tpCurveNoClean">TP curve no clean</param>
        /// <param name="isDashboard">IsDashboard flag</param>
        /// <returns>Returns the high chart</returns>
        private Highcharts plotTPData(Dictionary<DateTime, Tuple<int, double, string>> tpCurveClean, Dictionary<DateTime, Tuple<int, double, string>> tpCurveNoClean, bool isDashboard)
        {
            try
            {
                double cleanAverage = 0;
                double noCleanAverage = 0;
                double xaxisMinValue = 0.0;
                double xaxisMaxValue = Convert.ToDouble(tpCurveClean.Last().Value.Item1);
                List<Point> replacePts = new List<Point>();
                List<Point> cleanedPts = new List<Point>();
                List<double> xseries = new List<double>();
                double[] chartdata1 = new double[tpCurveClean.Count];
                double[] chartdata2 = new double[tpCurveNoClean.Count];
                Point[] chartData_Point1 = new Point[tpCurveClean.Count];
                Point[] chartData_Point2 = new Point[tpCurveNoClean.Count];
                int counter = 0;
                Number width, height;
                foreach (DateTime dateTime in tpCurveClean.Keys)
                {
                    Tuple<int, double, string> tuple = tpCurveClean[dateTime];
                    chartData_Point1[counter] = new Point();
                    chartData_Point1[counter].X = tuple.Item1;
                    chartData_Point1[counter].Y = !double.IsInfinity(tuple.Item2) ? tuple.Item2 : 0;
                    chartdata1[counter] = !double.IsInfinity(tuple.Item2) ? tuple.Item2 : 0;
                    xseries.Add(tuple.Item1);
                    counter++;
                    if (tuple.Item3 == "Clean")
                    {
                        cleanedPts.Add(new Point() { X = tuple.Item1, Y = tuple.Item2 });
                    }
                }
                Number? MaximumWeek = chartData_Point1 != null && chartData_Point1.Length > 0 ? chartData_Point1[chartdata1.Count() - 1].X : 0;

                cleanAverage = chartdata1.Length > 0 ? chartdata1.Average() : 0;
                counter = 0;
                if (isDashboard == true)
                {
                    width = 500;
                    height = 290;
                }
                else
                {
                    width = 650;
                    height = 300;
                }
                foreach (DateTime dateTime in tpCurveNoClean.Keys)
                {
                    Tuple<int, double, string> tuple = tpCurveNoClean[dateTime];
                    chartData_Point2[counter] = new Point();
                    chartData_Point2[counter].X = tuple.Item1;
                    chartData_Point2[counter].Y = !double.IsInfinity(tuple.Item2) ? tuple.Item2 : 0;
                    chartdata2[counter] = !double.IsInfinity(tuple.Item2) ? tuple.Item2 : 0;
                    counter++;
                    if (tuple.Item3 == "Replace")
                    {
                        replacePts.Add(new Point() { X = tuple.Item1, Y = tuple.Item2 });
                    }
                }
                noCleanAverage = chartdata2.Length > 0 ? chartdata2.Average() : 0;
                xaxisMinValue = xseries.Count > 0 ? xseries[0] : 0;

                // Set up area color fill gradient parameters
                Gradient gradLine = new Gradient();
                int[] LinearGradient = new int[] { 0, 0, 0, 300 };
                gradLine.LinearGradient = LinearGradient;
                object[,] stops2 = new object[,] { { 0, "#F7EF9B" }, { 1, "#FFFFFF" } };
                gradLine.Stops = stops2;

                Series withCleaning = new Series
                {
                    Name = "With Cleaning",
                    Data = new Data(chartData_Point1),
                    PlotOptionsArea = new PlotOptionsArea
                    {
                        FillColor = new BackColorOrGradient(Color.FromArgb(30, 0, 128, 0)),
                        Color = Color.FromArgb(80, 153, 80)
                    }
                };

                Series withoutCleaning = new Series
                {
                    Name = "Without Cleaning",
                    Data = new Data(chartData_Point2),
                    PlotOptionsArea = new PlotOptionsArea
                    {
                        FillColor = new BackColorOrGradient(gradLine),
                        Color = System.Drawing.Color.Goldenrod
                    }
                };
                Highcharts chart1 = new Highcharts("chart")
                    .SetOptions(new GlobalOptions
                    {
                        Lang = new DotNet.Highcharts.Helpers.Lang { ThousandsSep = ",", DecimalPoint = "." }
                    })
                   .InitChart(new Chart { Width = width, Height = height, DefaultSeriesType = ChartTypes.Area, ZoomType = ZoomTypes.Xy, SpacingRight = 20 })
                   .SetTitle(new Title { Text = "Throughput Forecast" })
                   .SetTooltip(new Tooltip
                   {
                       HeaderFormat = "<b>Week: {point.x:.0f}</b><br>",
                       PointFormat = "<b>{series.name}: {point.y:,.2f}</b><br>",
                       Enabled = true,
                       Shared = true
                   })
                   .SetXAxis(new XAxis
                   {
                       Title = new XAxisTitle { Text = "Number of Weeks" },
                       Type = AxisTypes.Linear,
                       MinRange = xaxisMinValue,
                       Min = xaxisMinValue,
                       Max = xaxisMaxValue,
                       TickInterval = 20,
                       Labels = new XAxisLabels { Formatter = "function() { return this.value;  }" }
                   })
                   .SetCredits(new Credits { Enabled = false })
                   .SetLegend(new Legend
                   {
                       BorderWidth = 1,
                   })
                   .SetYAxis(new YAxis
                   {
                       Title = new YAxisTitle { Text = "Throughput" },
                       Labels = new YAxisLabels { Formatter = "function() { return this.value; }" }
                   })
                   .SetPlotOptions(new PlotOptions
                   {
                       Area = new PlotOptionsArea
                       {
                           Marker = new PlotOptionsAreaMarker
                           {
                               Enabled = false,
                               Symbol = "circle",
                               Radius = 2,
                               States = new PlotOptionsAreaMarkerStates
                               {
                                   Hover = new PlotOptionsAreaMarkerStatesHover { Enabled = true }
                               }
                           },
                           PointInterval = 1,
                           PointStart = new PointStart(xaxisMinValue),
                       }
                   })
                   .SetSeries(new[] {  withoutCleaning, withCleaning,
                   new Series
                   {
                       Name = "Replace",
                       Type = ChartTypes.Scatter,
                       Data = new Data(replacePts.ToArray()),
                       Color = Color.Blue,
                   },
                   new Series
                   {
                       Name = "Clean",
                       Type = ChartTypes.Scatter,
                       Data = new Data(cleanedPts.ToArray()),
                       Color = Color.Red
                   },
                   new Series
                   {
                       Name = "Without Cleaning Average",
                       Type = ChartTypes.Spline,
                       Data = new Data(new[] { new Point
                                                       {
                                                           X = xaxisMinValue,
                                                           Y = noCleanAverage,
                                                       },
                                                       new Point
                                                       {
                                                           X = MaximumWeek,
                                                           Y = noCleanAverage,
                                                       }
                                                   }),
                       Color = Color.Goldenrod
            ,
                       PlotOptionsSpline=new PlotOptionsSpline
                       {
                           DashStyle=DashStyles.ShortDash,
                           LineWidth=1,
                           Marker = new PlotOptionsSplineMarker{Enabled = false},
                       }
                     },
                     new Series
                   {
                       Name = "With Cleaning Average",
                       Type = ChartTypes.Spline,
                       Data = new Data(new[] { new Point
                                                       {
                                                           X = xaxisMinValue,
                                                           Y = cleanAverage,
                                                       },
                                                       new Point
                                                       {
                                                           X = MaximumWeek,
                                                           Y = cleanAverage,
                                                       }
                                                   }),
                       Color = Color.ForestGreen,
                       PlotOptionsSpline=new PlotOptionsSpline
                       {
                           DashStyle=DashStyles.ShortDash,
                           LineWidth=1,
                           Marker = new PlotOptionsSplineMarker{Enabled = false}
                       }
                     }
                   }
                );
                return chart1;
            }
            catch (Exception)
            {
                throw;
            }
        }