Created
May 17, 2020 01:30
-
-
Save gavilanch/88b626f50642154b33fe9561698b68dd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function initializeCounterComponent(container) { | |
var chart = container.querySelector('#myChart'); | |
inicializarChart(chart); | |
var button = container.querySelector("#counterClick"); | |
var title = container.querySelector("h1"); | |
if (button) { | |
button.addEventListener("click", (e) => { | |
let button = e.target; | |
button.innerHTML = "Hello"; | |
title.innerHTML = "The button has been clicked!"; | |
}); | |
} | |
var $dateStart = $(container.querySelector('#dateStart')); | |
var $dateEnd = $(container.querySelector('#dateEnd')); | |
$dateStart.datetimepicker( | |
{ useCurrent: false } | |
); | |
$dateEnd.datetimepicker(); | |
$dateStart.on("change.datetimepicker", function (e) { | |
$dateEnd.datetimepicker('minDate', e.date); | |
}); | |
$dateEnd.on("change.datetimepicker", function (e) { | |
$dateStart.datetimepicker('maxDate', e.date); | |
}); | |
}; | |
function inicializarChart(chart) { | |
var ctx = chart.getContext('2d'); | |
var data = [0, 10, 5, 2, 20, 30, 45]; | |
var chart = new Chart(ctx, { | |
// The type of chart we want to create | |
type: 'line', | |
// The data for our dataset | |
data: { | |
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'], | |
datasets: [{ | |
label: 'My First dataset', | |
backgroundColor: 'rgb(255, 99, 132)', | |
borderColor: 'rgb(255, 99, 132)', | |
data: data | |
}] | |
}, | |
// Configuration options go here | |
options: {} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment