diff --git a/app/javascript/controllers/admin_controller.js b/app/javascript/controllers/admin_controller.js index 4ad3d4f..e94648a 100644 --- a/app/javascript/controllers/admin_controller.js +++ b/app/javascript/controllers/admin_controller.js @@ -1,12 +1,28 @@ import { Controller } from '@hotwired/stimulus'; import 'chartkick/chart.js'; +import Chartkick from 'chartkick'; require('datatables.net'); require('datatables.net-bs5'); export default class extends Controller { + static targets = []; + + static values = { + type: String, + data: Array, + options: Object, + }; + + chart = null; + connect() { this.table = document.getElementsByClassName('table-admin').DataTable(); + this.chart = new Chartkick[this.typeValue]( + this.element.id, + this.dataValue, + this.optionsValue, + ); } disconnect() {