JMSL Chart Programmer's Guide
2D Drawing Elements >> AxisXY >> Axis Unit  Previous Page  Contents  Next Page

Axis Unit

The AxisUnit node controls placing of a unit tag on an axis. The tag is the value of the Title attribute in the node. By default, it is empty.

The axis unit is used for labeling only; it has no other effect on the chart.

Setting the Axis Unit

In this example, the axis unit for the x-axis is set to "hours" and the axis unit for the y-axis is set to "meters". While not required, the axis titles are also set.


(Download Code)

import com.imsl.chart.*;

public class SampleAxisUnit extends JFrameChart {
    
    public SampleAxisUnit() {
        Chart chart = getChart();
        AxisXY axis = new AxisXY(chart);
        double y[] = {4, 2, 3, 9};
        new Data(axis, y);
        
        axis.getAxisX().getAxisTitle().setTitle("Time");
        axis.getAxisY().getAxisTitle().setTitle("Height");
        
        axis.getAxisX().getAxisUnit().setTitle("hours");
        axis.getAxisY().getAxisUnit().setTitle("meters");
    }
    
    public static void main(String argv[]) {
        new SampleAxisUnit().setVisible(true);
    }
}



©  Visual Numerics, Inc.  All rights reserved.  Previous Page  Contents  Next Page