Browse Source

Use render to file

pull/8/head
Florian Mounier 13 years ago
parent
commit
25b7133bf3
  1. 28
      demo/simple_test.py

28
demo/simple_test.py

@ -30,8 +30,7 @@ bar.add('test2', map(abs, rng))
bar.x_labels = map(str, rng) bar.x_labels = map(str, rng)
bar.title = "Bar test" bar.title = "Bar test"
bar.fill = True bar.fill = True
with open('out-bar.svg', 'w') as f: bar.render_to_file('out-bar.svg')
f.write(bar.render())
hbar = HorizontalBar() hbar = HorizontalBar()
rng = [18, 9, 7, 3, 1, 0, -5] rng = [18, 9, 7, 3, 1, 0, -5]
@ -41,9 +40,7 @@ hbar.add('test2', rng2)
hbar.x_labels = map( hbar.x_labels = map(
lambda x: '%s / %s' % x, zip(map(str, rng), map(str, rng2))) lambda x: '%s / %s' % x, zip(map(str, rng), map(str, rng2)))
hbar.title = "Horizontal Bar test" hbar.title = "Horizontal Bar test"
with open('out-horizontalbar.svg', 'w') as f: hbar.render_to_file('out-horizontalbar.svg')
f.write(hbar.render())
rng = [3, -32, 39, 12] rng = [3, -32, 39, 12]
rng2 = [24, -8, 18, 12] rng2 = [24, -8, 18, 12]
@ -61,16 +58,14 @@ stackedbar = StackedBar(config)
stackedbar.add('@@@@@@@', rng) stackedbar.add('@@@@@@@', rng)
stackedbar.add('++++++', rng2) stackedbar.add('++++++', rng2)
stackedbar.add('--->', rng3) stackedbar.add('--->', rng3)
with open('out-stackedbar.svg', 'w') as f: stackedbar.render_to_file('out-stackedbar.svg')
f.write(stackedbar.render())
config.title = "Horizontal Stacked Bar test" config.title = "Horizontal Stacked Bar test"
hstackedbar = HorizontalStackedBar(config) hstackedbar = HorizontalStackedBar(config)
hstackedbar.add('@@@@@@@', rng) hstackedbar.add('@@@@@@@', rng)
hstackedbar.add('++++++', rng2) hstackedbar.add('++++++', rng2)
hstackedbar.add('--->', rng3) hstackedbar.add('--->', rng3)
with open('out-horizontalstackedbar.svg', 'w') as f: hstackedbar.render_to_file('out-horizontalstackedbar.svg')
f.write(hstackedbar.render())
line = Line(Config(y_scale=.0005, style=NeonStyle, line = Line(Config(y_scale=.0005, style=NeonStyle,
zero=1, interpolate='cubic', zero=1, interpolate='cubic',
@ -86,8 +81,7 @@ line.add('10^x', map(lambda x: 10 ** (x / 333.), rng))
line.add('10^10^x', map(lambda x: ((x / 333.) ** (x / 333.)), rng)) line.add('10^10^x', map(lambda x: ((x / 333.) ** (x / 333.)), rng))
line.x_labels = map(str, rng) line.x_labels = map(str, rng)
line.title = "Line test" line.title = "Line test"
with open('out-line.svg', 'w') as f: line.render_to_file('out-line.svg')
f.write(line.render())
stackedline = StackedLine(Config(y_scale=.0005, fill=True)) stackedline = StackedLine(Config(y_scale=.0005, fill=True))
stackedline.add('test1', [1, 3, 2, 18, 2, 13, 8]) stackedline.add('test1', [1, 3, 2, 18, 2, 13, 8])
@ -95,8 +89,7 @@ stackedline.add('test2', [4, 1, 10, 1, 3, 12, 3])
stackedline.add('test3', [9, 3, 2, 10, 8, 2, 3]) stackedline.add('test3', [9, 3, 2, 10, 8, 2, 3])
stackedline.x_labels = ['a', 'b', 'c', 'd', 'e', 'f', 'g'] stackedline.x_labels = ['a', 'b', 'c', 'd', 'e', 'f', 'g']
stackedline.title = "Stackedline test" stackedline.title = "Stackedline test"
with open('out-stackedline.svg', 'w') as f: stackedline.render_to_file('out-stackedline.svg')
f.write(stackedline.render())
xy = XY(Config(x_scale=1, fill=True, style=NeonStyle, interpolate='cubic')) xy = XY(Config(x_scale=1, fill=True, style=NeonStyle, interpolate='cubic'))
xy.add('test1', [(1981, 1), (2004, 2), (2003, 10), (2012, 8), (1999, -4)]) xy.add('test1', [(1981, 1), (2004, 2), (2003, 10), (2012, 8), (1999, -4)])
@ -104,8 +97,7 @@ xy.add('test2', [(1988, -1), (1986, 12), (2007, 7), (2010, 4), (1999, 2)])
# xy.add('test2', [(1980, 0), (1985, 2), (1995, -2), (2005, 4), (2020, -4)]) # xy.add('test2', [(1980, 0), (1985, 2), (1995, -2), (2005, 4), (2020, -4)])
# (2005, 6), (2010, -6), (2015, 3), (2020, -3), (2025, 0)]) # (2005, 6), (2010, -6), (2015, 3), (2020, -3), (2025, 0)])
xy.title = "XY test" xy.title = "XY test"
with open('out-xy.svg', 'w') as f: xy.render_to_file('out-xy.svg')
f.write(xy.render())
pie = Pie(Config(style=NeonStyle)) pie = Pie(Config(style=NeonStyle))
pie.add('test', [11, 8, 21]) pie.add('test', [11, 8, 21])
@ -114,8 +106,7 @@ pie.add('test3', [24, 10, 32])
pie.add('test4', [20, 18, 9]) pie.add('test4', [20, 18, 9])
pie.add('test5', [17, 5, 10]) pie.add('test5', [17, 5, 10])
pie.title = "Pie test" pie.title = "Pie test"
with open('out-pie.svg', 'w') as f: pie.render_to_file('out-pie.svg')
f.write(pie.render())
config = Config() config = Config()
config.fill = True config.fill = True
@ -128,5 +119,4 @@ radar.add('test', [1, 4, 1, 5, 7, 2, 5])
radar.add('test2', [10, 2, 7, 5, 1, 9, 4]) radar.add('test2', [10, 2, 7, 5, 1, 9, 4])
radar.title = "Radar test" radar.title = "Radar test"
with open('out-radar.svg', 'w') as f: radar.render_to_file('out-radar.svg')
f.write(radar.render())

Loading…
Cancel
Save