示例#1
0
        public JsonResult GetDebitMovementsOverTime()
        {
            var interval = new Interval(DateTime.Now, DateTimeUnitEnums.Months, 6);

            var intervalsByMonth = interval.GetIntervalsByMonth();

            var dataSetActualExpenditures = new ChartDataset();
            var expenditures = _expenditureService.GetExpenditures(new Models.SearchParameters.ExpenditureGetListSearchParameters()
            {
                UserId = CurrentUser, StartDate = interval.StartDate, EndDate = interval.EndDate
            });

            foreach (var intervalByMonth in intervalsByMonth)
            {
                var expendituresByMonth = expenditures.Where(x => intervalByMonth.Value.IsBetween(x.DateExpenditure));
                var value = new ChartValue(((int)expendituresByMonth.Sum(x => x.Cost)).ToString());
                dataSetActualExpenditures.Values.Add(value);
            }

            var chartData = new ChartData()
            {
                Labels        = intervalsByMonth.Keys.ToList(),
                ChartDatasets = new List <ChartDataset>()
                {
                    dataSetActualExpenditures
                }
            };

            return(Json(chartData, JsonRequestBehavior.AllowGet));
        }
示例#2
0
        /// <summary>
        /// ИНициирует или возвращает датасет по умолчанию
        /// </summary>
        /// <returns></returns>
        public IChartDataset EnsureDataset()
        {
            if (0 != Children.Count)
            {
                return(Children[0]);
            }
            var ds = new ChartDataset();

            Add(ds);
            return(ds);
        }
示例#3
0
        public void CanAddElement()
        {
            var chart = new Chart();
            var ds    = new ChartDataset();
            var tt    = new ChartSet();
            var tl    = new ChartTrendLine();
            var tl2   = new ChartTrendLine();
            var tls   = new ChartTrendLines();

            tl2.SetParentElement(tls);
            tt.SetParentElement(ds);

            chart.Add(ds).Add(tt).Add(tl).Add(tl2);
            Assert.AreEqual(1, chart.Datasets.Children.Count);
            Assert.AreEqual(1, chart.Datasets.Children.First().Children.Count);
            Assert.AreEqual(1, chart.TrendLines.Children.Count);
        }
示例#4
0
        public async Task <ChartDataset> GetDriverStatistics(IdentityUser identityUser, DateTime?dateTime, int id)
        {
            var _date   = dateTime ?? DateTime.Now;
            var _driver = await _context.Drivers.Include(x => x.Orders).FirstOrDefaultAsync(x => x.Id == id);

            var _statistics = new ChartDataset()
            {
                id = _driver.Id,

                label = _driver.Name + " " + _driver.Surname,

                backgroundColor = ColorHelper.GetColorByID(_driver.Id),

                borderColor = ColorHelper.GetColorByID(_driver.Id),

                data = JsonConvert.SerializeObject(GetMonthEarnings(_driver.Orders
                                                                    .Where(x => x.IsPaid && x.State == OrderState.Close && x.StartDate.Year == _date.Year)
                                                                    .ToList()))
            };

            return(_statistics);
        }
示例#5
0
        /// <summary>
        ///     Парсит датасеты вида 100.2,50.50;23.5,66.4 и выдаёт готовый график
        /// </summary>
        /// <param name="chartData">Представление датасетов</param>
        /// <returns>Сформированный график</returns>
        public static IChart ParseDatasets(string chartData) {
            var chart = new Chart {
                Config = new ChartConfig()
            };

            var datasets = chartData.SmartSplit(false, true, new[] {';'});

            foreach (var ds in datasets) {
                var dataset = new ChartDataset();

                EnumerableExtensions.DoForEach(ds.SmartSplit(false, true, new[] { ',' }), _ => dataset.Add(new ChartSet().SetValue(_.ToDecimal()))
                );


                chart.Add(dataset);
            }

            for (var i = 0; i < chart.Datasets.Children.Select(_ => _.Children.Count()).Max(); i++) {
                chart.Add(new ChartCategory().SetLabelValue(""));
            }

            return chart;
        }
        private DataTable BuildOutputDataSet(ChartDataset inputDataset, ChartSettings chartSettings)
        {
            var table = new DataTable("ChartData");

            table.Columns.Add("Moment", typeof(DateTime));
            table.Columns.Add("OpenPrice", typeof(Decimal));
            table.Columns.Add("ClosePrice", typeof(Decimal));
            table.Columns.Add("MaxPrice", typeof(Decimal));
            table.Columns.Add("MinPrice", typeof(Decimal));
            table.Columns.Add("VolumeInBaseCurrency", typeof(Decimal));

            table.Columns.Add("BuyPrice", typeof(Decimal));
            table.Columns.Add("SellPrice", typeof(Decimal));

            table.Columns.AddRange(IndicatorSeriesViewSettings.GetIndicatorSeriesViewSettings(chartSettings)
                                   .Select(viewSettings => new DataColumn(viewSettings.IndicatorValue, typeof(Decimal))).ToArray());

            foreach (var candle in inputDataset.Candles)
            {
                var rowValues = new List <object>();
                rowValues.Add(candle.Moment);
                rowValues.Add(candle.OpenPrice);
                rowValues.Add(candle.ClosePrice);
                rowValues.Add(candle.MaxPrice);
                rowValues.Add(candle.MinPrice);

                rowValues.Add(candle.VolumeInBaseCurrency);

                var tradingData = inputDataset.TradingData.Single(data => data.Moment == candle.Moment);
                rowValues.Add(tradingData.BuyPrice);
                rowValues.Add(tradingData.SellPrice);

                foreach (var indicatorDataset in inputDataset.IndicatorData)
                {
                    switch (indicatorDataset.Settings.Type)
                    {
                    case IndicatorType.HighestMaxPrice:
                        rowValues.Add(indicatorDataset.Values.OfType <SimpleIndicatorValue>()
                                      .Where(value => value.Moment == candle.Moment)
                                      .Select(value => value.Value)
                                      .FirstOrDefault());
                        break;

                    case IndicatorType.EMA:
                        rowValues.Add(indicatorDataset.Values.OfType <SimpleIndicatorValue>()
                                      .Where(value => value.Moment == candle.Moment)
                                      .Select(value => value.Value)
                                      .FirstOrDefault());
                        break;

                    case IndicatorType.MACD:
                        var macdValues = indicatorDataset.Values
                                         .OfType <MACDValue>()
                                         .Where(value => value.Moment == candle.Moment)
                                         .Select(value => new object[] { value.MACD, value.Signal, value.Histogram })
                                         .FirstOrDefault() ??
                                         new object[] { DBNull.Value, DBNull.Value, DBNull.Value };
                        rowValues.AddRange(macdValues);
                        break;

                    case IndicatorType.Stochastic:
                        var stochasticValues = indicatorDataset.Values
                                               .OfType <StochasticValue>()
                                               .Where(value => value.Moment == candle.Moment)
                                               .Select(value => new object[] { value.K, value.D })
                                               .FirstOrDefault() ??
                                               new object[] { DBNull.Value, DBNull.Value };
                        rowValues.AddRange(stochasticValues);
                        break;

                    case IndicatorType.RelativeStrengthIndex:
                        rowValues.Add(indicatorDataset.Values.OfType <SimpleIndicatorValue>()
                                      .Where(value => value.Moment == candle.Moment)
                                      .Select(value => value.Value)
                                      .FirstOrDefault());
                        break;

                    case IndicatorType.AccumulationDistribution:
                        rowValues.Add(indicatorDataset.Values.OfType <SimpleIndicatorValue>()
                                      .Where(value => value.Moment == candle.Moment)
                                      .Select(value => value.Value)
                                      .FirstOrDefault());
                        break;

                    case IndicatorType.WilliamsR:
                        rowValues.Add(indicatorDataset.Values.OfType <SimpleIndicatorValue>()
                                      .Where(value => value.Moment == candle.Moment)
                                      .Select(value => value.Value)
                                      .FirstOrDefault());
                        break;

                    case IndicatorType.ParabolicSAR:
                        rowValues.Add(indicatorDataset.Values.OfType <SimpleIndicatorValue>()
                                      .Where(value => value.Moment == candle.Moment)
                                      .Select(value => value.Value)
                                      .FirstOrDefault());
                        break;

                    default:
                        throw new ArgumentOutOfRangeException(nameof(indicatorDataset.Settings.Type));
                    }
                }
                table.Rows.Add(rowValues.ToArray());
            }

            return(table);
        }
        public ICollection <ChartDataset> MediaReajustes(List <int> empresasIds, int ano)
        {
            var negociacoes = _db.Negociacoes
                              .Where(x => x.Ano == ano && x.EmpresaId.HasValue && empresasIds.Contains(x.EmpresaId.Value))
                              .Include(x => x.Orcado)
                              .Include(x => x.Negociado)
                              .Include(x => x.Concorrentes)
                              .ThenInclude(c => c.Reajuste);

            var qtdaNegociacoes = negociacoes.Count();

            if (qtdaNegociacoes > 0)
            {
                ChartDataset orcado = new ChartDataset
                {
                    Label = "Orçado",
                    Data  = new List <ChartData>
                    {
                        new ChartData {
                            Y = Math.Round(negociacoes.Average(x => x.Orcado.Piso), 2), Label = "Piso"
                        },
                        new ChartData {
                            Y = Math.Round(negociacoes.Average(x => x.Orcado.Salario), 2), Label = "Salário"
                        },
                        new ChartData {
                            Y = Math.Round(negociacoes.Average(x => x.Orcado.VaVr), 2), Label = "VA/VR"
                        },
                        new ChartData {
                            Y = Math.Round(negociacoes.Average(x => x.Orcado.VaVrFerias), 2), Label = "VA/VR Férias"
                        },
                        new ChartData {
                            Y = Math.Round(negociacoes.Average(x => x.Orcado.AuxCreche), 2), Label = "Aux. Creche"
                        }
                    }
                };

                ChartDataset negociado = new ChartDataset
                {
                    Label = "Negociado",
                    Data  = new List <ChartData>
                    {
                        new ChartData {
                            Y = Math.Round(negociacoes.Average(x => x.Negociado.Piso), 2), Label = "Piso"
                        },
                        new ChartData {
                            Y = Math.Round(negociacoes.Average(x => x.Negociado.Salario), 2), Label = "Salário"
                        },
                        new ChartData {
                            Y = Math.Round(negociacoes.Average(x => x.Negociado.VaVr), 2), Label = "VA/VR"
                        },
                        new ChartData {
                            Y = Math.Round(negociacoes.Average(x => x.Negociado.VaVrFerias), 2), Label = "VA/VR Férias"
                        },
                        new ChartData {
                            Y = Math.Round(negociacoes.Average(x => x.Negociado.AuxCreche), 2), Label = "Aux. Creche"
                        }
                    }
                };

                List <Negociacao> negociaoesComConcorrentes = negociacoes.Where(x => x.Concorrentes.Count() > 0).ToList();
                ChartDataset      concorrentes = new ChartDataset
                {
                    Label = "Concorrentes",
                    Data  = new List <ChartData> {
                        new ChartData {
                            Y = 0, Label = "Piso"
                        },
                        new ChartData {
                            Y = 0, Label = "Salário"
                        },
                        new ChartData {
                            Y = 0, Label = "VA/VR"
                        },
                        new ChartData {
                            Y = 0, Label = "VA/VR Férias"
                        },
                        new ChartData {
                            Y = 0, Label = "Aux. Creche"
                        }
                    }
                };
                if (negociaoesComConcorrentes.Count() > 0)
                {
                    concorrentes = new ChartDataset
                    {
                        Label = "Concorrentes",
                        Data  = new List <ChartData> {
                            new ChartData {
                                Y = Math.Round(negociaoesComConcorrentes.Average(x => x.Concorrentes.Average(y => y.Reajuste.Piso)), 2), Label = "Piso"
                            },
                            new ChartData {
                                Y = Math.Round(negociaoesComConcorrentes.Average(x => x.Concorrentes.Average(y => y.Reajuste.Salario)), 2), Label = "Salário"
                            },
                            new ChartData {
                                Y = Math.Round(negociaoesComConcorrentes.Average(x => x.Concorrentes.Average(y => y.Reajuste.VaVr)), 2), Label = "VA/VR"
                            },
                            new ChartData {
                                Y = Math.Round(negociaoesComConcorrentes.Average(x => x.Concorrentes.Average(y => y.Reajuste.VaVrFerias)), 2), Label = "VA/VR Férias"
                            },
                            new ChartData {
                                Y = Math.Round(negociaoesComConcorrentes.Average(x => x.Concorrentes.Average(y => y.Reajuste.AuxCreche)), 2), Label = "Aux. Creche"
                            }
                        }
                    };
                }

                return(new List <ChartDataset> {
                    orcado, negociado, concorrentes
                });
            }

            return(new List <ChartDataset>());
        }
示例#8
0
        public ChartDataset GetChartData(ChartSettings settings)
        {
            var chartDataset = new ChartDataset();

            chartDataset.Candles = _candleLoadingService.LoadCandles(
                settings.CurrencyPairId,
                settings.Period,
                settings.CandleRangeSize,
                settings.CurrentMoment).ToList();

            foreach (var indicatorSettings in settings.Indicators)
            {
                var indicatorDataset = new IndicatorDataset();
                indicatorDataset.Settings = indicatorSettings;

                var candles = indicatorSettings.CandlePeriod != settings.Period ?
                              _candleLoadingService.LoadCandles(
                    settings.CurrencyPairId,
                    indicatorSettings.CandlePeriod,
                    settings.CandleRangeSize,
                    settings.CurrentMoment).ToList() :
                              chartDataset.Candles;

                switch (indicatorSettings.Type)
                {
                case IndicatorType.HighestMaxPrice:
                    indicatorDataset.Values = _indicatorComputingService.ComputeHighestMaxPrices(
                        candles,
                        ((CommonIndicatorSettings)indicatorSettings).Period);
                    break;

                case IndicatorType.EMA:
                    indicatorDataset.Values = _indicatorComputingService.ComputeEMA(
                        candles,
                        ((CommonIndicatorSettings)indicatorSettings).Period);
                    break;

                case IndicatorType.MACD:
                    indicatorDataset.Values = _indicatorComputingService.ComputeMACD(
                        candles,
                        ((MACDSettings)indicatorSettings).EMAPeriod1,
                        ((MACDSettings)indicatorSettings).EMAPeriod2,
                        ((MACDSettings)indicatorSettings).SignalPeriod);
                    break;

                case IndicatorType.Stochastic:
                    indicatorDataset.Values = _indicatorComputingService.ComputeStochastic(
                        candles,
                        ((StochasticSettings)indicatorSettings).Period,
                        ((StochasticSettings)indicatorSettings).SMAPeriodK,
                        ((StochasticSettings)indicatorSettings).SMAPeriodD);
                    break;

                case IndicatorType.RelativeStrengthIndex:
                    indicatorDataset.Values = _indicatorComputingService.ComputeRelativeStrengthIndex(
                        candles,
                        ((CommonIndicatorSettings)indicatorSettings).Period);
                    break;

                case IndicatorType.AccumulationDistribution:
                    indicatorDataset.Values = _indicatorComputingService.ComputeAccumulationDistribution(
                        candles);
                    break;

                case IndicatorType.WilliamsR:
                    indicatorDataset.Values = _indicatorComputingService.ComputeWilliamsR(
                        candles,
                        ((CommonIndicatorSettings)indicatorSettings).Period);
                    break;

                case IndicatorType.ParabolicSAR:
                    indicatorDataset.Values = _indicatorComputingService.ComputeParabolicSAR(candles);
                    break;

                default:
                    throw new AnalysisException("Undefined indicator type");
                }
                chartDataset.IndicatorData.Add(indicatorDataset);
            }

            var defaultTradingSettings = _configurationService.GetTradingSettings();

            var tradingSettings = _configurationService.GetTradingSettings();

            tradingSettings.Period = settings.Period;
            tradingSettings.Moment = settings.CurrentMoment;
            _configurationService.UpdateTradingSettings(tradingSettings);

            foreach (var candle in chartDataset.Candles)
            {
                tradingSettings.Moment = candle.Moment;

                _configurationService.UpdateTradingSettings(tradingSettings);

                //var newPositionInfo = await _marketNewPositionAnalysisService.ProcessMarketPosition(settings.CurrencyPairId);

                var tradingData = new TradingData
                {
                    Moment = candle.Moment
                };

                //switch (newPositionInfo.PositionType)
                //{
                //	case NewMarketPositionType.Buy:
                //		tradingData.BuyPrice = candle.ClosePrice;
                //		break;
                //}
                chartDataset.TradingData.Add(tradingData);
            }

            _configurationService.UpdateTradingSettings(defaultTradingSettings);

            return(chartDataset);
        }
        public JsonResult Index(RequestData requestData)
        {
            docStartDate           = new XmlDocument();
            docEndDate             = new XmlDocument();
            startDateExchangeRates = new List <ExchangeRate>();
            endDateExchangeRates   = new List <ExchangeRate>();

            string start_date_str = requestData.start_date;
            string end_date_str   = requestData.end_date;

            if (start_date_str == "" || end_date_str == "")
            {
                ViewBag.Message = "Başlangıç ve bitiş tarihi boş olamaz.";
                return(null);
            }
            else
            {
                // Bitiş tarihinin başlangıç tarihinden küçük olup olmadığını kontrol etmek için
                // gelen ifadeleri DateTime'a çeviriyoruz.
                DateTime start_date = DateTime.ParseExact(start_date_str, "yyyy-MM-dd", CultureInfo.InstalledUICulture);
                DateTime end_date   = DateTime.ParseExact(end_date_str, "yyyy-MM-dd", CultureInfo.InstalledUICulture);

                if (start_date > end_date)
                {
                    ViewBag.Message = "Bitiş tarihi başlangıç tarihinden küçük olamaz.";
                    return(null);
                }
                else
                {
                    // Başlangıç ve bitiş tarihini DateTime'a çevirdikten sonra gün ve ay kısmının başındaki 0'ları atıyor.
                    // Tcmb Url'i oluşturulurken sorun olmaması adına gün ve ay eğer tek haneli ise başlarına 0 ekliyoruz.
                    // Ör: 1/1/2019 => 01/01/2019
                    string startDateDay = start_date.Day.ToString();
                    if (startDateDay.Length == 1)
                    {
                        startDateDay = "0" + startDateDay;
                    }
                    string startDateMonth = start_date.Month.ToString();
                    if (startDateMonth.Length == 1)
                    {
                        startDateMonth = "0" + startDateMonth;
                    }
                    string startDateYear = start_date.Year.ToString();
                    string startDate     = startDateDay + '.' + startDateMonth + '.' + startDateYear;

                    string endDateDay = end_date.Day.ToString();
                    if (endDateDay.Length == 1)
                    {
                        endDateDay = "0" + endDateDay;
                    }
                    string endDateMonth = end_date.Month.ToString();
                    if (endDateMonth.Length == 1)
                    {
                        endDateMonth = "0" + endDateMonth;
                    }
                    string endDateYear = end_date.Year.ToString();
                    string endDate     = endDateDay + '.' + endDateMonth + '.' + endDateYear;

                    // Excel çıktısı için son girilen başlangıç ve bitiş tarihlerini Session'a atıyoruz.
                    Session["start_date_excel"] = startDate;
                    Session["end_date_excel"]   = endDate;

                    // Başlangıç ve bitiş tarihi eğer daha önceden de girilmişse Tcmb linkine gitmeden
                    // veriyi Session üzerinden getiriyoruz.
                    if (Session[startDate + "-" + endDate] != null)
                    {
                        return(Json(Session[startDate + "-" + endDate], JsonRequestBehavior.AllowGet));
                    }

                    // Chart üzerinde verileri göstermek için ChartData modeli oluşturduk.
                    var chartData = new ChartData();

                    // Chart üzerindeki label'lara başlangıç ve bitiş tarihlerini yazdırıyoruz.
                    List <string> dates = new List <string>();
                    dates.Add(startDate);
                    dates.Add(endDate);
                    chartData.labels = dates;

                    // Girilen başlangıç ve bitiş tarihlerine ilişkin Tcmb üzerinde veri olup olmadığını kontrol ederek
                    // veri yoksa hata döndürüyoruz.
                    string startDateLink = "https://www.tcmb.gov.tr/kurlar/" + startDateYear + startDateMonth + "/" + startDateDay + startDateMonth + startDateYear + ".xml";
                    try {
                        docStartDate.Load(startDateLink);
                    } catch {
                        Response.StatusCode = (int)HttpStatusCode.BadRequest;
                        string error = "Resmi tatil, hafta sonu ve yarım iş günü çalışılan günlerde gösterge niteliğinde kur bilgisi yayımlanmamaktadır.";
                        return(Json(error));
                    }

                    string endDateLink = "https://www.tcmb.gov.tr/kurlar/" + endDateYear + endDateMonth + "/" + endDateDay + endDateMonth + endDateYear + ".xml";
                    try {
                        docEndDate.Load(endDateLink);
                    } catch {
                        Response.StatusCode = (int)HttpStatusCode.BadRequest;
                        string error = "Resmi tatil, hafta sonu ve yarım iş günü çalışılan günlerde gösterge niteliğinde kur bilgisi yayımlanmamaktadır.";
                        return(Json(error));
                    }

                    // Tcmb üzerinden Döviz Cinsi ve Döviz Satış değerlerine ulaşıyoruz.
                    foreach (XmlNode node in docStartDate.DocumentElement)
                    {
                        string name    = node["Isim"].InnerText;
                        string selling = node["ForexSelling"].InnerText;

                        var exchangeRate = new ExchangeRate();
                        exchangeRate.name    = name;
                        exchangeRate.selling = selling;
                        startDateExchangeRates.Add(exchangeRate);
                    }

                    foreach (XmlNode node in docEndDate.DocumentElement)
                    {
                        string name    = node["Isim"].InnerText;
                        string selling = node["ForexSelling"].InnerText;

                        var exchangeRate = new ExchangeRate();
                        exchangeRate.name    = name;
                        exchangeRate.selling = selling;
                        endDateExchangeRates.Add(exchangeRate);
                    }

                    List <ChartDataset> list = new List <ChartDataset>();

                    for (int i = 0; i < startDateExchangeRates.Count; i++)
                    {
                        // Chart üzerinde her döviz cinsi için ayrı bir renk oluşturmak adına random renk değerleri atıyoruz.
                        int    firstColor  = rand.Next(256);
                        int    secondColor = rand.Next(256);
                        int    thirdColor  = rand.Next(256);
                        string color       = "rgb(" + firstColor + ", " + secondColor + ", " + thirdColor + ")";

                        // Chart üzerindeki verilere ilişkin ChartDataset modelimizi oluşturarak
                        // bu verileri listeye dolduruyoruz.
                        var chartDataSet = new ChartDataset();
                        chartDataSet.label           = startDateExchangeRates[i].name;
                        chartDataSet.backgroundColor = color;
                        chartDataSet.borderColor     = color;
                        List <string> data = new List <string>();
                        data.Add(startDateExchangeRates[i].selling);
                        data.Add(endDateExchangeRates[i].selling);
                        chartDataSet.data = data;
                        chartDataSet.fill = false;

                        list.Add(chartDataSet);
                    }

                    chartData.datasets = list;

                    // Girilen başlangıç ve bitiş tarihine ilişkin veriyi Session'a atıyoruz.
                    Session[startDate + "-" + endDate] = chartData;

                    // Excel çıktısı için son elde edilen verileri Session'a atıyoruz.
                    Session["list_excel"] = list;

                    return(Json(chartData, JsonRequestBehavior.AllowGet));
                }
            }
        }
示例#10
0
        public ActionResult GetChartData()
        {
            ApplicationDbContext db    = new ApplicationDbContext();
            ChartObject          chart = new ChartObject();

            chart.datasets = new List <ChartDataset>();
            chart.labels   = new List <string>()
            {
                "October", "November", "December", "January", "February", "March"
            };
            IQueryable <Income> allIncome = from i in db.Incomes
                                            select i;
            IQueryable <Expense> allExpense = from e in db.Expenses
                                              select e;

            ChartDataset ds = new ChartDataset();

            ds.data = new List <int>()
            {
                0, 0, 0, 0, 0, 0
            };
            foreach (Income i in allIncome)
            {
                if (i.PayDay.Month == 10)
                {
                    ds.data[0] += Convert.ToInt32(i.GrossPayment);
                }
                if (i.PayDay.Month == 11)
                {
                    ds.data[1] += Convert.ToInt32(i.GrossPayment);
                }
                if (i.PayDay.Month == 12)
                {
                    ds.data[2] += Convert.ToInt32(i.GrossPayment);
                }
                if (i.PayDay.Month == 1)
                {
                    ds.data[3] += Convert.ToInt32(i.GrossPayment);
                }
                if (i.PayDay.Month == 2)
                {
                    ds.data[4] += Convert.ToInt32(i.GrossPayment);
                }
                if (i.PayDay.Month == 3)
                {
                    ds.data[5] += Convert.ToInt32(i.GrossPayment);
                }
            }

            ds.label                = "Income";
            ds.fillColor            = "rgba(0, 168, 0, 0.6)";
            ds.pointColor           = "rgba(0, 168, 0, 0.6)";
            ds.strokeColor          = "rgba(0, 168, 0, 0.6)";
            ds.pointStrokeColor     = "#c1c7d1";
            ds.pointHighlightFill   = "#fff";
            ds.pointHighlightStroke = "rgb(220,220,220)";
            chart.datasets.Add(ds);

            ChartDataset ds2 = new ChartDataset();

            ds2.data = new List <int>()
            {
                0, 0, 0, 0, 0, 0
            };
            foreach (Expense e in allExpense)
            {
                if (e.ExpenseDate.Month == 10)
                {
                    ds2.data[0] += Convert.ToInt32(e.ExpenseAmount);
                }
                if (e.ExpenseDate.Month == 11)
                {
                    ds2.data[1] += Convert.ToInt32(e.ExpenseAmount);
                }
                if (e.ExpenseDate.Month == 12)
                {
                    ds2.data[2] += Convert.ToInt32(e.ExpenseAmount);
                }
                if (e.ExpenseDate.Month == 1)
                {
                    ds2.data[3] += Convert.ToInt32(e.ExpenseAmount);
                }
                if (e.ExpenseDate.Month == 2)
                {
                    ds2.data[4] += Convert.ToInt32(e.ExpenseAmount);
                }
                if (e.ExpenseDate.Month == 3)
                {
                    ds2.data[5] += Convert.ToInt32(e.ExpenseAmount);
                }
            }

            ds2.label            = "Expense";
            ds2.fillColor        = "rgba(255, 0, 0, 0.6)";
            ds2.strokeColor      = "rgba(255, 0, 0, 0.6)";
            ds2.pointColor       = "rgba(255, 0, 0, 0.6)";
            ds2.pointStrokeColor = "rgba(60,141,188,1)";

            ds2.pointHighlightFill   = "#fff";
            ds2.pointHighlightStroke = "rgba(60,141,188,1)";
            chart.datasets.Add(ds2);

            return(Json(chart, JsonRequestBehavior.AllowGet));
        }