Skip to content

Make library UMD #68

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

Open
wants to merge 1 commit 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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
.idea
bower_components/
node_modules
/yarn.lock
10 changes: 10 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
.idea
bower_components
node_modules
/yarn.lock
/bower.json
/index-graph2d.html
/app-graph2d.js
/index.html
/app.js
/app_requirejs.js
/index_requirejs.html
20 changes: 18 additions & 2 deletions angular-vis.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
angular.module('ngVis', [])
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define('angular-visjs', ['angular', 'vis'], factory);
} else if (typeof module === 'object' && module.exports) {
// Node. Does not work with strict CommonJS, but
// only CommonJS-like environments that support module.exports,
// like Node.
module.exports = factory(require('angular'), require('vis'));
} else {
// Browser globals (root is window)
root.returnExports = factory(root.angular, root.vis);
}
}(this, function (angular, vis) {

return angular.module('ngVis', [])

.factory('VisDataSet', function () {
'use strict';
Expand Down Expand Up @@ -224,4 +239,5 @@ angular.module('ngVis', [])
}
};
})
;
.name;
}));
35 changes: 17 additions & 18 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ngVisApp.controller('appController', function ($scope, $location, $timeout, VisD
orientation: ['top', 'bottom'],
autoResize: [true, false],
showCurrentTime: [true, false],
showCustomTime: [true, false],
// showCustomTime: [true, false],
showMajorLabels: [true, false],
showMinorLabels: [true, false],
align: ['left', 'center', 'right'],
Expand Down Expand Up @@ -42,7 +42,7 @@ ngVisApp.controller('appController', function ($scope, $location, $timeout, VisD
orientation: 'bottom',
// padding: 5,
showCurrentTime: true,
showCustomTime: true,
// showCustomTime: true,
showMajorLabels: true,
showMinorLabels: true
// type: 'box', // dot | point
Expand Down Expand Up @@ -102,18 +102,18 @@ ngVisApp.controller('appController', function ($scope, $location, $timeout, VisD
};

var groups = VisDataSet([
{id: 0, content: 'First', value: 1},
{id: 1, content: 'Third', value: 3},
{id: 2, content: 'Second', value: 2}
]);
{id: 0, content: 'First', value: 1},
{id: 1, content: 'Third', value: 3},
{id: 2, content: 'Second', value: 2}
]);
var items = VisDataSet([
{id: 0, group: 0, content: 'item 0', start: new Date(2014, 3, 17), end: new Date(2014, 3, 21)},
{id: 1, group: 0, content: 'item 1', start: new Date(2014, 3, 19), end: new Date(2014, 3, 20)},
{id: 2, group: 1, content: 'item 2', start: new Date(2014, 3, 16), end: new Date(2014, 3, 24)},
{id: 3, group: 1, content: 'item 3', start: new Date(2014, 3, 23), end: new Date(2014, 3, 24)},
{id: 4, group: 1, content: 'item 4', start: new Date(2014, 3, 22), end: new Date(2014, 3, 26)},
{id: 5, group: 2, content: 'item 5', start: new Date(2014, 3, 24), end: new Date(2014, 3, 27)}
]);
{id: 0, group: 0, content: 'item 0', start: new Date(2014, 3, 17), end: new Date(2014, 3, 21)},
{id: 1, group: 0, content: 'item 1', start: new Date(2014, 3, 19), end: new Date(2014, 3, 20)},
{id: 2, group: 1, content: 'item 2', start: new Date(2014, 3, 16), end: new Date(2014, 3, 24)},
{id: 3, group: 1, content: 'item 3', start: new Date(2014, 3, 23), end: new Date(2014, 3, 24)},
{id: 4, group: 1, content: 'item 4', start: new Date(2014, 3, 22), end: new Date(2014, 3, 26)},
{id: 5, group: 2, content: 'item 5', start: new Date(2014, 3, 24), end: new Date(2014, 3, 27)}
]);

$scope.data = {groups: groups, items: items};
var orderedContent = 'content';
Expand All @@ -129,7 +129,7 @@ ngVisApp.controller('appController', function ($scope, $location, $timeout, VisD
$scope.options = angular.extend(options, {
groupOrder: orderedContent,
editable: true
})
});

$scope.onSelect = function (items) {
// debugger;
Expand All @@ -152,14 +152,13 @@ ngVisApp.controller('appController', function ($scope, $location, $timeout, VisD
};

$scope.events = {
rangechange: $scope.onRangeChange,
rangechanged: $scope.onRangeChanged,
// rangechange: $scope.onRangeChange,
// rangechanged: $scope.onRangeChanged,
onload: $scope.onLoaded,
select: $scope.onSelect,
click: $scope.onClick,
doubleClick: $scope.onDoubleClick,
contextmenu: $scope.rightClick
};

})
;
});
182 changes: 182 additions & 0 deletions app_requirejs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
require.config({
paths: {
angular: 'node_modules/angular/angular',
'angular-visjs': 'angular-vis',
vis: 'node_modules/vis/dist/vis',
moment: 'node_modules/moment/moment'
},
shim: {
angular: {exports: 'angular'}
}
});

require(['angular', 'angular-visjs', 'moment'], (angular, ngVis, moment) => {

'use strict';


var ngVisApp = angular.module('ngVisApp', [ngVis]);

ngVisApp.controller('appController', function ($scope, $location, $timeout, VisDataSet) {

$scope.logs = {};

$scope.defaults = {
orientation: ['top', 'bottom'],
autoResize: [true, false],
showCurrentTime: [true, false],
// showCustomTime: [true, false],
showMajorLabels: [true, false],
showMinorLabels: [true, false],
align: ['left', 'center', 'right'],
stack: [true, false],

moveable: [true, false],
zoomable: [true, false],
selectable: [true, false],
editable: [true, false]
};

var options = {
align: 'center', // left | right (String)
autoResize: true, // false (Boolean)
editable: true,
selectable: true,
// start: null,
// end: null,
// height: null,
// width: '100%',
// margin: {
// axis: 20,
// item: 10
// },
// min: null,
// max: null,
// maxHeight: null,
orientation: 'bottom',
// padding: 5,
showCurrentTime: true,
// showCustomTime: true,
showMajorLabels: true,
showMinorLabels: true
// type: 'box', // dot | point
// zoomMin: 1000,
// zoomMax: 1000 * 60 * 60 * 24 * 30 * 12 * 10,
// groupOrder: 'content'
};

var now = moment().minutes(0).seconds(0).milliseconds(0);

var sampleData = function () {
return VisDataSet([
{
id: 1,
content: '<i class="fi-flag"></i> item 1',
start: moment().add('days', 1),
className: 'magenta'
},
{
id: 2,
content: '<a href="http://visjs.org" target="_blank">visjs.org</a>',
start: moment().add('days', 2)
},
{
id: 3,
content: 'item 3',
start: moment().add('days', -2)
},
{
id: 4,
content: 'item 4',
start: moment().add('days', 1),
end: moment().add('days', 3),
type: 'range'
},
{
id: 7,
content: '<i class="fi-anchor"></i> item 7',
start: moment().add('days', -3),
end: moment().add('days', -2),
type: 'range',
className: 'orange'
},
{
id: 5,
content: 'item 5',
start: moment().add('days', -1),
type: 'point'
},
{
id: 6,
content: 'item 6',
start: moment().add('days', 4),
type: 'point'
}
]);
};

var groups = VisDataSet([
{id: 0, content: 'First', value: 1},
{id: 1, content: 'Third', value: 3},
{id: 2, content: 'Second', value: 2}
]);
var items = VisDataSet([
{id: 0, group: 0, content: 'item 0', start: new Date(2014, 3, 17), end: new Date(2014, 3, 21)},
{id: 1, group: 0, content: 'item 1', start: new Date(2014, 3, 19), end: new Date(2014, 3, 20)},
{id: 2, group: 1, content: 'item 2', start: new Date(2014, 3, 16), end: new Date(2014, 3, 24)},
{id: 3, group: 1, content: 'item 3', start: new Date(2014, 3, 23), end: new Date(2014, 3, 24)},
{id: 4, group: 1, content: 'item 4', start: new Date(2014, 3, 22), end: new Date(2014, 3, 26)},
{id: 5, group: 2, content: 'item 5', start: new Date(2014, 3, 24), end: new Date(2014, 3, 27)}
]);

$scope.data = {groups: groups, items: items};
var orderedContent = 'content';
var orderedSorting = function (a, b) {
// option groupOrder can be a property name or a sort function
// the sort function must compare two groups and return a value
// > 0 when a > b
// < 0 when a < b
// 0 when a == b
return a.value - b.value;
};

$scope.options = angular.extend(options, {
groupOrder: orderedContent,
editable: true
});

$scope.onSelect = function (items) {
// debugger;
alert('select');
};

$scope.onClick = function (props) {
//debugger;
alert('Click');
};

$scope.onDoubleClick = function (props) {
// debugger;
alert('DoubleClick');
};

$scope.rightClick = function (props) {
alert('Right click!');
props.event.preventDefault();
};

$scope.events = {
// rangechange: $scope.onRangeChange,
// rangechanged: $scope.onRangeChanged,
onload: $scope.onLoaded,
select: $scope.onSelect,
click: $scope.onClick,
doubleClick: $scope.onDoubleClick,
contextmenu: $scope.rightClick
};

});

angular.bootstrap(document, [ngVisApp.name]);

});
3 changes: 3 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,8 @@
"angular": "~1.5.0",
"vis": "~4.16.0",
"moment": "^2.15.1"
},
"devDependencies": {
"requirejs": "^2.3.2"
}
}
79 changes: 79 additions & 0 deletions index_requirejs.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<!doctype html>
<html class="no-js" lang="en">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>AngularVis</title>
<link rel="stylesheet" href="node_modules/vis/dist/vis.min.css"/>
<style>
#showcase {
padding: 30px;
background-color: #fbfbfb;
}

.fluid {
width: 100%;
max-width: 100%;
}

.vis.timeline {
background-color: #ffffff;
}

.vis.timeline .item {
/*background-color: #008CBA;*/
/*border-color: #008CBA;*/
/*color: #ffffff;*/
/*font-family: 'Helvetica Neue', Helvetica, Helvetica, Arial, sans-serif;*/
/*font-kerning: auto;*/
/*font-size: 13px;*/
/*font-style: normal;*/
/*font-variant: normal;*/
/*font-variant-ligatures: normal;*/
/*font-weight: normal;*/
}

.vis.timeline .item.green {
background-color: green;
border-color: green;
color: #ffffff;
}

.vis.timeline .item.red {
background-color: red;
border-color: red;
color: #ffffff;
}

.vis.timeline .item.orange {
background-color: orange;
border-color: orange;
}

.vis.timeline .item.magenta {
background-color: magenta;
border-color: magenta;
color: #ffffff;
}

.vis.timeline .item.past {
filter: alpha(opacity=50);
opacity: 0.5;
}

h6 {
font-size: 0.75rem;
}

pre {
font-size: 0.9rem;
}
</style>
<script data-main="app_requirejs.js" src="node_modules/requirejs/require.js"></script>
</head>
<body ng-controller="appController">

<vis-timeline data="data" options="options" events="events"></vis-timeline>

</body>
</html>
Loading