_x_axisやなどのグラフのメソッドのいくつかをオーバーライドしたいので、Pygal で XY グラフをサブクラス化することを考えています_y_axis。
import pygal
from pygal.style import Style, CleanStyle
class CustomXY(pygal.XY):
def __init__(self, *args, **kwargs):
super(CustomXY, self).__init__(*args, **kwargs)
def _x_axis(self):
pass
def _y_axis(self):
pass
scatter = CustomXY(stroke=False, show_y_guides=False, truncate_legend=20)
このコードを実行しようとすると、次のエラーが発生します。
Traceback (most recent call last):
File "pygal_test2.py", line 12, in <module>
scatter = CustomXY(stroke=False, show_y_guides=False, truncate_legend=20)
File "pygal_test2.py", line 6, in __init__
super(CustomXY, self).__init__(*args, **kwargs)
File "/usr/lib/python2.7/site-packages/pygal/ghost.py", line 71, in __init__
self.cls = REAL_CHARTS[name]
KeyError: 'CustomXY'
に置き換えるCustomXY(pygal.XY)と、 次のCustomXY(pygal.graph.xy.XY)エラーが表示されます。
Traceback (most recent call last):
File "pygal_test2.py", line 12, in <module>
scatter = CustomXY(stroke=False, show_y_guides=False, truncate_legend=20)
File "pygal_test2.py", line 6, in __init__
super(CustomXY, self).__init__(*args, **kwargs)
File "/usr/lib/python2.7/site-packages/pygal/graph/line.py", line 33, in __init__
super(Line, self).__init__(*args, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'stroke'
Pygal グラフをサブクラス化するための推奨される方法は何ですか?