From 2b6815e2240314692a0b1169d78ccf2dd17c1966 Mon Sep 17 00:00:00 2001 From: Jan Michael Yu Date: Mon, 30 Apr 2018 17:22:36 +0800 Subject: [PATCH 1/2] ignore intellij specific files --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index 93425f66..6f35ad76 100644 --- a/.gitignore +++ b/.gitignore @@ -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 From 786cf77e4fe7f971aea58635707d2e6660e2380e Mon Sep 17 00:00:00 2001 From: Jan Michael Yu Date: Mon, 30 Apr 2018 18:13:11 +0800 Subject: [PATCH 2/2] Fixing Issue #545: Improve chart features #545 Moving charts functions to separate service. --- .../ui/app/landing/charts.service.js | 185 ++++++++++++++++++ .../ui/app/landing/landing.controller.js | 149 +------------- 2 files changed, 190 insertions(+), 144 deletions(-) create mode 100644 app/themes/dashboard/ui/app/landing/charts.service.js diff --git a/app/themes/dashboard/ui/app/landing/charts.service.js b/app/themes/dashboard/ui/app/landing/charts.service.js new file mode 100644 index 00000000..36d1d30b --- /dev/null +++ b/app/themes/dashboard/ui/app/landing/charts.service.js @@ -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: '{series.name}
', + pointFormatter: /* istanbul ignore next Unreachable */ function() { + return (this.xCategory || this.x) + ': ' + (this.yCategory || this.y) + '
'; + } + }, + 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: '{series.name}
', + pointFormatter: /* istanbul ignore next Unreachable */ function() { + return (this.xCategory || this.x) + ': ' + (this.yCategory || this.y) + '
'; + } + }, + 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 + }; + } +}()); diff --git a/app/themes/dashboard/ui/app/landing/landing.controller.js b/app/themes/dashboard/ui/app/landing/landing.controller.js index 1293830f..813dc83f 100644 --- a/app/themes/dashboard/ui/app/landing/landing.controller.js +++ b/app/themes/dashboard/ui/app/landing/landing.controller.js @@ -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') }); @@ -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: '{series.name}
', - pointFormatter: /* istanbul ignore next Unreachable */ function() { - return (this.xCategory || this.x) + ': ' + (this.yCategory || this.y) + '
'; - } - }, - 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: '{series.name}
', - pointFormatter: /* istanbul ignore next Unreachable */ function() { - return (this.xCategory || this.x) + ': ' + (this.yCategory || this.y) + '
'; - } - }, - 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 - } - }; - } }());