#!/usr/bin/env python

import sys; sys.path.append('../../../') # show python where the modules are
import web.image.graph

graph = web.image.graph.ScatterGraph(
    xAxis={'max':200, 'unit':20, 'label':'Value 1 /cm^2'}, 
    yAxis={'max':200, 'unit':20, 'label':'Value 2 /cm^2'},
    points=[(0,0),(13,68),(200,200)],
    size=(500, 300),
    bgColor=(240,240,240),
    title='Test Graph'
)
graph.save('scatter.ps')

graph = web.image.graph.BarGraph(
    xAxis={'max':200, 'unit':20, 'label':'Value 1 /cm^2'}, 
    yAxis={'max':200, 'unit':20, 'label':'Value 2 /cm^2'},
    points=[10,20,40,50,200,89, 30, 60, 70, 60],
    size=(500, 300),
    bgColor=(240,240,240),
    title='Test Graph'
)
graph.save('bar.png')

graph = web.image.graph.PieChart(
    points={
        'food':10,
        'numbers':20,
        'numbers2':30,
    },
    size=(500, 300),
    bgColor=(240,240,240),
    title='Test Graph'
)
graph.save('pie.jpg')

graph = web.image.graph.BarGraph(
    xAxis={'max':200, 'unit':20, 'label':'Value 1 /cm^2'}, 
    yAxis={'max':200, 'unit':20, 'label':'Value 2 /cm^2'},
    points=[10,20,40,50,200,89, 30, 60, 70, 60],
    size=(500, 300),
    bgColor=web.image.html2tuple('#F0F0F0'),
    title='Test Graph'
)
fp = open('string.pdf','wb')
fp.write(graph.toString('pdf'))
fp.close()
