@@ -6,81 +6,81 @@ import { i18n } from "../i18n"
66import { classNames } from "../util/lang"
77
88export interface D3Config {
9- drag : boolean
10- zoom : boolean
11- depth : number
12- scale : number
13- repelForce : number
14- centerForce : number
15- linkDistance : number
16- fontSize : number
17- opacityScale : number
18- removeTags : string [ ]
19- showTags : boolean
20- focusOnHover ?: boolean
21- enableRadial ?: boolean
9+ drag : boolean
10+ zoom : boolean
11+ depth : number
12+ scale : number
13+ repelForce : number
14+ centerForce : number
15+ linkDistance : number
16+ fontSize : number
17+ opacityScale : number
18+ removeTags : string [ ]
19+ showTags : boolean
20+ focusOnHover ?: boolean
21+ enableRadial ?: boolean
2222}
2323
2424interface GraphOptions {
25- localGraph : Partial < D3Config > | undefined
26- globalGraph : Partial < D3Config > | undefined
25+ localGraph : Partial < D3Config > | undefined
26+ globalGraph : Partial < D3Config > | undefined
2727}
2828
2929const defaultOptions : GraphOptions = {
30- localGraph : {
31- drag : true ,
32- zoom : true ,
33- depth : 1 ,
34- scale : 1.1 ,
35- repelForce : 0.5 ,
36- centerForce : 0.3 ,
37- linkDistance : 30 ,
38- fontSize : 0.6 ,
39- opacityScale : 1 ,
40- showTags : true ,
41- removeTags : [ ] ,
42- focusOnHover : false ,
43- enableRadial : false ,
44- } ,
45- globalGraph : {
46- drag : true ,
47- zoom : true ,
48- depth : - 1 ,
49- scale : 0.9 ,
50- repelForce : 0.5 ,
51- centerForce : 0.2 ,
52- linkDistance : 30 ,
53- fontSize : 0.6 ,
54- opacityScale : 1 ,
55- showTags : true ,
56- removeTags : [ ] ,
57- focusOnHover : true ,
58- enableRadial : true ,
59- } ,
30+ localGraph : {
31+ drag : true ,
32+ zoom : true ,
33+ depth : 1 ,
34+ scale : 1.1 ,
35+ repelForce : 0.5 ,
36+ centerForce : 0.3 ,
37+ linkDistance : 30 ,
38+ fontSize : 0.6 ,
39+ opacityScale : 1 ,
40+ showTags : true ,
41+ removeTags : [ ] ,
42+ focusOnHover : true ,
43+ enableRadial : false ,
44+ } ,
45+ globalGraph : {
46+ drag : true ,
47+ zoom : true ,
48+ depth : - 1 ,
49+ scale : 0.9 ,
50+ repelForce : 0.5 ,
51+ centerForce : 0.2 ,
52+ linkDistance : 30 ,
53+ fontSize : 0.6 ,
54+ opacityScale : 3 ,
55+ showTags : true ,
56+ removeTags : [ ] ,
57+ focusOnHover : true ,
58+ enableRadial : true ,
59+ } ,
6060}
6161
6262export default ( ( opts ?: Partial < GraphOptions > ) => {
63- const Graph : QuartzComponent = ( { displayClass, cfg } : QuartzComponentProps ) => {
64- const localGraph = { ...defaultOptions . localGraph , ...opts ?. localGraph }
65- const globalGraph = { ...defaultOptions . globalGraph , ...opts ?. globalGraph }
66- return (
67- < div class = { classNames ( displayClass , "graph" ) } >
68- < h3 > { i18n ( cfg . locale ) . components . graph . title } </ h3 >
69- < div class = "graph-outer" >
70- < div class = "graph-container" data-cfg = { JSON . stringify ( localGraph ) } > </ div >
71- < button class = "global-graph-icon" aria-label = "Global Graph" >
72- < svg
73- version = "1.1"
74- xmlns = "http://www.w3.org/2000/svg"
75- xmlnsXlink = "http://www.w3.org/1999/xlink"
76- x = "0px"
77- y = "0px"
78- viewBox = "0 0 55 55"
79- fill = "currentColor"
80- xmlSpace = "preserve"
81- >
82- < path
83- d = "M49,0c-3.309,0-6,2.691-6,6c0,1.035,0.263,2.009,0.726,2.86l-9.829,9.829C32.542,17.634,30.846,17,29,17
63+ const Graph : QuartzComponent = ( { displayClass, cfg } : QuartzComponentProps ) => {
64+ const localGraph = { ...defaultOptions . localGraph , ...opts ?. localGraph }
65+ const globalGraph = { ...defaultOptions . globalGraph , ...opts ?. globalGraph }
66+ return (
67+ < div class = { classNames ( displayClass , "graph" ) } >
68+ < h3 > { i18n ( cfg . locale ) . components . graph . title } </ h3 >
69+ < div class = "graph-outer" >
70+ < div class = "graph-container" data-cfg = { JSON . stringify ( localGraph ) } > </ div >
71+ < button class = "global-graph-icon" aria-label = "Global Graph" >
72+ < svg
73+ version = "1.1"
74+ xmlns = "http://www.w3.org/2000/svg"
75+ xmlnsXlink = "http://www.w3.org/1999/xlink"
76+ x = "0px"
77+ y = "0px"
78+ viewBox = "0 0 55 55"
79+ fill = "currentColor"
80+ xmlSpace = "preserve"
81+ >
82+ < path
83+ d = "M49,0c-3.309,0-6,2.691-6,6c0,1.035,0.263,2.009,0.726,2.86l-9.829,9.829C32.542,17.634,30.846,17,29,17
8484 s-3.542,0.634-4.898,1.688l-7.669-7.669C16.785,10.424,17,9.74,17,9c0-2.206-1.794-4-4-4S9,6.794,9,9s1.794,4,4,4
8585 c0.74,0,1.424-0.215,2.019-0.567l7.669,7.669C21.634,21.458,21,23.154,21,25s0.634,3.542,1.688,4.897L10.024,42.562
8686 C8.958,41.595,7.549,41,6,41c-3.309,0-6,2.691-6,6s2.691,6,6,6s6-2.691,6-6c0-1.035-0.263-2.009-0.726-2.86l12.829-12.829
@@ -91,19 +91,19 @@ export default ((opts?: Partial<GraphOptions>) => {
9191 S11,10.103,11,9z M6,51c-2.206,0-4-1.794-4-4s1.794-4,4-4s4,1.794,4,4S8.206,51,6,51z M33,49c0,2.206-1.794,4-4,4s-4-1.794-4-4
9292 s1.794-4,4-4S33,46.794,33,49z M29,31c-3.309,0-6-2.691-6-6s2.691-6,6-6s6,2.691,6,6S32.309,31,29,31z M47,41c0,1.103-0.897,2-2,2
9393 s-2-0.897-2-2s0.897-2,2-2S47,39.897,47,41z M49,10c-2.206,0-4-1.794-4-4s1.794-4,4-4s4,1.794,4,4S51.206,10,49,10z"
94- />
95- </ svg >
96- </ button >
97- </ div >
98- < div class = "global-graph-outer" >
99- < div class = "global-graph-container" data-cfg = { JSON . stringify ( globalGraph ) } > </ div >
100- </ div >
101- </ div >
102- )
103- }
94+ />
95+ </ svg >
96+ </ button >
97+ </ div >
98+ < div class = "global-graph-outer" >
99+ < div class = "global-graph-container" data-cfg = { JSON . stringify ( globalGraph ) } > </ div >
100+ </ div >
101+ </ div >
102+ )
103+ }
104104
105- Graph . css = style
106- Graph . afterDOMLoaded = script
105+ Graph . css = style
106+ Graph . afterDOMLoaded = script
107107
108- return Graph
108+ return Graph
109109} ) satisfies QuartzComponentConstructor
0 commit comments