Topic: Questions about charts, labels and JS
Marta Szymanska staff pro premium answered 8 years ago
diworm answered 8 years ago
//Statistics chart
$(function () {
var data = {
labels: [<?=$data['timeline'];?>],
datasets: [
<?=$data['dataset'];?>
]
};
var option = {
responsive: true,
title: {
display: true,
text: 'Custom Chart Title'
},
legend: {
display: true,
position: 'top',
labels: {
fontColor: 'rgb(255, 99, 132)'
}
}
};
// Get the context of the canvas element we want to select
var ctx = document.getElementById("statistics").getContext('2d');
var myLineChart = new Chart(ctx).Line(data, option); //'Line' defines type of the chart.
});
But no legend and no chart title for me with this code.
Docs for legend: http://www.chartjs.org/docs/#chart-configuration-legend-configuration
thinking out loud: Maybee I need to add labels in option.legend, but my logic down here, coz I add labels in 'dataset' and if I do this with another chart type all hints work normaly.... Marta Szymanska staff pro premium answered 8 years ago
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
- User: Free
- Premium support: No
- Technology: General Bootstrap questions
- MDB Version: -
- Device: -
- Browser: -
- OS: -
- Provided sample code: No
- Provided link: No