Skip to content

Commit da074b3

Browse files
committed
impr: remove futures show
1 parent af53a56 commit da074b3

File tree

3 files changed

+89
-94
lines changed

3 files changed

+89
-94
lines changed

src/common/Styles.ts

-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ export interface FeatureIconFontStyle {
128128

129129
export interface FeatureStyle extends Padding, Margin {
130130
id: string
131-
show: boolean
132131
backgroundColor: string
133132
activeBackgroundColor: string
134133
size: number

src/view/CrosshairFeatureView.ts

+77-79
Original file line numberDiff line numberDiff line change
@@ -94,85 +94,83 @@ export default class CrosshairFeatureView extends View<YAxis> {
9494
}
9595
const y = crosshair.y!
9696
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)
176174
}
177175
})
178176
}

src/view/IndicatorTooltipView.ts

+12-14
Original file line numberDiff line numberDiff line change
@@ -413,20 +413,18 @@ export default class IndicatorTooltipView extends View<YAxis> {
413413
const middleFeatures: TooltipFeatureStyle[] = []
414414
const rightFeatures: TooltipFeatureStyle[] = []
415415
features.forEach(feature => {
416-
if (feature.show) {
417-
switch (feature.position) {
418-
case 'left': {
419-
leftFeatures.push(feature)
420-
break
421-
}
422-
case 'middle': {
423-
middleFeatures.push(feature)
424-
break
425-
}
426-
case 'right': {
427-
rightFeatures.push(feature)
428-
break
429-
}
416+
switch (feature.position) {
417+
case 'left': {
418+
leftFeatures.push(feature)
419+
break
420+
}
421+
case 'middle': {
422+
middleFeatures.push(feature)
423+
break
424+
}
425+
case 'right': {
426+
rightFeatures.push(feature)
427+
break
430428
}
431429
}
432430
})

0 commit comments

Comments
 (0)