This commit is contained in:
David Brazda
2024-11-15 07:10:41 +01:00
parent 2c656fa640
commit 1deb397e28
3 changed files with 27 additions and 25 deletions

File diff suppressed because one or more lines are too long

View File

@ -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.12', version='2.2.13',
packages=find_packages(), packages=find_packages(),
python_requires='>=3.8', python_requires='>=3.8',
install_requires=[ install_requires=[

View File

@ -14,6 +14,7 @@ interface LineElement {
export class Legend { export class Legend {
private handler: Handler; private handler: Handler;
public div: HTMLDivElement; public div: HTMLDivElement;
public contentWrapper: HTMLDivElement;
private ohlcEnabled: boolean = false; private ohlcEnabled: boolean = false;
private percentEnabled: boolean = false; private percentEnabled: boolean = false;
@ -27,37 +28,38 @@ export class Legend {
constructor(handler: Handler) { constructor(handler: Handler) {
this.legendHandler = this.legendHandler.bind(this) this.legendHandler = this.legendHandler.bind(this)
this.handler = handler; this.handler = handler;
this.ohlcEnabled = false; this.ohlcEnabled = false;
this.percentEnabled = false this.percentEnabled = false
this.linesEnabled = false this.linesEnabled = false
this.colorBasedOnCandle = false this.colorBasedOnCandle = false
// 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 = `${(handler.scale.width * 100) - 8}vw` this.div.style.maxWidth = `${(handler.scale.width * 100) - 8}vw`;
// Important: Set these styles to make it scrollable this.div.style.maxHeight = '300px';
this.div.style.height = '300px'; // Fixed height instead of maxHeight
this.div.style.overflowY = 'auto'; this.div.style.overflowY = 'auto';
this.div.style.display = 'block'; // Ensure it's a block element this.div.style.overflowX = 'hidden';
this.div.style.position = 'relative'; // Helps with positioning this.div.style.display = 'none'; // This will be changed to 'block' when needed
// Optional: Add some styling for better appearance // Create a wrapper for the content to ensure proper scrolling
this.div.style.border = '1px solid #ccc'; this.contentWrapper = document.createElement('div');
this.div.style.padding = '10px'; this.contentWrapper.style.minHeight = '100%'; // Ensure content fills the space
this.div.style.display = 'none';
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'; // Make span block-level
this.candle = document.createElement('div')
this.candle = document.createElement('div');
this.div.appendChild(this.text)
this.div.appendChild(this.candle) // Append in the correct order
handler.div.appendChild(this.div) this.contentWrapper.appendChild(this.text);
this.contentWrapper.appendChild(this.candle);
// this.makeSeriesRows(handler); this.div.appendChild(this.contentWrapper);
handler.div.appendChild(this.div);
handler.chart.subscribeCrosshairMove(this.legendHandler) handler.chart.subscribeCrosshairMove(this.legendHandler)
} }