While developing an application for one of my projects, I had a need to plot several graphs showing the trends of the inputted data. In the course of finding a solution for this, I came across a great PyS60 API called PySchart by Marcel Pinheiro Caraciolo which provides a standard to construct graphs on PyS60 platform.

Line Chart using PySchart on PyS60However, PySchart couldn’t plot several line graphs on the same canvas yet this was very important in my application as I wanted the user to easily make comparison for the different item’s trends. Luckily, the project had been released under the GNU General Public License v2. I talked to the Caraciolo who was very kind enough to give me the necessary support to improve the line chart portion of the project.

Today, I have uploaded an improved version of the line chart API/library which allows support for different line graphs on the same canvas.

Below is a simple code snippet on how you can implement the graph in the image above.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from appuifw import *
import e32
from linechart import LineChart
 
def quit():
    print "Exit key pressed"
    app_lock.signal()
 
canvas = Canvas()
app.body = canvas
 
dataset = [[(0, 32.5),(1, 45.0), (2, 90.0)],[(0,32.7),(1,67.5),(2.0,67.3),(3,100),(4,65)]]
chart = LineChart(app.body.size,[0,5,1,0,125,25], dataset, [(255,140,0),(51,96,161),(114,171,242),(16,77,140),(250,210,125),(206,125,49)], legend=["Revenues", "Profits"], colorBack = (237,246,253), xaxislabels=["Jan","Feb","Mar","Apr","May","June"]) 
 
app.exit_key_handler = quit
app_lock = e32.Ao_lock()
app_lock.wait()

Download The Line Graph Example Here and Download The Full PySchart API Here

Hope it will be useful to someone out there and feel free to contact me in case of help or anything.

2 Comments

  • This is incredibly useful to me, and very well made. Thanks a million.
    Cheers from Germany
    Thomas

    • Hi Thomas,
      So glad that it is useful to you. Please share it as much as possible and thanx to Marcel Pinheiro Caraciolo who began a good work. Feel free to make more additions if any.

      Wish you luck in all you are doing with it.