Introduction
Show
Axis
Show
Ticker
Show
Axis Arrowhead
Ticker
Step Interval
Label
Step Interval
Label
Formats
Label
Angle/Label Font
Show
Label
Label
Color
Axis
Label Replacement
Text
Replacement
Introduction
To set properties on the
Axis grid, labels, range, intervals...etc, first create an IAxis object
that has a handle on the chart's Axis that would be edited. Then,
the minimum, maximum, step intervals...etc can be set by using the setMinScale,
setMaxScale, setScaleStep... etc. Please refer to IAxis in the EspressChart
API DOCS if additional information is desired. Some examples are
provided below.
// create an IAxis object, “hXAxis”, that has a handle on X-AxisShow Axis
IAxis hXAxis = chart.gethXAxis();// override the automatic X-Axis scale
hXAxis.setScaleAutomatic(false);// set the new minimum to 0, maximum to 42
hXAxis.setMinScale(new Integer(0));
hXAxis.setMaxScale(new Integer(42));// set step interval to 6
hXAxis.setScaleStep(new Integer(6));
// show axis interval tickersShow Axis Arrowhead
hXAxis.setTickersVisible(true);
Ticker
Step Interval
To set properties on the Axis Labels such as label intervals, label
numeric format...etc, first create an IDataPointSet object that has a handle
on the chart's DataPoints. Then, the properties can be edited through
methods in the IDataPointSet.
// create an IDataPointSet object that has a handle on DataPointsLabel Step Interval
IDataPointSet hDataPoints = chart.gethDataPoints();// For Ticker Step Interval example:
// set the ticker step to 6 units when category data column 3, thus index 2
hDataPoints.setTickerStep(2, 6);
// set the label step to every other tickerLabel Formats
hDataPoints.setLabelStep(2, 12);
// Setting the Date Format appearance for the chartTo set properties on the Axis Labels such as label font, label style, label color...etc, first create an ILabel object that has a handle on the chart's Axis. Then, the properties can be edited through methods in the ILabel class.
DateTimeFormat xAxisFormat = new DateTimeFormat();
xAxisFormat.hidedate=true;
xAxisFormat.monthSymbol=DateTimeFormat.MONTH_SHORT_STRING;
xAxisFormat.yearSymbol=DateTimeFormat.YEAR_1999;
xAxisFormat.separator2=" ";
hDataPoints.setLabelFormat(2, xAxisFormat);// following one example in TimeInstance
// Use getTimeInstance if axis data is in Time. Use getDateInstance if Date.
// Use getDateTimeInstance if TimeStamp.
LocaleDateTimeFormat localeDT = LocaleDateTimeFormat.getTimeInstance( java.text.DateFormat.MEDIUM, java.util.Locale.GERMANY);
// format the 3rd column of the data source
hDataPoints.setLabelFormat(2, localeDT);// set LocaleNumericFormat to include currency symbol in Japan
LocaleNumericFormat localeNF = LocaleNumericFormat.getCurrencyInstance(java.util.Locale.JAPAN);
// format the 3rd column of the data source
hDataPoints.setLabelFormat(2, localeNF);// Set X-Axis labels’ logical format appearance to either “T” or “F”
LogicalFormat xLogicalFormat = new LogicalFormat(LogicalFormat.T_F);
// format the 3rd column of the data source
hDataPoints.setLabelFormat(2, xLogicalFormat);// set X-Axis value label using currency sign
NumericFormat nf = new NumericFormat();
nf.currencySymbol = '$';
// format the 3rd column of the data source which must be numeric data
hDataPoints.setLabelFormat(2, nf);
// create an IAxis object that has a handle on X-AxisLabel Angle/Label Font
IAxis hXAxis = chart.gethXAxis();// create an ILabel object that has a handle on x-axis labels
ILabel hXLabel = hXAxis.gethLabel();
// set X-Axis label font & anglesShow Label
hXLabel.setFont(new Font("TIMES_ROMAN", Font.PLAIN, 12));
hXLabel.setAngle(30); //angle in degrees counter-clockwise
hXLabel.setVisible(true);Label Color
// set label text to blue colorAxis Label Replacement
hXLabel.setColor( Color.blue);
// the number of string array elements must be equal toText Replacement
// the number of tickers
hXAxis.setTickerLabels(new String[] {"A","","AB","Last"});
// Text ReplacementPlease refer to IAxis, DateTimeFormat, LocaleDateTimeFormat, LocaleNumericFormat, LogicalFormat, Numeric Format, ILabel, & IDataPointSet in EspressChart APIDocs for additional information.
hDataPoints.replace(“oldtext”, “newtext”);