Skip to content

Commit 0473eb2

Browse files
dustinhuynhbrendanheywood
authored andcommitted
Make checkbox labels coloured to match the charts #177
1 parent a177c75 commit 0473eb2

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

collector/database/chart.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,16 @@
6767
$displayedmetrics[] = $m->get_name();
6868
$displayed = true;
6969
}
70-
71-
$checkboxes[] = ['checkbox' => html_writer::checkbox($m->get_name(), 1, $displayed, $m->get_label(),
72-
['onchange' => 'this.form.submit()'])];
70+
$checkbox = html_writer::checkbox($m->get_name(), 1, $displayed, '',
71+
['id' => $m->get_name(), 'onchange' => 'this.form.submit()']);
72+
$label = html_writer::tag('label', $m->get_label(), ['for' => $m->get_name(), 'style' => 'display:inline-block; margin: 0;']);
73+
$color = html_writer::tag('span', '',
74+
['style' => 'display:inline-block; width:2.5em; height:1em; background-color:' . $m->get_colour() . '; margin: 0 6px; vertical-align: middle;']);
75+
$checkboxes[] = [
76+
'checkbox' => html_writer::tag('div', $checkbox . $color . $label, [
77+
'style' => 'display: inline-flex; align-items: center; margin-right: 16px;',
78+
]),
79+
];
7380

7481
if (!in_array($m->group, $groups) && !empty($m->group)) {
7582
$groups += [$m->group => get_string($m->group, 'tool_cloudmetrics')];
@@ -304,7 +311,7 @@
304311
$context['checkboxes'] = $checkboxes;
305312
$context['metriclabel'] = $context['metriclabel'] ?? get_string('multiplemetrics', 'cltr_database');
306313
$context['frequency'] = html_writer::empty_tag('input',
307-
array('type' => 'hidden', 'name' => 'graphfrequency', 'value' => $displayfrequency));
314+
['type' => 'hidden', 'name' => 'graphfrequency', 'value' => $displayfrequency]);
308315
$renderer = $PAGE->get_renderer('tool_cloudmetrics');
309316

310317
echo $OUTPUT->header();

0 commit comments

Comments
 (0)