Record Class DataLabels
<c:dLbls>): which fields
are drawn beside each data point, an optional label position, an
optional numberFormat override (§21.2.2.79 numFmt) that formats
the value independently of the value axis, plus optional label text
styling (§21.2.2.216 <c:txPr>): rotation, color, bold and font
size.
Positions are the OOXML dLblPos tokens (§21.2.2.48): bestFit,
b, ctr, inBase, inEnd, l, outEnd,
r, t. A position is only valid for chart types that permit it
(e.g. outEnd for a clustered bar, ctr/inEnd/
outEnd/bestFit for a pie); leave it null to let the chart type
pick its default. Excel refuses a position on an area chart (2-D or 3-D), a
radar or doughnut chart, and a 3-D bar, column or line chart; on those the
position is kept in the model but not saved.
Text styling fields are null to inherit the chart-style default:
rotation is in whole degrees (e.g. -90 for a vertical label),
textColor is an explicit color, bold toggles weight, and
fontSize is in points. textColor must be an RGB color;
Chart.Builder.dataLabels(DataLabels) throws
IllegalStateException for a theme, indexed or automatic color.
ChartView.setSeriesDataLabels(int, DataLabels)
applies the text styling too, with the same RGB-only rule.
Attach with Chart.Builder.dataLabels(DataLabels) (applies to the most
recently added series). Data labels are re-emitted as <c:dLbls> on save
and read back via ChartView.seriesDataLabels(int).
-
Constructor Summary
ConstructorsConstructorDescriptionDataLabels(boolean showValue, boolean showCategoryName, boolean showSeriesName, boolean showPercent, boolean showLegendKey, String position, String numberFormat) Backward-compatible constructor without text styling (all txPr fields inherit).DataLabels(boolean showValue, boolean showCategoryName, boolean showSeriesName, boolean showPercent, boolean showLegendKey, String position, String numberFormat, Integer rotation, Color textColor, Boolean bold, Double fontSize) Creates an instance of aDataLabelsrecord class. -
Method Summary
Modifier and TypeMethodDescriptionbold()Returns the value of theboldrecord component.static DataLabelsLabels showing the category name.final booleanIndicates whether some other object is "equal to" this one.fontSize()Returns the value of thefontSizerecord component.final inthashCode()Returns a hash code value for this object.booleanWhether any label text styling (rotation / color / bold / size) is set.booleanWhether any field is shown (i.e.Returns the value of thenumberFormatrecord component.static DataLabelspercent()Labels showing the value as a percent of the total (pie / doughnut).position()Returns the value of thepositionrecord component.rotation()Returns the value of therotationrecord component.static DataLabelsLabels showing the series name.booleanReturns the value of theshowCategoryNamerecord component.booleanReturns the value of theshowLegendKeyrecord component.booleanReturns the value of theshowPercentrecord component.booleanReturns the value of theshowSeriesNamerecord component.booleanReturns the value of theshowValuerecord component.Returns the value of thetextColorrecord component.final StringtoString()Returns a string representation of this record class.static DataLabelsvalue()Labels showing the data value.Copy with the given label bold flag (nullinherits).withFontSize(Double points) Copy with the given label font size in points (nullinherits).withNumberFormat(String numberFormat) Copy with the given number-format override (nullinherits the axis).withPosition(String position) Copy with the given position token (nullclears it).withRotation(Integer degrees) Copy with the given label rotation in whole degrees (nullinherits).withShowCategoryName(boolean show) Copy showing (or hiding) the category name.withShowLegendKey(boolean show) Copy showing (or hiding) the legend-key swatch beside the label.withShowPercent(boolean show) Copy showing (or hiding) the percent-of-total value.withShowSeriesName(boolean show) Copy showing (or hiding) the series name.withShowValue(boolean show) Copy showing (or hiding) the data value.withTextColor(Color color) Copy with the given label text color, an RGB color (nullinherits).
-
Constructor Details
-
DataLabels
public DataLabels(boolean showValue, boolean showCategoryName, boolean showSeriesName, boolean showPercent, boolean showLegendKey, String position, String numberFormat) Backward-compatible constructor without text styling (all txPr fields inherit). Delegates to the canonical constructor. -
DataLabels
public DataLabels(boolean showValue, boolean showCategoryName, boolean showSeriesName, boolean showPercent, boolean showLegendKey, String position, String numberFormat, Integer rotation, Color textColor, Boolean bold, Double fontSize) Creates an instance of aDataLabelsrecord class.- Parameters:
showValue- the value for theshowValuerecord componentshowCategoryName- the value for theshowCategoryNamerecord componentshowSeriesName- the value for theshowSeriesNamerecord componentshowPercent- the value for theshowPercentrecord componentshowLegendKey- the value for theshowLegendKeyrecord componentposition- the value for thepositionrecord componentnumberFormat- the value for thenumberFormatrecord componentrotation- the value for therotationrecord componenttextColor- the value for thetextColorrecord componentbold- the value for theboldrecord componentfontSize- the value for thefontSizerecord component
-
-
Method Details
-
value
Labels showing the data value. -
categoryName
Labels showing the category name. -
seriesName
Labels showing the series name. -
percent
Labels showing the value as a percent of the total (pie / doughnut). -
isVisible
public boolean isVisible()Whether any field is shown (i.e. the labels actually render). -
hasTextStyle
public boolean hasTextStyle()Whether any label text styling (rotation / color / bold / size) is set. -
withShowValue
Copy showing (or hiding) the data value. -
withShowCategoryName
Copy showing (or hiding) the category name. -
withShowSeriesName
Copy showing (or hiding) the series name. -
withShowPercent
Copy showing (or hiding) the percent-of-total value. -
withShowLegendKey
Copy showing (or hiding) the legend-key swatch beside the label. -
withPosition
Copy with the given position token (nullclears it). -
withNumberFormat
Copy with the given number-format override (nullinherits the axis). -
withRotation
Copy with the given label rotation in whole degrees (nullinherits). -
withTextColor
Copy with the given label text color, an RGB color (nullinherits). -
withBold
Copy with the given label bold flag (nullinherits). -
withFontSize
Copy with the given label font size in points (nullinherits). -
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
showValue
public boolean showValue()Returns the value of theshowValuerecord component.- Returns:
- the value of the
showValuerecord component
-
showCategoryName
public boolean showCategoryName()Returns the value of theshowCategoryNamerecord component.- Returns:
- the value of the
showCategoryNamerecord component
-
showSeriesName
public boolean showSeriesName()Returns the value of theshowSeriesNamerecord component.- Returns:
- the value of the
showSeriesNamerecord component
-
showPercent
public boolean showPercent()Returns the value of theshowPercentrecord component.- Returns:
- the value of the
showPercentrecord component
-
showLegendKey
public boolean showLegendKey()Returns the value of theshowLegendKeyrecord component.- Returns:
- the value of the
showLegendKeyrecord component
-
position
Returns the value of thepositionrecord component.- Returns:
- the value of the
positionrecord component
-
numberFormat
Returns the value of thenumberFormatrecord component.- Returns:
- the value of the
numberFormatrecord component
-
rotation
Returns the value of therotationrecord component.- Returns:
- the value of the
rotationrecord component
-
textColor
Returns the value of thetextColorrecord component.- Returns:
- the value of the
textColorrecord component
-
bold
Returns the value of theboldrecord component.- Returns:
- the value of the
boldrecord component
-
fontSize
Returns the value of thefontSizerecord component.- Returns:
- the value of the
fontSizerecord component
-