general-reports
general-reports copied to clipboard
Graph values not JSON format
https://github.com/moneymanagerex/general-reports/tree/master/packages/AccountSummary
https://github.com/moneymanagerex/moneymanagerex/issues/1695
Using this project: https://github.com/rxi/json.lua JSON may be encoded more easy.
json = require "json"
local sys_locale=os.setlocale("", "numeric");
print(os.setlocale("C", "numeric"));
local total = 0;
local data = '';
local count = 0;
local colors = {"#FF6666", "#FFB266", "#FFFF66", "#B2FF66", "#66FF66", "#66FFB2", "#66FFFF", "#66B2FF", "#6666FF", "#B266FF", "#FF66FF", "#FF66B2"};
function handle_record(record)
local base = record:get('BALANCE') * record:get("CURRVALUE");
record:set("BASE", base);
total = total + base;
local color = colors[1 + (count % #colors)];
data = data .. json.encode({value = base, color = color } ) .. ',';
record:set('COLOR', color);
count = count + 1;
end
function complete(result)
result:set("Total", total);
result:set('CHART_DATA', data);
print(os.setlocale(sys_locale, "numeric"));
end