#
# Draw two charts, graph1.pdf and graph2.pdf.
#
from pychart import *

can = canvas.init("graph1.pdf")
data = chart_data.read_csv("lines.csv")
ar = area.T(x_range = (0,100), y_range = (0,100),
            x_axis = axis.X(label="X", tic_interval=10),
            y_axis = axis.Y(label="Y", tic_interval=10))
eb = error_bar.error_bar2(tic_len=5, hline_style=line_style.gray50)
ar.add_plot(line_plot.T(label="foo", data=data, error_bar=eb, y_error_minus_col=3),
            line_plot.T(label="bar", data=data, ycol=2, error_bar=eb, y_error_minus_col=3))
ar.draw(can)
tb = text_box.T(loc=(40, 130), text="This is\nimportant!", line_style=None)
tb.add_arrow((ar.x_pos(data[6][0]), ar.y_pos(data[6][1])), "cb")
tb.draw(can)

can = canvas.init("graph2.pdf")
ar = area.T(loc=(200, 0), x_range=(0,100), y_range=(0,100),
            x_axis = axis.X(label="X", tic_interval=10),
            y_axis = axis.Y(label="Y", tic_interval=10))
ar.add_plot(line_plot.T(label="foo", data=data, data_label_format="/8{}%d"),
            line_plot.T(label="bar", data=data, ycol=2))
ar.draw(can)

# Note: can.close() is called automatically for every open canvas.
