Absolut- hier das ganze Template:
templates/metamodel_prerendered_CUSTOM_metallnotierung_diagr amm.html5
Code:
<?php if (count($this->data)): ?>
<?php foreach ($this->data as $arrItem): ?>
<?php $this->block('item'); ?>
<?php foreach ($arrItem['attributes'] as $field => $strName): ?>
<?php if ((isset($arrItem[$this->getFormat()][$field]) && ($strValue = $arrItem[$this->getFormat()][$field])
|| (isset($arrItem['text'][$field]) && ($strValue = $arrItem['text'][$field])))): ?>
<?php if (!$this->view->get('hideLabels')): ?>
<div class="label"><?= sprintf($GLOBALS['TL_LANG']['MSC']['field_label'], $strName) ?></div>
<?php endif; ?>
<?php endif; ?>
<!-- Werte in Array speichern, Kommas durch Punkte ersetzen-->
<?php $array[] = trim(str_replace(",", ".", $strValue)); ?>
<?php endforeach; ?>
<?php $this->endblock(); ?>
<?php endforeach; ?>
<!-- Funktionen zur Überprüfung von geraden / ungeraden Stellen im Array-->
<?php
function odd($var){
return($var & 1);
}
function even($var){
return !($var & 1);
}
?>
<!--Array in Preise und Daten unterteilen-->
<?php
$arrayPrices = array_values(array_filter($array, "odd", ARRAY_FILTER_USE_KEY));
$arrayDates = array_values(array_filter($array, "even", ARRAY_FILTER_USE_KEY));
?>
<?php else : ?>
<?php endif; ?>
<!-- Global definitions -->
<script>
Chart.defaults.global.animation.duration = 2000;
</script>
<!-- Options -->
<script>
var options = {
responsive: true,
showDatapoints: true,
legend: {
position: 'top'
},
tooltips: {
mode: 'index',
intersect: false,
},
hover: {
mode: 'nearest',
intersect: true
},
scales: {
xAxes: [{
display: true,
scaleLabel: {
display: true,
labelString: 'Datum'
},
ticks: {
beginAtZero: true
}
}],
yAxes: [{
display: true,
scaleLabel: {
display: true,
labelString: 'Preis in EUR'
},
ticks: {
beginAtZero: true
}
}]
}
};
</script>
<!-- Canvas -->
<canvas id="canvas"></canvas>
<!-- Configure and render charts -->
<script>
var config_canvas = {
type: 'line',
data: {
labels: [
<?php foreach ($arrayDates as $key => $value): ?>
<?php echo "'" . $value . "'" . ','?>
<?php endforeach; ?>
],
datasets: [{
label: 'Preisverlauf',
borderColor: "#4caf50",
backgroundColor: "#4caf50",
pointRadius: 0,
fill: false,
spanGaps: false,
data: [
<?php foreach ($arrayPrices as $key => $value): ?>
<?php echo "'" . $value . "'" . ','?>
<?php endforeach; ?>
],
}]
},
options: options
};
var ctx_canvas = document.getElementById('canvas').getContext('2d');
window.myLine = new Chart(ctx_canvas, config_canvas);
</script>
EDIT: Gerade nochmal ausprobiert: Ja, benutze ich
PHP-Code:
<?php foreach ($arrayDates as $key => $value): ?>
<?php echo "'" . $value . "'" . ','?>
<?php endforeach; ?>
roh, dann gibt es den richtigen Output- isoliere ich das in einem <script>Tag, dann gibt es wieder den "span class=..." Salat.
Lesezeichen