C
C#13mo ago
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; }
}
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;
}
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?
3 Replies
Angius
Angius13mo ago
You're probably looking to use charts.js or some other package like that Send the chart data as properly-formatted JSON, and use that to create the chart with JS
Denis
Denis13mo ago
Or you can use components from companies such as Syncfusion, DevExpress, or open source solutions. Syncfusion provides components for free to open-source projects
Accord
Accord13mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server
More Posts