@@ -94,85 +94,83 @@ export default class CrosshairFeatureView extends View<YAxis> {
94
94
}
95
95
const y = crosshair . y !
96
96
features . forEach ( feature => {
97
- if ( feature . show ) {
98
- const {
99
- marginLeft = 0 , marginTop = 0 , marginRight = 0 ,
100
- paddingLeft = 0 , paddingTop = 0 , paddingRight = 0 , paddingBottom = 0 ,
101
- color, activeColor, backgroundColor, activeBackgroundColor,
102
- borderRadius, size = 0 , type, content
103
- } = feature
104
- let width = size
105
- if ( type === 'icon_font' ) {
106
- const iconFont = content as FeatureIconFontStyle
107
- width = paddingLeft + calcTextWidth ( iconFont . code , size , 'normal' , iconFont . family ) + paddingRight
108
- }
109
- if ( isRight ) {
110
- x -= ( width + marginRight )
111
- } else {
112
- x += marginLeft
113
- }
114
- let finalColor = color
115
- let finalBackgroundColor = backgroundColor
116
- if ( this . _activeFeatureInfo ?. feature . id === feature . id ) {
117
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- ignore
118
- finalColor = activeColor ?? color
119
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- ignore
120
- finalBackgroundColor = activeBackgroundColor ?? backgroundColor
121
- }
122
- const eventHandler = {
123
- mouseClickEvent : this . _featureClickEvent ( { crosshair, feature } ) ,
124
- mouseMoveEvent : this . _featureMouseMoveEvent ( { crosshair, feature } )
125
- }
126
- if ( type === 'icon_font' ) {
127
- const iconFont = content as FeatureIconFontStyle
128
- this . createFigure ( {
129
- name : 'text' ,
130
- attrs : {
131
- text : iconFont . code ,
132
- x,
133
- y : y + marginTop ,
134
- baseline : 'middle'
135
- } ,
136
- styles : {
137
- paddingLeft,
138
- paddingTop,
139
- paddingRight,
140
- paddingBottom,
141
- borderRadius,
142
- size,
143
- family : iconFont . family ,
144
- color : finalColor ,
145
- backgroundColor : finalBackgroundColor
146
- }
147
- } , eventHandler ) ?. draw ( ctx )
148
- } else {
149
- this . createFigure ( {
150
- name : 'rect' ,
151
- attrs : { x, y : y + marginTop - size / 2 , width : size , height : size } ,
152
- styles : {
153
- paddingLeft,
154
- paddingTop,
155
- paddingRight,
156
- paddingBottom,
157
- color : finalBackgroundColor
158
- }
159
- } , eventHandler ) ?. draw ( ctx )
160
- const path = content as FeaturePathStyle
161
- this . createFigure ( {
162
- name : 'path' ,
163
- attrs : { path : path . path , x, y : y + marginTop + paddingTop - size / 2 , width : size , height : size } ,
164
- styles : {
165
- style : path . style ,
166
- lineWidth : path . lineWidth ,
167
- color : finalColor
168
- }
169
- } ) ?. draw ( ctx )
170
- }
171
- if ( isRight ) {
172
- x -= marginLeft
173
- } else {
174
- x += ( width + marginRight )
175
- }
97
+ const {
98
+ marginLeft = 0 , marginTop = 0 , marginRight = 0 ,
99
+ paddingLeft = 0 , paddingTop = 0 , paddingRight = 0 , paddingBottom = 0 ,
100
+ color, activeColor, backgroundColor, activeBackgroundColor,
101
+ borderRadius, size = 0 , type, content
102
+ } = feature
103
+ let width = size
104
+ if ( type === 'icon_font' ) {
105
+ const iconFont = content as FeatureIconFontStyle
106
+ width = paddingLeft + calcTextWidth ( iconFont . code , size , 'normal' , iconFont . family ) + paddingRight
107
+ }
108
+ if ( isRight ) {
109
+ x -= ( width + marginRight )
110
+ } else {
111
+ x += marginLeft
112
+ }
113
+ let finalColor = color
114
+ let finalBackgroundColor = backgroundColor
115
+ if ( this . _activeFeatureInfo ?. feature . id === feature . id ) {
116
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- ignore
117
+ finalColor = activeColor ?? color
118
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- ignore
119
+ finalBackgroundColor = activeBackgroundColor ?? backgroundColor
120
+ }
121
+ const eventHandler = {
122
+ mouseClickEvent : this . _featureClickEvent ( { crosshair, feature } ) ,
123
+ mouseMoveEvent : this . _featureMouseMoveEvent ( { crosshair, feature } )
124
+ }
125
+ if ( type === 'icon_font' ) {
126
+ const iconFont = content as FeatureIconFontStyle
127
+ this . createFigure ( {
128
+ name : 'text' ,
129
+ attrs : {
130
+ text : iconFont . code ,
131
+ x,
132
+ y : y + marginTop ,
133
+ baseline : 'middle'
134
+ } ,
135
+ styles : {
136
+ paddingLeft,
137
+ paddingTop,
138
+ paddingRight,
139
+ paddingBottom,
140
+ borderRadius,
141
+ size,
142
+ family : iconFont . family ,
143
+ color : finalColor ,
144
+ backgroundColor : finalBackgroundColor
145
+ }
146
+ } , eventHandler ) ?. draw ( ctx )
147
+ } else {
148
+ this . createFigure ( {
149
+ name : 'rect' ,
150
+ attrs : { x, y : y + marginTop - size / 2 , width : size , height : size } ,
151
+ styles : {
152
+ paddingLeft,
153
+ paddingTop,
154
+ paddingRight,
155
+ paddingBottom,
156
+ color : finalBackgroundColor
157
+ }
158
+ } , eventHandler ) ?. draw ( ctx )
159
+ const path = content as FeaturePathStyle
160
+ this . createFigure ( {
161
+ name : 'path' ,
162
+ attrs : { path : path . path , x, y : y + marginTop + paddingTop - size / 2 , width : size , height : size } ,
163
+ styles : {
164
+ style : path . style ,
165
+ lineWidth : path . lineWidth ,
166
+ color : finalColor
167
+ }
168
+ } ) ?. draw ( ctx )
169
+ }
170
+ if ( isRight ) {
171
+ x -= marginLeft
172
+ } else {
173
+ x += ( width + marginRight )
176
174
}
177
175
} )
178
176
}
0 commit comments