Skip to content
Snippets Groups Projects
Commit b8b08c5e authored by Robert Goldmann's avatar Robert Goldmann
Browse files

Fixed #489 - new default chart: rest per month

parent d89d93cb
No related branches found
No related tags found
1 merge request!229Feature/index page
Pipeline #2372 failed
...@@ -42,6 +42,10 @@ public class DefaultCharts ...@@ -42,6 +42,10 @@ public class DefaultCharts
getChartFromFile("charts/IncomesAndExpendituresPerMonthByCategories.js"), getChartFromFile("charts/IncomesAndExpendituresPerMonthByCategories.js"),
ChartType.DEFAULT, 13); ChartType.DEFAULT, 13);
private static final Chart CHART_REST_PER_MONTH = new Chart("charts.default.restPerMonth",
getChartFromFile("charts/RestPerMonth.js"),
ChartType.DEFAULT, 2);
public static List<Chart> getDefaultCharts() public static List<Chart> getDefaultCharts()
{ {
...@@ -52,6 +56,7 @@ public class DefaultCharts ...@@ -52,6 +56,7 @@ public class DefaultCharts
charts.add(CHART_INCOMES_AND_EXPENDITURES_BY_CATEGORY_BAR); charts.add(CHART_INCOMES_AND_EXPENDITURES_BY_CATEGORY_BAR);
charts.add(CHART_INCOMES_AND_EXPENDITURES_BY_CATEGORY_PIE); charts.add(CHART_INCOMES_AND_EXPENDITURES_BY_CATEGORY_PIE);
charts.add(CHART_INCOMES_AND_EXPENDITURES_PER_MONTH_BY_CATEGORIES); charts.add(CHART_INCOMES_AND_EXPENDITURES_PER_MONTH_BY_CATEGORIES);
charts.add(CHART_REST_PER_MONTH);
charts.sort(Comparator.comparing(Chart::getName)); charts.sort(Comparator.comparing(Chart::getName));
return charts; return charts;
......
/* This list will be dynamically filled with all the transactions between
* the start and and date you select on the "Show Chart" page
* and filtered according to your specified filter.
* An example entry for this list and tutorial about how to create custom charts ca be found in the BudgetMaster wiki:
* https://github.com/deadlocker8/BudgetMaster/wiki/How-to-create-custom-charts
*/
var transactionData = [];
// Note: All variables starting with "localized" are only available inside default charts.
moment.locale(localizedLocale);
var dates = [];
var rests = [];
transactionData = transactionData.reverse();
for(var i = 0; i < transactionData.length; i++)
{
var transaction = transactionData[i];
// create new sums if month is not already in list
var date = moment(transaction.date).startOf('month').format('MMM YY');
if(!dates.includes(date))
{
dates.push(date);
rests.push(0);
}
var lastIndex = rests.length - 1;
rests[lastIndex] = rests[lastIndex] + transaction.amount;
}
// convert all sums to decimal
rests.forEach(function(value, index)
{
this[index] = value / 100;
}, rests);
// Prepare your chart settings here (mandatory)
var plotlyData = [
{
x: dates,
y: rests,
type: 'bar',
},
];
// Add your Plotly layout settings here (optional)
var plotlyLayout = {
title: {
text: localizedTitle
},
yaxis: {
title: localizedData['label1'] + localizedCurrency,
rangemode: 'tozero',
tickformat: '.2f',
showline: true
},
xaxis: {
tickformat: '%d.%m.%y'
}
};
// Add your Plotly configuration settings here (optional)
var plotlyConfig = {
showSendToCloud: false,
displaylogo: false,
showLink: false,
responsive: true,
displayModeBar: true,
toImageButtonOptions: {
format: 'png',
filename: 'BudgetMaster_chart_export',
height: 1080,
width: 1920,
}
};
// Don't touch this line
Plotly.newPlot('chart-canvas', plotlyData, plotlyLayout, plotlyConfig);
\ No newline at end of file
...@@ -341,7 +341,8 @@ charts.default.incomesAndExpendituresByCategoryPie=Eingaben/Ausgaben nach Katego ...@@ -341,7 +341,8 @@ charts.default.incomesAndExpendituresByCategoryPie=Eingaben/Ausgaben nach Katego
charts.default.incomesAndExpendituresByCategoryPie.localization='{"label1": "Ausgaben", "label2": "Einnahmen"'} charts.default.incomesAndExpendituresByCategoryPie.localization='{"label1": "Ausgaben", "label2": "Einnahmen"'}
charts.default.incomesAndExpendituresPerMonthByCategories=Eingaben/Ausgaben pro Monat (nach Kategorien) charts.default.incomesAndExpendituresPerMonthByCategories=Eingaben/Ausgaben pro Monat (nach Kategorien)
charts.default.incomesAndExpendituresPerMonthByCategories.localization='{"label1": "Ausgaben", "label2": "Einnahmen"'} charts.default.incomesAndExpendituresPerMonthByCategories.localization='{"label1": "Ausgaben", "label2": "Einnahmen"'}
charts.default.categoryBudget=Verbrauch nach Kategorien charts.default.restPerMonth=Rest pro Monat
charts.default.restPerMonth.localization='{"label1": "Rest in "'}
chart.new.label.name=Name chart.new.label.name=Name
chart.new.label.script=Script chart.new.label.script=Script
......
...@@ -341,7 +341,8 @@ charts.default.incomesAndExpendituresByCategoryPie=Incomes/Expenditures by categ ...@@ -341,7 +341,8 @@ charts.default.incomesAndExpendituresByCategoryPie=Incomes/Expenditures by categ
charts.default.incomesAndExpendituresByCategoryPie.localization='{"label1": "Expenditures", "label2": "Incomes"'} charts.default.incomesAndExpendituresByCategoryPie.localization='{"label1": "Expenditures", "label2": "Incomes"'}
charts.default.incomesAndExpendituresPerMonthByCategories=Incomes/Expenditures per month (By categories) charts.default.incomesAndExpendituresPerMonthByCategories=Incomes/Expenditures per month (By categories)
charts.default.incomesAndExpendituresPerMonthByCategories.localization='{"label1": "Expenditures", "label2": "Incomes"'} charts.default.incomesAndExpendituresPerMonthByCategories.localization='{"label1": "Expenditures", "label2": "Incomes"'}
charts.default.categoryBudget=Consumption by categories charts.default.restPerMonth=Rest per month
charts.default.restPerMonth.localization='{"label1": "Rest in "'}
chart.new.label.name=Name chart.new.label.name=Name
chart.new.label.script=Script chart.new.label.script=Script
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment