JSFiddle - React, Tailwind, and code Playground
by Nikola Mihin
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js"></script>
JavaScript
var bigmac = {
type: "horizontalBar",
title: "Big Mac Index",
labels: ["Serbia", "Venezuela", "USA", "Germany", "Switzerland"],
datasets: [{
label: "2016",
backgroundColor: "#8eb9f6",
data: [3, 4, 3, 2, 3, 6],
},
{
label: "2017",
backgroundColor: "#b5c244",
data: [3, 4, 3, 2, 3, 6],
},
{
label: "2018",
backgroundColor: "#d73425",
data: [3, 4, 3, 2, 3, 6],
},
]
}
var p = {
"p1": "value1",
"p2": "value2",
"p3": "value3"
};
var obLength = Object.keys(bigmacJSON).length;
if (typeof Object.keys(value) !== 'undefined' && Object.keys(value).length > 0) {
// You have an array
}
var bigmacJSON = [{
"CountryName": "United States",
"BigMacIndexForYears": [{
"DollarPrice": 5.28,
"Year": 2018,
"EuroAdjValuation": -10.77122255944
},
{
"DollarPrice": 5.3,
"Year": 2017,
"EuroAdjValuation": -1.5005913049094
},
{
"DollarPrice": 5.04,
"Year": 2016,
"EuroAdjValuation": -1.6364445594728
},
{
"DollarPrice": 4.79,
"Year": 2015,
"EuroAdjValuation": 4.6204451110379
},
{
"DollarPrice": 4.795,
"Year": 2014,
"EuroAdjValuation": -15.542853050824
},
{
"DollarPrice": 4.5566666666667,
"Year": 2013,
"EuroAdjValuation": -9.4475279198301
},
{
"DollarPrice": 4.3275,
"Year": 2012,
"EuroAdjValuation": -9.9502612069648
},
{
"DollarPrice": 4.065,
"Year": 2011,
"EuroAdjValuation": -26.636587459842
},
{
"DollarPrice": 3.73,
"Year": 2010,
"EuroAdjValuation": 0
},
...