|
|
|
@ -116,11 +116,13 @@ class Graph(BaseGraph):
|
|
|
|
|
self.svg.node(text, 'tspan', class_='label') |
|
|
|
|
self.svg.node(text, 'tspan', class_='value') |
|
|
|
|
|
|
|
|
|
def _x_axis(self, draw_axes=True): |
|
|
|
|
def _x_axis(self): |
|
|
|
|
"""Make the x axis: labels and guides""" |
|
|
|
|
if not self._x_labels: |
|
|
|
|
return |
|
|
|
|
axis = self.svg.node(self.nodes['plot'], class_="axis x") |
|
|
|
|
axis = self.svg.node(self.nodes['plot'], class_="axis x%s" % ( |
|
|
|
|
' always_show' if self.show_x_guides else '' |
|
|
|
|
)) |
|
|
|
|
truncation = self.truncate_label |
|
|
|
|
if not truncation: |
|
|
|
|
if self.x_label_rotation or len(self._x_labels) <= 1: |
|
|
|
@ -134,7 +136,7 @@ class Graph(BaseGraph):
|
|
|
|
|
truncation = reverse_text_len( |
|
|
|
|
available_space, self.label_font_size) |
|
|
|
|
|
|
|
|
|
if 0 not in [label[1] for label in self._x_labels] and draw_axes: |
|
|
|
|
if 0 not in [label[1] for label in self._x_labels]: |
|
|
|
|
self.svg.node(axis, 'path', |
|
|
|
|
d='M%f %f v%f' % (0, 0, self.view.height), |
|
|
|
|
class_='line') |
|
|
|
@ -162,14 +164,13 @@ class Graph(BaseGraph):
|
|
|
|
|
guides = self.svg.node(axis, class_='guides') |
|
|
|
|
x = self.view.x(position) |
|
|
|
|
y = self.view.height + 5 |
|
|
|
|
if draw_axes: |
|
|
|
|
last_guide = (self._y_2nd_labels and label == lastlabel) |
|
|
|
|
self.svg.node( |
|
|
|
|
guides, 'path', |
|
|
|
|
d='M%f %f v%f' % (x, 0, self.view.height), |
|
|
|
|
class_='%s%sline' % ( |
|
|
|
|
'major ' if major else '', |
|
|
|
|
'guide ' if position != 0 and not last_guide else '')) |
|
|
|
|
last_guide = (self._y_2nd_labels and label == lastlabel) |
|
|
|
|
self.svg.node( |
|
|
|
|
guides, 'path', |
|
|
|
|
d='M%f %f v%f' % (x, 0, self.view.height), |
|
|
|
|
class_='%s%sline' % ( |
|
|
|
|
'major ' if major else '', |
|
|
|
|
'guide ' if position != 0 and not last_guide else '')) |
|
|
|
|
y += .5 * self.label_font_size + 5 |
|
|
|
|
text = self.svg.node( |
|
|
|
|
guides, 'text', |
|
|
|
@ -186,7 +187,9 @@ class Graph(BaseGraph):
|
|
|
|
|
|
|
|
|
|
if self._x_2nd_labels: |
|
|
|
|
secondary_ax = self.svg.node( |
|
|
|
|
self.nodes['plot'], class_="axis x x2") |
|
|
|
|
self.nodes['plot'], class_="axis x x2%s" % ( |
|
|
|
|
' always_show' if self.show_x_guides else '' |
|
|
|
|
)) |
|
|
|
|
for label, position in self._x_2nd_labels: |
|
|
|
|
major = label in x_labels_major |
|
|
|
|
if not (self.show_minor_x_labels or major): |
|
|
|
@ -206,14 +209,15 @@ class Graph(BaseGraph):
|
|
|
|
|
text.attrib['transform'] = "rotate(%d %f %f)" % ( |
|
|
|
|
-self.x_label_rotation, x, y) |
|
|
|
|
|
|
|
|
|
def _y_axis(self, draw_axes=True): |
|
|
|
|
def _y_axis(self): |
|
|
|
|
"""Make the y axis: labels and guides""" |
|
|
|
|
if not self._y_labels or not self.show_y_labels: |
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
axis = self.svg.node(self.nodes['plot'], class_="axis y") |
|
|
|
|
|
|
|
|
|
if 0 not in [label[1] for label in self._y_labels] and draw_axes: |
|
|
|
|
if (0 not in [label[1] for label in self._y_labels] and |
|
|
|
|
self.show_y_guides): |
|
|
|
|
self.svg.node( |
|
|
|
|
axis, 'path', |
|
|
|
|
d='M%f %f h%f' % (0, self.view.height, self.view.width), |
|
|
|
@ -228,7 +232,7 @@ class Graph(BaseGraph):
|
|
|
|
|
y = self.view.y(position) |
|
|
|
|
if not y: |
|
|
|
|
continue |
|
|
|
|
if draw_axes: |
|
|
|
|
if self.show_y_guides: |
|
|
|
|
self.svg.node( |
|
|
|
|
guides, 'path', |
|
|
|
|
d='M%f %f h%f' % (0, y, self.view.width), |
|
|
|
|