Inheritance: ChartElementBase
        private static void FillData(DataSetElement dataSet, 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
                          };

                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);
                    set.Link.Width = 600;
                    set.Link.Height = 400;
                }

                dataSet.AddSet(set);
            }
        }
        private static void FillData(DataSetElement dataSet, int factoryId, string chartName) {
            //
            // Build Data
            //
            var outputs = FactoryRepository.FindAllFactoryOutputByFactoryId(factoryId);

            var num = 0;
            foreach(var output in outputs) {
                SetElementBase set;
                if(chartName == "Scatter")
                    set = new XYSetElement(output.DatePro.Value.DayOfYear, output.Quantity ?? 0);
                else
                    set = new XYSetElement(output.DatePro.Value.DayOfYear, output.DatePro.Value.DayOfYear, output.Quantity ?? 0);

                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;
                }

                dataSet.AddSet(set);
            }
        }
        private static void AddSeries(RadarChart radar, string seriesName, int count) {
            var dataset = new DataSetElement { SeriesName = seriesName };
            for(int i = 0; i < count; i++)
                dataset.AddSet(new ValueSetElement(rnd.Next(3, 10)));

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

            var chart = new MultiSeriesChart
                        {
                            Caption = "Factory 정보",
                            SubCaption = "일일 생산량",
                            Palette = rnd.Next(1, 5),
                            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
                        };

            var outputs = FactoryRepository.FindAllFactoryOutputByFactoryId(factoryId);
            foreach(var output in outputs) {
                chart.AddCategory(output.DatePro.Value.ToMonthDayString(), true);
                //var category = new CategoryElement
                //               {
                //                   Label = output.DatePro.Value.ToMonthDayString()
                //               };
                // chart.Categories.CategoryElements.Add(category);
            }


            for(int i = 1; i < 4; i++) {
                var dataSet = new DataSetElement
                              {
                                  SeriesName = "Factory " + i,
                                  ShowValues = false
                              };
                FillData(dataSet, i);
                chart.DataSets.Add(dataSet);
            }

            return chart;
        }
 private static void FillDataSet(DataSetElement dataset, double min, double max, double step, double avg, double stDev) {
     var stDev2 = stDev * stDev;
     for(var x = min; x <= max; x += step) {
         var s = x - avg;
         var fs = 100 * Math.Exp(-s * s / stDev2);
         dataset.AddSet(new ValueSetElement(fs));
     }
 }
        /// <summary>
        /// 원하는 Chart를 빌드합니다.
        /// </summary>
        public override IChart BuildFusionChart() {
            var min = Request["Min"].AsDouble(-5.0);
            var max = Request["Max"].AsDouble(5.0);
            var step = Request["Step"].AsDouble(0.2);

            var avgs = new List<double>();
            var stDevs = new List<double>();

            var i = 0;
            while(true) {
                // Request Parameter로 ND0=avg,stDev&ND1=avg2,stDev2 이런 식으로 오는 것을 파싱한다.
                //
                var nd = Request["ND" + i++].AsText();

                if(nd.IsWhiteSpace())
                    break;
                var avgStDev = nd.Split(",");

                avgs.Add(avgStDev[0].AsDouble(0.0));
                stDevs.Add(avgStDev[1].AsDouble(0.0));
            }

            var chart = new MultiSeriesChart
                        {
                            Caption = "정규분포도",
                            SubCaption = "다중",
                            Palette = rnd.Next(1, 5),
                            XAxisName = "X",
                            YAxisName = "Frequency",
                            NumVisiblePlot = MaxPlotNumber / 2,
                            LabelStep = 5,
                            BaseFontAttr = { Font = "맑은 고딕", FontSize = "16" },
                            BorderAttr = { Show = true },
                            ShowLabels = true,
                            RotateLabels = true,
                            ShowValues = false,
                            BackgroundAttr =
                            {
                                BgColor = Color.WhiteSmoke,
                                BgAlpha = 100
                            },
                            ShowShadow = true,
                        };

            chart.Categories.FontAttr.FontSize = "12";
            FillCategories(chart.Categories, min, max, step);

            for(var x = 0; x < avgs.Count; x++) {
                var dataset = new DataSetElement();
                FillDataSet(dataset, min, max, step, avgs[x], stDevs[x]);
                chart.DataSets.Add(dataset);
                chart.VTrendLines.Add(new DoubleLineElement
                                      {
                                          StartValue = avgs[x],
                                          Color = Color.Brown,
                                          DisplayValue = "Average"
                                      });
            }

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

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

            chart.ShowShadow = true;

            var outputs = FactoryRepository.FindAllFactoryOutputByFactoryId(factoryId);
            foreach(var output in outputs) {
                chart.AddCategory(output.DatePro.Value.ToMonthDayString(), true);
                //var category = new CategoryElement
                //               {
                //                   Label = output.DatePro.Value.ToMonthDayString()
                //               };
                // chart.Categories.CategoryElements.Add(category);
            }


            for(int i = 1; i < 4; i++) {
                var dataSet = new DataSetElement
                              {
                                  SeriesName = "Factory " + i.ToString(),
                                  ShowValues = false,
                                  RenderAs = (i % 4 == 1) ? GraphKind.Area : ((i % 4 == 3) ? GraphKind.Line : GraphKind.Column)
                              };

                if(lineDual == 1 && i == 3) {
                    dataSet.RenderAs = GraphKind.Line;
                    dataSet.ParentYAxis = YAxisKind.S;
                }

                FillData(dataSet, i);
                chart.DataSets.Add(dataSet);
            }

            chart.TrendLines.Add(new DoubleLineElement
                                 {
                                     StartValue = 120,
                                     DisplayValue = "Good",
                                     Color = "#009933".FromHtml()
                                 });
            //chart.TrendLines.TrendlineElements.Add(new DoubleLineElement
            //                                       {
            //                                           StartValue = 120,
            //                                           DisplayValue = "Good",
            //                                           Color = "#009933".FromHtml()
            //                                       });

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

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

            chart.ShowShadow = true;

            var outputs = FactoryRepository.FindAllFactoryOutputByFactoryId(factoryId);
            foreach(var output in outputs) {
                chart.AddCategory(output.DatePro.Value.ToMonthDayString(), true);
                //var category = new CategoryElement
                //               {
                //                   Label = output.DatePro.Value.ToMonthDayString()
                //               };
                //chart.Categories.CategoryElements.Add(category);
            }


            for(int d = 0; d < 2; d++) {
                var datasetCollection = new DataSetCollection();

                for(int i = 1; i < 4; i++) {
                    var dataSet = new DataSetElement
                                  {
                                      SeriesName = "Factory " + i,
                                      ShowValues = false
                                  };

                    if(lineDual == 1 && i == 3) {
                        dataSet.RenderAs = GraphKind.Line;
                        dataSet.ParentYAxis = YAxisKind.S;
                    }

                    FillData(dataSet, i);
                    datasetCollection.Add(dataSet);
                }
                chart.DataSetCollections.Add(datasetCollection);
            }

            // add LineSet
            chart.LineSet.SeriesName = "Cost as % of Revenue";

            foreach(var output in outputs) {
                chart.LineSet.SetElements.Add(new ValueSetElement { Value = rnd.Next(40, 100) });
            }

            return chart;
        }