public ActionResult ChartYtd(ViewModels.PmsSummary.ChartViewModel viewModel) { var kpi = _kpiService.GetKpi(new GetKpiRequest { Id = viewModel.Id }); if (kpi.YtdFormula == YtdFormula.Sum) { var artifactDesignerViewModel = new ArtifactDesignerViewModel(); artifactDesignerViewModel.BarChart = new BarChartViewModel(); var previewViewModel = new ArtifactPreviewViewModel(); artifactDesignerViewModel.BarChart.Series.Add(new BarChartViewModel.SeriesViewModel { KpiId = viewModel.Id, Label = "Achievement", ValueAxis = ValueAxis.KpiActual.ToString() }); var request = new GetCartesianChartDataRequest(); request.GraphicName = "Year To Date"; request.GraphicType = "barachievement"; request.HeaderTitle = "Year To Date"; request.MeasurementId = viewModel.MeasurementId; request.PeriodeType = PeriodeType.Monthly; request.RangeFilter = RangeFilter.YTD; request.Start = new DateTime(viewModel.Year, 1, 1); request.End = new DateTime(viewModel.Year, 12, 1); request.ValueAxis = ValueAxis.KpiActual; artifactDesignerViewModel.BarChart.MapPropertiesToInstance <GetCartesianChartDataRequest>(request); var chartData = _artifactService.GetChartData(request); previewViewModel.GraphicType = "barachievement"; previewViewModel.BarChart = new BarChartDataViewModel(); previewViewModel.BarChart.Title = "Year To Date"; previewViewModel.BarChart.ValueAxisTitle = _measurementService.GetMeasurement(new GetMeasurementRequest { Id = viewModel.MeasurementId }).Name; previewViewModel.BarChart.Series = chartData.Series.MapTo <BarChartDataViewModel.SeriesViewModel>(); previewViewModel.BarChart.Periodes = chartData.Periodes; previewViewModel.BarChart.SeriesType = chartData.SeriesType; previewViewModel.PeriodeType = "Monthly"; previewViewModel.TimePeriodes = chartData.TimePeriodes; return(Json(previewViewModel, JsonRequestBehavior.AllowGet)); } return(Content("KPI's Year To Date formula is not SUM type")); }
public ActionResult ChartYearly(ViewModels.PmsSummary.ChartViewModel viewModel) { var artifactDesignerViewModel = new ArtifactDesignerViewModel(); artifactDesignerViewModel.BarChart = new BarChartViewModel(); var previewViewModel = new ArtifactPreviewViewModel(); artifactDesignerViewModel.BarChart.Series.Add(new BarChartViewModel.SeriesViewModel { KpiId = viewModel.Id, Label = "Achievement", ValueAxis = ValueAxis.KpiActual.ToString() }); var request = new GetCartesianChartDataRequest(); request.GraphicName = "Yearly"; request.GraphicType = "barachievement"; request.HeaderTitle = "Yearly"; request.MeasurementId = viewModel.MeasurementId; request.PeriodeType = PeriodeType.Yearly; request.RangeFilter = RangeFilter.CurrentYear; request.ValueAxis = ValueAxis.KpiActual; artifactDesignerViewModel.BarChart.MapPropertiesToInstance <GetCartesianChartDataRequest>(request); var chartData = _artifactService.GetChartData(request); previewViewModel.GraphicType = "barachievement"; previewViewModel.BarChart = new BarChartDataViewModel(); previewViewModel.BarChart.Title = "Yearly"; previewViewModel.BarChart.ValueAxisTitle = _measurementService.GetMeasurement(new GetMeasurementRequest { Id = viewModel.MeasurementId }).Name; previewViewModel.BarChart.Series = chartData.Series.MapTo <BarChartDataViewModel.SeriesViewModel>(); previewViewModel.BarChart.Periodes = chartData.Periodes; previewViewModel.BarChart.SeriesType = chartData.SeriesType; previewViewModel.PeriodeType = "Monthly"; previewViewModel.TimePeriodes = chartData.TimePeriodes; return(Json(previewViewModel, JsonRequestBehavior.AllowGet)); }