Skip to content

Commit

Permalink
Init chartkick
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenyeargin committed Feb 4, 2024
1 parent b593f0f commit 84ea6c0
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions app/javascript/controllers/admin_controller.js
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down

0 comments on commit 84ea6c0

Please sign in to comment.