3👍
The problem is that there’s a type mismatch at genDates. The labels array will evaluate as an array with a single string in it unlike in your original example. To work around this you could return an array directly and remove the wrapping array from your chart definition.
0👍
var areaChartData = {
labels: labelsnuevos(productos),
// here goes my dataset
};
function labelsnuevos(productos)
{
var labels = [];
$.each(productos, function(key, value) {
var lab = value.nombre;
labels.push(lab);
});
return labels;
}
I have productos instead of dates, but you need to pass your “dates” to a variable, in this case my variable I sproductos, then with foreach you take and push its value.
- [Chartjs]-ChartJS xAxis label position
- [Chartjs]-Chart Js Change Label orientation on x-Axis for Line Charts
Source:stackexchange.com