Ejemplo n.º 1
0
        public JsonResult GetJobProfileByCategoriesChartData()
        {
            var curJob = this.jobsRepo.FindOne(new ByIdSpecify <Job>(this.CurrentJobId));

            var skillCatNames = curJob.JobSkills.Select(x => x.SkillCategory).Distinct().Select(x => x.Name);

            var skillCatGroupedData = curJob.JobSkills.GroupBy(g => g.SkillCategoryId);

            var skillsData = new List <ChartSeriesModel>();

            foreach (var skillCat in skillCatGroupedData)
            {
                if (skillCat.Any())
                {
                    var skillData = new ChartSeriesModel
                    {
                        Name = skillCat.First().SkillCategory.Name,
                        CategoryAvgEstimate = Math.Round((double)skillCat.Sum(x => x.Estimate) / skillCat.Count(), 2)
                    };

                    foreach (var jobSkill in skillCat)
                    {
                        skillData.Categories.Add(jobSkill.Skill.Name);
                        skillData.Data.Add(jobSkill.Estimate);
                    }

                    skillsData.Add(skillData);
                }
            }

            return(this.Json(
                       new { SkillCatNames = skillCatNames, SkillsData = skillsData },
                       JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
        private void UpdatePresenters(ChartLayoutContext context)
        {
            int index = 0;
            ChartSeriesModel series = this.Model;

            if (this.chart.chartArea.IsTreeLoaded && (this.HasPointTemplate || this.SupportsDefaultVisuals))
            {
                foreach (DataPoint point in series.DataPointsInternal)
                {
                    // point is empty or is laid-out outside the clip area, skip it from visualization.
                    if (point.isEmpty || !context.ClipRect.IntersectsWith(point.layoutSlot))
                    {
                        continue;
                    }

                    FrameworkElement element = this.GetDataPointVisual(point, index);
                    if (element != null)
                    {
                        this.ArrangeUIElement(element, point.layoutSlot);
                        index++;
                    }
                }
            }

            while (index < this.realizedDataPointPresenters.Count)
            {
                var presenter = this.realizedDataPointPresenters[index];
                if (presenter.Visibility == Visibility.Visible)
                {
                    presenter.Visibility = Visibility.Collapsed;
                }
                index++;
            }
        }
Ejemplo n.º 3
0
        protected virtual void GenerateDataPoints(SizedQueue longPeriodItems, SizedQueue shortPeriodItems, SizedQueue signalPeriodItems)
        {
            ChartSeriesModel model = this.Owner.Model;

            int currentIndex = 0;
            CategoricalDataPoint point;
            double signalEMA = 0d;
            double macd      = 0d;

            foreach (var item in this.itemsSource)
            {
                macd = this.CalculateMacdValue(longPeriodItems, shortPeriodItems, currentIndex, item);
                signalPeriodItems.EnqueueItem(macd);

                signalEMA = CalculateSignal(this.signalPeriod, signalPeriodItems, currentIndex, signalEMA, macd);

                if (model.DataPointsInternal.Count > currentIndex)
                {
                    point       = model.DataPointsInternal[currentIndex] as CategoricalDataPoint;
                    point.Value = macd - signalEMA;
                }
                else
                {
                    point       = this.GenerateDataPoint(item, -1) as CategoricalDataPoint;
                    point.Value = macd - signalEMA;
                    model.DataPointsInternal.Add(point);
                }

                currentIndex++;
            }
        }
        protected override void BindCore()
        {
            int currentIndex = 0;

            StochasticSlowIndicator owner       = this.Owner as StochasticSlowIndicator;
            ChartSeriesModel        model       = this.Owner.Model;
            ChartSeriesModel        signalModel = owner.SignalModel;

            int currentMainPeriod    = this.MainPeriod;
            int currentSlowingPeriod = this.SlowingPeriod;
            int currentSignalPeriod  = this.SignalPeriod;

            SizedQueue highValues      = new SizedQueue(currentMainPeriod);
            SizedQueue lowValues       = new SizedQueue(currentMainPeriod);
            SizedQueue fastStochValues = new SizedQueue(currentSlowingPeriod);
            SizedQueue slowStochValues = new SizedQueue(currentSignalPeriod);

            foreach (var item in this.itemsSource)
            {
                double high  = (double)this.HighBinding.GetValue(item);
                double low   = (double)this.LowBinding.GetValue(item);
                double close = (double)this.CloseBinding.GetValue(item);

                double fastStochValue = CalculateMainValue(highValues, lowValues, high, low, close);
                fastStochValues.EnqueueItem(fastStochValue);

                double slowStochValue = MovingAverageIndicatorDataSource.CalculateCurrentValue(fastStochValues);
                slowStochValues.EnqueueItem(slowStochValue);

                double slowSignalValue = MovingAverageIndicatorDataSource.CalculateCurrentValue(slowStochValues);

                CategoricalDataPoint point, point2;
                if (model.DataPointsInternal.Count > currentIndex)
                {
                    point       = model.DataPointsInternal[currentIndex] as CategoricalDataPoint;
                    point.Value = slowStochValue;
                }
                else
                {
                    point       = this.GenerateDataPoint(item, -1) as CategoricalDataPoint;
                    point.Value = slowStochValue;
                    model.DataPointsInternal.Add(point);
                }

                if (signalModel.DataPointsInternal.Count > currentIndex)
                {
                    point2       = signalModel.DataPointsInternal[currentIndex] as CategoricalDataPoint;
                    point2.Value = slowSignalValue;
                }
                else
                {
                    point2       = this.GenerateDataPoint(item, -1) as CategoricalDataPoint;
                    point2.Value = slowSignalValue;
                    signalModel.DataPointsInternal.Add(point2);
                }

                currentIndex++;
            }
        }
Ejemplo n.º 5
0
        private void UpdatePresenters(ChartLayoutContext context)
        {
            int index = 0;
            ChartSeriesModel series = this.Model;

            if (this.HasPointTemplate || this.SupportsDefaultVisuals)
            {
                foreach (DataPoint point in series.DataPointsInternal)
                {
                    // point is laid-out outside the clip area, skip it from visualization
                    if (!context.ClipRect.IntersectsWith(point.layoutSlot))
                    {
                        continue;
                    }

                    if (this.drawWithComposition)
                    {
                        var containerVisual = this.GetContainerVisual(index);
                        this.chart.ContainerVisualsFactory.PrepareBarIndicatorVisual(containerVisual, point);
                        index++;
                    }
                    else
                    {
                        FrameworkElement element = this.GetDataPointVisual(point, index);
                        if (element != null)
                        {
                            this.ArrangeUIElement(element, point.layoutSlot);
                            index++;
                        }
                    }
                }
            }

            if (this.drawWithComposition)
            {
                while (index < this.realizedVisualDataPoints.Count)
                {
                    this.realizedVisualDataPoints[index].IsVisible = false;
                    index++;
                }
            }
            else
            {
                while (index < this.realizedDataPoints.Count)
                {
                    this.realizedDataPoints[index].Visibility = Visibility.Collapsed;
                    index++;
                }
            }
        }
Ejemplo n.º 6
0
        public JsonResult GetOptionByBarChart(GridPager pager, string queryStr)
        {
            List <Spl_ProductModel> list      = m_BLL.GetList(ref pager, queryStr);
            List <decimal?>         costPrice = new List <decimal?>();

            list.ForEach(a => costPrice.Add(a.CostPrice));
            List <decimal?> price = new List <decimal?>();

            list.ForEach(a => price.Add(a.Price));
            List <string> names = new List <string>();

            list.ForEach(a => names.Add(a.Name));
            List <ChartSeriesModel> seriesList = new List <ChartSeriesModel>();
            ChartSeriesModel        series1    = new ChartSeriesModel()
            {
                name = "成本价",
                type = "bar",
                data = costPrice
            };
            ChartSeriesModel series2 = new ChartSeriesModel()
            {
                name = "零售价",
                type = "bar",
                data = price
            };

            seriesList.Add(series1);
            seriesList.Add(series2);
            var option = new
            {
                title   = new{ text = "成本价零售价对照表" },
                tooltip = new{},
                legend  = new { data = "成本价零售价对照表" },
                xAxis   = new{ data = names },
                yAxis   = new{},
                series  = seriesList
            };

            return(Json(option));
        }
Ejemplo n.º 7
0
        public JsonResult GetOptionByBarChart2(GridPager pager, string queryStr)
        {
            List <ProductPillarModel> list      = m_BLL.GetListByPillar(ref pager, queryStr);
            List <decimal?>           costPrice = new List <decimal?>();

            list.ForEach(a => costPrice.Add(a.Price));
            List <decimal?> numbers = new List <decimal?>();

            list.ForEach(a => numbers.Add(a.Number));
            List <string> names = new List <string>();

            list.ForEach(a => names.Add(a.Name + "(" + a.Color + ")"));
            List <ChartSeriesModel> seriesList = new List <ChartSeriesModel>();
            ChartSeriesModel        series1    = new ChartSeriesModel()
            {
                name = "价格",
                type = "bar",
                data = costPrice
            };
            ChartSeriesModel series2 = new ChartSeriesModel()
            {
                name = "销量",
                type = "bar",
                data = numbers
            };

            seriesList.Add(series1);
            seriesList.Add(series2);
            var option = new
            {
                title   = new { text = "销量和价格对照表" },
                tooltip = new { },
                legend  = new { data = new string[] { "价格", "销量" } },
                xAxis   = new { data = names },
                yAxis   = new { },
                series  = seriesList
            };

            return(Json(option));
        }
Ejemplo n.º 8
0
        private void UpdateLabels(ChartLayoutContext context)
        {
            int index = 0;
            ChartSeriesModel series = this.Model;
            ChartSeriesLabelUpdateContext labelContext = new ChartSeriesLabelUpdateContext();

            labelContext.PlotDirection = this.Model.GetTypedValue <AxisPlotDirection>(AxisModel.PlotDirectionPropertyKey, AxisPlotDirection.Vertical);
            labelContext.IsPlotInverse = this.Model.GetIsPlotInverse(labelContext.PlotDirection);

            if (this.showLabelsCache)
            {
                foreach (DataPoint point in series.DataPointsInternal)
                {
                    // point is empty or is laid-out outside the clip area, skip it from visualization.
                    if (point.isEmpty || !context.ClipRect.IntersectsWith(point.layoutSlot))
                    {
                        continue;
                    }

                    labelContext.Point             = point;
                    labelContext.PointVirtualIndex = index;
                    this.ProcessDataPointLabels(labelContext);
                    index++;
                }
            }

            while (index < this.labels.Count)
            {
                List <FrameworkElement> pointLabels = this.labels[index].Value;
                foreach (FrameworkElement label in pointLabels)
                {
                    label.Visibility = Visibility.Collapsed;
                }
                index++;
            }
        }
Ejemplo n.º 9
0
        private void UpdatePresenters(ChartLayoutContext context)
        {
            int index = 0;
            ChartSeriesModel series = this.Model;

            if (this.chart.chartArea.IsTreeLoaded && (this.HasPointTemplate || this.SupportsDefaultVisuals))
            {
                foreach (DataPoint point in series.DataPointsInternal)
                {
                    // point is empty or is laid-out outside the clip area, skip it from visualization.
                    if (point.isEmpty || !context.ClipRect.IntersectsWith(point.layoutSlot))
                    {
                        if (this.drawWithComposition)
                        {
                            var containerVisual = this.GetContainerVisual(index, point);
                            if (containerVisual.IsVisible)
                            {
                                containerVisual.IsVisible = false;
                            }

                            index++;
                        }
                        continue;
                    }

                    if (this.drawWithComposition)
                    {
                        var containerVisual = this.GetContainerVisual(index, point);
                        this.chart.ContainerVisualsFactory.PreparePointTemplateSeriesVisual(containerVisual, point);
                        if (!containerVisual.IsVisible)
                        {
                            containerVisual.IsVisible = true;
                        }
                        index++;
                    }
                    else
                    {
                        FrameworkElement element = this.GetDataPointVisual(point, index);
                        if (element != null)
                        {
                            this.ArrangeUIElement(element, point.layoutSlot);
                            index++;
                        }
                    }
                }
            }

            if (this.drawWithComposition)
            {
                while (index < this.realizedContainerVisuals.Count)
                {
                    var containerVisual = this.realizedContainerVisuals.Keys.ElementAtOrDefault(index);
                    if (containerVisual != null && containerVisual.IsVisible)
                    {
                        containerVisual.IsVisible = false;
                    }

                    index++;
                }
            }
            else
            {
                while (index < this.realizedDataPointPresenters.Count)
                {
                    var presenter = this.realizedDataPointPresenters[index];
                    if (presenter.Visibility == Visibility.Visible)
                    {
                        presenter.Visibility = Visibility.Collapsed;
                    }

                    index++;
                }
            }
        }
Ejemplo n.º 10
0
        public JsonResult GetJobProfileSkillsChartData(long?jobId, long?candidateId)
        {
            var skillsData = new List <ChartSeriesModel>();
            var skillNames = new List <string>();
            Job curJob     = null;

            if (jobId.HasValue)
            {
                curJob = this.jobsRepo.FindOne(new ByIdSpecify <Job>(jobId.Value));

                skillNames.AddRange(curJob.JobSkills.Where(x => x.Estimate > 0).Select(x => x.Skill).Select(x => x.Name));

                skillsData.Add(new ChartSeriesModel
                {
                    Name  = "Job Profile",
                    Data  = curJob.JobSkills.Where(x => x.Estimate > 0).Select(x => double.Parse(x.Estimate.ToString())).ToList(),
                    YAxis = 0
                });
            }

            if (candidateId.HasValue)
            {
                var candidate = this.usersRepo.FindOne(new ByIdSpecify <User>(candidateId.Value));

                var seriesName = string.Format("{0} {1} Profile", candidate.LastName, candidate.FirstName);

                var userSkills = new List <UserSkill>();
                if (curJob != null)
                {
                    userSkills = candidate.UsersSkills.Where(x => curJob.JobSkills.Any(a => a.SkillId == x.SkillId && a.Estimate > 0)).ToList();
                }
                else
                {
                    skillNames.AddRange(candidate.UsersSkills.Select(x => x.Skill).Select(x => x.Name));
                    userSkills = candidate.UsersSkills.ToList();
                }

                skillsData.Add(new ChartSeriesModel
                {
                    Name  = seriesName,
                    Data  = userSkills.Select(x => double.Parse(x.Estimate.ToString())).ToList(),
                    YAxis = 0
                });

                // Select TestResults for candidate skills
                var testResults = candidate.TestResults.Where(x => userSkills.Any(s => s.SkillId == x.Test.SkillId)).ToList();

                var skillTestRes = new ChartSeriesModel
                {
                    Name  = "Test Results",
                    YAxis = 1
                };
                foreach (var skill in userSkills)
                {
                    var testRes = testResults.FirstOrDefault(x => x.Test.SkillId == skill.SkillId);
                    if (testRes != null)
                    {
                        // Percent correct answers
                        var totalQuestions = testRes.Test.Questions.Count;
                        var correctAnswers = testRes.ResultQuestions.Count(x => x.ResultAnswers.Any(a => a.IsCorrect && a.IsChoisen));
                        skillTestRes.Data.Add(Math.Round((double)correctAnswers / totalQuestions * 100, 2));
                    }
                    else
                    {
                        skillTestRes.Data.Add(0);
                    }
                }

                skillsData.Add(skillTestRes);
            }

            return(this.Json(new { SkillNames = skillNames, SkillsData = skillsData }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 11
0
        public ActionResult GetReportData(int type, int qKyUnit, int qCreator, string qKyDate1, string qKyDate2, int userId, int unitId, int dataType)
        {
            List <string>           names      = new List <string>();
            List <ChartSeriesModel> seriesList = new List <ChartSeriesModel>();
            List <int>           nums          = new List <int>();
            List <DataZoomModel> dzList        = new List <DataZoomModel>();
            ChartSeriesModel     csm           = new ChartSeriesModel();
            string rsljson = "";

            DateTime beginDate = Md5Helper.GMT2Local(qKyDate1);
            DateTime endDate   = Md5Helper.GMT2Local(qKyDate2);

            var records = db.view_report.Where(p => p.ky_date >= beginDate && p.ky_date <= endDate && p.record_state != 1000);   //

            if (dataType == Global.SELF_DATA)
            {
                records = records.Where(p => p.creater_id.Value == userId);
            }
            else if (qCreator != 0)
            {
                records = records.Where(p => p.creater_id == qCreator);
            }
            if (dataType == Global.UNIT_DATA)
            {
                records = records.Where(p => p.ky_unit == unitId);
            }
            else if (qKyUnit != 0)
            {
                records = records.Where(p => p.ky_unit == qKyUnit);
            }
            switch (type)
            {
            case 1:
                var rslList = records.GroupBy(p => p.xz).ToList();
                csm.name = "案件性质";
                csm.type = "bar";
                foreach (var rsl in rslList)
                {
                    names.Add(rsl.Key);
                    nums.Add(rsl.Count());
                }
                csm.data = nums;
                seriesList.Add(csm);
                var option = new
                {
                    title   = new { text = "案件性质汇总统计" },
                    tooltip = new { },
                    xAxis   = new
                    {
                        axisLabel = new { interval = "0", rotate = "30" },
                        data      = names
                    },
                    yAxis  = new { },
                    series = seriesList
                };
                rsljson = JsonConvert.SerializeObject(option);
                break;

            case 2:
                var rslList2 = records.GroupBy(p => p.bg_unit_name).ToList();
                csm.name = "接警单位";
                csm.type = "bar";
                foreach (var rsl in rslList2)
                {
                    names.Add(rsl.Key);
                    nums.Add(rsl.Count());
                }
                csm.data = nums;
                seriesList.Add(csm);
                var option2 = new
                {
                    title   = new { text = "接警单位汇总统计" },
                    tooltip = new { },
                    xAxis   = new
                    {
                        axisLabel = new { interval = "0", rotate = "30" },
                        data      = names
                    },
                    yAxis  = new { },
                    series = seriesList
                };
                rsljson = JsonConvert.SerializeObject(option2);
                break;

            case 3:
                var rslList3 = records.GroupBy(p => p.jjr_name).ToList();
                csm.name = "接警人";
                csm.type = "bar";
                foreach (var rsl in rslList3)
                {
                    names.Add(rsl.Key);
                    nums.Add(rsl.Count());
                }
                csm.data = nums;
                seriesList.Add(csm);
                var option3 = new
                {
                    title   = new { text = "接警人汇总统计" },
                    tooltip = new { },
                    xAxis   = new
                    {
                        axisLabel = new { interval = "0", rotate = "45" },
                        data      = names
                    },
                    yAxis  = new { },
                    series = seriesList
                };
                rsljson = JsonConvert.SerializeObject(option3);
                break;

            case 4:
                var rslList4 = records.OrderBy(p => p.ky_date).GroupBy(p => p.ky_date).ToList();
                csm.name = "接警日期";
                csm.type = "line";
                foreach (var rsl in rslList4)
                {
                    names.Add(rsl.Key.Value.ToString("yyyy-MM-dd"));
                    nums.Add(rsl.Count());
                }
                csm.data = nums;
                seriesList.Add(csm);

                DataZoomModel dz = new DataZoomModel()
                {
                    end = 100
                };
                dzList.Add(dz);
                DataZoomModel dz1 = new DataZoomModel()
                {
                    type = "inside"
                };
                dzList.Add(dz1);
                var option4 = new
                {
                    title   = new { text = "日均案件统计" },
                    tooltip = new { },
                    xAxis   = new
                    {
                        data = names
                    },
                    dataZoom = dzList,
                    yAxis    = new { },
                    series   = seriesList
                };
                rsljson = JsonConvert.SerializeObject(option4);
                break;

            case 5:
                var rslList5 = records.Select(n => new { record_id = n.record_id, ky_month = n.ky_date.Value.Year + "-" + n.ky_date.Value.Month })
                               .GroupBy(p => p.ky_month).ToList();
                csm.name = "接警月";
                csm.type = "line";
                foreach (var rsl in rslList5)
                {
                    names.Add(rsl.Key);
                    nums.Add(rsl.Count());
                }
                csm.data = nums;
                seriesList.Add(csm);
                DataZoomModel dz2 = new DataZoomModel()
                {
                    end = 100
                };
                dzList.Add(dz2);
                DataZoomModel dz3 = new DataZoomModel()
                {
                    type = "inside"
                };
                dzList.Add(dz3);
                var option5 = new
                {
                    title   = new { text = "月均案件统计" },
                    tooltip = new { },
                    xAxis   = new
                    {
                        data = names
                    },
                    yAxis    = new { },
                    dataZoom = dzList,
                    series   = seriesList
                };
                rsljson = JsonConvert.SerializeObject(option5);
                break;
            }

            return(Content(rsljson));
        }