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
f07c170c
Commit
f07c170c
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
2496e2ab
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
157 additions
and
54 deletions
+157
-54
ChartDataManager.php
src/Managers/ChartManager/ChartDataManager.php
+8
-18
CoreServiceProvider.php
src/Providers/CoreServiceProvider.php
+6
-1
BarChartData.php
src/Views/Limitless/Barchart/Attachments/BarChartData.php
+3
-6
LineChartData.php
src/Views/Limitless/Linechart/Attachments/LineChartData.php
+6
-19
PieChartData.php
src/Views/Limitless/Piechart/Attachments/PieChartData.php
+78
-0
piechart.init.js
src/Views/Limitless/Piechart/Attachments/piechart.init.js
+12
-9
Config.php
src/Views/Limitless/Piechart/Config.php
+2
-1
Index.blade.php
src/Views/Limitless/Piechart/Documentation/Index.blade.php
+41
-0
PieChart.blade.php
src/Views/Limitless/Piechart/PieChart.blade.php
+1
-0
No files found.
src/Managers/ChartManager/ChartDataManager.php
View file @
f07c170c
...
...
@@ -33,63 +33,53 @@ Class ChartDataManager {
return
new
SeriesData
();
}
public
function
setColors
(
$color
)
:
ChartDataManager
public
function
setColors
(
$color
)
{
if
(
is_array
(
$color
))
{
$this
->
colors
=
array_merge
(
$this
->
colors
,
$color
);
}
else
{
$this
->
colors
[]
=
$color
;
}
return
$this
;
}
public
function
setAnimationDuration
(
int
$value
)
:
ChartDataManager
public
function
setAnimationDuration
(
int
$value
)
{
$this
->
animationDuration
=
$value
;
return
$this
;
}
public
function
setYAxisLabelValueFormat
(
string
$value
)
:
ChartDataManager
public
function
setYAxisLabelValueFormat
(
string
$value
)
{
$this
->
yAxisLabelValueFormat
=
$value
;
return
$this
;
}
public
function
setRawData
(
string
$value
)
:
ChartDataManager
public
function
setRawData
(
string
$value
)
{
$this
->
rawData
=
$value
;
return
$this
;
}
public
function
setIsStacked
(
bool
$value
)
:
ChartDataManager
public
function
setIsStacked
(
bool
$value
)
{
$this
->
isStacked
=
$value
;
return
$this
;
}
public
function
setMarkLine
(
string
$value
)
:
ChartDataManager
public
function
setMarkLine
(
string
$value
)
{
$this
->
markLine
=
$value
;
return
$this
;
}
public
function
addCategories
(
$category
)
:
ChartDataManager
public
function
addCategories
(
$category
)
{
if
(
is_array
(
$category
))
{
$this
->
categories
=
array_merge
(
$this
->
categories
,
$category
);
}
else
{
$this
->
categories
[]
=
$category
;
}
return
$this
;
}
public
function
addSeries
(
SeriesData
$series
)
:
ChartDataManager
public
function
addSeries
(
SeriesData
$series
)
{
$this
->
series
->
push
(
$series
);
$this
->
numberOfCharts
=
$this
->
series
->
numberOfCharts
();
return
$this
;
}
public
function
getParentData
()
:
array
...
...
src/Providers/CoreServiceProvider.php
View file @
f07c170c
...
...
@@ -25,7 +25,7 @@
use
Ceetrox\Providers\PicassoServiceProvider\PicassoServiceProvider
;
use
Ceetrox\Sidekick\Views\Limitless\Barchart\Attachments\BarChartData
;
use
Ceetrox\Sidekick\Views\Limitless\Linechart\Attachments\LineChartData
;
use
Ceetrox\Sidekick\Views\Limitless\
Linechart\ChartManager\ChartDataManager
;
use
Ceetrox\Sidekick\Views\Limitless\
Piechart\Attachments\PieChartData
;
use
Illuminate\Support\ServiceProvider
;
use
Illuminate\Foundation\AliasLoader
;
...
...
@@ -70,6 +70,11 @@
$loader
=
AliasLoader
::
getInstance
();
$loader
->
alias
(
'SidekickBarChartDataManager'
,
BarChartData
::
class
);
});
$this
->
app
->
booting
(
function
()
{
$loader
=
AliasLoader
::
getInstance
();
$loader
->
alias
(
'SidekickPieChartDataManager'
,
PieChartData
::
class
);
});
}
}
...
...
src/Views/Limitless/Barchart/Attachments/BarChartData.php
View file @
f07c170c
...
...
@@ -23,22 +23,19 @@ Class BarChartData extends ChartDataManager {
return
new
self
;
}
public
function
setTitle
(
string
$value
)
:
BarChartData
public
function
setTitle
(
string
$value
)
{
$this
->
title
=
$value
;
return
$this
;
}
public
function
setIsHorizontal
(
bool
$value
)
:
BarChartData
public
function
setIsHorizontal
(
bool
$value
)
{
$this
->
isHorizontal
=
$value
;
return
$this
;
}
public
function
setShowBarValues
(
bool
$value
)
:
BarChartData
public
function
setShowBarValues
(
bool
$value
)
{
$this
->
showBarValues
=
$value
;
return
$this
;
}
public
function
toJson
()
:
string
...
...
src/Views/Limitless/Linechart/Attachments/LineChartData.php
View file @
f07c170c
...
...
@@ -31,51 +31,38 @@ Class LineChartData extends ChartDataManager {
return
new
self
;
}
public
function
setTitle
(
$value
)
:
LineChartData
public
function
setTitle
(
$value
)
{
if
(
is_array
(
$value
))
{
$this
->
titles
=
array_merge
(
$this
->
titles
,
$value
);
}
else
{
$this
->
titles
[]
=
$value
;
}
return
$this
;
}
public
function
setHasBoundaryGap
(
bool
$value
)
:
LineChartData
public
function
setHasBoundaryGap
(
bool
$value
)
{
$this
->
hasBoundaryGap
=
$value
;
return
$this
;
}
public
function
setIsInverted
(
bool
$value
)
:
LineChartData
public
function
setIsInverted
(
bool
$value
)
{
$this
->
isInverted
=
$value
;
return
$this
;
}
public
function
setHasDataZoom
(
bool
$value
)
:
LineChartData
public
function
setHasDataZoom
(
bool
$value
)
{
$this
->
hasDataZoom
=
$value
;
return
$this
;
}
public
function
setRawData
(
string
$value
)
:
LineChartData
{
$this
->
rawData
=
$value
;
return
$this
;
}
public
function
setShowPointValues
(
bool
$value
)
:
LineChartData
public
function
setShowPointValues
(
bool
$value
)
{
$this
->
showPointValues
=
$value
;
return
$this
;
}
public
function
setIsArea
(
bool
$value
)
:
LineChartData
public
function
setIsArea
(
bool
$value
)
{
$this
->
isArea
=
$value
;
return
$this
;
}
public
function
toJson
()
:
string
...
...
src/Views/Limitless/Piechart/Attachments/PieChartData.php
0 → 100644
View file @
f07c170c
<?php
namespace
Ceetrox\Sidekick\Views\Limitless\Piechart\Attachments
;
use
Ceetrox\Managers\ChartManager\ChartDataManager
;
Class
PieChartData
extends
ChartDataManager
{
private
?
string
$title
;
private
?
string
$subtitle
;
private
?
string
$pieType
;
private
?
bool
$hasLabel
;
private
?
bool
$hasLabelOnEmphasis
;
public
function
__construct
()
{
parent
::
__construct
();
$this
->
title
=
null
;
$this
->
subtitle
=
null
;
$this
->
pieType
=
null
;
$this
->
hasLabel
=
null
;
$this
->
hasLabelOnEmphasis
=
null
;
}
public
static
function
getInstance
()
:
PieChartData
{
return
new
self
;
}
public
function
setTitle
(
string
$value
)
{
$this
->
title
=
$value
;
}
public
function
setSubtitle
(
string
$value
)
{
$this
->
subtitle
=
$value
;
}
public
function
setPieType
(
string
$value
)
{
$this
->
pieType
=
$value
;
}
public
function
setHasLabel
(
bool
$value
)
{
$this
->
hasLabel
=
$value
;
}
public
function
setHasLabelOnEmphasis
(
bool
$value
)
{
$this
->
hasLabelOnEmphasis
=
$value
;
}
public
function
toJson
()
:
string
{
return
json_encode
(
$this
->
toArray
());
}
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
->
title
))
$data
[
'title'
]
=
$this
->
title
;
if
(
!
is_null
(
$this
->
subtitle
))
$data
[
'subtitle'
]
=
$this
->
subtitle
;
if
(
!
is_null
(
$this
->
pieType
))
$data
[
'pieType'
]
=
$this
->
pieType
;
if
(
!
is_null
(
$this
->
hasLabel
))
$data
[
'label'
]
=
$this
->
hasLabel
;
if
(
!
is_null
(
$this
->
hasLabelOnEmphasis
))
$data
[
'labelOnEmphasis'
]
=
$this
->
hasLabelOnEmphasis
;
$data
=
array_merge
(
$data
,
$this
->
getParentData
());
return
$data
;
}
}
\ No newline at end of file
src/Views/Limitless/Piechart/Attachments/piechart.init.js
View file @
f07c170c
...
...
@@ -59,20 +59,23 @@ function set_data(elementObject, callback) {
];
let
options
;
let
objectData
=
elementObject
.
attr
(
'
data
'
)
?
JSON
.
parse
(
elementObject
.
attr
(
'
data
'
))
:
null
;
let
rawData
=
elementObject
.
attr
(
'
raw
'
)
?
JSON
.
parse
(
elementObject
.
attr
(
'
raw
'
))
:
null
;
if
(
rawData
==
null
)
{
// variables (this will be set by user)
let
title
=
elementObject
.
attr
(
'
title
'
)
??
null
;
let
subtitle
=
elementObject
.
attr
(
'
subtitle
'
)
??
null
;
let
colors
=
JSON
.
parse
(
elementObject
.
attr
(
'
colors
'
))
??
defaultColors
;
let
pieType
=
elementObject
.
attr
(
'
pie-type
'
)
??
null
;
// donut or rose types
let
showLabel
=
(
elementObject
.
attr
(
'
label
'
)
==
'
true
'
||
elementObject
.
attr
(
'
label
'
)
==
true
);
let
labelOnEmphasis
=
(
elementObject
.
attr
(
'
emphasis-label
'
)
==
'
true
'
||
elementObject
.
attr
(
'
emphasis-label
'
)
==
true
);
let
animationDuration
=
elementObject
.
attr
(
'
animation-duration
'
)
??
750
;
let
series
=
JSON
.
parse
(
elementObject
.
attr
(
'
series
'
))
??
null
;
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
.
showLabel
??
((
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
;
...
...
src/Views/Limitless/Piechart/Config.php
View file @
f07c170c
...
...
@@ -71,7 +71,8 @@
->
withColors
(
$parameters
[
'colors'
]
??
null
)
->
withAnimationDuration
(
$parameters
[
'animation-duration'
]
??
750
)
->
withSeries
(
$parameters
[
'series'
]
??
null
)
->
withRaw
(
$parameters
[
'raw'
]
??
null
);
->
withRaw
(
$parameters
[
'raw'
]
??
null
)
->
withData
(
$parameters
[
'data'
]
??
null
);
}
...
...
src/Views/Limitless/Piechart/Documentation/Index.blade.php
View file @
f07c170c
...
...
@@ -5,6 +5,34 @@
@
php
$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.
$chartDataManager
->
addSeries
(
$sd
);
$sd
=
$chartDataManager
::
getSeriesDataInstance
();
$sd
->
setName
(
'APR'
);
$sd
->
setCategoryValues
([
90
,
40
,
70
,
20
,
90
]);
$sd
->
setIndex
(
0
);
$chartDataManager
->
addSeries
(
$sd
);
$chartDataManager
->
setIsHorizontal
(
true
);
$chartDataManager
->
setShowBarValues
(
true
);
$dataObject
=
$chartDataManager
->
toJson
();
// sample backend data
$series
=
[
'ONC'
,
'APR'
,
'SPR'
,
'PHX'
,
'BRG'
];
...
...
@@ -114,6 +142,19 @@
@
endphp
<
div
class
="
row
">
<div class="
col
-
xl
-
6
">
@Limitless::CardStart(['title' => "
Basic
Pie
Setup
", 'icon' => 'icon-info22' ] )
@Limitless::PieChart([
'data' =>
$dataObject
])
@Limitless::CardStop
</div>
<div class="
col
-
xl
-
6
">
</div>
</div>
<div class="
row
">
<div class="
col
-
xl
-
6
">
@Limitless::CardStart(['title' => "
Basic
Pie
Setup
", 'icon' => 'icon-info22' ] )
...
...
src/Views/Limitless/Piechart/PieChart.blade.php
View file @
f07c170c
...
...
@@ -9,6 +9,7 @@
animation-duration=
"{{ $animationDuration }}"
series=
"{{ json_encode($series) }}"
raw=
"{{ json_encode(json_decode($raw)) }}"
data=
"{{ $data }}"
>
</div>
</div>
\ No newline at end of file
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