How to change the color under the graph, the bottom part (make fill) in Chart.js?
1 answer
According to the documentation, you must set the fill
value to true
and set the desired color to bacgroundColor
.
var ctx = document.getElementById("myChart"); var ctx = document.getElementById("myChart").getContext("2d"); var myChart = new Chart(ctx, { type: 'line', data: { labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"], datasets: [{ data: [65, 59, 80, 81, 56, 55, 40], fill: true, backgroundColor: [ 'rgb(13, 152, 186)' ], }] } });
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.1.6/Chart.bundle.js"></script> <canvas id="myChart" width="400" height="400"></canvas>
|