fix
This commit is contained in:
File diff suppressed because one or more lines are too long
2
setup.py
2
setup.py
@ -5,7 +5,7 @@ with open('README.md', 'r', encoding='utf-8') as f:
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='lightweight_charts',
|
name='lightweight_charts',
|
||||||
version='2.2.18',
|
version='2.2.19',
|
||||||
packages=find_packages(),
|
packages=find_packages(),
|
||||||
python_requires='>=3.8',
|
python_requires='>=3.8',
|
||||||
install_requires=[
|
install_requires=[
|
||||||
|
|||||||
@ -38,13 +38,13 @@ export class Legend {
|
|||||||
// Create container div
|
// Create container div
|
||||||
this.div = document.createElement('div');
|
this.div = document.createElement('div');
|
||||||
this.div.classList.add('legend');
|
this.div.classList.add('legend');
|
||||||
this.div.style.maxWidth = '300px'; // Fixed width instead of percentage
|
this.div.style.maxWidth = '300px';
|
||||||
this.div.style.minWidth = '200px'; // Add minimum width to ensure readability
|
this.div.style.minWidth = '200px';
|
||||||
this.div.style.maxHeight = '300px';
|
this.div.style.maxHeight = '300px';
|
||||||
this.div.style.overflowY = 'auto';
|
this.div.style.overflowY = 'auto';
|
||||||
this.div.style.overflowX = 'hidden';
|
this.div.style.overflowX = 'hidden';
|
||||||
this.div.style.position = 'absolute';
|
this.div.style.position = 'absolute';
|
||||||
this.div.style.backgroundColor = 'rgba(19, 23, 34, 0.60)';
|
this.div.style.backgroundColor = 'rgba(19, 23, 34, 0.85)';
|
||||||
this.div.style.color = '#D1D4DC';
|
this.div.style.color = '#D1D4DC';
|
||||||
this.div.style.padding = '12px';
|
this.div.style.padding = '12px';
|
||||||
this.div.style.borderRadius = '4px';
|
this.div.style.borderRadius = '4px';
|
||||||
@ -54,6 +54,7 @@ export class Legend {
|
|||||||
this.div.style.fontSize = '12px';
|
this.div.style.fontSize = '12px';
|
||||||
this.div.style.zIndex = '5';
|
this.div.style.zIndex = '5';
|
||||||
this.div.style.display = 'none';
|
this.div.style.display = 'none';
|
||||||
|
this.div.style.pointerEvents = 'all';
|
||||||
|
|
||||||
// Create collapse button
|
// Create collapse button
|
||||||
this.collapseButton = document.createElement('div');
|
this.collapseButton = document.createElement('div');
|
||||||
@ -69,8 +70,13 @@ export class Legend {
|
|||||||
this.collapseButton.style.color = '#D1D4DC';
|
this.collapseButton.style.color = '#D1D4DC';
|
||||||
this.collapseButton.style.fontSize = '16px';
|
this.collapseButton.style.fontSize = '16px';
|
||||||
this.collapseButton.style.userSelect = 'none';
|
this.collapseButton.style.userSelect = 'none';
|
||||||
this.collapseButton.innerHTML = '−'; // Minus sign for collapse
|
this.collapseButton.style.zIndex = '6';
|
||||||
this.collapseButton.addEventListener('click', () => this.toggleCollapse());
|
this.collapseButton.style.pointerEvents = 'all';
|
||||||
|
this.collapseButton.innerHTML = '−';
|
||||||
|
this.collapseButton.addEventListener('click', (e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
this.toggleCollapse();
|
||||||
|
});
|
||||||
|
|
||||||
// Style the scrollbar
|
// Style the scrollbar
|
||||||
const style = document.createElement('style');
|
const style = document.createElement('style');
|
||||||
@ -102,16 +108,19 @@ export class Legend {
|
|||||||
this.contentWrapper.style.display = 'flex';
|
this.contentWrapper.style.display = 'flex';
|
||||||
this.contentWrapper.style.flexDirection = 'column';
|
this.contentWrapper.style.flexDirection = 'column';
|
||||||
this.contentWrapper.style.gap = '4px';
|
this.contentWrapper.style.gap = '4px';
|
||||||
this.contentWrapper.style.marginTop = '20px'; // Add space for collapse button
|
this.contentWrapper.style.marginTop = '20px';
|
||||||
|
this.contentWrapper.style.pointerEvents = 'all';
|
||||||
|
|
||||||
this.text = document.createElement('span');
|
this.text = document.createElement('span');
|
||||||
this.text.style.lineHeight = '1.8';
|
this.text.style.lineHeight = '1.8';
|
||||||
this.text.style.display = 'block';
|
this.text.style.display = 'block';
|
||||||
this.text.style.color = '#D1D4DC';
|
this.text.style.color = '#D1D4DC';
|
||||||
|
this.text.style.pointerEvents = 'all';
|
||||||
|
|
||||||
this.candle = document.createElement('div');
|
this.candle = document.createElement('div');
|
||||||
this.candle.style.color = '#D1D4DC';
|
this.candle.style.color = '#D1D4DC';
|
||||||
this.candle.style.width = '100%';
|
this.candle.style.width = '100%';
|
||||||
|
this.candle.style.pointerEvents = 'all';
|
||||||
|
|
||||||
// Append in the correct order
|
// Append in the correct order
|
||||||
this.contentWrapper.appendChild(this.text);
|
this.contentWrapper.appendChild(this.text);
|
||||||
@ -123,23 +132,6 @@ export class Legend {
|
|||||||
handler.chart.subscribeCrosshairMove(this.legendHandler)
|
handler.chart.subscribeCrosshairMove(this.legendHandler)
|
||||||
}
|
}
|
||||||
|
|
||||||
private toggleCollapse() {
|
|
||||||
this.isCollapsed = !this.isCollapsed;
|
|
||||||
|
|
||||||
if (this.isCollapsed) {
|
|
||||||
// Collapse
|
|
||||||
this.contentWrapper.style.display = 'none';
|
|
||||||
this.div.style.maxHeight = 'auto';
|
|
||||||
this.div.style.height = 'auto';
|
|
||||||
this.collapseButton.innerHTML = '+'; // Plus sign for expand
|
|
||||||
} else {
|
|
||||||
// Expand
|
|
||||||
this.contentWrapper.style.display = 'flex';
|
|
||||||
this.div.style.maxHeight = '300px';
|
|
||||||
this.collapseButton.innerHTML = '−'; // Minus sign for collapse
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
toJSON() {
|
toJSON() {
|
||||||
const {_lines, handler, ...serialized} = this;
|
const {_lines, handler, ...serialized} = this;
|
||||||
return serialized;
|
return serialized;
|
||||||
@ -158,18 +150,24 @@ export class Legend {
|
|||||||
let row = document.createElement('div')
|
let row = document.createElement('div')
|
||||||
row.style.display = 'flex'
|
row.style.display = 'flex'
|
||||||
row.style.alignItems = 'center'
|
row.style.alignItems = 'center'
|
||||||
row.style.width = '100%' // Key fix - make row take full width
|
|
||||||
row.style.justifyContent = 'space-between' // Spread content across the full width
|
|
||||||
row.style.padding = '4px 0'
|
row.style.padding = '4px 0'
|
||||||
row.style.color = '#D1D4DC'
|
row.style.color = '#D1D4DC'
|
||||||
|
row.style.width = '100%'
|
||||||
|
row.style.pointerEvents = 'all'
|
||||||
|
row.style.cursor = 'default'
|
||||||
|
|
||||||
let div = document.createElement('div')
|
let div = document.createElement('div')
|
||||||
|
div.style.flex = '1'
|
||||||
|
div.style.pointerEvents = 'all'
|
||||||
|
|
||||||
let toggle = document.createElement('div')
|
let toggle = document.createElement('div')
|
||||||
toggle.classList.add('legend-toggle-switch');
|
toggle.classList.add('legend-toggle-switch');
|
||||||
|
toggle.style.pointerEvents = 'all'
|
||||||
|
|
||||||
let svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
let svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
||||||
svg.setAttribute("width", "22");
|
svg.setAttribute("width", "22");
|
||||||
svg.setAttribute("height", "16");
|
svg.setAttribute("height", "16");
|
||||||
|
svg.style.pointerEvents = 'all'
|
||||||
|
|
||||||
let group = document.createElementNS("http://www.w3.org/2000/svg", "g");
|
let group = document.createElementNS("http://www.w3.org/2000/svg", "g");
|
||||||
group.innerHTML = openEye
|
group.innerHTML = openEye
|
||||||
@ -208,6 +206,21 @@ export class Legend {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private toggleCollapse() {
|
||||||
|
this.isCollapsed = !this.isCollapsed;
|
||||||
|
|
||||||
|
if (this.isCollapsed) {
|
||||||
|
this.contentWrapper.style.display = 'none';
|
||||||
|
this.div.style.maxHeight = 'auto';
|
||||||
|
this.div.style.height = 'auto';
|
||||||
|
this.collapseButton.innerHTML = '+';
|
||||||
|
} else {
|
||||||
|
this.contentWrapper.style.display = 'flex';
|
||||||
|
this.div.style.maxHeight = '300px';
|
||||||
|
this.collapseButton.innerHTML = '−';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
legendItemFormat(num: number, decimal: number) { return num.toFixed(decimal).toString().padStart(8, ' ') }
|
legendItemFormat(num: number, decimal: number) { return num.toFixed(decimal).toString().padStart(8, ' ') }
|
||||||
|
|
||||||
shorthandFormat(num: number) {
|
shorthandFormat(num: number) {
|
||||||
|
|||||||
Reference in New Issue
Block a user