@@ -20,129 +20,133 @@ import initChart from '@/components/chart'
2020import type { Ref } from 'vue'
2121
2222const props = {
23- height : {
24- type : [ String , Number ] as PropType < string | number > ,
25- default : 400
26- } ,
27- width : {
28- type : [ String , Number ] as PropType < string | number > ,
29- default : '100%'
30- } ,
31- tooltipFormat : {
32- type : String as PropType < string > ,
33- default : ''
34- } ,
35- legendData : {
36- type : Array as PropType < Array < string > > ,
37- default : ( ) => [ ]
38- } ,
39- seriesData : {
40- type : Array as PropType < Array < string > > ,
41- default : ( ) => [ ]
42- } ,
43- labelShow : {
44- type : Array as PropType < Array < string > > ,
45- default : ( ) => [ ]
46- } ,
47- linksData : {
48- type : Array as PropType < Array < string > > ,
49- default : ( ) => [ ]
50- } ,
51- labelFormat : {
52- type : String as PropType < string > ,
53- default : ''
54- }
23+ height : {
24+ type : [ String , Number ] as PropType < string | number > ,
25+ default : 400
26+ } ,
27+ width : {
28+ type : [ String , Number ] as PropType < string | number > ,
29+ default : '100%'
30+ } ,
31+ tooltipFormat : {
32+ type : String as PropType < string > ,
33+ default : ''
34+ } ,
35+ legendData : {
36+ type : Array as PropType < Array < string > > ,
37+ default : ( ) => [ ]
38+ } ,
39+ seriesData : {
40+ type : Array as PropType < Array < string > > ,
41+ default : ( ) => [ ]
42+ } ,
43+ labelShow : {
44+ type : Array as PropType < Array < string > > ,
45+ default : ( ) => [ ]
46+ } ,
47+ linksData : {
48+ type : Array as PropType < Array < string > > ,
49+ default : ( ) => [ ]
50+ } ,
51+ labelFormat : {
52+ type : String as PropType < string > ,
53+ default : ''
54+ }
5555}
5656
5757const GraphChart = defineComponent ( {
58- name : 'GraphChart' ,
59- props,
60- setup ( props ) {
61- const graphChartRef : Ref < HTMLDivElement | null > = ref ( null )
58+ name : 'GraphChart' ,
59+ props,
60+ setup ( props ) {
61+ const graphChartRef : Ref < HTMLDivElement | null > = ref ( null )
6262
63- const option = {
64- tooltip : {
65- trigger : 'item' ,
66- triggerOn : 'mousemove' ,
67- backgroundColor : '#2D303A' ,
68- padding : [ 8 , 12 ] ,
69- formatter : props . tooltipFormat ,
70- color : '#2D303A' ,
71- textStyle : {
72- rich : {
73- a : {
74- fontSize : 12 ,
75- color : '#2D303A' ,
76- lineHeight : 12 ,
77- align : 'left' ,
78- padding : [ 4 , 4 , 4 , 4 ]
79- }
80- }
81- }
82- } ,
83- legend : [ {
84- orient : 'horizontal' ,
85- top : 6 ,
86- left : 6 ,
87- data : props . legendData
88- } ] ,
89- series : [ {
90- type : 'graph' ,
91- layout : 'force' ,
92- nodeScaleRatio : 1.2 ,
93- draggable : true ,
94- animation : false ,
95- data : props . seriesData ,
96- roam : true ,
97- symbol : 'roundRect' ,
98- symbolSize : 70 ,
99- categories : props . legendData ,
100- label : {
101- show : props . labelShow ,
102- position : 'inside' ,
103- formatter : props . labelFormat ,
104- color : '#222222' ,
105- textStyle : {
106- rich : {
107- a : {
108- fontSize : 12 ,
109- color : '#222222' ,
110- lineHeight : 12 ,
111- align : 'left' ,
112- padding : [ 4 , 4 , 4 , 4 ]
113- }
114- }
115- }
116- } ,
117- edgeSymbol : [ 'circle' , 'arrow' ] ,
118- edgeSymbolSize : [ 4 , 12 ] ,
119- force : {
120- repulsion : 1000 ,
121- edgeLength : 300
122- } ,
123- links : props . linksData ,
124- lineStyle : {
125- color : '#999999'
126- }
127- } ]
128- }
63+ const option = {
64+ tooltip : {
65+ trigger : 'item' ,
66+ triggerOn : 'mousemove' ,
67+ backgroundColor : '#2D303A' ,
68+ padding : [ 8 , 12 ] ,
69+ formatter : props . tooltipFormat ,
70+ color : '#2D303A' ,
71+ textStyle : {
72+ rich : {
73+ a : {
74+ fontSize : 12 ,
75+ color : '#2D303A' ,
76+ lineHeight : 12 ,
77+ align : 'left' ,
78+ padding : [ 4 , 4 , 4 , 4 ]
79+ }
80+ }
81+ }
82+ } ,
83+ legend : [
84+ {
85+ orient : 'horizontal' ,
86+ top : 6 ,
87+ left : 6 ,
88+ data : props . legendData
89+ }
90+ ] ,
91+ series : [
92+ {
93+ type : 'graph' ,
94+ layout : 'force' ,
95+ nodeScaleRatio : 1.2 ,
96+ draggable : true ,
97+ animation : false ,
98+ data : props . seriesData ,
99+ roam : true ,
100+ symbol : 'roundRect' ,
101+ symbolSize : 70 ,
102+ categories : props . legendData ,
103+ label : {
104+ show : props . labelShow ,
105+ position : 'inside' ,
106+ formatter : props . labelFormat ,
107+ color : '#222222' ,
108+ textStyle : {
109+ rich : {
110+ a : {
111+ fontSize : 12 ,
112+ color : '#222222' ,
113+ lineHeight : 12 ,
114+ align : 'left' ,
115+ padding : [ 4 , 4 , 4 , 4 ]
116+ }
117+ }
118+ }
119+ } ,
120+ edgeSymbol : [ 'circle' , 'arrow' ] ,
121+ edgeSymbolSize : [ 4 , 12 ] ,
122+ force : {
123+ repulsion : 1000 ,
124+ edgeLength : 300
125+ } ,
126+ links : props . linksData ,
127+ lineStyle : {
128+ color : '#999999'
129+ }
130+ }
131+ ]
132+ }
129133
130- initChart ( graphChartRef , option )
134+ initChart ( graphChartRef , option )
131135
132- return { graphChartRef }
133- } ,
134- render ( ) {
135- const { height, width } = this
136- return (
137- < div
138- ref = 'graphChartRef'
139- style = { {
140- height : typeof height === 'number' ? height + 'px' : height ,
141- width : typeof width === 'number' ? width + 'px' : width
142- } }
143- />
144- )
145- }
136+ return { graphChartRef }
137+ } ,
138+ render ( ) {
139+ const { height, width } = this
140+ return (
141+ < div
142+ ref = 'graphChartRef'
143+ style = { {
144+ height : typeof height === 'number' ? height + 'px' : height ,
145+ width : typeof width === 'number' ? width + 'px' : width
146+ } }
147+ />
148+ )
149+ }
146150} )
147151
148152export default GraphChart
0 commit comments