diff --git a/src/main/java/de/deadlocker8/budgetmaster/charts/ChartController.java b/src/main/java/de/deadlocker8/budgetmaster/charts/ChartController.java index 4b2ec96c76d0ffbc2255f6f55e93989af04e96fa..91b8e766c3927c56c6da97dc9aa8518c5af3b061 100644 --- a/src/main/java/de/deadlocker8/budgetmaster/charts/ChartController.java +++ b/src/main/java/de/deadlocker8/budgetmaster/charts/ChartController.java @@ -92,7 +92,7 @@ public class ChartController extends BaseController @RequestMapping("/charts/newChart") public String newChart(Model model) { - Chart emptyChart = new Chart(null, null, ChartType.CUSTOM, -1); + Chart emptyChart = DefaultCharts.CHART_DEFAULT; model.addAttribute("chart", emptyChart); model.addAttribute("settings", settingsService.getSettings()); return "charts/newChart"; diff --git a/src/main/java/de/deadlocker8/budgetmaster/charts/DefaultCharts.java b/src/main/java/de/deadlocker8/budgetmaster/charts/DefaultCharts.java index 6c3877590786cfa5523c19cb9823bfac4bbabd1e..258bed052e26d70f432fbf2abd4d1f03f9d41daf 100644 --- a/src/main/java/de/deadlocker8/budgetmaster/charts/DefaultCharts.java +++ b/src/main/java/de/deadlocker8/budgetmaster/charts/DefaultCharts.java @@ -14,6 +14,10 @@ public class DefaultCharts { private static final Logger LOGGER = LoggerFactory.getLogger(DefaultCharts.class); + public static final Chart CHART_DEFAULT = new Chart(null, + getChartFromFile("charts/Default.js"), + ChartType.CUSTOM, -1); + private static final Chart CHART_ACCOUNT_SUM_PER_DAY = new Chart("charts.default.accountSumPerDay", getChartFromFile("charts/AccountSumPerDay.js"), ChartType.DEFAULT, 4); diff --git a/src/main/resources/charts/Default.js b/src/main/resources/charts/Default.js new file mode 100644 index 0000000000000000000000000000000000000000..a8d58d41732ce9dbe28aba5cc8bd4a0c92a84354 --- /dev/null +++ b/src/main/resources/charts/Default.js @@ -0,0 +1,28 @@ +/* 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 = []; + +// Prepare your chart settings here (mandatory) +var plotlyData = [{ + x: [], + y: [], + type: 'bar' +}]; + +// Add your Plotly layout settings here (optional) +var plotlyLayout = {}; + +// Add your Plotly configuration settings here (optional) +var plotlyConfig = { + showSendToCloud: false, + displaylogo: false, + showLink: false, + responsive: true +}; + +// Don't touch this line +Plotly.newPlot('chart-canvas', plotlyData, plotlyLayout, plotlyConfig); diff --git a/src/main/resources/languages/_de.properties b/src/main/resources/languages/_de.properties index 0c776e65cce96809e512c8dd6f8e9b3f110e21a0..c4dfee473de2ae910d4be2dde08eea58800f98cb 100644 --- a/src/main/resources/languages/_de.properties +++ b/src/main/resources/languages/_de.properties @@ -371,32 +371,3 @@ chart.quick.last.week.days=Letzte 7 Tage chart.quick.last.month.days=Letzte 30 Tage chart.quick.last.year.days=Letzte 365 Tage chart.quick.until.today=Alle bis heute - -chart.script.default=/* This list will be dynamically filled with all the transactions between\n \ -* the start and and date you select on the "Show Chart" page\n \ -* and filtered according to your specified filter.\n \ -* An example entry for this list and tutorial about how to create custom charts ca be found in the BudgetMaster wiki:\n \ -* https://github.com/deadlocker8/BudgetMaster/wiki/How-to-create-custom-charts\n \ -*/\n \ -var transactionData = [];\n \ -\n \ -// Prepare your chart settings here (mandatory)\n \ -var plotlyData = ['{'\n \ -\tx: [],\n \ -\ty: [],\n \ -\ttype: 'bar'\n \ -'}'];\n \ -\n \ -// Add your Plotly layout settings here (optional)\n \ -var plotlyLayout = '{}';\n \ -\n \ -// Add your Plotly configuration settings here (optional)\n \ -var plotlyConfig = '{'\n \ -\tshowSendToCloud: false,\n \ -\tdisplaylogo: false,\n \ -\tshowLink: false,\n \ -\tresponsive: true\n \ -'}';\n \ -\n \ -// Don't touch this line\n \ -Plotly.newPlot(''chart-canvas'', plotlyData, plotlyLayout, plotlyConfig); diff --git a/src/main/resources/languages/_en.properties b/src/main/resources/languages/_en.properties index 6408e482984f7c47dad395e3999e2cfe47741d0c..19615067477e8168b0ae764b1f39d30d8dd4ce70 100644 --- a/src/main/resources/languages/_en.properties +++ b/src/main/resources/languages/_en.properties @@ -370,32 +370,3 @@ chart.quick.last.week.days=Last 7 days chart.quick.last.month.days=Last 30 days chart.quick.last.year.days=Last 365 days chart.quick.until.today=Until today - -chart.script.default=/* This list will be dynamically filled with all the transactions between\n \ -* the start and and date you select on the "Show Chart" page\n \ -* and filtered according to your specified filter.\n \ -* An example entry for this list and tutorial about how to create custom charts ca be found in the BudgetMaster wiki:\n \ -* https://github.com/deadlocker8/BudgetMaster/wiki/How-to-create-custom-charts\n \ -*/\n \ -var transactionData = [];\n \ -\n \ -// Prepare your chart settings here (mandatory)\n \ -var plotlyData = ['{'\n \ -\tx: [],\n \ -\ty: [],\n \ -\ttype: 'bar'\n \ -'}'];\n \ -\n \ -// Add your Plotly layout settings here (optional)\n \ -var plotlyLayout = '{}';\n \ -\n \ -// Add your Plotly configuration settings here (optional)\n \ -var plotlyConfig = '{'\n \ -\tshowSendToCloud: false,\n \ -\tdisplaylogo: false,\n \ -\tshowLink: false,\n \ -\tresponsive: true\n \ -'}';\n \ -\n \ -// Don''t touch this line\n \ -Plotly.newPlot(''chart-canvas'', plotlyData, plotlyLayout, plotlyConfig); diff --git a/src/main/resources/templates/charts/newChart.ftl b/src/main/resources/templates/charts/newChart.ftl index 5efd990e220a0a74aa324ccc982971e580a0194c..6bda7ecac8d50623c10642874a54df76b2e5c426 100644 --- a/src/main/resources/templates/charts/newChart.ftl +++ b/src/main/resources/templates/charts/newChart.ftl @@ -49,7 +49,7 @@ <#-- script --> <div class="row"> <div class="input-field col sl2" style="width: 100%"> - <textarea id="chart-script" name="script" <@validation.validation "script" "materialize-textarea"/>><#if chart.getScript()??>${chart.getScript()}<#else>${locale.getString("chart.script.default")}</#if></textarea> + <textarea id="chart-script" name="script" <@validation.validation "script" "materialize-textarea"/>>${chart.getScript()}</textarea> </div> </div>