Skip to content

Commit

Permalink
Hidden unavailable options.
Browse files Browse the repository at this point in the history
  • Loading branch information
jjmontesl committed May 23, 2016
1 parent 51996f9 commit 2174b95
Show file tree
Hide file tree
Showing 16 changed files with 336 additions and 572 deletions.
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ module.exports = function(grunt) {
src: ['cubesviewer/**/*.js'], // 'test/*.js'
options: {
destination: 'build/doc',
configure : 'jsdoc.conf.json'
configure : 'doc/jsdoc/jsdoc.conf.json'
}
}
},
Expand Down
34 changes: 19 additions & 15 deletions TODO.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Consider contributing to CubesViewer. This is a possible roadmap.
* Make charts more interactive (allow cut from chart, etc).

* Series annotation system: markers for annotations in time or other dimension.
* Default cube settings is incorrect? it should only be applied if the view is not otherwise configured (ie loaded or json)

* Abstract backend?? Create CV objects for dimensions, levels, etc... Plug cubes as one more adaptor???
* Divide in reusable angular directives (ie. start with fact viewer). JS doc. Make views
Expand All @@ -47,8 +48,6 @@ Consider contributing to CubesViewer. This is a possible roadmap.
* Use controllerAs.
* Better loading bar (account for pending requests, etc).



[2.4]

* Data alerts (server-backed, depending on criteria, with triggers (use cubetl)).
Expand Down Expand Up @@ -77,35 +76,40 @@ Consider contributing to CubesViewer. This is a possible roadmap.

[2.1]

* Export image (https://github.com/gabelerner/canvg works with nvd3).
* Export SVG (svg crowbar).
* Restore cached content notice (is missing, commented out).
* Map charts.
* Issue #55 (chart shows measure name, not measure label).
* Fix submenu timer hack: is causing issues already. Watch contents and perhaps debounce menu activation?
* Add "accumulated", "difference" and other calculations to series and charts.
* Add "accumulated", "difference" and other operations to series and charts.
* Add "grouping", allowing to group drilled down items (custom groups) using an aggregation of choice...
Ability to save groups.
* Add "reduce to N items" operation on series (allows to represent charts adding "Others" for the rest),
reducing using some criteria -> uses grouping.
* Automatically hide legend if too many results.
* Finish calculations: show infos, mark which ones are enabled, order, add series colorize (positive/negative), move "invert 2nd serie" as a calculation?
* Range filter.
* Test and close issue #39, "strings with hyphen cause dimension filter to work inexpectedly" as shall be fixed.
* Export image (https://github.com/gabelerner/canvg works with nvd3).
* Export SVG (svg crowbar).
* Map charts.

[2.0]

* Commit refactor branch, update repositories, remove -devel from version name.
* Publish / announce.
* Test / QA.
* Uncomment studio.html code that asks for the server url to connect to.
* Create site, update readme, and site screenshots.
* Create site, update readme.
* Update screenshots.
* Reviewed and improved doc
* Submenu loading issue
* Pie chart/radar: do not draw if wrong column number message is being shown
* Add product subcategory to demo data.

* Cleanup code.
* Test CORS issue from server (localhost:8000 -> localhost:5000), test JSONP.
* Site (page). Show a couple of charts view, a table, and an enabled-controls view.
SAME views to be automatically opened in the explorer sample.
Add angular integration doc and example page.
* Hide all unavailable options and not implemented options.
* Default cube settings is incorrect? it should only be applied if the view is not otherwise configured (ie loaded or json)
* Update examples (at least up to date, but add facts, add public data).

* Reviewed and improved doc.
* Dimension filter hierarchy level issue + drill more, drill less minibuttons + horizontal more/less
* Submenu loading issue
* Commit to master (both projects).
* Pie chart/radar: do not draw if wrong column number message is being shown
* Update docs (repo first). Add angular integration doc and example page.

10 changes: 8 additions & 2 deletions cubesviewer/core/cubesviewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ angular.module('cv').config([ '$logProvider', 'cvOptions', /* 'editableOptions',
undoEnabled: true,
undoSize: 32,

hideControls: false,
seriesOperationsEnabled: false,

hideControls: false,

gaTrackEvents: false,

Expand Down Expand Up @@ -219,7 +221,11 @@ function CubesViewer() {
* @param routine Function that will be executed within CubesViewer Angular context.
*/
this.apply = function(routine) {
angular.element(document).scope().$apply(routine);
if (! angular.element(document).scope()) {
setTimeout(function() { cubesviewer.apply(routine); }, 1000);
} else {
angular.element(document).scope().$apply(routine);
}
};

};
Expand Down
2 changes: 1 addition & 1 deletion cubesviewer/cubes/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ angular.module('cv.cubes').service("cubesCacheService", ['$rootScope', '$log', '
var timediff = Math.round ((new Date().getTime() - cubesCacheService.cache[requestHash].time) / 1000);
if (timediff > cvOptions.cacheNotice) {
//cubesviewer.showInfoMessage("Data loaded from cache<br/>(" + timediff + " minutes old)", 1000);
console.debug("Data loaded from cache (" + timediff + " minutes old)");
$log.debug("Data loaded from cache (" + Math.floor(timediff / 60, 2) + " minutes old)");
}

jqxhr = $.Deferred();
Expand Down
6 changes: 6 additions & 0 deletions cubesviewer/cubes/cubes-cvextensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ cubes.Cube.prototype.measureAggregates = function(measureName) {
return aggregates;
};

cubes.Cube.prototype.aggregateFromName = function(aggregateName) {
var aggregates = $.grep(this.aggregates, function(ia) { return aggregateName ? ia.name == aggregateName : !ia.measure; } );
return aggregates.length == 1 ? aggregates[0] : null;
};



/*
* Processes a cell and returns an object with consistent information:
Expand Down
2 changes: 1 addition & 1 deletion cubesviewer/cubes/cubes-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ angular.module('cv.cubes').service("cubesService", ['$rootScope', '$log', 'cvOpt
if (path.charAt(0) == '/') path = cvOptions.cubesUrl + path;

if (cvOptions.debug) {
$log.debug("Cubes request: " + path + " (" + params + ")");
$log.debug("Cubes request: " + path + " (" + JSON.stringify(params) + ")");
}

var jqxhr = $.get(path, params, cubesService._cubesRequestCallback(successCallback), cvOptions.jsonRequestType);
Expand Down
25 changes: 11 additions & 14 deletions cubesviewer/cubesviewer.templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,7 @@ angular.module('cv').run(['$templateCache', function($templateCache) {
" </ul>\n" +
" </li>\n" +
"\n" +
" <!--\n" +
" <li class=\"dropdown-submenu\">\n" +
" <a tabindex=\"0\"><i class=\"fa fa-fw fa-arrows-h\"></i> Range filter</a>\n" +
" <ul class=\"dropdown-menu\">\n" +
Expand All @@ -563,31 +564,23 @@ angular.module('cv').run(['$templateCache', function($templateCache) {
" <li ng-repeat=\"(hikey,hi) in dimension.hierarchies\" class=\"dropdown-submenu\">\n" +
" <a tabindex=\"0\" href=\"\" onclick=\"return false;\">{{ hi.label }}</a>\n" +
" <ul class=\"dropdown-menu\">\n" +
" <!-- ng-click=\"selectDrill(dimension.name + '@' + hi.name + ':' + level.name, true)\" -->\n" +
" <li ng-repeat=\"level in hi.levels\" ng-click=\"showDimensionFilter(dimension.name + '@' + hi.name + ':' + level.name )\"><a href=\"\">{{ level.label }}</a></li>\n" +
" </ul>\n" +
" </li>\n" +
" </ul>\n" +
"\n" +
" <ul ng-if=\"dimension.hierarchies_count() == 1\" class=\"dropdown-menu\">\n" +
" <!-- selectDrill(dimension.name + ':' + level.name, true) -->\n" +
" <li ng-repeat=\"level in dimension.default_hierarchy().levels\" ng-click=\"showDimensionFilter(level);\"><a href=\"\">{{ level.label }}</a></li>\n" +
" </ul>\n" +
"\n" +
" </li>\n" +
"\n" +
" </ul>\n" +
" </li>\n" +
"\n" +
" <!--\n" +
" // Events\n" +
" $(view.container).find('.cv-view-show-dimensionfilter').click( function() {\n" +
" cubesviewer.views.cube.dimensionfilter.drawDimensionFilter(view, $(this).attr('data-dimension'));\n" +
" return false;\n" +
" });\n" +
" -->\n" +
"\n" +
" <div class=\"divider\"></div>\n" +
"\n" +
" <li ng-class=\"{ 'disabled': view.params.cuts.length == 0 }\"><a href=\"\"><i class=\"fa fa-fw fa-trash\"></i> Clear filters</a></li>\n" +
"\n" +
" </ul>\n"
Expand Down Expand Up @@ -634,11 +627,13 @@ angular.module('cv').run(['$templateCache', function($templateCache) {
" <li ng-click=\"selectChartType('lines-stacked')\"><a href=\"\"><i class=\"fa fa-fw fa-area-chart\"></i> Areas</a></li>\n" +
" <li ng-click=\"selectChartType('radar')\"><a href=\"\"><i class=\"fa fa-fw fa-bullseye\"></i> Radar</a></li>\n" +
"\n" +
" <div class=\"divider\"></div>\n" +
" <!-- <div class=\"divider\"></div> -->\n" +
"\n" +
" <!-- <li><a href=\"\"><i class=\"fa fa-fw fa-dot-circle-o\"></i> Bubbles</a></li> -->\n" +
" <!--\n" +
" <li><a href=\"\"><i class=\"fa fa-fw fa-dot-circle-o\"></i> Bubbles</a></li>\n" +
" <li><a href=\"\"><i class=\"fa fa-fw fa-square\"></i> Treemap</a></li>\n" +
" <li ng-click=\"selectChartType('sunburst')\"><a href=\"\"><i class=\"fa fa-fw fa-sun-o\"></i> Sunburst</a></li>\n" +
" -->\n" +
"\n" +
" <!--\n" +
" <div class=\"divider\"></div>\n" +
Expand Down Expand Up @@ -718,16 +713,18 @@ angular.module('cv').run(['$templateCache', function($templateCache) {
" </ul>\n" +
" </li>\n" +
"\n" +
" <div ng-show=\"view.params.mode == 'series' || view.params.mode == 'chart'\" class=\"divider\"></div>\n" +
" <div ng-show=\"cvOptions.seriesOperationsEnabled && (view.params.mode == 'series' || view.params.mode == 'chart')\" class=\"divider\"></div>\n" +
"\n" +
" <li ng-show=\"view.params.mode == 'series' || view.params.mode == 'chart'\" class=\"dropdown-submenu\">\n" +
" <li ng-show=\"cvOptions.seriesOperationsEnabled && (view.params.mode == 'series' || view.params.mode == 'chart')\" class=\"dropdown-submenu\">\n" +
" <a tabindex=\"0\" ><i class=\"fa fa-fw fa-calculator\"></i> Series operations</a>\n" +
" <ul class=\"dropdown-menu\">\n" +
" <li ng-click=\"selectOperation('difference')\"><a href=\"\"><i class=\"fa fa-fw fa-line-chart\"></i> Difference</a></li>\n" +
" <li ng-click=\"selectOperation('percentage')\"><a href=\"\"><i class=\"fa fa-fw fa-percent\"></i> Change rate</a></li>\n" +
" <!--\n" +
" <li ng-click=\"selectOperation('accum')\"><a href=\"\"><i class=\"fa fa-fw\">&sum;</i> Accumulated</a></li>\n" +
" <div class=\"divider\"></div>\n" +
" <li ng-click=\"selectOperation('fill-zeros')\"><a href=\"\"><i class=\"fa fa-fw\">0</i> Replace blanks with zeroes</a></li>\n" +
" -->\n" +
" <div class=\"divider\"></div>\n" +
" <li ng-click=\"selectOperation(null)\"><a href=\"\"><i class=\"fa fa-fw fa-times\"></i> Clear operations</a></li>\n" +
" </ul>\n" +
Expand Down Expand Up @@ -843,7 +840,7 @@ angular.module('cv').run(['$templateCache', function($templateCache) {
" <div class=\"cv-view-viewinfo-extra\">\n" +
"\n" +
" <div ng-if=\"view.params.mode == 'series' || view.params.mode == 'chart'\" class=\"label label-secondary cv-infopiece cv-view-viewinfo-extra\" style=\"color: black; background-color: #ccccff;\">\n" +
" <span style=\"max-width: 350px;\"><i class=\"fa fa-fw fa-crosshairs\"></i> <b>Measure:</b> {{ (view.params.yaxis != null) ? view.params.yaxis : \"None\" }}</span>\n" +
" <span style=\"max-width: 350px;\"><i class=\"fa fa-fw fa-crosshairs\"></i> <b>Measure:</b> {{ (view.params.yaxis != null) ? view.cube.aggregateFromName(view.params.yaxis).label : \"None\" }}</span>\n" +
" <button type=\"button\" class=\"btn btn-info btn-xs\" style=\"visibility: hidden; margin-left: -20px;\"><i class=\"fa fa-fw fa-info\"></i></button>\n" +
" </div>\n" +
"\n" +
Expand Down
135 changes: 2 additions & 133 deletions cubesviewer/views/cube/chart/chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ angular.module('cv.views.cube').controller("CubesViewerViewsCubeChartController"

// Process data
//$scope._sortData (data.cells, view.params.xaxis != null ? true : false);
this._addRows(data);
this._addRows($scope, data);
seriesOperationsService.applyCalculations($scope.view, $scope.view.grid.data, view.grid.columnDefs);

// Join keys
Expand All @@ -122,138 +122,7 @@ angular.module('cv.views.cube').controller("CubesViewerViewsCubeChartController"
/*
* Adds rows.
*/
this._addRows = function(data) {

console.debug("FIXME: addRows method in charts controller is duplicated (from series controller)!")

var view = $scope.view;
var rows = $scope.view.grid.data;

var counter = 0;
var dimensions = view.cube.dimensions;
var measures = view.cube.measures;
var details = view.cube.details;

// Copy drilldown as we'll modify it
var drilldown = view.params.drilldown.slice(0);

// Include X Axis if necessary
if (view.params.xaxis != null) {
drilldown.splice(0,0, view.params.xaxis);
}
var baseidx = ((view.params.xaxis == null) ? 0 : 1);

var addedCols = [];
$(data.cells).each(function (idx, e) {

var row = [];
var key = [];

// For the drilldown level, if present
for (var i = 0; i < drilldown.length; i++) {

// Get dimension
var parts = view.cube.dimensionParts(drilldown[i]);
var infos = parts.hierarchy.readCell(e, parts.level);

// Values and Labels
var drilldownLevelValues = [];
var drilldownLevelLabels = [];

$(infos).each(function(idx, info) {
drilldownLevelValues.push (info.key);
drilldownLevelLabels.push (info.label);
});

key.push (drilldownLevelLabels.join(" / "));

}

// Set key
var colKey = (view.params.xaxis == null) ? view.params.yaxis : key[0];
var value = (e[view.params.yaxis]);
var rowKey = (view.params.xaxis == null) ? key.join (' / ') : key.slice(1).join (' / ');

// Search or introduce
var row = $.grep(rows, function(ed) { return ed["key"] == rowKey; });
if (row.length > 0) {
row[0][colKey] = value;
} else {
var newrow = {};
newrow["key"] = rowKey;
newrow[colKey] = value;

for (var i = baseidx ; i < key.length; i++) {
newrow["key" + (i - baseidx)] = key[i];
}
rows.push ( newrow );
}


// Add column definition if the column hasn't been added yet
if (addedCols.indexOf(colKey) < 0) {
addedCols.push(colKey);

var ag = $.grep(view.cube.aggregates, function(ag) { return ag.ref == view.params.yaxis })[0];

var col = {
name: colKey,
field: colKey,
index : colKey,
cellClass : "text-right",
sorttype : "number",
width : 75, //cubesviewer.views.cube.explore.defineColumnWidth(view, colKey, 75),
cellTemplate: '<div class="ui-grid-cell-contents" title="TOOLTIP">{{ col.colDef.formatter(COL_FIELD, row, col) }}</div>',
formatter: $scope.columnFormatFunction(ag),
//footerValue: $scope.columnFormatFunction(ag)(data.summary[ag.ref], null, col)
//formatoptions: {},
//cellattr: cubesviewer.views.cube.explore.columnTooltipAttr(ag.ref),
//footerCellTemplate = '<div class="ui-grid-cell-contents text-right">{{ col.colDef.footerValue }}</div>';
};
view.grid.columnDefs.push(col);
}
});

//var label = [];data
$(view.params.drilldown).each (function (idx, e) {
var col = {
name: view.cube.cvdim_dim(e).label,
field: "key" + idx,
index : "key" + idx,
//cellClass : "text-right",
//sorttype : "number",
width : 190, //cubesviewer.views.cube.explore.defineColumnWidth(view, "key" + idx, 190)
//cellTemplate: '<div class="ui-grid-cell-contents" title="TOOLTIP">{{ col.colDef.formatter(COL_FIELD, row, col) }}</div>',
//formatter: $scope.columnFormatFunction(ag),
//footerValue: $scope.columnFormatFunction(ag)(data.summary[ag.ref], null, col)
//formatoptions: {},
//cellattr: cubesviewer.views.cube.explore.columnTooltipAttr(ag.ref),
//footerCellTemplate = '<div class="ui-grid-cell-contents text-right">{{ col.colDef.footerValue }}</div>';
};
view.grid.columnDefs.splice(idx, 0, col);
});

if (view.params.drilldown.length == 0 && rows.length > 0) {
rows[0]["key0"] = view.params.yaxis;

var col = {
name: "Measure",
field: "key0",
index : "key0",
//cellClass : "text-right",
//sorttype : "number",
width : 190, //cubesviewer.views.cube.explore.defineColumnWidth(view, "key0", 190)
//cellTemplate: '<div class="ui-grid-cell-contents" title="TOOLTIP">{{ col.colDef.formatter(COL_FIELD, row, col) }}</div>',
//formatter: $scope.columnFormatFunction(ag),
//footerValue: $scope.columnFormatFunction(ag)(data.summary[ag.ref], null, col)
//formatoptions: {},
//cellattr: cubesviewer.views.cube.explore.columnTooltipAttr(ag.ref),
//footerCellTemplate = '<div class="ui-grid-cell-contents text-right">{{ col.colDef.footerValue }}</div>';
};
view.grid.columnDefs.splice(0, 0, col);
}

};
this._addRows = cubesviewer._seriesAddRows;

this.cleanupNvd3 = function() {

Expand Down
Loading

0 comments on commit 2174b95

Please sign in to comment.