Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
S
sidekick
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Privat - Marco Schmiedel
sidekick
Commits
b463cf54
Commit
b463cf54
authored
Jul 27, 2022
by
Kevin Yumang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SERV-2286 - data chart manager objects WIP
parent
c40d5217
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
177 additions
and
0 deletions
+177
-0
ChartDataManager.php
...iews/Limitless/Linechart/DataManager/ChartDataManager.php
+65
-0
Series.php
src/Views/Limitless/Linechart/DataManager/Series.php
+22
-0
SeriesData.php
src/Views/Limitless/Linechart/DataManager/SeriesData.php
+63
-0
Index.blade.php
src/Views/Limitless/Linechart/Documentation/Index.blade.php
+27
-0
No files found.
src/Views/Limitless/Linechart/DataManager/ChartDataManager.php
0 → 100644
View file @
b463cf54
<?php
namespace
Ceetrox\Sidekick\Views\Limitless\Linechart\DataManager
;
Class
ChartDataManager
{
private
$categories
;
private
$series
;
public
function
__construct
()
{
$this
->
categories
=
[];
$this
->
series
=
new
Series
();
}
public
static
function
getInstance
()
:
ChartDataManager
{
return
new
self
;
}
public
static
function
getSeriesDataInstance
()
:
SeriesData
{
return
new
SeriesData
();
}
public
function
getSeries
()
:
Series
{
return
$this
->
series
;
}
private
function
getCategories
()
:
array
{
return
$this
->
categories
;
}
public
function
addCategories
(
$category
)
:
ChartDataManager
{
if
(
is_array
(
$category
))
{
$this
->
categories
=
array_merge
(
$this
->
categories
,
$category
);
}
else
{
$this
->
categories
[]
=
$category
;
}
return
$this
;
}
public
function
addSeries
(
SeriesData
$series
)
:
ChartDataManager
{
$this
->
getSeries
()
->
push
(
$series
);
return
$this
;
}
public
function
toJson
()
:
string
{
return
json_encode
(
$this
->
toArray
());
}
public
function
toArray
()
:
array
{
$data
[
'series'
]
=
$this
->
getSeries
()
->
toArray
();
$data
[
'categories'
]
=
$this
->
getCategories
();
return
$data
;
}
}
\ No newline at end of file
src/Views/Limitless/Linechart/DataManager/Series.php
0 → 100644
View file @
b463cf54
<?php
namespace
Ceetrox\Sidekick\Views\Limitless\Linechart\DataManager
;
use
Illuminate\Support\Collection
;
class
Series
extends
Collection
{
/**
* @return array
*/
public
function
toArray
()
:
array
{
$return
=
[];
$this
->
each
(
function
(
SeriesData
$entry
)
use
(
&
$return
)
{
$return
[]
=
$entry
->
toArray
();
});
return
$return
;
}
}
src/Views/Limitless/Linechart/DataManager/SeriesData.php
0 → 100644
View file @
b463cf54
<?php
namespace
Ceetrox\Sidekick\Views\Limitless\Linechart\DataManager
;
class
SeriesData
{
private
$name
;
private
$categoryValues
;
private
$index
;
public
function
__construct
()
{
$this
->
categoryValues
=
[];
$this
->
index
=
0
;
}
private
function
getName
()
:
string
{
return
$this
->
name
;
}
private
function
getCategoryValues
()
:
array
{
return
$this
->
categoryValues
;
}
private
function
getIndex
()
:
int
{
return
$this
->
index
;
}
public
function
setName
(
string
$name
)
:
SeriesData
{
$this
->
name
=
$name
;
return
$this
;
}
public
function
setCategoryValues
(
$values
)
:
SeriesData
{
if
(
is_array
(
$values
))
{
$this
->
categoryValues
=
array_merge
(
$this
->
categoryValues
,
$values
);
}
else
{
$this
->
categoryValues
[]
=
$values
;
}
return
$this
;
}
public
function
setIndex
(
int
$index
)
:
SeriesData
{
$this
->
index
=
$index
;
return
$this
;
}
public
function
toArray
()
:
array
{
return
[
'name'
=>
$this
->
getName
(),
'data'
=>
$this
->
getCategoryValues
(),
'index'
=>
$this
->
getIndex
(),
];
}
}
src/Views/Limitless/Linechart/Documentation/Index.blade.php
View file @
b463cf54
...
@@ -5,6 +5,28 @@
...
@@ -5,6 +5,28 @@
@
php
@
php
$chartDataManager
=
\Ceetrox\Sidekick\Views\Limitless\Linechart\DataManager\ChartDataManager
::
getInstance
();
// or $chartDataManager = new \Ceetrox\Sidekick\Views\Limitless\Linechart\DataManager\ChartDataManager();
// accepts string or array.
$chartDataManager
->
addCategories
(
'Mon'
);
$chartDataManager
->
addCategories
([
'Tue'
,
'Wed'
,
'Thu'
,
'Fri'
]);
$sd
=
$chartDataManager
::
getSeriesDataInstance
();
$sd
->
setName
(
'ONC'
);
$sd
->
setCategoryValues
(
100
);
$sd
->
setCategoryValues
([
200
,
300
,
400
,
500
]);
$chartDataManager
->
addSeries
(
$sd
);
$sd
=
$chartDataManager
::
getSeriesDataInstance
();
$sd
->
setName
(
'APR'
);
$sd
->
setCategoryValues
([
10
,
20
,
30
,
40
,
50
]);
$chartDataManager
->
addSeries
(
$sd
);
$output
=
$chartDataManager
->
toArray
();
// sample backend data
// sample backend data
$categories
=
[
'Jan'
,
'Feb'
,
'Mar'
,
'Apr'
,
'May'
,
'Jun'
,
'July'
,
'Aug'
,
'Sep'
,
'Oct'
,
'Nov'
,
'Dec'
];
$categories
=
[
'Jan'
,
'Feb'
,
'Mar'
,
'Apr'
,
'May'
,
'Jun'
,
'July'
,
'Aug'
,
'Sep'
,
'Oct'
,
'Nov'
,
'Dec'
];
$series
=
[
'ONC'
,
'APR'
,
'SPR'
,
'PHX'
];
$series
=
[
'ONC'
,
'APR'
,
'SPR'
,
'PHX'
];
...
@@ -12,12 +34,16 @@
...
@@ -12,12 +34,16 @@
$seriesData
=
[];
$seriesData
=
[];
$multichartSeriesData
=
[];
$multichartSeriesData
=
[];
foreach
(
$series
as
$s
)
{
foreach
(
$series
as
$s
)
{
$data
[
'name'
]
=
$multiData
[
'name'
]
=
$s
;
$data
[
'name'
]
=
$multiData
[
'name'
]
=
$s
;
$dataArray
=
[];
$dataArray
=
[];
foreach
(
$categories
as
$c
)
{
foreach
(
$categories
as
$c
)
{
$dataArray
[]
=
rand
(
1
,
100
);
$dataArray
[]
=
rand
(
1
,
100
);
}
}
$data
[
'data'
]
=
$multiData
[
'data'
]
=
$dataArray
;
$data
[
'data'
]
=
$multiData
[
'data'
]
=
$dataArray
;
$data
[
'index'
]
=
0
;
//rand(0,1); on what chart index to add.
$data
[
'index'
]
=
0
;
//rand(0,1); on what chart index to add.
$multiData
[
'index'
]
=
rand
(
0
,
1
);
$multiData
[
'index'
]
=
rand
(
0
,
1
);
...
@@ -25,6 +51,7 @@
...
@@ -25,6 +51,7 @@
$multichartSeriesData
[]
=
$multiData
;
$multichartSeriesData
[]
=
$multiData
;
}
}
dd
(
$output
,
$seriesData
,
$categories
);
// json string data should be valid else it will return null
// json string data should be valid else it will return null
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment