You are a guest. Restricted access. Read more.

Charts

HChart canvas is used for showing charts. container. This canvas is important since it is the main canvas for the Android version of SCaVis and is based on JFreeChart. You can find the usage of this canvas in Sect. Android (but we used the BeanShell syntax in that section). Here we will show a simple example based on Jython:

Code example

  Download for this example is disabled for non-members
 1: from java.awt import Color
 2: from java.awt import Font
 3: from math  import *
 4: from jhplot import HChart,P1D
 5:
 6: c1 = HChart("Canvas",600,600, 2, 1)
 7: c1.setGTitle("Chart examples")
 8: c1.cd(1,1)
 9: c1.visible()
10:
11: c1.setChartPie()
12: c1.setName("Pie example")
13: c1.valuePie("Hamburg",1.0)
14: c1.valuePie("London",2.0)
15: c1.valuePie("Paris",1.0)
16: c1.valuePie("Bern",1.0)
17: c1.update()
18:
19: c1.cd(2,1)
20: c1.setChartPie3D()
21: c1.setName("3D Pie example")
22: c1.valuePie3D("Berlin",30.0)
23: c1.valuePie3D("Madrid",20.0)
24: c1.valuePie3D("Munich",12.0)
25: c1.update()

The output shows 2 pie charts as shown below:

One can also produce bar chart, line chart and a histogram chart. Read the book "Scientific data analysis using Jython scripting and Java" for more details.

Sergei Chekanov 2010/03/07 17:38

Navigation

Print/export