/// <summary>
        /// 원하는 Chart를 빌드합니다.
        /// </summary>
        public override IChart BuildFusionChart()
        {
            var factoryId      = Request["FactoryId"].AsInt(1);
            var numVisiblePlot = Request["numVisiblePlot"].AsInt(12);

            var chart = new SingleSeriesChart
            {
                Caption    = "Factory" + factoryId + " 정보",
                SubCaption = "일일 생산량",
                Palette    = Math.Max(1, Math.Min(5, factoryId)),
                //RotateLabels = true,
                //PlaceValuesInside = true,
                //RotateValues = true,
                XAxisName      = "Day",
                YAxisName      = "Units",
                NumVisiblePlot = numVisiblePlot,
                BaseFontAttr   = { Font = "맑은 고딕" },
                BorderAttr     = { Show = true },
                BackgroundAttr = { BgColor = Color.White, BgAlpha = 100 },
                ShowShadow     = true
            };

            FillData(chart, factoryId);

            return(chart);
        }
Beispiel #2
0
        public override IChart BuildFusionChart()
        {
            ParseParameters();

            var chart = new SingleSeriesChart
            {
                Caption    = "사용자 정의 그래프",
                SubCaption = Expression,
                Palette    = rnd.Next(1, 5),
                XAxisName  = "X",
                YAxisName  = "Y",
                //NumVisiblePlot = VarCount / 10,
                LabelStep      = Math.Min(VarCount / 50, 50),
                BaseFontAttr   = { Font = "맑은 고딕", FontSize = "16" },
                BorderAttr     = { Show = true },
                ShowLabels     = true,
                RotateLabels   = false,
                ShowValues     = false,
                BackgroundAttr =
                {
                    BgColor = Color.WhiteSmoke,
                    BgAlpha = 100
                },
                ShowShadow = true,
            };

            chart.Categories.FontAttr.FontSize = "8";

            BuildExpressionGraph(chart);

            return(chart);
        }
        private static void FillData(SingleSeriesChart chart, int factoryId)
        {
            //
            // Build Data
            //
            var outputs = FactoryRepository.FindAllFactoryOutputByFactoryId(factoryId);

            var num = 0;

            foreach (var output in outputs)
            {
                var set = new ValueSetElement
                {
                    Label = output.DatePro.Value.ToShortDateString(),
                    Value = output.Quantity ?? 0
                };

                switch (num % 4)
                {
                case 0:
                    set.Link.SetLink(FusionLinkMethod.Local, "javascript:PopUp('April')");
                    break;

                case 1:
                    set.Link.SetLink(FusionLinkMethod.PopUp,
                                     WebTool.GetScriptPath("~/Charts/Ajax/Default.aspx?FactoryId=") + factoryId);
                    break;

                case 2:
                    set.Link.SetFameLink(WebTool.GetScriptPath("~/Charts/Ajax/Default.aspx?FactoryId=") + factoryId, "_blank");
                    break;

                case 3:
                    set.Link.SetJavascriptLink("PopUp", "April");
                    break;

                default:
                    set.Link.SetLink(FusionLinkMethod.Local, "http://www.realweb21.com");
                    break;
                }

                num++;
                //if ((num++ % 2) == 0)
                //    set.Link.SetLink(FusionLinkMethod.Local, "javascript:PopUp('April');"); // 실제 Javascript 메소드를 쓰려면 "PopUp-April" 로만 쓰면 된다.
                //else
                //{
                //    set.Link.SetLink(FusionLinkMethod.PopUp, WebTool.GetScriptPath("~/Charts/Ajax/Default.aspx?FactoryId=") + factoryId.ToString());
                //    set.Link.Width = 600;
                //    set.Link.Height = 400;
                //}

                chart.SetElements.Add(set);
            }
        }
Beispiel #4
0
        private void BuildExpressionGraph(SingleSeriesChart chart)
        {
            var expr = new NCalc.Expression(Expression, EvaluateOptions.IgnoreCase | EvaluateOptions.IterateParameters);

            var step = (Upper - Lower) / VarCount;

            var x = EnumerableTool.Step(Lower, Upper, step).ToArray();

            expr.Parameters["x"] = x;

            var y = ((IEnumerable)expr.Evaluate()).ToListUnsafe <double>();

            for (var i = 0; i < x.Length; i++)
            {
                chart.SetElements.Add(new ValueSetElement(y[i])
                {
                    Label = x[i].ToString("#.0")
                });
            }
        }
        private static void FillNormalDistributionData(SingleSeriesChart chart, double avg, double stDev)
        {
            var min  = avg - 5.0;
            var max  = avg + 5.0;
            var step = (max - min) / 100.0;

            var stDev2 = stDev * stDev;

            for (var x = min; x < max; x += step)
            {
                var s = x - avg;
                var y = 100 * Math.Exp(-s * s / stDev2);
                chart.SetElements.Add(new ValueSetElement(y)
                {
                    Label = x.ToString("#.0")
                });
            }
            chart.VTrendLines.Add(new DoubleLineElement
            {
                StartValue   = avg,
                Color        = Color.Brown,
                DisplayValue = "Average"
            });
        }