ensure textboxes and searchboxes do not clash, fix legend item deletion, fix legend throwing error
This commit is contained in:
@ -471,10 +471,15 @@ class Line(SeriesCommon):
|
|||||||
"""
|
"""
|
||||||
self._chart._lines.remove(self) if self in self._chart._lines else None
|
self._chart._lines.remove(self) if self in self._chart._lines else None
|
||||||
self.run_script(f'''
|
self.run_script(f'''
|
||||||
|
{self.id}legendItem = {self._chart.id}.legend._lines.find((line) => line.series == {self.id}.series)
|
||||||
|
{self._chart.id}.legend._lines = {self._chart.id}.legend._lines.filter((item) => item != {self.id}legendItem)
|
||||||
|
|
||||||
|
if ({self.id}legendItem) {{
|
||||||
|
{self._chart.id}.legend.div.removeChild({self.id}legendItem.row)
|
||||||
|
}}
|
||||||
|
|
||||||
{self._chart.id}.chart.removeSeries({self.id}.series)
|
{self._chart.id}.chart.removeSeries({self.id}.series)
|
||||||
{self._chart.id}.legend.lines.forEach(line => {{
|
delete {self.id}legendItem
|
||||||
if (line.line === {self.id}) {self._chart.id}.legend.div.removeChild(line.row)
|
|
||||||
}})
|
|
||||||
delete {self.id}
|
delete {self.id}
|
||||||
''')
|
''')
|
||||||
|
|
||||||
@ -506,10 +511,15 @@ class Histogram(SeriesCommon):
|
|||||||
Irreversibly deletes the histogram.
|
Irreversibly deletes the histogram.
|
||||||
"""
|
"""
|
||||||
self.run_script(f'''
|
self.run_script(f'''
|
||||||
|
{self.id}legendItem = {self._chart.id}.legend._lines.find((line) => line.series == {self.id}.series)
|
||||||
|
{self._chart.id}.legend._lines = {self._chart.id}.legend._lines.filter((item) => item != {self.id}legendItem)
|
||||||
|
|
||||||
|
if ({self.id}legendItem) {{
|
||||||
|
{self._chart.id}.legend.div.removeChild({self.id}legendItem.row)
|
||||||
|
}}
|
||||||
|
|
||||||
{self._chart.id}.chart.removeSeries({self.id}.series)
|
{self._chart.id}.chart.removeSeries({self.id}.series)
|
||||||
{self._chart.id}.legend.lines.forEach(line => {{
|
delete {self.id}legendItem
|
||||||
if (line.line === {self.id}) {self._chart.id}.legend.div.removeChild(line.row)
|
|
||||||
}})
|
|
||||||
delete {self.id}
|
delete {self.id}
|
||||||
''')
|
''')
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@ -1,6 +1,7 @@
|
|||||||
export interface GlobalParams extends Window {
|
export interface GlobalParams extends Window {
|
||||||
pane: paneStyle; // TODO shouldnt need this cause of css variables
|
pane: paneStyle; // TODO shouldnt need this cause of css variables
|
||||||
handlerInFocus: string;
|
handlerInFocus: string;
|
||||||
|
textBoxFocused: boolean;
|
||||||
callbackFunction: Function;
|
callbackFunction: Function;
|
||||||
containerDiv: HTMLElement;
|
containerDiv: HTMLElement;
|
||||||
setCursor: Function;
|
setCursor: Function;
|
||||||
@ -41,6 +42,7 @@ export function globalParamInit() {
|
|||||||
document.body.style.cursor = window.cursor;
|
document.body.style.cursor = window.cursor;
|
||||||
}
|
}
|
||||||
window.cursor = 'default';
|
window.cursor = 'default';
|
||||||
|
window.textBoxFocused = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const setCursor = (type: string | undefined) => {
|
export const setCursor = (type: string | undefined) => {
|
||||||
|
|||||||
@ -308,7 +308,7 @@ export class Handler {
|
|||||||
chart.div.appendChild(searchWindow);
|
chart.div.appendChild(searchWindow);
|
||||||
|
|
||||||
chart.commandFunctions.push((event: KeyboardEvent) => {
|
chart.commandFunctions.push((event: KeyboardEvent) => {
|
||||||
if (window.handlerInFocus !== chart.id) return false
|
if (window.handlerInFocus !== chart.id || window.textBoxFocused) return false
|
||||||
if (searchWindow.style.display === 'none') {
|
if (searchWindow.style.display === 'none') {
|
||||||
if (/^[a-zA-Z0-9]$/.test(event.key)) {
|
if (/^[a-zA-Z0-9]$/.test(event.key)) {
|
||||||
searchWindow.style.display = 'flex';
|
searchWindow.style.display = 'flex';
|
||||||
|
|||||||
@ -209,6 +209,7 @@ export class Legend {
|
|||||||
else {
|
else {
|
||||||
data = param.seriesData.get(e.series) as LineData
|
data = param.seriesData.get(e.series) as LineData
|
||||||
}
|
}
|
||||||
|
if (!data?.value) return;
|
||||||
let price;
|
let price;
|
||||||
if (e.series.seriesType() == 'Histogram') {
|
if (e.series.seriesType() == 'Histogram') {
|
||||||
price = this.shorthandFormat(data.value)
|
price = this.shorthandFormat(data.value)
|
||||||
|
|||||||
@ -84,7 +84,11 @@ export class TopBar {
|
|||||||
textBox.classList.add('topbar-textbox-input');
|
textBox.classList.add('topbar-textbox-input');
|
||||||
textBox.value = text
|
textBox.value = text
|
||||||
textBox.style.width = `${(textBox.value.length+2)}ch`
|
textBox.style.width = `${(textBox.value.length+2)}ch`
|
||||||
|
textBox.addEventListener('focus', () => {
|
||||||
|
window.textBoxFocused = true;
|
||||||
|
})
|
||||||
textBox.addEventListener('input', (e) => {
|
textBox.addEventListener('input', (e) => {
|
||||||
|
e.preventDefault();
|
||||||
textBox.style.width = `${(textBox.value.length+2)}ch`;
|
textBox.style.width = `${(textBox.value.length+2)}ch`;
|
||||||
});
|
});
|
||||||
textBox.addEventListener('keydown', (e) => {
|
textBox.addEventListener('keydown', (e) => {
|
||||||
@ -95,6 +99,7 @@ export class TopBar {
|
|||||||
});
|
});
|
||||||
textBox.addEventListener('blur', () => {
|
textBox.addEventListener('blur', () => {
|
||||||
window.callbackFunction(`${callbackName}_~_${textBox.value}`)
|
window.callbackFunction(`${callbackName}_~_${textBox.value}`)
|
||||||
|
window.textBoxFocused = false;
|
||||||
});
|
});
|
||||||
this.appendWidget(textBox, align, true)
|
this.appendWidget(textBox, align, true)
|
||||||
return textBox
|
return textBox
|
||||||
|
|||||||
Reference in New Issue
Block a user