Skip to content
This repository has been archived by the owner on Oct 5, 2020. It is now read-only.

Fixes #545 #552

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ node_modules
/slush-dashboard
/slush-map
/slush-cards
.idea/modules.xml
.idea/slush-marklogic-node.iml
.idea/vcs.xml
.idea/workspace.xml
185 changes: 185 additions & 0 deletions app/themes/dashboard/ui/app/landing/charts.service.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
(function () {
'use strict';

angular.module('app.landing')
.factory('chartsService', ChartsService);

ChartsService.$inject = [];
function ChartsService() {

function top10Chart(title, type, xFacet, xLabel, limit, callback) {
return {
options: {
chart: {
type: type,
zoomType: 'xy'
},
tooltip: {
style: {
padding: 10,
fontWeight: 'bold'
},
shared: true,
crosshairs: true,
headerFormat: '<b>{series.name}</b><br>',
pointFormatter: /* istanbul ignore next Unreachable */ function() {
return (this.xCategory || this.x) + ': <b>' + (this.yCategory || this.y) + '</b><br>';
}
},
legend: {
enabled: false
},
plotOptions: {
series: {
cursor: 'pointer',
point: {
events: {
click: function (e) {
var facet = this.series.name;
var x = this.xCategory || this.x;
var y = this.yCategory || this.y;
if (callback) callback(facet, x, y);
}
}
}
}
}
},
title: {
text: title
},

xAxis: {
title: {
text: xLabel
},
labels: (type !== 'bar' ? {
rotation: -45
} : {})
},
// constraint name for x axis
//xAxisMLConstraint: xFacet,
// optional constraint name for categorizing x axis values
xAxisCategoriesMLConstraint: xFacet,

// grouping results
//seriesNameMLConstraint: yFacet,
//dataPointNameMLConstraint: yFacet,

yAxis: {
title: {
text: 'Frequency'
}
},
// constraint name for y axis ($frequency is special value for value/tuple frequency)
yAxisMLConstraint: '$frequency',

// zAxis: {
// title: {
// text: null
// }
// },
//zAxisMLConstraint: '$frequency',
// limit of returned results

size: {
height: 250
},
resultLimit: limit || /* istanbul ignore next Unreachable */ 10,
credits: {
enabled: true
}
};
}

function top10Chartv2(title, type, xFacet, xLabel, yFacet, yLabel, limit, callback) {
return {
options: {
chart: {
type: type,
zoomType: 'xy'
},
tooltip: {
style: {
padding: 10,
fontWeight: 'bold'
},
shared: false,
split: true,
crosshairs: true,
headerFormat: '<b>{series.name}</b><br>',
pointFormatter: /* istanbul ignore next Unreachable */ function() {
return (this.xCategory || this.x) + ': <b>' + (this.yCategory || this.y) + '</b><br>';
}
},
legend: {
enabled: true
},
plotOptions: {
series: {
cursor: 'pointer',
point: {
events: {
click: function (e) {
var facet = this.series.name;
var x = this.xCategory || this.x;
var y = this.yCategory || this.y;
if (callback) callback(facet, x, y);
}
}
}
}
}
},
title: {
text: title
},

xAxis: {
title: {
text: xLabel
},
labels: (type !== 'bar' ? {
rotation: -45
} : /* istanbul ignore next Unreachable */ {})
},
// constraint name for x axis
// xAxisMLConstraint: xFacet,
// optional constraint name for categorizing x axis values
xAxisCategoriesMLConstraint: xFacet,

// grouping results
seriesNameMLConstraint: yFacet,
//dataPointNameMLConstraint: yFacet,

yAxis: {
title: {
text: 'Frequency'
}
},
// constraint name for y axis ($frequency is special value for value/tuple frequency)
yAxisMLConstraint: '$frequency',

// zAxis: {
// title: {
// text: null
// }
// },
//zAxisMLConstraint: '$frequency',

size: {
height: 250
},
resultLimit: 0,
credits: {
enabled: true
}
};
}

return {
top10Chart: top10Chart,
top10Chartv2: top10Chartv2
};
}
}());
149 changes: 5 additions & 144 deletions app/themes/dashboard/ui/app/landing/landing.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
angular.module('app.landing')
.controller('LandingCtrl', LandingCtrl);

LandingCtrl.$inject = ['$scope', 'userService', 'MLSearchFactory'];
LandingCtrl.$inject = ['$scope', 'userService', 'MLSearchFactory', 'chartsService'];

function LandingCtrl($scope, userService, searchFactory) {
function LandingCtrl($scope, userService, searchFactory, chartsService) {

var ctrl = this;

angular.extend(ctrl, {
eyeColor: top10Chart('Eye Color', 'pie', 'eyeColor', 'Eye Color', 50),
gender: top10Chart('Gender', 'bar', 'gender', 'Gender', 50),
combined: top10Chartv2('Eye Color vs Gender', 'column', 'eyeColor', 'Eye Color',
eyeColor: chartsService.top10Chart('Eye Color', 'pie', 'eyeColor', 'Eye Color', 50),
gender: chartsService.top10Chart('Gender', 'bar', 'gender', 'Gender', 50),
combined: chartsService.top10Chartv2('Eye Color vs Gender', 'column', 'eyeColor', 'Eye Color',
'gender', 'Gender')
});

Expand All @@ -30,143 +30,4 @@

}

function top10Chart(title, type, xFacet, xLabel, limit) {
return {
options: {
chart: {
type: type,
zoomType: 'xy'
},
tooltip: {
style: {
padding: 10,
fontWeight: 'bold'
},
shared: true,
crosshairs: true,
headerFormat: '<b>{series.name}</b><br>',
pointFormatter: /* istanbul ignore next Unreachable */ function() {
return (this.xCategory || this.x) + ': <b>' + (this.yCategory || this.y) + '</b><br>';
}
},
legend: {
enabled: false
}
},
title: {
text: title
},

xAxis: {
title: {
text: xLabel
},
labels: (type !== 'bar' ? {
rotation: -45
} : {})
},
// constraint name for x axis
//xAxisMLConstraint: xFacet,
// optional constraint name for categorizing x axis values
xAxisCategoriesMLConstraint: xFacet,

// grouping results
//seriesNameMLConstraint: yFacet,
//dataPointNameMLConstraint: yFacet,

yAxis: {
title: {
text: 'Frequency'
}
},
// constraint name for y axis ($frequency is special value for value/tuple frequency)
yAxisMLConstraint: '$frequency',

// zAxis: {
// title: {
// text: null
// }
// },
//zAxisMLConstraint: '$frequency',
// limit of returned results

size: {
height: 250
},
resultLimit: limit || /* istanbul ignore next Unreachable */ 10,
credits: {
enabled: true
}
};
}

function top10Chartv2(title, type, xFacet, xLabel, yFacet, yLabel, limit) {
return {
options: {
chart: {
type: type,
zoomType: 'xy'
},
tooltip: {
style: {
padding: 10,
fontWeight: 'bold'
},
shared: false,
split: true,
crosshairs: true,
headerFormat: '<b>{series.name}</b><br>',
pointFormatter: /* istanbul ignore next Unreachable */ function() {
return (this.xCategory || this.x) + ': <b>' + (this.yCategory || this.y) + '</b><br>';
}
},
legend: {
enabled: true
}
},
title: {
text: title
},

xAxis: {
title: {
text: xLabel
},
labels: (type !== 'bar' ? {
rotation: -45
} : /* istanbul ignore next Unreachable */ {})
},
// constraint name for x axis
// xAxisMLConstraint: xFacet,
// optional constraint name for categorizing x axis values
xAxisCategoriesMLConstraint: xFacet,

// grouping results
seriesNameMLConstraint: yFacet,
//dataPointNameMLConstraint: yFacet,

yAxis: {
title: {
text: 'Frequency'
}
},
// constraint name for y axis ($frequency is special value for value/tuple frequency)
yAxisMLConstraint: '$frequency',

// zAxis: {
// title: {
// text: null
// }
// },
//zAxisMLConstraint: '$frequency',

size: {
height: 250
},
resultLimit: 0,
credits: {
enabled: true
}
};
}
}());