skip to main content
Gantt > Programmer's documentation > Developing with the JViews Charts SDK > Scales > Scale Annotations
 
Scale Annotations
The complete source code of this example can be found in <installdir>/jviews-charts/codefragments/chart/scale-annotation/src/ScaleAnnotation.java.
The IlvScale class supports a special kind of decoration that can be used to indicate a data value on a scale as an annotation.
Such annotation objects are instances of the IlvScaleAnnotation class. This class allows you to draw a string representation of a data value over the scale labels. The string may be either a specific label explicitly set or the data value formatted into a string.
Here are some examples:
*To draw the value along the x-axis of a given data point as a formatted string, use the following code:
 
IlvAnnotation annotation = new IlvScaleAnnotation(xValue);
chart.getXScale().addAnnotation(annotation);
*To display a specific text instead of the data value, the code would be:
 
annotation.setText("Release date");
*To remove the scale annotation, use the following method:
 
chart.getXScale().removeAnnotation(annotation);
The text annotation is drawn by a dedicated IlvScaleAnnotation attribute, which is an instance of IlvLabelRenderer. This label renderer object handles all the properties related to the label drawing, like border, text color, font, and so on, and can be retrieved by invoking the getLabelRenderer method.
For example, to draw the annotation as a white opaque bordered label, use the following code:
 
annotation.getLabelRenderer().setBorder(BorderFactory.createLineBorder(Color.bl
ack));
annotation.getLabelRenderer().setOpaque(true);
annotation.getLabelRenderer().setBackground(Color.white);
Scales Annotations

Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.