Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #143: Set timeout on scope destroy to 500ms instead 10000ms #144

Open
wants to merge 4 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
41 changes: 29 additions & 12 deletions c3-angular.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*! c3-angular - v1.3.1 - 2016-08-04
/*! c3-angular - v1.3.1 - 2017-01-05
* https://github.com/jettro/c3-angular-directive
* Copyright (c) 2016 ; Licensed */
* Copyright (c) 2017 ; Licensed */
angular.module('gridshore.c3js.chart', []);
angular.module('gridshore.c3js.chart')
.directive('chartAxes', ChartAxes);
Expand Down Expand Up @@ -765,6 +765,10 @@ angular.module('gridshore.c3js.chart')
*
* {@link http://c3js.org/reference.html#data-order| c3js doc}
*
* @param {Function} sort-data-function Provide a function for sorting.
*
* {@link http://c3js.org/reference.html#data-order| c3js doc}
*
* @param {Boolean} show-labels Configure to show the labels 'true' or not, default is false.
*
* {@link http://c3js.org/reference.html#data-labels| c3js doc}
Expand Down Expand Up @@ -887,6 +891,9 @@ function C3Chart ($timeout) {
if (attrs.callbackFunction) {
chartCtrl.addChartCallbackFunction(scope.callbackFunction());
}
if (attrs.sortDataFunction) {
chartCtrl.addSortDataFunction(scope.sortDataFunction());
}
if (transitionDuration) {
chartCtrl.addTransitionDuration(transitionDuration);
}
Expand Down Expand Up @@ -914,6 +921,7 @@ function C3Chart ($timeout) {
"chartColumns": "=chartColumns",
"chartX": "=chartX",
"callbackFunction": "&",
"sortDataFunction": "&",
"emptyLabel": "@emptyLabel"
},
"template": "<div><div id='{{bindto}}'></div><div ng-transclude></div></div>",
Expand Down Expand Up @@ -1089,6 +1097,7 @@ function ChartController($scope, $timeout) {
this.addXSValues = addXSValues;

this.addChartCallbackFunction = addChartCallbackFunction;
this.addSortDataFunction = addSortDataFunction;
this.addInitialConfig = addInitialConfig;

this.addDataLabelsFormatFunction = addDataLabelsFormatFunction;
Expand Down Expand Up @@ -1204,6 +1213,9 @@ function ChartController($scope, $timeout) {
config.data.order = $scope.sorting;
}
}
if ($scope.sortDataFunction) {
config.data.order = $scope.sortDataFunction;
}
if ($scope.transitionDuration != null) {
config.transition = config.transition || {};
config.transition.duration = $scope.transitionDuration;
Expand Down Expand Up @@ -1407,7 +1419,7 @@ function ChartController($scope, $timeout) {
$scope.chart = $scope.chart.destroy();
resetVars();
}
}, 10000)
}, 500)
});
}

Expand Down Expand Up @@ -1439,6 +1451,10 @@ function ChartController($scope, $timeout) {
$scope.chartCallbackFunction = chartCallbackFunction;
}

function addSortDataFunction(sortDataFunction) {
$scope.sortDataFunction = sortDataFunction;
}

function addTransitionDuration(transitionDuration) {
$scope.transitionDuration = transitionDuration;
}
Expand Down Expand Up @@ -2703,22 +2719,23 @@ angular.module('gridshore.c3js.chart')
* Example:
* {@link http://jettro.github.io/c3-angular-directive/#examples}
*/
function Selection () {
function Selection() {
var selectionLinker = function (scope, element, attrs, chartCtrl) {
var enabled = attrs.enabled;
var grouped = attrs.grouped;
var multiple = attrs.multiple;
var selection = {};

if (enabled && enabled === 'true') {
var selection = {"enabled": true};
if (grouped && grouped === 'true') {
selection.grouped = true;
}
if (multiple && multiple === 'true') {
selection.multiple = true;
}
chartCtrl.addSelection(selection);
selection.enabled = true;
}
if (grouped && grouped === 'true') {
selection.grouped = true;
}
if (multiple && multiple === 'true') {
selection.multiple = true;
}
chartCtrl.addSelection(selection);
};

return {
Expand Down
6 changes: 3 additions & 3 deletions c3-angular.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion c3-angular.min.js.map

Large diffs are not rendered by default.

624 changes: 313 additions & 311 deletions examples/assets/js/angular.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions examples/assets/js/angular.min.js.map

Large diffs are not rendered by default.

41 changes: 29 additions & 12 deletions examples/assets/js/c3-angular.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*! c3-angular - v1.3.1 - 2016-08-04
/*! c3-angular - v1.3.1 - 2017-01-05
* https://github.com/jettro/c3-angular-directive
* Copyright (c) 2016 ; Licensed */
* Copyright (c) 2017 ; Licensed */
angular.module('gridshore.c3js.chart', []);
angular.module('gridshore.c3js.chart')
.directive('chartAxes', ChartAxes);
Expand Down Expand Up @@ -765,6 +765,10 @@ angular.module('gridshore.c3js.chart')
*
* {@link http://c3js.org/reference.html#data-order| c3js doc}
*
* @param {Function} sort-data-function Provide a function for sorting.
*
* {@link http://c3js.org/reference.html#data-order| c3js doc}
*
* @param {Boolean} show-labels Configure to show the labels 'true' or not, default is false.
*
* {@link http://c3js.org/reference.html#data-labels| c3js doc}
Expand Down Expand Up @@ -887,6 +891,9 @@ function C3Chart ($timeout) {
if (attrs.callbackFunction) {
chartCtrl.addChartCallbackFunction(scope.callbackFunction());
}
if (attrs.sortDataFunction) {
chartCtrl.addSortDataFunction(scope.sortDataFunction());
}
if (transitionDuration) {
chartCtrl.addTransitionDuration(transitionDuration);
}
Expand Down Expand Up @@ -914,6 +921,7 @@ function C3Chart ($timeout) {
"chartColumns": "=chartColumns",
"chartX": "=chartX",
"callbackFunction": "&",
"sortDataFunction": "&",
"emptyLabel": "@emptyLabel"
},
"template": "<div><div id='{{bindto}}'></div><div ng-transclude></div></div>",
Expand Down Expand Up @@ -1089,6 +1097,7 @@ function ChartController($scope, $timeout) {
this.addXSValues = addXSValues;

this.addChartCallbackFunction = addChartCallbackFunction;
this.addSortDataFunction = addSortDataFunction;
this.addInitialConfig = addInitialConfig;

this.addDataLabelsFormatFunction = addDataLabelsFormatFunction;
Expand Down Expand Up @@ -1204,6 +1213,9 @@ function ChartController($scope, $timeout) {
config.data.order = $scope.sorting;
}
}
if ($scope.sortDataFunction) {
config.data.order = $scope.sortDataFunction;
}
if ($scope.transitionDuration != null) {
config.transition = config.transition || {};
config.transition.duration = $scope.transitionDuration;
Expand Down Expand Up @@ -1407,7 +1419,7 @@ function ChartController($scope, $timeout) {
$scope.chart = $scope.chart.destroy();
resetVars();
}
}, 10000)
}, 500)
});
}

Expand Down Expand Up @@ -1439,6 +1451,10 @@ function ChartController($scope, $timeout) {
$scope.chartCallbackFunction = chartCallbackFunction;
}

function addSortDataFunction(sortDataFunction) {
$scope.sortDataFunction = sortDataFunction;
}

function addTransitionDuration(transitionDuration) {
$scope.transitionDuration = transitionDuration;
}
Expand Down Expand Up @@ -2703,22 +2719,23 @@ angular.module('gridshore.c3js.chart')
* Example:
* {@link http://jettro.github.io/c3-angular-directive/#examples}
*/
function Selection () {
function Selection() {
var selectionLinker = function (scope, element, attrs, chartCtrl) {
var enabled = attrs.enabled;
var grouped = attrs.grouped;
var multiple = attrs.multiple;
var selection = {};

if (enabled && enabled === 'true') {
var selection = {"enabled": true};
if (grouped && grouped === 'true') {
selection.grouped = true;
}
if (multiple && multiple === 'true') {
selection.multiple = true;
}
chartCtrl.addSelection(selection);
selection.enabled = true;
}
if (grouped && grouped === 'true') {
selection.grouped = true;
}
if (multiple && multiple === 'true') {
selection.multiple = true;
}
chartCtrl.addSelection(selection);
};

return {
Expand Down
6 changes: 3 additions & 3 deletions examples/assets/js/c3-angular.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/assets/js/c3-angular.min.js.map

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions examples/assets/js/d3.min.js

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions src/c3chart-directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ angular.module('gridshore.c3js.chart')
*
* {@link http://c3js.org/reference.html#data-order| c3js doc}
*
* @param {Function} sort-data-function Provide a function for sorting.
*
* {@link http://c3js.org/reference.html#data-order| c3js doc}
*
* @param {Boolean} show-labels Configure to show the labels 'true' or not, default is false.
*
* {@link http://c3js.org/reference.html#data-labels| c3js doc}
Expand Down Expand Up @@ -167,6 +171,9 @@ function C3Chart ($timeout) {
if (attrs.callbackFunction) {
chartCtrl.addChartCallbackFunction(scope.callbackFunction());
}
if (attrs.sortDataFunction) {
chartCtrl.addSortDataFunction(scope.sortDataFunction());
}
if (transitionDuration) {
chartCtrl.addTransitionDuration(transitionDuration);
}
Expand Down Expand Up @@ -194,6 +201,7 @@ function C3Chart ($timeout) {
"chartColumns": "=chartColumns",
"chartX": "=chartX",
"callbackFunction": "&",
"sortDataFunction": "&",
"emptyLabel": "@emptyLabel"
},
"template": "<div><div id='{{bindto}}'></div><div ng-transclude></div></div>",
Expand Down
10 changes: 9 additions & 1 deletion src/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ function ChartController($scope, $timeout) {
this.addXSValues = addXSValues;

this.addChartCallbackFunction = addChartCallbackFunction;
this.addSortDataFunction = addSortDataFunction;
this.addInitialConfig = addInitialConfig;

this.addDataLabelsFormatFunction = addDataLabelsFormatFunction;
Expand Down Expand Up @@ -162,6 +163,9 @@ function ChartController($scope, $timeout) {
config.data.order = $scope.sorting;
}
}
if ($scope.sortDataFunction) {
config.data.order = $scope.sortDataFunction;
}
if ($scope.transitionDuration != null) {
config.transition = config.transition || {};
config.transition.duration = $scope.transitionDuration;
Expand Down Expand Up @@ -365,7 +369,7 @@ function ChartController($scope, $timeout) {
$scope.chart = $scope.chart.destroy();
resetVars();
}
}, 10000)
}, 500)
});
}

Expand Down Expand Up @@ -397,6 +401,10 @@ function ChartController($scope, $timeout) {
$scope.chartCallbackFunction = chartCallbackFunction;
}

function addSortDataFunction(sortDataFunction) {
$scope.sortDataFunction = sortDataFunction;
}

function addTransitionDuration(transitionDuration) {
$scope.transitionDuration = transitionDuration;
}
Expand Down
19 changes: 10 additions & 9 deletions src/selection-directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,23 @@ angular.module('gridshore.c3js.chart')
* Example:
* {@link http://jettro.github.io/c3-angular-directive/#examples}
*/
function Selection () {
function Selection() {
var selectionLinker = function (scope, element, attrs, chartCtrl) {
var enabled = attrs.enabled;
var grouped = attrs.grouped;
var multiple = attrs.multiple;
var selection = {};

if (enabled && enabled === 'true') {
var selection = {"enabled": true};
if (grouped && grouped === 'true') {
selection.grouped = true;
}
if (multiple && multiple === 'true') {
selection.multiple = true;
}
chartCtrl.addSelection(selection);
selection.enabled = true;
}
if (grouped && grouped === 'true') {
selection.grouped = true;
}
if (multiple && multiple === 'true') {
selection.multiple = true;
}
chartCtrl.addSelection(selection);
};

return {
Expand Down