I’m trying to render a line chart using Morris.js, but the chart is not displaying correctly. Here is my code:
var transformedData = [
{
y: "Gennaio",
a: 0,
b: 0,
c: 0,
d: 0,
e: 0,
f: 7044,
g: 0,
h: 0,
i: 10338,
j: 0,
k: 3428
},
{
y: "Febbraio",
a: 0,
b: 0,
c: 0,
d: 0,
e: 0,
f: 8189,
g: 103,
h: 0,
i: 4779,
j: 2006,
k: 16654
},
{
y: "Marzo",
a: 0,
b: 0,
c: 0,
d: 5377,
e: 0,
f: 7583,
g: 3301,
h: 0,
i: 0,
j: 337,
k: 3736
},
{
y: "Aprile",
a: 0,
b: 0,
c: 0,
d: 0,
e: 0,
f: 20202,
g: 0,
h: 0,
i: 4868,
j: 0,
k: 6292
},
{
y: "Maggio",
a: 0,
b: 1793,
c: 0,
d: 6106,
e: 0,
f: 20030,
g: 20967,
h: 0,
i: 1499,
j: 1402,
k: 11716
},
{
y: "Giugno",
a: 0,
b: 0,
c: 0,
d: 0,
e: 0,
f: 11274,
g: 9798,
h: 34021,
i: 5998,
j: 1032,
k: 42561
},
{
y: "Luglio",
a: 0,
b: 0,
c: 0,
d: 0,
e: 0,
f: 15338,
g: 0,
h: 42292,
i: 4420,
j: 0,
k: 1452
},
{
y: "Agosto",
a: 0,
b: 0,
c: 0,
d: 0,
e: 1990,
f: 3240,
g: 0,
h: 0,
i: 7158,
j: 517,
k: 0
},
{
y: "Settembre",
a: 0,
b: 0,
c: 0,
d: 22193,
e: 1171,
f: 0,
g: 1125,
h: 4763,
i: 0,
j: 0,
k: 0
},
{
y: "Ottobre",
a: 0,
b: 0,
c: 0,
d: 0,
e: 0,
f: 0,
g: 0,
h: 0,
i: 0,
j: 0,
k: 9317
},
{
y: "Novembre",
a: 0,
b: 0,
c: 0,
d: 0,
e: 0,
f: 0,
g: 0,
h: 0,
i: 0,
j: 0,
k: 0
},
{
y: "Dicembre",
a: 0,
b: 0,
c: 0,
d: 0,
e: 0,
f: 0,
g: 0,
h: 0,
i: 0,
j: 0,
k: 0
}
];
// Build the graph
Morris.Line({
resize: true,
element: "morrisLine",
data: transformedData,
xkey: "y",
ykeys: ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k"],
labels: [
"ATHENA COLLEZIONI",
"CAMPEGGI DESIGN",
"CESAR",
"FLEXTEAM",
"GLAMORA",
"INTEC",
"MODULA",
"MODULA - GAGGENAU",
"MODULA - NEFF",
"OPINIONCIATTI",
"RIMADESIO"
]
});
The chart is not rendering, and I’m not sure why. The data seems to be correctly formatted, and I’ve verified that the transformedData array contains the expected values.
Here are some additional details:
The element ID is correct and exists in the HTML.
The data values are all numbers.
The ykeys and labels arrays match the data structure.
What could be causing the chart not to render? Any help would be appreciated!
https://jsfiddle.net/7y8qot6c/1/