-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
5 changed files
with
75 additions
and
59 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<script src="js/chart.umd.js"></script> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
/** @var string $chartName */ | ||
/** @var string $xTitle */ | ||
/** @var string $yTitle */ | ||
/** @var array $dataSet */ // ['label' => 'string', 'data' => [array]] | ||
?> | ||
<?= component('chart.chartJs', once: true) ?> | ||
|
||
<div style="margin-top: 20px; background-color: white;max-width: 1200px;"> | ||
<canvas id="<?= $chartName ?>"></canvas> | ||
</div> | ||
|
||
<script> | ||
const ctx<?= $chartName ?> = document.getElementById('<?= $chartName ?>'); | ||
|
||
const handleResize<?= $chartName ?> = (chart) => { | ||
chart.resize(); | ||
} | ||
|
||
new Chart(ctx<?= $chartName ?>, { | ||
type: 'line', | ||
data: { | ||
datasets: [ | ||
<?php foreach ($dataSet as $data) { ?> | ||
{ | ||
label: '<?= $data['label'] ?>', | ||
data: <?= json_encode($data['data']) ?>, | ||
borderWidth: 1 | ||
}, | ||
<?php } ?> | ||
] | ||
}, | ||
options: { | ||
responsive: true, | ||
onResize: handleResize<?= $chartName ?>, | ||
maintainAspectRatio: true, | ||
scales: { | ||
x: { | ||
title: { | ||
display: true, | ||
text: '<?= $xTitle ?>', | ||
} | ||
}, | ||
y: { | ||
beginAtZero: true, | ||
title: { | ||
display: true, | ||
text: '<?= $yTitle ?>' | ||
} | ||
} | ||
} | ||
} | ||
}); | ||
</script> |
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