JSFiddle - React, Tailwind, and code Playground
HTML
<canvas
id="patents-per-category-bar-chart"
width="400"
height="400"
></canvas>
JavaScript
var categoryLabels = [];
var categoryValues = [];
const data = {
"category": {
"health medicine and biotechnology": 37,
"instrumentation": 38,
"storage": 30,
"systems": 71,
"aeronautics": 1,
"electronics": 47,
"optics": 60,
"materials": 119,
"undefined": 3,
"communications": 32,
"sensors": 102,
"robotics": 37,
"software": 49,
"propulsion": 9,
"manufacturing": 40,
"environment": 24,
"aerospace": 79
}
}
for (let item in data.category) {
if (!data.category.hasOwnProperty(item)) {
continue;
}
categoryLabels.push(item);
categoryValues.push(data.category[item]);
}
console.log(categoryLabels, categoryValues)