Browse Source

Add new config option for hiding all dots except major labeled ones

pull/116/head
Clément Plasse 11 years ago
parent
commit
986860cab6
  1. 4
      pygal/config.py
  2. 24
      pygal/graph/line.py

4
pygal/config.py

@ -140,6 +140,10 @@ class Config(MetaConfig('ConfigBase', (object,), {})):
show_dots = Key(True, bool, "Look", "Set to false to remove dots")
show_only_major_dots = Key(
False, bool, "Look",
"Set to true to show only major dots according to their majored label")
dots_size = Key(2.5, float, "Look", "Radius of the dots")
stroke = Key(

24
pygal/graph/line.py

@ -67,10 +67,30 @@ class Line(Graph):
points = serie.points
view_values = list(map(self.view, points))
if self.show_dots:
if self.show_only_major_dots:
major_dots_index = []
if self.x_labels:
if self.x_labels_major:
major_dots_index = []
for major in self.x_labels_major:
start = -1
while True:
try:
index = self.x_labels.index(
major, start + 1)
except ValueError:
break
else:
major_dots_index.append(index)
start = index
elif self.x_labels_major_every:
major_dots_index = range(
0, len(self.x_labels), self.x_labels_major_every)
for i, (x, y) in enumerate(view_values):
if None in (x, y):
if None in (x, y) or (self.show_only_major_dots
and i not in major_dots_index):
continue
metadata = serie.metadata.get(i)
classes = []
if x > self.view.width / 2:

Loading…
Cancel
Save