# Archived:How to plot sparklines using PySymbian

Aquivado: Este artigo foi arquivado, pois o conteúdo não é mais considerado relevante para se criar soluções comerciais atuais. Se você achar que este artigo ainda é importante, inclua o template {{ForArchiveReview|escreva a sua justificativa}}.

All PySymbian articles have been archived. PySymbian is no longer maintained by Nokia and is not guaranteed to work on more recent Symbian devices. It is not possible to submit apps to Nokia Store.

Tested with
Devices(s): Nokia N96

Compatibility
Platform(s): S60 2nd Edition, S60 3rd Edition

Article
Keywords: graphics, canvas
Created: cyke64 (15 Mar 2007)
Last edited: hamishwillee (31 May 2013)

## Overview

Python has its drawing API very similar to PIL. Porting from PIL to S60 is very easy. Here's an example for porting a sparkline drawing function from Joe Gregorio's article at xml.com

## Code

`# import modulesfrom appuifw import *import e32 lock = e32.Ao_lock()  # declare exit lockc = Canvas()app.body = cdraw = c._draw # define colorsred, green, blue, gray = 0xff0000, 0x00ff00, 0x0000ff, 0x777777 def plot_sparkline(results, step=2, height=20, \    min_m=None, max_m=None, last_m=None, \    min_color=blue, max_color=green, last_color=red):    coords = zip(range(1,len(results)*step+1, step), \       [height - 3  - y/(101.0/(height-4)) for y in results])    draw.line(coords, gray)    if min_m:        min_pt = coords[results.index(min(results))]        draw.rectangle([min_pt[0]-1, min_pt[1]-1, min_pt[0]+1, min_pt[1]+1], fill=min_color)    if max_m:        max_pt = coords[results.index(max(results))]        draw.rectangle([max_pt[0]-1, max_pt[1]-1, max_pt[0]+1, max_pt[1]+1], fill=max_color)    if last_m:        end = coords[-1]        draw.rectangle([end[0]-1, end[1]-1, end[0]+1, end[1]+1], fill=last_color)  results = [88,84,82,92,82,86,66,82,44,64,66,88,96,80,24,26, \        14,0,0,26,8,6,6,24,52,66,36,6,10,14,30]plot_sparkline(results, 3, 30, min_m=1, max_m=1, last_m=1) app.exit_key_handler = lock.signallock.wait() # Wait for exit`

Sparklines