Open ebsaral opened 7 years ago
Temporarily I did this:
class LineBar(Line, Bar):
def __init__(self, config=None, **kwargs):
super(LineBar, self).__init__(config=config, **kwargs)
self.y_title_secondary = kwargs.get('y_title_secondary')
def _make_y_title(self):
super(LineBar, self)._make_y_title()
# Add secondary title
if self.y_title_secondary:
yc = self.margin_box.top + self.view.height / 2
xc = self.width - 10
text2 = self.svg.node(
self.nodes['title'], 'text', class_='title',
x=xc,
y=yc
)
text2.attrib['transform'] = "rotate(%d %f %f)" % (
-90, xc, yc)
text2.text = self.y_title_secondary
def _plot(self):
for i, serie in enumerate(self.series, 1):
self.bar(serie)
for i, serie in enumerate(self.secondary_series, 1):
self.line(serie, True)
chart = LineBar(width=650,
height=550,
margin=0,
margin_right=30,
legend_at_bottom=True,
x_title="x title",
y_title='First Y Title',
y_title_secondary='Second Y Title',
range=(0, 100),
secondary_range=(0, 100))
chart.add("Energy (kWh)", range(1, 31))
chart.add("Insolation (kwh/m2)", range(1, 31), secondary=True)
I ran into the same problem!
your should send this as a PR :)
Is it possible to add a y axis title for the secondary graph?