File tree Expand file tree Collapse file tree 4 files changed +98
-1
lines changed Expand file tree Collapse file tree 4 files changed +98
-1
lines changed Original file line number Diff line number Diff line change 4
4
"description" : " A JavaScript library dedicated to graph drawing." ,
5
5
"homepage" : " http://sigmajs.org" ,
6
6
"bugs" : " http://github.com/jacomyal/sigma.js/issues" ,
7
+ "main" : " dist/sigma.js" ,
7
8
"repository" : {
8
9
"type" : " git" ,
9
10
"url" : " http://github.com/jacomyal/sigma.js.git"
19
20
}
20
21
],
21
22
"license" : " MIT" ,
22
- "main" : " build/sigma.require.js" ,
23
23
"devDependencies" : {
24
+ "graphology" : " 0.0.4" ,
24
25
"mocha" : " ^3.0.2"
25
26
},
26
27
"keywords" : [
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Sigma.js Camera Class
3
+ * ======================
4
+ *
5
+ * Class designed to store camera information & used to update it.
6
+ */
7
+
8
+ /**
9
+ * Camera class
10
+ *
11
+ * @constructor
12
+ */
13
+ export default class Camera {
14
+ constructor ( ) {
15
+
16
+ // Properties
17
+ this . x = 0 ;
18
+ this . y = 0 ;
19
+ this . angle = 0 ;
20
+ this . ratio = 0 ;
21
+ }
22
+ }
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Sigma.js Core Class
3
+ * ====================
4
+ *
5
+ * Core class holding state for the bound graph and using a combination of
6
+ * a renderer & camera to display the bound graph on screen.
7
+ */
8
+ import Camera from './camera' ;
9
+ import { isGraph } from './utils' ;
10
+
11
+ // TODO: possibility to pass a camera
12
+
13
+ /**
14
+ * Sigma class
15
+ *
16
+ * @constructor
17
+ * @param {Graph } graph - A graphology Graph instance.
18
+ */
19
+ export default class Sigma {
20
+ constructor ( graph ) {
21
+
22
+ // Checking the arguments
23
+ if ( ! isGraph ( graph ) )
24
+ throw new Error ( 'Sigma.constructor: given graph is not an instance of a graphology implementation.' ) ;
25
+
26
+ // Properties
27
+ this . graph = graph ;
28
+ this . camera = new Camera ( ) ;
29
+ }
30
+
31
+ /**---------------------------------------------------------------------------
32
+ * Getters
33
+ **---------------------------------------------------------------------------
34
+ */
35
+
36
+ /**
37
+ * Method returning the graph bound to the instance.
38
+ *
39
+ * @return {Graph } - The bound graph.
40
+ */
41
+ getGraph ( ) {
42
+ return this . graph ;
43
+ }
44
+
45
+ /**
46
+ * Method returning the instance's camera.
47
+ *
48
+ * @return {Camera } - The instance's graph.
49
+ */
50
+ getCamera ( ) {
51
+ return this . camera ;
52
+ }
53
+ }
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Sigma.js Utils
3
+ * ===============
4
+ *
5
+ * Various helper functions & classes used throughout the library.
6
+ */
7
+
8
+ /**
9
+ * Function returning whether the given value is a graphology Graph instance.
10
+ *
11
+ * @param {any } value - Target value.
12
+ * @return {boolean }
13
+ */
14
+ export function isGraph ( value ) {
15
+ return (
16
+ value &&
17
+ typeof value === 'object' &&
18
+ typeof value . addUndirectedEdgeWithKey === 'function' &&
19
+ typeof value . dropNodes === 'function'
20
+ ) ;
21
+ }
You can’t perform that action at this time.
0 commit comments