Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graph values not JSON format #64

Open
vomikan opened this issue Apr 13, 2020 · 2 comments
Open

Graph values not JSON format #64

vomikan opened this issue Apr 13, 2020 · 2 comments

Comments

@vomikan
Copy link
Member

vomikan commented Apr 13, 2020

https://github.com/moneymanagerex/general-reports/tree/master/packages/AccountSummary

image

@vomikan
Copy link
Member Author

vomikan commented Apr 19, 2020

@vomikan
Copy link
Member Author

vomikan commented Apr 20, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant