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
e0962a92
Commit
e0962a92
authored
Aug 01, 2022
by
Kevin Yumang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SERV-2286 - pie chart data manager object WIP
parent
b36b438c
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
213 additions
and
58 deletions
+213
-58
ChartDataManager.php
src/Managers/ChartManager/ChartDataManager.php
+2
-2
ISeriesData.php
src/Managers/ChartManager/ISeriesData.php
+8
-0
LineSeriesData.php
src/Managers/ChartManager/LineSeriesData.php
+92
-0
PieSeriesData.php
src/Managers/ChartManager/PieSeriesData.php
+46
-0
Series.php
src/Managers/ChartManager/Series.php
+2
-2
SeriesData.php
src/Managers/ChartManager/SeriesData.php
+9
-18
PieChartData.php
src/Views/Limitless/Piechart/Attachments/PieChartData.php
+7
-3
piechart.init.js
src/Views/Limitless/Piechart/Attachments/piechart.init.js
+11
-10
Index.blade.php
src/Views/Limitless/Piechart/Documentation/Index.blade.php
+36
-23
No files found.
src/Managers/ChartManager/ChartDataManager.php
View file @
e0962a92
...
...
@@ -30,7 +30,7 @@ Class ChartDataManager {
$this
->
markLine
=
null
;
}
public
static
function
getSeriesDataInstance
()
:
SeriesData
public
static
function
getSeriesDataInstance
()
:
I
SeriesData
{
return
new
SeriesData
();
}
...
...
@@ -83,7 +83,7 @@ Class ChartDataManager {
}
}
public
function
addSeries
(
SeriesData
$series
)
public
function
addSeries
(
I
SeriesData
$series
)
{
$this
->
series
->
push
(
$series
);
$this
->
numberOfCharts
=
$this
->
series
->
numberOfCharts
();
...
...
src/Managers/ChartManager/ISeriesData.php
0 → 100644
View file @
e0962a92
<?php
namespace
Ceetrox\Managers\ChartManager
;
interface
ISeriesData
{
public
function
getIndex
()
:
int
;
public
function
toArray
()
:
array
;
}
src/Managers/ChartManager/LineSeriesData.php
0 → 100644
View file @
e0962a92
<?php
namespace
Ceetrox\Managers\ChartManager
;
class
LineSeriesData
implements
ISeriesData
{
private
string
$name
;
private
array
$categoryValues
;
private
int
$index
;
private
?
string
$type
;
private
?
string
$stackName
;
private
?
bool
$showPointValues
;
private
?
bool
$isArea
;
private
?
string
$markLine
;
public
function
__construct
()
{
$this
->
categoryValues
=
[];
$this
->
index
=
0
;
$this
->
type
=
null
;
$this
->
stackName
=
null
;
$this
->
showPointValues
=
null
;
$this
->
isArea
=
null
;
$this
->
markLine
=
null
;
}
public
function
getIndex
()
:
int
{
return
$this
->
index
;
}
public
function
setName
(
string
$name
)
{
$this
->
name
=
$name
;
}
public
function
setCategoryValues
(
$values
)
{
if
(
is_array
(
$values
))
{
$this
->
categoryValues
=
array_merge
(
$this
->
categoryValues
,
$values
);
}
else
{
$this
->
categoryValues
[]
=
$values
;
}
}
public
function
setIndex
(
int
$index
)
{
$this
->
index
=
$index
;
}
public
function
setType
(
string
$value
)
{
$this
->
type
=
$value
;
}
public
function
setStackName
(
string
$value
)
{
$this
->
stackName
=
$value
;
}
public
function
setShowPointValues
(
bool
$value
)
{
$this
->
showPointValues
=
$value
;
}
public
function
setIsArea
(
bool
$value
)
{
$this
->
isArea
=
$value
;
}
public
function
setMarkLine
(
string
$value
)
{
$this
->
markLine
=
$value
;
}
public
function
toArray
()
:
array
{
$data
=
[];
$data
[
'name'
]
=
$this
->
name
;
$data
[
'data'
]
=
$this
->
categoryValues
;
$data
[
'index'
]
=
$this
->
index
;
if
(
!
is_null
(
$this
->
type
))
$data
[
'type'
]
=
$this
->
type
;
if
(
!
is_null
(
$this
->
stackName
))
$data
[
'stacked'
]
=
$this
->
stackName
;
if
(
!
is_null
(
$this
->
showPointValues
))
$data
[
'pointValues'
]
=
$this
->
showPointValues
;
if
(
!
is_null
(
$this
->
markLine
))
$data
[
'markLine'
]
=
$this
->
markLine
;
if
(
!
is_null
(
$this
->
isArea
))
$data
[
'isArea'
]
=
$this
->
isArea
;
return
$data
;
}
}
src/Managers/ChartManager/PieSeriesData.php
0 → 100644
View file @
e0962a92
<?php
namespace
Ceetrox\Managers\ChartManager
;
class
PieSeriesData
implements
ISeriesData
{
private
?
string
$name
;
private
array
$data
;
private
int
$index
;
public
function
__construct
()
{
$this
->
name
=
null
;
$this
->
data
=
[];
$this
->
index
=
0
;
}
public
function
setName
(
string
$value
)
{
$this
->
name
=
$value
;
}
public
function
addData
(
string
$name
,
float
$value
)
{
$data
=
(
object
)[];
$data
->
name
=
$name
;
$data
->
value
=
$value
;
$this
->
data
[]
=
$data
;
}
public
function
getIndex
()
:
int
{
return
$this
->
index
;
}
public
function
toArray
()
:
array
{
$data
=
[];
$data
[
'data'
]
=
$this
->
data
;
$data
[
'name'
]
=
$this
->
name
;
return
$data
;
}
}
src/Managers/ChartManager/Series.php
View file @
e0962a92
...
...
@@ -8,7 +8,7 @@ class Series extends Collection
public
function
toArray
()
:
array
{
$return
=
[];
$this
->
each
(
function
(
SeriesData
$entry
)
use
(
&
$return
)
{
$this
->
each
(
function
(
I
SeriesData
$entry
)
use
(
&
$return
)
{
$return
[]
=
$entry
->
toArray
();
});
...
...
@@ -17,7 +17,7 @@ class Series extends Collection
public
function
numberOfCharts
()
:
int
{
return
$this
->
unique
(
function
(
SeriesData
$entry
)
{
return
$this
->
unique
(
function
(
I
SeriesData
$entry
)
{
return
$entry
->
getIndex
();
})
->
count
();
}
...
...
src/Managers/ChartManager/SeriesData.php
View file @
e0962a92
<?php
namespace
Ceetrox\Managers\ChartManager
;
class
SeriesData
class
SeriesData
implements
ISeriesData
{
private
string
$name
;
private
array
$categoryValues
;
...
...
@@ -28,57 +28,48 @@ class SeriesData
return
$this
->
index
;
}
public
function
setName
(
string
$name
)
:
SeriesData
public
function
setName
(
string
$name
)
{
$this
->
name
=
$name
;
return
$this
;
}
public
function
setCategoryValues
(
$values
)
:
SeriesData
public
function
setCategoryValues
(
$values
)
{
if
(
is_array
(
$values
))
{
$this
->
categoryValues
=
array_merge
(
$this
->
categoryValues
,
$values
);
}
else
{
$this
->
categoryValues
[]
=
$values
;
}
return
$this
;
}
public
function
setIndex
(
int
$index
)
:
SeriesData
public
function
setIndex
(
int
$index
)
{
$this
->
index
=
$index
;
return
$this
;
}
public
function
setType
(
string
$value
)
:
SeriesData
public
function
setType
(
string
$value
)
{
$this
->
type
=
$value
;
return
$this
;
}
public
function
setStackName
(
string
$value
)
:
SeriesData
public
function
setStackName
(
string
$value
)
{
$this
->
stackName
=
$value
;
return
$this
;
}
public
function
setShowPointValues
(
bool
$value
)
:
SeriesData
public
function
setShowPointValues
(
bool
$value
)
{
$this
->
showPointValues
=
$value
;
return
$this
;
}
public
function
setIsArea
(
bool
$value
)
:
SeriesData
public
function
setIsArea
(
bool
$value
)
{
$this
->
isArea
=
$value
;
return
$this
;
}
public
function
setMarkLine
(
string
$value
)
:
SeriesData
public
function
setMarkLine
(
string
$value
)
{
$this
->
markLine
=
$value
;
return
$this
;
}
public
function
toArray
()
:
array
...
...
src/Views/Limitless/Piechart/Attachments/PieChartData.php
View file @
e0962a92
...
...
@@ -2,6 +2,8 @@
namespace
Ceetrox\Sidekick\Views\Limitless\Piechart\Attachments
;
use
Ceetrox\Managers\ChartManager\ChartDataManager
;
use
Ceetrox\Managers\ChartManager\ISeriesData
;
use
Ceetrox\Managers\ChartManager\PieSeriesData
;
Class
PieChartData
extends
ChartDataManager
{
...
...
@@ -25,6 +27,11 @@ Class PieChartData extends ChartDataManager {
return
new
self
;
}
public
static
function
getSeriesDataInstance
()
:
ISeriesData
{
return
new
PieSeriesData
();
}
public
function
setSubtitle
(
string
$value
)
{
$this
->
subtitle
=
$value
;
...
...
@@ -52,9 +59,6 @@ Class PieChartData extends ChartDataManager {
public
function
toArray
()
:
array
{
// set if conditions so we can only pass attributes that are set.
// if attributes are not set then we can check and use the manual parameters of the charts.
$data
=
[];
if
(
!
is_null
(
$this
->
subtitle
))
$data
[
'subtitle'
]
=
$this
->
subtitle
;
...
...
src/Views/Limitless/Piechart/Attachments/piechart.init.js
View file @
e0962a92
...
...
@@ -68,16 +68,17 @@ function set_data(elementObject, callback) {
// variables (this will be set by user)
let
title
=
objectData
?.
title
??
(
elementObject
.
attr
(
'
title
'
)
??
null
);
let
subtitle
=
objectData
?.
subtitle
??
(
elementObject
.
attr
(
'
subtitle
'
)
??
null
);
let
pieType
=
objectData
?.
pieType
??
(
elementObject
.
attr
(
'
pie-type
'
)
??
null
);
//
nested,
donut or rose types
let
showLabel
=
objectData
.
showL
abel
??
((
elementObject
.
attr
(
'
label
'
)
==
'
true
'
||
elementObject
.
attr
(
'
label
'
)
==
true
));
let
labelOnEmphasis
=
objectData
.
labelOnEmphasis
??
((
elementObject
.
attr
(
'
emphasis-label
'
)
==
'
true
'
||
elementObject
.
attr
(
'
emphasis-label
'
)
==
true
));
let
pieType
=
objectData
?.
pieType
??
(
elementObject
.
attr
(
'
pie-type
'
)
??
null
);
// donut or rose types
let
showLabel
=
objectData
?.
l
abel
??
((
elementObject
.
attr
(
'
label
'
)
==
'
true
'
||
elementObject
.
attr
(
'
label
'
)
==
true
));
let
labelOnEmphasis
=
objectData
?
.
labelOnEmphasis
??
((
elementObject
.
attr
(
'
emphasis-label
'
)
==
'
true
'
||
elementObject
.
attr
(
'
emphasis-label
'
)
==
true
));
let
colors
=
objectData
?.
colors
??
(
JSON
.
parse
(
elementObject
.
attr
(
'
colors
'
))
??
defaultColors
);
let
animationDuration
=
objectData
?.
animationDuration
??
(
elementObject
.
attr
(
'
animation-duration
'
)
??
750
);
let
series
=
objectData
?.
series
??
(
JSON
.
parse
(
elementObject
.
attr
(
'
series
'
))
??
null
);
let
nested
=
series
.
nested
??
false
;
let
nested
=
(
Array
.
isArray
(
series
)
&&
series
.
length
>
1
)
??
false
;
if
(
Array
.
isArray
(
series
)
&&
series
.
length
==
1
)
series
=
series
[
0
];
// if series is array and has only one object then set first
let
seriesNames
=
setSeriesNames
(
series
,
nested
);
let
seriesObject
=
nested
?
setNestedSeries
(
series
,
showLabel
,
labelOnEmphasis
)
:
setSeries
(
series
,
pieType
,
showLabel
,
labelOnEmphasis
);
...
...
@@ -164,7 +165,7 @@ function setNestedSeries(series, showLabel, labelOnEmphasis) {
if
(
!
series
||
series
.
length
==
0
)
return
[];
let
data
=
[{
name
:
series
.
name
,
name
:
series
[
0
]
.
name
,
type
:
'
pie
'
,
selectedMode
:
'
single
'
,
radius
:
[
0
,
'
50%
'
],
...
...
@@ -180,10 +181,10 @@ function setNestedSeries(series, showLabel, labelOnEmphasis) {
}
}
},
data
:
series
.
innerD
ata
data
:
series
[
0
].
d
ata
},
{
name
:
series
.
name
,
name
:
series
[
1
]
.
name
,
type
:
'
pie
'
,
radius
:
[
'
60%
'
,
'
85%
'
],
itemStyle
:
{
...
...
@@ -206,7 +207,7 @@ function setNestedSeries(series, showLabel, labelOnEmphasis) {
}
}
},
data
:
series
.
outerD
ata
data
:
series
[
1
].
d
ata
}];
return
data
;
...
...
@@ -219,8 +220,8 @@ function setSeriesNames(series, nested) {
if
(
nested
)
{
let
nestedSeries
;
let
innerSeries
=
series
.
innerD
ata
.
map
(
function
(
item
){
return
item
.
name
});
let
outerSeries
=
series
.
outerD
ata
.
map
(
function
(
item
){
return
item
.
name
});
let
innerSeries
=
series
[
0
].
d
ata
.
map
(
function
(
item
){
return
item
.
name
});
let
outerSeries
=
series
[
1
].
d
ata
.
map
(
function
(
item
){
return
item
.
name
});
nestedSeries
=
innerSeries
.
concat
(
outerSeries
);
return
nestedSeries
;
...
...
src/Views/Limitless/Piechart/Documentation/Index.blade.php
View file @
e0962a92
...
...
@@ -8,29 +8,28 @@
$chartDataManager
=
SidekickPieChartDataManager
::
getInstance
();
// or $chartDataManager = new SidekickPieChartDataManager();
// accepts string or array.
$chartDataManager
->
addCategories
(
'Mon'
);
$chartDataManager
->
addCategories
([
'Tue'
,
'Wed'
,
'Thu'
,
'Fri'
]);
$sd
=
$chartDataManager
::
getSeriesDataInstance
();
$sd
->
setName
(
'ONC'
);
$sd
->
setCategoryValues
(
10
);
$sd
->
setCategoryValues
([
100
,
50
,
80
,
60
]);
$sd
->
setIndex
(
0
);
// 0 as default.
$sd
->
addData
(
'ONC'
,
20
);
$sd
->
addData
(
'APR'
,
50
);
$sd
->
addData
(
'PHX'
,
33.33
);
$sd
->
setName
(
'Projects'
);
$chartDataManager
->
addSeries
(
$sd
);
$sd
=
$chartDataManager
::
getSeriesDataInstance
();
$sd
->
setName
(
'APR'
);
$sd
->
setCategoryValues
([
90
,
40
,
70
,
20
,
90
]
);
$sd
->
setIndex
(
0
);
$sd
->
addData
(
'A'
,
22
);
$sd
->
addData
(
'B'
,
55
);
$sd
->
addData
(
'C'
,
88.33
);
$sd
->
setName
(
'Projects 2'
);
$chartDataManager
->
addSeries
(
$sd
);
$chartDataManager
->
setHasLabel
(
false
);
$dataObject
=
$chartDataManager
->
toJson
();
// sample backend data
// series should be an object or if nested, array of objects limit 2.
$series
=
[
'ONC'
,
'APR'
,
'SPR'
,
'PHX'
,
'BRG'
];
// basic data
...
...
@@ -42,23 +41,37 @@
$data
[
'data'
][]
=
$seriesData
;
}
// nested pie data
$nestedSeriesInner
=
[
'ONC'
,
'APR'
,
'SPR'
,
'PHX'
];
$nestedSeriesOuter
=
[
'BRG'
,
'SDK'
,
'OCT'
,
'SIG'
];
$nestedData
[
'name'
]
=
'All Projects'
;
$nestedData
[
'nested'
]
=
true
;
// this will be auto set when inner and outer data have values
$nestedData
=
[];
$seriesData
=
[];
foreach
(
$nestedSeriesInner
as
$i
)
{
$
nestedSeriesInnerData
=
(
object
)[];
$
nestedSeriesInnerData
->
name
=
$i
;
$
nestedSeriesInnerData
->
value
=
rand
(
1
,
100
);
$
nestedData
[
'innerData'
][]
=
$nestedSeriesInnerData
;
$
series
=
(
object
)[];
$
series
->
name
=
$i
;
$
series
->
value
=
rand
(
1
,
100
);
$
seriesData
[]
=
$series
;
}
$nestedSeriesData
=
[];
$nestedSeriesData
[
'data'
]
=
$seriesData
;
$nestedSeriesData
[
'name'
]
=
'Project 1'
;
$nestedData
[]
=
$nestedSeriesData
;
$seriesData
=
[];
foreach
(
$nestedSeriesOuter
as
$o
)
{
$
nestedSeriesOuterData
=
(
object
)[];
$
nestedSeriesOuterData
->
name
=
$o
;
$
nestedSeriesOuterData
->
value
=
rand
(
1
,
100
);
$
nestedData
[
'outerData'
][]
=
$nestedSeriesOuterData
;
$
series
=
(
object
)[];
$
series
->
name
=
$o
;
$
series
->
value
=
rand
(
1
,
100
);
$
seriesData
[]
=
$series
;
}
$nestedSeriesData
=
[];
$nestedSeriesData
[
'data'
]
=
$seriesData
;
$nestedSeriesData
[
'name'
]
=
'Project 2'
;
$nestedData
[]
=
$nestedSeriesData
;
$rawData
=
'{
"color":[
...
...
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