mirror of
https://github.com/bendtherules/chart-builder-demo.git
synced 2026-08-18 13:42:05 +00:00
Add plot random button
This commit is contained in:
+22
-6
@@ -43,13 +43,17 @@ app.value("allData",{
|
||||
|
||||
|
||||
app.controller("mainController", ["allData","$scope",function (allData,$scope) {
|
||||
$scope.data = {};
|
||||
$scope.data.chooserDimensions = allData.dimensions;
|
||||
$scope.data.chosenDimension = undefined;
|
||||
$scope.data.chooserMeasures = allData.measures;
|
||||
$scope.data.chosenMeasure = undefined;
|
||||
init();
|
||||
|
||||
$scope.data.values = allData.values;
|
||||
function init() {
|
||||
$scope.data = {};
|
||||
$scope.data.chooserDimensions = allData.dimensions;
|
||||
$scope.data.chosenDimension = undefined;
|
||||
$scope.data.chooserMeasures = allData.measures;
|
||||
$scope.data.chosenMeasure = undefined;
|
||||
|
||||
$scope.data.values = allData.values;
|
||||
}
|
||||
|
||||
$scope.allowDrop = function(ev,location) {
|
||||
// var prevLocation = ev.dataTransfer.getData("location");
|
||||
@@ -128,4 +132,16 @@ app.controller("mainController", ["allData","$scope",function (allData,$scope) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function getRandomInt(min, max) {
|
||||
return Math.floor(Math.random() * (max - min + 1)) + min;
|
||||
}
|
||||
|
||||
$scope.plotRandom = function () {
|
||||
var indexDimension = getRandomInt(0,($scope.data.chooserDimensions.length - 1));
|
||||
var indexMeasure = getRandomInt(0,($scope.data.chooserMeasures.length - 1));
|
||||
|
||||
moveData("chooser.dimension","chosen.dimension", $scope.data.chooserDimensions[indexDimension]);
|
||||
moveData("chooser.measure","chosen.measure", $scope.data.chooserMeasures[indexMeasure]);
|
||||
}
|
||||
}]);
|
||||
|
||||
Reference in New Issue
Block a user