Start working on the Stats Viewer application
This commit is contained in:
parent
cb3bc7c86c
commit
91863d85a8
18 changed files with 422 additions and 1 deletions
58
module/Apps/TestApp.mjs
Normal file
58
module/Apps/TestApp.mjs
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
import Chart from "chart.js/auto";
|
||||
import { filePath } from "../consts.mjs";
|
||||
|
||||
const { ApplicationV2, HandlebarsApplicationMixin } = foundry.applications.api;
|
||||
|
||||
const data = [
|
||||
{ face: 1, count: Math.floor(Math.random() * 50) },
|
||||
{ face: 2, count: Math.floor(Math.random() * 50) },
|
||||
{ face: 3, count: Math.floor(Math.random() * 50) },
|
||||
{ face: 4, count: Math.floor(Math.random() * 50) },
|
||||
{ face: 5, count: Math.floor(Math.random() * 50) },
|
||||
{ face: 6, count: Math.floor(Math.random() * 50) },
|
||||
];
|
||||
|
||||
export class TestApp extends HandlebarsApplicationMixin(ApplicationV2) {
|
||||
// #region Options
|
||||
static DEFAULT_OPTIONS = {
|
||||
window: {
|
||||
title: `Dice Pool`,
|
||||
frame: true,
|
||||
positioned: true,
|
||||
resizable: false,
|
||||
minimizable: true,
|
||||
},
|
||||
position: {
|
||||
width: `auto`,
|
||||
height: `auto`,
|
||||
},
|
||||
actions: {
|
||||
},
|
||||
};
|
||||
|
||||
static PARTS = {
|
||||
numberOfDice: {
|
||||
template: filePath(`templates/Apps/TestApp/main.hbs`),
|
||||
},
|
||||
};
|
||||
// #endregion
|
||||
|
||||
_onRender() {
|
||||
const canvas = this.element.querySelector(`canvas`);
|
||||
new Chart(
|
||||
canvas,
|
||||
{
|
||||
type: `bar`,
|
||||
data: {
|
||||
labels: data.map( r => r.face),
|
||||
datasets: [
|
||||
{
|
||||
label: `d6 Rolls`,
|
||||
data: data.map(r => r.count),
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
);
|
||||
};
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue