mirror of
https://github.com/pyecharts/pyecharts.git
synced 2026-01-25 17:06:27 +00:00
Fix: 修正 X/Y 轴初始化问题 (#1132)
This commit is contained in:
parent
1fcd9157da
commit
49084c6378
@ -14,7 +14,6 @@ class Bar(RectChart):
|
||||
|
||||
def __init__(self, init_opts: opts.InitOpts = opts.InitOpts()):
|
||||
super().__init__(init_opts=init_opts)
|
||||
self.options.update(yAxis=[opts.AxisOpts().opts])
|
||||
|
||||
def add_yaxis(
|
||||
self,
|
||||
|
||||
@ -15,7 +15,6 @@ class Boxplot(RectChart):
|
||||
|
||||
def __init__(self, init_opts: opts.InitOpts = opts.InitOpts()):
|
||||
super().__init__(init_opts=init_opts)
|
||||
self.options.update(yAxis=[opts.AxisOpts().opts])
|
||||
|
||||
def add_yaxis(
|
||||
self,
|
||||
|
||||
@ -13,7 +13,6 @@ class EffectScatter(RectChart):
|
||||
|
||||
def __init__(self, init_opts: opts.InitOpts = opts.InitOpts()):
|
||||
super().__init__(init_opts=init_opts)
|
||||
self.options.update(yAxis=[opts.AxisOpts().opts])
|
||||
|
||||
def add_yaxis(
|
||||
self,
|
||||
|
||||
@ -15,7 +15,6 @@ class HeatMap(RectChart):
|
||||
|
||||
def __init__(self, init_opts: opts.InitOpts = opts.InitOpts()):
|
||||
super().__init__(init_opts=init_opts)
|
||||
self.options.update(yAxis=[opts.AxisOpts().opts])
|
||||
self.set_global_opts(visualmap_opts=opts.VisualMapOpts(orient="horizontal"))
|
||||
|
||||
def add_yaxis(
|
||||
|
||||
@ -16,7 +16,6 @@ class Kline(RectChart):
|
||||
|
||||
def __init__(self, init_opts: opts.InitOpts = opts.InitOpts()):
|
||||
super().__init__(init_opts=init_opts)
|
||||
self.options.update(yAxis=[opts.AxisOpts().opts])
|
||||
self.set_global_opts(
|
||||
xaxis_opts=opts.AxisOpts(is_scale=True),
|
||||
yaxis_opts=opts.AxisOpts(is_scale=True),
|
||||
|
||||
@ -14,7 +14,6 @@ class Line(RectChart):
|
||||
|
||||
def __init__(self, init_opts: opts.InitOpts = opts.InitOpts()):
|
||||
super().__init__(init_opts=init_opts)
|
||||
self.options.update(yAxis=[opts.AxisOpts().opts])
|
||||
|
||||
def add_yaxis(
|
||||
self,
|
||||
|
||||
@ -18,7 +18,6 @@ class Scatter(RectChart):
|
||||
|
||||
def __init__(self, init_opts: opts.InitOpts = opts.InitOpts()):
|
||||
super().__init__(init_opts=init_opts)
|
||||
self.options.update(yAxis=[opts.AxisOpts().opts])
|
||||
|
||||
def add_yaxis(
|
||||
self,
|
||||
|
||||
@ -157,6 +157,10 @@ class Chart(Base):
|
||||
|
||||
|
||||
class RectChart(Chart):
|
||||
def __init__(self, init_opts: opts.InitOpts = opts.InitOpts()):
|
||||
super().__init__(init_opts=init_opts)
|
||||
self.options.update(xAxis=[opts.AxisOpts().opts], yAxis=[opts.AxisOpts().opts])
|
||||
|
||||
def extend_axis(
|
||||
self,
|
||||
xaxis_data: Sequence = None,
|
||||
@ -175,7 +179,6 @@ class RectChart(Chart):
|
||||
return self
|
||||
|
||||
def add_xaxis(self, xaxis_data: Sequence):
|
||||
self.options.update(xAxis=[opts.AxisOpts().opts])
|
||||
self.options["xAxis"][0].update(data=xaxis_data)
|
||||
self._xaxis_data = xaxis_data
|
||||
return self
|
||||
|
||||
@ -1,15 +1,34 @@
|
||||
from nose.tools import eq_
|
||||
from unittest.mock import patch
|
||||
|
||||
from nose.tools import assert_in, eq_
|
||||
|
||||
from pyecharts import options as opts
|
||||
from pyecharts.charts import Line
|
||||
|
||||
|
||||
def test_bar_base():
|
||||
@patch("pyecharts.render.engine.write_utf8_html_file")
|
||||
def test_bar_base(fake_writer):
|
||||
c = (
|
||||
Line()
|
||||
.add_xaxis(["A", "B", "C"])
|
||||
.add_yaxis("series0", [1, 2, 4])
|
||||
.add_yaxis("series1", [2, 3, 6])
|
||||
)
|
||||
c.render()
|
||||
_, content = fake_writer.call_args[0]
|
||||
eq_(c.theme, "white")
|
||||
eq_(c.renderer, "canvas")
|
||||
|
||||
|
||||
@patch("pyecharts.render.engine.write_utf8_html_file")
|
||||
def test_set_global_opts(fake_writer):
|
||||
c = (
|
||||
Line()
|
||||
.set_global_opts(xaxis_opts=opts.AxisOpts(is_inverse=True))
|
||||
.add_xaxis(["A", "B", "C"])
|
||||
.add_yaxis("series0", [1, 2, 4])
|
||||
.add_yaxis("series1", [2, 3, 6])
|
||||
)
|
||||
c.render()
|
||||
_, content = fake_writer.call_args[0]
|
||||
assert_in('"inverse": true', content)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user