kevinkhill / lavacharts

Lavacharts is a graphing / charting library for PHP 5.4+ that wraps Google's Javascript Chart API.
http://lavacharts.com
Other
620 stars 142 forks source link

Lavacharts pie charts broken in live environment #225

Closed kjdion84 closed 4 years ago

kjdion84 commented 7 years ago

I have lavacharts working perfectly on localhost:

Imgur

But they are completely broken on live environment:

Imgur

Any idea why this is happening? Its using the exact same code in the exact same PHP version. I am using Siteground for my live environment and WAMPSERVER for localhost.

kjdion84 commented 7 years ago

I found something interesting:

$chart.setData({"cols":[{"type":"string","label":"Vertical"},{"type":"number","label":"Leads"}],"rows":[{"c":[{"v":"Education"},{"v":8}]},{"c":[{"v":"Auto Loan"},{"v":7}]},{"c":[{"v":"Personal Loan"},{"v":7}]}]});

vs:

$chart.setData({"cols":[{"type":"string","label":"Vertical"},{"type":"number","label":"Leads"}],"rows":[{"c":[{"v":"Education"},{"v":"8"}]},{"c":[{"v":"Auto Loan"},{"v":"7"}]},{"c":[{"v":"Personal Loan"},{"v":"7"}]}]});

It looks like the live environment is interpreting these as strings rather than numbers. I think this is the problem. How do I fix this?

kjdion84 commented 7 years ago

I fixed the issue by casting the variables with (int) for the charts.

kevinkhill commented 7 years ago

I wonder if it would be worthwhile to have all number columns be cast to floats or ints while they are converted to json.

I also want to know why the json would be output differently on dev vs live. Maybe a dumb question, but the php versions? Identical environments?

kevinkhill commented 7 years ago

Maybe using the encode_json option JSON_NUMERIC_CHECK to force numeric output would work....

kjdion84 commented 7 years ago

I have no idea.

kevinkhill commented 7 years ago

I can't promise a time frame, but I will look into this when I get a chance. But this definitely seems to be a bug.

kevinkhill commented 4 years ago

I'm going to close this, just because it is so stale. This project is not abandoned, just in a stable state for now. I am always happy to help and please open a new issue if needed.

Thank you for using Lavacharts!