Skip to content

Commit 745c14b

Browse files
committed
Fix toolbox hotkey chart selection and toolbox resize display bug (#267)
1 parent e199e54 commit 745c14b

3 files changed

Lines changed: 20 additions & 7 deletions

File tree

lightweight_charts/js/callback.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,6 @@ function makeSearchBox(chart) {
225225
chart.chart.subscribeCrosshairMove((param) => {
226226
if (param.point) yPrice = param.point.y;
227227
})
228-
window.selectedChart = chart
229-
chart.wrapper.addEventListener('mouseover', (event) => window.selectedChart = chart)
230228
chart.commandFunctions.push((event) => {
231229
if (selectedChart !== chart) return false
232230
if (searchWindow.style.display === 'none') {

lightweight_charts/js/funcs.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ if (!window.Chart) {
7070
if (this.commandFunctions[i](event)) break
7171
}
7272
})
73+
74+
window.selectedChart = this
75+
this.wrapper.addEventListener('mouseover', (e) => window.selectedChart = this)
76+
7377
if (!autoSize) return
7478
window.addEventListener('resize', () => this.reSize())
7579
}
@@ -78,15 +82,21 @@ if (!window.Chart) {
7882
this.chart.resize(window.innerWidth * this.scale.width, (window.innerHeight * this.scale.height) - topBarOffset)
7983
this.wrapper.style.width = `${100 * this.scale.width}%`
8084
this.wrapper.style.height = `${100 * this.scale.height}%`
81-
if (this.legend) {
82-
if (this.scale.height === 0 || this.scale.width === 0) {
83-
this.legend.div.style.display = 'none'
85+
86+
if (this.scale.height === 0 || this.scale.width === 0) {
87+
this.legend.div.style.display = 'none'
88+
if (this.toolBox) {
89+
this.toolBox.elem.style.display = 'none'
8490
}
85-
else {
86-
this.legend.div.style.display = 'flex'
91+
}
92+
else {
93+
this.legend.div.style.display = 'flex'
94+
if (this.toolBox) {
95+
this.toolBox.elem.style.display = 'flex'
8796
}
8897
}
8998

99+
90100
}
91101
makeCandlestickSeries() {
92102
this.markers = []

lightweight_charts/js/toolbox.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@ if (!window.ToolBox) {
117117
this.chart.activeIcon.action(true)
118118
})
119119
this.chart.commandFunctions.push((event) => {
120+
121+
if (this.chart !== window.selectedChart) {
122+
return
123+
}
124+
120125
if (event.altKey && event.code === keyCmd) {
121126
event.preventDefault()
122127
if (this.chart.activeIcon) {

0 commit comments

Comments
 (0)