5.2.5 Other Axis Properties

Scrolling

Axis can be set to be scrollable. This is very useful, when there are many elements or BoxZoomer plug-in is used. This can be enabled using setScrollable() method.

Enabling scroll ability:

1
2
3
4
5
6
// setting mapper
MathAxisMapper xMapper = new MathAxisMapper(0, 40);
// setting axis
Axis2DX axisX = new Axis2DX(xMapper);
// enabling scrolling
axisX.setScrollable(true);

Stacking Axes on Chart

There is a possibility to stack more than one axis on chart. This can be achieved using addBottomXAxis(), addTopXAxis(), addLeftYAxis() or addRightYAxis() methods.

1
2
3
4
5
6
Axis2DY axisY2 = new Axis2DY(new MathAxisMapper(0, 17)); //creating axis
axisY2.setTitle("Number of Values");
//...
Chart2D chart = new Chart2D(); //creating chart
//..
chart.addRightYAxis(axisY2); //stacking y axis to right with title "Number of Values"

Stacked Axes on Chart Demonstration

Figure 5.2.2.2 Stacked Axes on Chart Demonstration

View Source

Stacking Axes on each other

There is a possibility to stack axis one on each other.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
    //...........
    // adding axes to chart
    chart.setXAxis(axisX);
    chart.setLeftYAxis(axisYS);
    chart.setLeftYAxis(axisYR);
    chart.setLeftYAxis(axisYQ);
    // stacking axes
    axisYQ.setStackAxis2DY(axisYS);
    axisYS.setStackAxis2DY(axisYR);
    // setting space among axes
    Axis2DY.setStackedYAxisMargin(chart, 0.01f);
    // setting how much space axes should take
    chart.setStackedLeftYAxisProportion(new double[] { 0.4, 0.3, 0.3 });
    //...........

Stacked Axes on Each Other Demonstration

Figure 5.2.2.3 Stacked Axes on Each Other Demonstration

View Source

Formulas

There is a possibility to format titles of axes which consists of formulas using Latex document mark-up language. In order, for this feature to work, Image paint mode for title should be set.

For instance, there is formula (cos(x))^2, this could be formatted using Latex in this way:

1
2
3
4
5
6
//setting axis
Axis2DY yAxis = new Axis2DY(yMapper);
//setting title
yAxis.setTitle("{cos^2{x}}");
//setting title's paint mode
yAxis.getPaintStyle().setPaintMode(AxisPaintTags.TITLE,	PaintMode.IMAGE_PAINT);

Highlighting the middle subtick

There is a possibility to highlight the middle subtick on math axis.

 
// setting Highlight for Middle Subtick
axisX.getTickSettings().setHighlightMiddleSubtick(true);

Text Paint Modes

There are 2 paint modes available for axis text styling:

Ladder Text Paint Mode

This paint mode displays text rotation by angle which is set by setRotationAngle and text is rotation in accordance to that angle.

1
2
3
4
// setting paint mode for y axis title
axisY.getTitleSettings().setTextPaintMode(TextPaintMode.LADDER_PAINT);
// setting angle by which axis title should be rotated
axisY.getTitleSettings().setRotationAngle(Math.PI/2);

Ladder Text Paint Mode for Y-axis title Demonstration

Figure 5.2.2.4 Ladder Text Paint Mode for Y-axis title Demonstration

View Source