Sections
Timeline
View Tickets
New Ticket
Sub-Sections
Download
Unified Diff
Zip Archive
Metanav
Preferences
About Trac
Links
Slowchop Studios
Gerald Kaszuba
Advertisement

Changeset 52

Show
Ignore:
Timestamp:
25/08/08 08:03:22 (3 months ago)
Author:
gak
Message:
  • Added stripes and grid line chart to examples
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/examples/line.py

    r51 r52  
    88sys.path.insert(0, os.path.join(ROOT, '..')) 
    99 
     10from pygooglechart import Chart 
    1011from pygooglechart import SimpleLineChart 
    1112from pygooglechart import XYLineChart 
     
    6061def fill(): 
    6162 
    62     # Set the vertical range to 0 to 50 
     63    # Set the vertical range from 0 to 50 
    6364    max_y = 50 
    6465    chart = SimpleLineChart(200, 125, y_range=[0, max_y]) 
     
    9697    chart.download('line-fill.png') 
    9798 
     99def stripes(): 
     100     
     101    # Set the vertical range from 0 to 100 
     102    max_y = 100 
     103 
     104    # Chart size of 200x125 pixels and specifying the range for the Y axis 
     105    chart = SimpleLineChart(200, 125, y_range=[0, max_y]) 
     106 
     107    # Add the chart data 
     108    data = [ 
     109        32, 34, 34, 32, 34, 34, 32, 32, 32, 34, 34, 32, 29, 29, 34, 34, 34, 37, 
     110        37, 39, 42, 47, 50, 54, 57, 60, 60, 60, 60, 60, 60, 60, 62, 62, 60, 55, 
     111        55, 52, 47, 44, 44, 40, 40, 37, 34, 34, 32, 32, 32, 31, 32 
     112    ] 
     113    chart.add_data(data) 
     114     
     115    # Set the line colour to blue 
     116    chart.set_colours(['0000FF']) 
     117 
     118    # Set the vertical stripes 
     119    chart.fill_linear_stripes(Chart.CHART, 0, 'CCCCCC', 0.2, 'FFFFFF', 0.2) 
     120 
     121    # Set the horizonal dotted lines 
     122    chart.set_grid(0, 25, 5, 5) 
     123 
     124    # The Y axis labels contains 0 to 100 skipping every 25, but remove the 
     125    # first number because it's obvious and gets in the way of the first X 
     126    # label. 
     127    left_axis = range(0, max_y + 1, 25) 
     128    left_axis[0] = '' 
     129    chart.set_axis_labels(Axis.LEFT, left_axis) 
     130 
     131    # X axis labels 
     132    chart.set_axis_labels(Axis.BOTTOM, \ 
     133        ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun']) 
     134 
     135    chart.download('line-stripes.png') 
     136 
    98137def main(): 
    99138    simple_random() 
     
    103142    sparklines() 
    104143    fill() 
     144    stripes() 
    105145 
    106146if __name__ == '__main__':