Well, I have a function in javascript that what it does is print a graph, at the moment it does it with random values, but I'm interested in executing it with predefined values, and trying to save an array of numbers in a variable, and send it to call, but it does not work, here is the code, to see if you can resolve my question, thank you.
Javascript
(function () {
$(document).on('ready page:load', function () {
var midata = [9, 13, 10, 9, 15, 8, 9, 11, 20, 16, 14, 21];
var randomData;
randomData = function () {
return _.map([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], function (i) {
return [i, parseInt((Math.floor(Math.random() * (1 + 20 - 10))) + 10)];
});
};
return $('.flot-linea').each(function () {
var $el, color;
$el = $(this);
color = EmVars.colorFromName($el.data('color') || 'info');
return $.plot($el, [
{
data: randomData()
}
], {
series: {
lines: {
show: true,
lineWidth: 1,
fill: true,
fillColor: {
colors: [
{
opacity: 0.3
}, {
opacity: 0.3
}
]
}
},
points: {
radius: 3,
show: true
},
grow: {
active: true,
steps: 50
},
shadowSize: 2
},
grid: {
hoverable: true,
clickable: true,
tickColor: EmVars.colors.light.color,
borderWidth: 1,
color: EmVars.colors.light.color
},
colors: [color],
xaxis: {},
yaxis: {
ticks: 5
},
tooltip: true,
tooltipOpts: {
content: "chart: %x.1 is %y.4",
defaultTheme: false,
shifts: {
x: 0,
y: 20
}
}
});
});
});
}).call(this);