You may be interested in reading the article we have written on the subject of Charting with the TeeChart for Java Component and MAC OSX. This article shows how we can use the TeeChart for Java chart library for designing applications with the operating system OSX.

To download and use TeeChart for Java follow the link to TeeChart for Java evaluation download.
For more information take a look at the TeeChart for Java pages.

Charting with the TeeChart for Java Component and MAC OSX

By Pep Jorge @joseplluisjorge | Steema Software

The TeeChart Java version component library offers the possibility of being used in Windows and MAC OSX systems and other environments that support Java such as Linux, as it has been designed using native java language code.

The charting library includes a long list of types of charts (series), including standard series types (line, bar, area, pie, Gantt, ...) and professional 3D series and types (surface, trisurface, tower, colorgrid, gauges ...). TeeChart's own tools may be added to charts, so that easy and fast annotations, paging, animations and other interactive value-add features may be included in the chart.

The Chart component also includes a list of Functions, which can be linked to a data source to be plotted in the Chart.

Here I will explain from scratch how to make a simple java desktop application for the OSX operating system in which we'll be using TeeChart Charting for Java and some sample values.

We can see the product details for Java TeeChart here:

The first thing we need to do is to download a trial version of the product TeeChart Java Web Suite; we can find the necessary information for downloading it on this page:

Once downloaded unzip the MAC. Zip file and within this we can find all the files necessary for use in our app. In this case we will use the TeeChart.Swing.jar.

This getting started guide assumes we have an installed version of Eclipse in our MAC.
Open Eclipse and do File -> New -> Java Project and give it a name:

New Project

We click "Next", select the tab "Libraries" and press the button "Add external JARs ..", here we will add the TeeChart Charting Library for Java to the application; to do so , locate the unzipped TeeChart evaluation download and select the file TeeChart.Swing.jar before clicking 'Finish'.

You should see the following:


Now that we've created the project, we need to create a new Java file (with .java extension) and add it into the project. To create a new Java file, right click on the name of your project (TeeChartJAvaMAC) in the Package explorer pane and select New -> Class.

We'll name the project ChartClass.


Now, we’re going to add some lines of code to this class. In this application we want to show a Window that contains a JPanel containing an embedded Chart. To do this, it is best to delete all the auto-generated code that the default class contains and start over again. As you can see below from the code sample, we inherit from the class JPanel.

Initially the class should look like this (code):

import java.awt.BorderLayout;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.UIManager;

final public class ChartClass extends JPanel {	

    /** Creates a new instance of Main */
    public ChartClass() {
        super(new BorderLayout());


From here we'll be adding all the working code to the class, you'll see the explanations in amongst the sections. The first step is to create a static method that will be the one we use to create and display in the Chart Window. This we will call createAndShowChart (). Inside we will create the window, give it a title, position, style, and make it visible within the application, it will take the following code:

    private static void createAndShowChart() {
        JFrame window = new JFrame("TeeChart for Java");

        window.addWindowListener(new WindowAdapter() {

            public void windowClosing(WindowEvent we) {



Now within the same method we will add the code necessary to create the Chart, and Series. We will also change various aspects of this, so we'll see how easy it is to work with the library.
TChart defines the object within the method, just before the line of code window.pack ():

// Creating the Chart object        
TChart myChart;
myChart = new TChart();

We're changing some of the features of the Chart to give it a different look, including applying a Theme. We then assign specific gradient colors of the Chart panel, change the position of the Legend and set the Walls to Transparent.
The necessary code would be:

        // Changing the Chart aspect        

Now it's time to create the series we want use in the Chart, we will opt for one Bar and Line Series. As you can see in the TeeChart example project or product specifications, the library of TeeChart for Java includes over 50 Series styles.

We created the two series, we'll add random data to each one and change some of its properties.

The code would be as follows:

        // Adding series to the Chart
        Bar bar1 = new Bar();
        Line line1 = new Line();
        // Changing the Series aspect

Now we need to relate the Series to the Chart, as here:


And to finish with this method we need to add our object, myChart, to the Window application. This line of code is enough:

   window.add(myChart, BorderLayout.CENTER);

Finally, we only need to add the main method 'Main' to our class, where we'll call the method CreateAndShowChart (), for this we'll use the code below, adding it to our class:

    public static void main(String[] args) {

        javax.swing.SwingUtilities.invokeLater(new Runnable() {

            public void run() {
                try {
                    // Calls the method where we create the Chart and add to the window
                } catch (Exception ex) {

The code won't compile without the necessary references added at the beginning of the class, we will need the following:

import java.awt.BorderLayout;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.UIManager;

import com.steema.teechart.TChart;
import com.steema.teechart.drawing.Color;
import com.steema.teechart.legend.LegendAlignment;
import com.steema.teechart.styles.Bar;
import com.steema.teechart.styles.Line;
import com.steema.teechart.themes.ThemesList;

Now if we compile and run our application we should get the following result:

Java Chart

You can download this example via this link.

Charting with the TeeChart for Java Component and MAC OSX



Steema Software SL. Copyright Information. e-mail

Privacy Policy. All other brands and product names are trademarks or registered trademarks of their respective owners.


July 17, 2013