Topic: Chart.js integration fails
leopoldus11
pro asked 10 years ago
Marta Szymanska
answered 10 years ago
<div class="container-fluid">
<!– SECTION 1 –>
<section class="section extra-margins" id="line">
<!–Section heading–>
<h1 class="section-heading wow fadeIn" data-wow-delay="0.2s">LINE CHART</h1>
<!–Section description–>
<p class="section-description wow fadeIn" data-wow-delay="0.4s">Lorem ipsum dolor sit amet, consetetur sadipscing elitr.</p>
<div class="row">
<div class="col-lg-6 col_black" style="background-color: darkgrey">
<canvas id="myChart"></canvas>
</div>
<div class="col-lg-6 col_grey" style="background-color: lightgrey">
Second column
</div>
</div>
</section>
<!– /SECTION 1 –>
</div>
In scripts:
<script>
$(function () {
var data = {
labels: ["January", "February", "March", "April", "May", "June", "July"],
datasets: [
{
label: "My First dataset",
fillColor: "rgba(220,220,220,0.2)",
strokeColor: "rgba(220,220,220,1)",
pointColor: "rgba(220,220,220,1)",
pointStrokeColor: "#fff",
pointHighlightFill: "#fff",
pointHighlightStroke: "rgba(220,220,220,1)",
data: [65, 59, 80, 81, 56, 55, 40]
},
{
label: "My Second dataset",
fillColor: "rgba(151,187,205,0.2)",
strokeColor: "rgba(151,187,205,1)",
pointColor: "rgba(151,187,205,1)",
pointStrokeColor: "#fff",
pointHighlightFill: "#fff",
pointHighlightStroke: "rgba(151,187,205,1)",
data: [28, 48, 40, 19, 86, 27, 90]
}
]
};
var option = {
responsive: true,
};
// Get the context of the canvas element we want to select
var ctx = document.getElementById("myChart").getContext('2d');
var myLineChart = new Chart(ctx).Line(data, option); //'Line' defines type of the chart.
});
</script>
PS. No need additional chart.js scripts.
I hope this answer helps you, if not write to us again and we try to help you.
Best,
Marta
leopoldus11
pro answered 10 years ago
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
- User: Pro
- Premium support: No
- Technology: General Bootstrap questions
- MDB Version: -
- Device: -
- Browser: -
- OS: -
- Provided sample code: No
- Provided link: No