Skip to content

Commit

Permalink
Fix: Page 中 js_host 与全局 CurrentConfig.ONLINE_HOST 表现不一致 (pyecharts#1150)
Browse files Browse the repository at this point in the history
* Fix: Page 中 js_host 与全局 CurrentConfig.ONLINE_HOST 表现不一致

* Add: LabelOpts 新增 interval 参数

* Fix: test
  • Loading branch information
chenjiandongx authored May 30, 2019
1 parent aff933e commit acf9b10
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pyecharts/charts/composite_charts/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ class Page:
def __init__(
self,
page_title: str = CurrentConfig.PAGE_TITLE,
js_host: str = CurrentConfig.ONLINE_HOST,
js_host: str = "",
interval: int = 1,
):
self.page_title = page_title
self.page_interval = interval
self.js_dependencies = utils.OrderedSet()
self.js_host = js_host
self.js_host = js_host or CurrentConfig.ONLINE_HOST
self._charts = []

def add(self, *charts):
Expand Down
2 changes: 2 additions & 0 deletions pyecharts/options/series_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def __init__(
font_family: Optional[str] = None,
rotate: Optional[Numeric] = None,
margin: Optional[Numeric] = 8,
interval: Union[Numeric, str, None] = None,
horizontal_align: Optional[str] = None,
vertical_align: Optional[str] = None,
formatter: Optional[JSFunc] = None,
Expand All @@ -102,6 +103,7 @@ def __init__(
"color": color,
"rotate": rotate,
"margin": margin,
"interval": interval,
"fontSize": font_size,
"fontStyle": font_style,
"fontWeight": font_weight,
Expand Down
30 changes: 30 additions & 0 deletions test/test_page.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from nose.tools import eq_

from example.commons import Faker
from pyecharts.charts import Bar, Line, Page


def _create_bar() -> Bar:
return Bar().add_xaxis(Faker.choose()).add_yaxis("商家A", Faker.values())


def _create_line() -> Line:
return Line().add_xaxis(Faker.choose()).add_yaxis("商家A", Faker.values())


def test_page_jshost_default():
bar = _create_bar()
line = _create_line()
page = Page().add(bar, line)
eq_(page.js_host, "https://assets.pyecharts.org/assets/")


def test_page_jshost_custom():
from pyecharts.globals import CurrentConfig

custom_host = "http://localhost:8888/assets/"
CurrentConfig.ONLINE_HOST = custom_host
bar = _create_bar()
line = _create_line()
page = Page().add(bar, line)
eq_(page.js_host, custom_host)
2 changes: 2 additions & 0 deletions test/test_series_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def test_label_options_defaults():
"color": None,
"rotate": None,
"margin": 8,
"interval": None,
"fontSize": 12,
"fontStyle": None,
"fontWeight": None,
Expand All @@ -37,6 +38,7 @@ def test_label_options_custom():
"color": None,
"rotate": None,
"margin": 8,
"interval": None,
"fontSize": 12,
"fontStyle": None,
"fontWeight": None,
Expand Down

0 comments on commit acf9b10

Please sign in to comment.