Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/source/reference/abstract_chart.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ ___



```{py:method} create_line(name: str, color: COLOR, style: LINE_STYLE, width: int, price_line: bool, price_label: bool) -> Line
```{py:method} create_line(name: str, color: COLOR, style: LINE_STYLE, type: LINE_TYPE, width: int, price_line: bool, price_label: bool) -> Line

Creates and returns a Line object, representing a `LineSeries` object in Lightweight Charts and can be used to create indicators. As well as the methods described below, the `Line` object also has access to:

Expand Down
2 changes: 1 addition & 1 deletion docs/source/reference/line.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# `Line`


````{py:class} Line(name: str, color: COLOR, style: LINE_STYLE, width: int, price_line: bool, price_label: bool, price_scale_id: str)
````{py:class} Line(name: str, color: COLOR, style: LINE_STYLE, type: LINE_TYPE, width: int, price_line: bool, price_label: bool, price_scale_id: str)

The `Line` object represents a `LineSeries` object in Lightweight Charts and can be used to create indicators. As well as the methods described below, the `Line` object also has access to:

Expand Down
3 changes: 3 additions & 0 deletions docs/source/reference/typing.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ Throughout the library, colors should be given as either rgb (`rgb(100, 100, 100
```{py:class} LINE_STYLE(Literal['solid', 'dotted', 'dashed', 'large_dashed', 'sparse_dotted'])
```

```{py:class} LINE_TYPE(Literal['simple', 'with_steps', 'curved'])
```

```{py:class} MARKER_POSITION(Literal['above', 'below', 'inside'])
```

Expand Down
9 changes: 5 additions & 4 deletions lightweight_charts/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from .topbar import TopBar
from .util import (
BulkRunScript, Pane, Events, IDGen, as_enum, jbool, js_json, TIME, NUM, FLOAT,
LINE_STYLE, MARKER_POSITION, MARKER_SHAPE, CROSSHAIR_MODE,
LINE_STYLE, LINE_TYPE, MARKER_POSITION, MARKER_SHAPE, CROSSHAIR_MODE,
PRICE_SCALE_MODE, marker_position, marker_shape, js_data,
)

Expand Down Expand Up @@ -424,7 +424,7 @@ def vertical_span(


class Line(SeriesCommon):
def __init__(self, chart, name, color, style, width, price_line, price_label, price_scale_id=None, crosshair_marker=True):
def __init__(self, chart, name, color, style, type, width, price_line, price_label, price_scale_id=None, crosshair_marker=True):

super().__init__(chart, name)
self.color = color
Expand All @@ -435,6 +435,7 @@ def __init__(self, chart, name, color, style, width, price_line, price_label, pr
{{
color: '{color}',
lineStyle: {as_enum(style, LINE_STYLE)},
lineType: {as_enum(type, LINE_TYPE)},
lineWidth: {width},
lastValueVisible: {jbool(price_label)},
priceLineVisible: {jbool(price_line)},
Expand Down Expand Up @@ -721,13 +722,13 @@ def fit(self):

def create_line(
self, name: str = '', color: str = 'rgba(214, 237, 255, 0.6)',
style: LINE_STYLE = 'solid', width: int = 2,
style: LINE_STYLE = 'solid', type: LINE_TYPE = 'simple', width: int = 2,
price_line: bool = True, price_label: bool = True, price_scale_id: Optional[str] = None
) -> Line:
"""
Creates and returns a Line object.
"""
self._lines.append(Line(self, name, color, style, width, price_line, price_label, price_scale_id))
self._lines.append(Line(self, name, color, style, type, width, price_line, price_label, price_scale_id))
return self._lines[-1]

def create_histogram(
Expand Down
2 changes: 2 additions & 0 deletions lightweight_charts/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ def jbool(b: bool): return 'true' if b is True else 'false' if b is False else N

LINE_STYLE = Literal['solid', 'dotted', 'dashed', 'large_dashed', 'sparse_dotted']

LINE_TYPE = Literal['simple', 'with_steps', 'curved']

MARKER_POSITION = Literal['above', 'below', 'inside']

MARKER_SHAPE = Literal['arrow_up', 'arrow_down', 'circle', 'square']
Expand Down