public function Tracking::content in Flot 8
Zooming.
1 string reference to 'Tracking::content'
- flot_examples.routing.yml in flot_examples/
flot_examples.routing.yml - flot_examples/flot_examples.routing.yml
File
- flot_examples/
src/ Controller/ Tracking.php, line 15
Class
- Tracking
- Demonstrate tracking values with the cursor.
Namespace
Drupal\flot_examples\ControllerCode
public function content() {
$cos = [];
$sin = [];
for ($i = 0; $i < 14; $i += 0.1) {
$sin[] = [
$i,
sin($i),
];
$cos[] = [
$i,
cos($i),
];
}
$data = [
[
'data' => $sin,
'label' => 'sin(x) = -0.00',
],
[
'data' => $cos,
'label' => 'cos(x) = -0.00',
],
];
$options = [
'series' => [
'lines' => [
'show' => TRUE,
],
],
'crosshair' => [
'mode' => "x",
],
'grid' => [
'hoverable' => TRUE,
'autoHighlight' => FALSE,
],
'yaxis' => [
'min' => -1.2,
'max' => 1.2,
],
];
$text = [];
$text[] = $this
->t("You can add crosshairs that'll track the mouse position, either on both axes or as here on only one.");
$text[] = $this
->t('If you combine it with listening on hover events, you can use it to track the intersection on the curves by interpolating the data points (look at the legend).');
$text[] = [
[
'#markup' => '<p id="hoverdata"></p>',
],
];
$output[] = [
'#type' => 'flot',
'#theme' => 'flot_examples',
'#data' => $data,
'#options' => $options,
'#attached' => [
'library' => [
'flot_examples/tracking',
],
],
'#text' => $text,
];
return $output;
}