Flot   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 17
dl 0
loc 33
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A drawGraph() 0 31 1
1
<?php
2
3
use Jaxon\Jaxon;
4
use Jaxon\Flot\FlotPlugin;
5
6
class Flot extends \Jaxon\App\FuncComponent
7
{
8
    public function drawGraph()
9
    {
10
        $flot = $this->response->plugin(FlotPlugin::class);
11
        // Create a new plot, to be displayed in the div with id "flot"
12
        $plot = $flot->plot('#flot')->width('450px')->height('300px');
0 ignored issues
show
Bug introduced by
The method plot() does not exist on Jaxon\Plugin\ResponsePluginInterface. It seems like you code against a sub-type of Jaxon\Plugin\ResponsePluginInterface such as Jaxon\Flot\FlotPlugin. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

12
        $plot = $flot->/** @scrutinizer ignore-call */ plot('#flot')->width('450px')->height('300px');
Loading history...
13
        // Set the ticks on X axis
14
        // $ticks = [];
15
        // for($i = 0; $i < 10; $i++) $ticks[] = [$i, 'Pt' . $i];
16
        // $plot->xaxis()->points($ticks);
17
        $plot->xaxis()->expr(0, 16, 1, 'plots.xaxis.label');
18
19
        // Add a first graph to the plot
20
        $graph = $plot->graph(['lines' => ['show' => true], 'label' => 'Sqrt']);
21
        $graph->series()
22
            ->expr(0, 14, 0.5, 'plots.sqrt.value', 'plots.sqrt.label');
23
24
        // Add a second graph to the plot
25
        $graph = $plot->graph([
26
            'lines' => ['show' => true],
27
            'points' => ['show' => true],
28
            'label' => 'Graph 2',
29
        ]);
30
        $graph->series()->points([
31
            [0, 3, 'Pt 1'],
32
            [4, 8, 'Pt 2'],
33
            [8, 5, 'Pt 3'],
34
            [9, 13, 'Pt 4'],
35
        ]);
36
37
        // Draw the graph
38
        $flot->draw($plot);
0 ignored issues
show
Bug introduced by
The method draw() does not exist on Jaxon\Plugin\ResponsePluginInterface. It seems like you code against a sub-type of Jaxon\Plugin\ResponsePluginInterface such as Jaxon\Flot\FlotPlugin. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

38
        $flot->/** @scrutinizer ignore-call */ 
39
               draw($plot);
Loading history...
39
    }
40
}
41
42
// Register object
43
$jaxon = jaxon();
44
45
$jaxonAppDir = dirname(__DIR__, 2) . '/public/app';
46
$jaxonAppURI = '/app';
47
48
$jaxon->setOption('js.app.export', true);
49
$jaxon->setOption('js.app.dir', $jaxonAppDir);
50
$jaxon->setOption('js.app.uri', $jaxonAppURI);
51
$jaxon->setOption('js.app.minify', false); // Optionally, the file can be minified
52
53
$jaxon->setOption('js.lib.uri', '/js');
54
$jaxon->register(Jaxon::CALLABLE_CLASS, Flot::class);
55