Merge pull request #245 from CodexLink/feat/impl-addl-price-scale-options

feat(price-scale-options): introduce missing `PriceScaleOptions` based on Version 4.1 TV Docs
This commit is contained in:
louisnw01
2024-01-13 17:02:41 +00:00
committed by GitHub
4 changed files with 14 additions and 8 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
docs/build/**

View File

@ -12,7 +12,6 @@ ___
Sets the initial data for the chart. Sets the initial data for the chart.
Columns should be named: Columns should be named:
: `time | open | high | low | close | volume` : `time | open | high | low | close | volume`
@ -206,7 +205,7 @@ ___
```{py:method} price_scale(mode: PRICE_SCALE_MODE, align_labels: bool, border_visible: bool, border_color: COLOR, text_color: COLOR, entire_text_only: bool, ticks_visible: bool, scale_margin_top: float, scale_margin_bottom: float) ```{py:method} price_scale(auto_scale: bool, mode: PRICE_SCALE_MODE, invert_scale: bool, align_labels: bool, scale_margin_top: float, scale_margin_bottom: float, border_visible: bool, border_color: COLOR, text_color: COLOR, entire_text_only: bool, visible: bool, ticks_visible: bool, minimum_width: float)
Price scale options for the chart. Price scale options for the chart.
``` ```

View File

@ -22,4 +22,4 @@ tables
4. [Charts](#charts) 4. [Charts](#charts)
5. [`Events`](./events.md) 5. [`Events`](./events.md)
6. [`Toolbox`](#ToolBox) 6. [`Toolbox`](#ToolBox)
7. [`Table`](#Table) 7. [`Table`](#Table)

View File

@ -2,7 +2,7 @@ import asyncio
import os import os
from base64 import b64decode from base64 import b64decode
from datetime import datetime from datetime import datetime
from typing import Union, Literal, List from typing import Union, Literal, List, Optional
import pandas as pd import pandas as pd
from .table import Table from .table import Table
@ -648,19 +648,25 @@ class Candlestick(SeriesCommon):
self.update(bar, _from_tick=True) self.update(bar, _from_tick=True)
def price_scale( def price_scale(
self, mode: PRICE_SCALE_MODE = 'normal', align_labels: bool = True, border_visible: bool = False, self, auto_scale: bool = True, mode: PRICE_SCALE_MODE = 'normal', invert_scale: bool = False,
border_color: str = None, text_color: str = None, entire_text_only: bool = False, align_labels: bool = True, scale_margin_top: float = 0.2, scale_margin_bottom: float = 0.2,
ticks_visible: bool = False, scale_margin_top: float = 0.2, scale_margin_bottom: float = 0.2): border_visible: bool = False, border_color: Optional[str] = None, text_color: Optional[str] = None,
entire_text_only: bool = False, visible: bool = True, ticks_visible: bool = False, minimum_width: int = 0
):
self.run_script(f''' self.run_script(f'''
{self.id}.series.priceScale().applyOptions({{ {self.id}.series.priceScale().applyOptions({{
autoScale: {jbool(auto_scale)},
mode: {price_scale_mode(mode)}, mode: {price_scale_mode(mode)},
invertScale: {jbool(invert_scale)},
alignLabels: {jbool(align_labels)}, alignLabels: {jbool(align_labels)},
scaleMargins: {{top: {scale_margin_top}, bottom: {scale_margin_bottom}}},
borderVisible: {jbool(border_visible)}, borderVisible: {jbool(border_visible)},
{f'borderColor: "{border_color}",' if border_color else ''} {f'borderColor: "{border_color}",' if border_color else ''}
{f'textColor: "{text_color}",' if text_color else ''} {f'textColor: "{text_color}",' if text_color else ''}
entireTextOnly: {jbool(entire_text_only)}, entireTextOnly: {jbool(entire_text_only)},
visible: {jbool(visible)},
ticksVisible: {jbool(ticks_visible)}, ticksVisible: {jbool(ticks_visible)},
scaleMargins: {{top: {scale_margin_top}, bottom: {scale_margin_bottom}}} minimumWidth: {minimum_width}
}})''') }})''')
def candle_style( def candle_style(