Non puoi selezionare più di 25 argomenti
Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
115 righe
3.6 KiB
115 righe
3.6 KiB
<? |
|
if (!empty($titolo) && !empty($serie) && !empty($idGraph)) { |
|
$arrangedData = reportManager::arrangeDataForGraph($serie); |
|
$dati = $arrangedData["dati"]; |
|
$categorie = $arrangedData["categorie"]; |
|
$subCategorie = $arrangedData["subCategorie"] ?? null; |
|
$groupsInfo = $arrangedData["groupsInfo"]; |
|
?> |
|
<div id="graph<?= $idGraph ?>"></div> |
|
<script> |
|
var thisChart<?= $idGraph ?> = Highcharts.chart('graph<?= $idGraph ?>', { |
|
chart: { |
|
type: 'column', |
|
zoomType: 'x', |
|
height: <?= $chartHeight ?>, |
|
}, |
|
title: { |
|
text: "<?= str_replace('"',"",$titolo) ?>" |
|
}, |
|
|
|
xAxis: { |
|
categories: [ |
|
"<?= implode('","',($subCategorie ?? $categorie)) ?>" |
|
], |
|
crosshair: true |
|
}, |
|
yAxis: { |
|
min: 0, |
|
<? if (count($dati) > 1 || !empty($subCategorie)) { ?> |
|
stackLabels: { |
|
enabled: true, |
|
style: { |
|
fontWeight: 'bold', |
|
color: ( // theme |
|
Highcharts.defaultOptions.title.style && |
|
Highcharts.defaultOptions.title.style.color |
|
) || 'gray', |
|
textOutline: 'none' |
|
} |
|
} |
|
<? } ?> |
|
}, |
|
<? if (count($dati) > 1 || !empty($subCategorie)) { ?> |
|
tooltip: { |
|
headerFormat: '<b>{point.x}</b><br/>', |
|
pointFormat: '{series.name}: {point.y}<br/>Total: {point.stackTotal}' |
|
}, |
|
<? } ?> |
|
plotOptions: { |
|
column: { |
|
pointPadding: 0.2, |
|
stacking: 'normal', |
|
borderWidth: 0 |
|
} |
|
}, |
|
series: [ |
|
<? |
|
foreach($dati AS $groupId => $macroData) { |
|
if (empty($subCategorie)) { |
|
?>{ |
|
name: "<?= str_replace('"',"",$groupsInfo[$groupId]["label"]) ?>", |
|
data: [ |
|
<? |
|
ksort($macroData); |
|
foreach($macroData AS $label => $data) { |
|
if (!is_array($data)) { |
|
?> |
|
{ |
|
y: <?= $data ?>, |
|
name: "<?= str_replace('"',"",$label) ?>", |
|
<? if (count($dati) === 1) { ?> |
|
color: '#<?= dechex(rand(0x000000, 0xFFFFFF)) ?>' |
|
<? } ?> |
|
}, |
|
<? |
|
} |
|
} |
|
?> |
|
] |
|
}, |
|
<? |
|
} else { |
|
ksort($macroData); |
|
foreach($macroData AS $macroLabel => $macroGroup) { |
|
?> |
|
{ |
|
name: "<?= str_replace('"',"",$macroLabel) ?>", |
|
data: [ |
|
<? |
|
ksort($macroGroup); |
|
foreach($macroGroup AS $label => $data) { |
|
if (!is_array($data)) { |
|
?> |
|
{ |
|
y: <?= $data ?>, |
|
name: "<?= str_replace('"',"",$label) ?>" |
|
}, |
|
<? |
|
} |
|
} |
|
?> |
|
] |
|
}, |
|
<? |
|
} |
|
} |
|
} |
|
?> |
|
] |
|
}) |
|
charts.push(thisChart<?= $idGraph ?>); |
|
</script> |
|
<? |
|
} |
|
?>
|