Upon running:
<script>
jQuery(document).ready(function($){
function PopulateProductSales(chart1) {
var items = '<?php echo $json ?>';
chart1.setDataSource(items);
}
});
</script>
the console returns:
TypeError: b is not an object
...null;if("string"==typeof b)return c==e?b:null;for(var d=Object.getPrototypeOf(b)... jchartfx.system.js
in the console. If however, I run:
<script>
jQuery(document).ready(function($){
function PopulateProductSales(chart1) {
var items = [{
"Month": "Jan 2014",
"Posts": 12,
}, {
"Month": "Feb 2013",
"Posts": 10,
}, {
"Month": "Mar 2013",
"Posts": 16,
}, {
"Month": "Apr 2013",
"Posts": 7,
}, {
"Month": "May 2012",
"Posts": 1,
}];
chart1.setDataSource(items);
}
});
</script>
my chart/graph loads fine. Furthermore, the dynamic data is valid json, since observing the results in both console and http://jsonlint.com/ .
<script>
var items = '<?php echo $json ?>';
console.log(items);
</script>
ouputs:
[{"month":"May 2013","posts":2},{"month":"March 2013","posts":1}...]
to the console. The dynamic data is exactly the same as the static! All jchartfx libraries are loaded correctly, the DOM get's parsed OK - so why won't the software work with my dynamic data?
Either your JSON is broken, or the API is waiting for an actual
Object
as in{}
.Try using http://jsonlint.com