I am working on Shopify and creating a d3 chart. I tried to pass data from Shopify liquid to javascript. The codes are as shown in the fiddle.
var temp_test = {
"events": []
};
var test = [
[
"<p>Everything is fresh. delicious and good.</p>",
undefined,
"12-23-2000",
"test",
"Start"
],
[
"<p>Everything is fresh. delicious and good.</p>",
undefined,
"12-23-2000",
"test",
"Start"
]
];
test.forEach(function(data) {
temp_test.events.push({
"title": data[0],
"image": data[1],
"date": data[2],
"content_1": data[3],
"content_2": data[4]
});
});
console.log('check for nan', temp_test);
https://jsfiddle.net/be83yk54/22/
(Strangely, the fiddle works just fine but Shopify does not and it is not Shopify problem).
console.log shows the data just fine, but when I click on the data to expand the object, the string is converted to number automatically and I got NaN instead of formatted date.