C#C
C#3y ago
4 replies
Melnar

❔ Making charts in .net core mvc

I want to create a linechart showing daily income and expense transactions. I have created in my BLL layer a DailySummaryDto which holds the info that i want to show

public class DailySummaryDto
{
    public int UserId { get; set; }
    public DateTime Date { get; set; }
    public decimal TotalIncome { get; set; }
    public decimal TotalExpense { get; set; }
}


I have also implemented a method do receive these properties
 public async Task<DailySummaryDto> GetDailySummaryAsync(int userId)
    {
        var transactions = await _unitOfWork.TransactionRepository.GetAllDailyAsync(userId);
        var totalIncome = await _unitOfWork.TransactionRepository.GetTotalIncomeAsync(transactions);
        var totalExpense = await _unitOfWork.TransactionRepository.GetTotalExpenseAsync(transactions);

        var dailySummaryDto = new DailySummaryDto
        {
            UserId = userId,
            Date = DateTime.Today,
            TotalIncome = totalIncome,
            TotalExpense = totalExpense
        };

        return dailySummaryDto;
    }


How do i display a line chart in view showing daily income and expense for the past week?
Which package to install to use charts?
Was this page helpful?