Skip to content

Commit d24b38e

Browse files
authored
Merge pull request #20 from Wtower/more-graphs
More graphs
2 parents f7366f4 + d7b9676 commit d24b38e

18 files changed

+314
-19
lines changed

docs/ga-dashboard-graph-bars.rst

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
ga-dashboard-graph-bars
2+
=======================
3+
4+
Render a bars graph in panel as in `Gentelella index`_. The graph consists of ga-progress_ bars.
5+
6+
.. _Gentelella index: https://colorlib.com/polygon/gentelella/index.html
7+
.. _ga-progress: ga-progress.html
8+
9+
.. image:: images/ga-dashboard-graph-bars.png
10+
11+
Binding reference
12+
-----------------
13+
14+
- ``graph-title``: The graph panel title (string)
15+
- ``graph-sub-title``: The subtitle presented next to title in smaller font size (string)
16+
- ``graph-heading``: The heading in the content (string)
17+
- ``graph-data``: The main graph data (array)
18+
19+
The graph data should follow the format:
20+
21+
::
22+
23+
[{lower: 1, upper: 5, percentage: 15, count: 6}, ...]
24+
25+
Transclude
26+
----------
27+
28+
The component allows the transclude of further content below.
29+
30+
Code sample
31+
-----------
32+
33+
::
34+
35+
<ga-dashboard-graph-bars graph-title="Age distribution"
36+
graph-heading="Percentage per age class"
37+
graph-data="$ctrl.dashboard.ages"></ga-dashboard-graph-bars>
38+

docs/ga-dashboard-graph-chart.rst

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
ga-dashboard-graph-chart
2+
========================
3+
4+
Render a `chart.js`_ graph in panel as in `Gentelella index`_.
5+
6+
.. _chart.js: http://www.chartjs.org/docs/
7+
.. _Gentelella index: https://colorlib.com/polygon/gentelella/index.html
8+
9+
.. image:: images/ga-dashboard-graph-chart.png
10+
11+
Binding reference
12+
-----------------
13+
14+
- ``graph-title``: The graph panel title (string)
15+
- ``graph-sub-title``: The subtitle presented next to title in smaller font size (string)
16+
- ``graph-heading``: The heading or name of the series (string)
17+
- ``graph-id``: A unique HTML id for jquery reference, default ``main-graph`` (string)
18+
- ``graph-type``: The Chart.js type: line, bar, radar, pie, doughnut, bubble (string)
19+
- ``graph-max-values``: If the values provided are more than this number, the remaining will be added to the last.
20+
For example, if the chart shows top 5 cities, and 6 are provided, the 6th value will be added to the 5th.
21+
Default 5 (integer)
22+
- ``graph-max-ellipsis``: If the above parameter is used, the text to replace the last label with.
23+
Default 'All others' (string)
24+
- ``graph-colours``: An array of strings with colours for the series, defaults to gentelella colours (array)
25+
- ``graph-data``: The main graph data (array)
26+
27+
The graph data should follow the format:
28+
29+
::
30+
31+
[{label: '', value: 0}, ...]
32+
33+
Transclude
34+
----------
35+
36+
The component allows the transclude of further content below.
37+
38+
Controller
39+
----------
40+
41+
The controller:
42+
43+
- Groups the data to the specified maximum (if any).
44+
- Transforms the data from the above more common JSON format to Chart.js format.
45+
- Initializes the Chart.js graph appropriately.
46+
47+
Code sample
48+
-----------
49+
50+
::
51+
52+
<ga-dashboard-graph-chart graph-title="Top cities"
53+
graph-heading="City"
54+
graph-id="canvas2"
55+
graph-type="pie"
56+
graph-data="$ctrl.dashboard.cities"></ga-dashboard-graph-chart>
57+

docs/ga-dashboard-graph-flot.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Binding reference
1515
- ``graph-range``: The date range to present (string)
1616
- ``graph-id``: A unique HTML id for jquery reference, default ``main-graph`` (string)
1717
- ``graph-legend-title``: The title of the legent column (string)
18+
- ``graph-colours``: An array of strings with colours for the series, defaults to gentelella colours (array)
1819
- ``graph-data``: The main graph data (array)
1920

2021
Regarding the graph data. Gentelella uses the `Flot`_ graph library that requires that data is sorted by date.
@@ -40,7 +41,10 @@ The component allows the transclude of markup for the legend column body.
4041
Controller
4142
----------
4243

43-
The controller calls initializes the Flot graph appropriately.
44+
The controller:
45+
46+
- Transforms the data from the above more common JSON format to Flot format.
47+
- Initializes the Flot graph appropriately.
4448

4549
Code sample
4650
-----------
9.3 KB
Loading
9.59 KB
Loading

docs/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ are based on the markup by `Gentelella`_ bootstrap template.
2424
ga-progress
2525
ga-dashboard-counter
2626
ga-dashboard-graph-flot
27+
ga-dashboard-graph-bars
28+
ga-dashboard-graph-chart
2729
form-field-text
2830
form-field-select
2931
form-field-checkbox
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* Created by gkarak on 22/12/2016.
3+
*/
4+
5+
angular
6+
.module('gaDashboardGraphBars')
7+
.component('gaDashboardGraphBars', {
8+
templateUrl: 'ng-gentelella/gentelella/ga-dashboard-graph-bars/ga-dashboard-graph-bars.template.html',
9+
bindings: {
10+
graphTitle: '@',
11+
graphSubTitle: '@',
12+
graphHeading: '@',
13+
graphData: '<'
14+
},
15+
transclude: true
16+
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/**
2+
* Created by gkarak on 22/12/2016.
3+
*/
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* Created by gkarak on 22/12/2016.
3+
*/
4+
5+
angular.module('gaDashboardGraphBars', [
6+
'gaPanel',
7+
'gaProgress'
8+
]);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<ga-panel panel-title="{{ $ctrl.graphTitle }}" panel-sub-title="{{ $ctrl.graphSubTitle }}">
2+
<h4>{{ $ctrl.graphHeading }}</h4>
3+
<div class="widget_summary" ng-repeat="item in $ctrl.graphData">
4+
<div class="w_left w_25">{{ item.lower }}-{{ item.upper }}</div>
5+
<div class="w_center w_55">
6+
<ga-progress progress-size="md" progress-value="{{ item.percent }}"></ga-progress>
7+
</div>
8+
<div class="w_right w_20 clearfix"><span>{{ item.count }}</span></div>
9+
</div>
10+
<div ng-transclude></div>
11+
</ga-panel>

0 commit comments

Comments
 (0)