Record Class DataLabels

java.lang.Object
java.lang.Record
io.keikai.axyra.sheets.content.DataLabels

public record DataLabels(boolean showValue, boolean showCategoryName, boolean showSeriesName, boolean showPercent, boolean showLegendKey, String position, String numberFormat, Integer rotation, Color textColor, Boolean bold, Double fontSize) extends Record
Series-level data labels (ECMA-376 §21.2.2.49 <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.

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.

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 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 a DataLabels record class.
      Parameters:
      showValue - the value for the showValue record component
      showCategoryName - the value for the showCategoryName record component
      showSeriesName - the value for the showSeriesName record component
      showPercent - the value for the showPercent record component
      showLegendKey - the value for the showLegendKey record component
      position - the value for the position record component
      numberFormat - the value for the numberFormat record component
      rotation - the value for the rotation record component
      textColor - the value for the textColor record component
      bold - the value for the bold record component
      fontSize - the value for the fontSize record component
  • Method Details

    • value

      public static DataLabels value()
      Labels showing the data value.
    • categoryName

      public static DataLabels categoryName()
      Labels showing the category name.
    • seriesName

      public static DataLabels seriesName()
      Labels showing the series name.
    • percent

      public static DataLabels 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

      public DataLabels withShowValue(boolean show)
      Copy showing (or hiding) the data value.
    • withShowCategoryName

      public DataLabels withShowCategoryName(boolean show)
      Copy showing (or hiding) the category name.
    • withShowSeriesName

      public DataLabels withShowSeriesName(boolean show)
      Copy showing (or hiding) the series name.
    • withShowPercent

      public DataLabels withShowPercent(boolean show)
      Copy showing (or hiding) the percent-of-total value.
    • withShowLegendKey

      public DataLabels withShowLegendKey(boolean show)
      Copy showing (or hiding) the legend-key swatch beside the label.
    • withPosition

      public DataLabels withPosition(String position)
      Copy with the given position token (null clears it).
    • withNumberFormat

      public DataLabels withNumberFormat(String numberFormat)
      Copy with the given number-format override (null inherits the axis).
    • withRotation

      public DataLabels withRotation(Integer degrees)
      Copy with the given label rotation in whole degrees (null inherits).
    • withTextColor

      public DataLabels withTextColor(Color color)
      Copy with the given label text color (null inherits).
    • withBold

      public DataLabels withBold(Boolean bold)
      Copy with the given label bold flag (null inherits).
    • withFontSize

      public DataLabels withFontSize(Double points)
      Copy with the given label font size in points (null inherits).
    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • showValue

      public boolean showValue()
      Returns the value of the showValue record component.
      Returns:
      the value of the showValue record component
    • showCategoryName

      public boolean showCategoryName()
      Returns the value of the showCategoryName record component.
      Returns:
      the value of the showCategoryName record component
    • showSeriesName

      public boolean showSeriesName()
      Returns the value of the showSeriesName record component.
      Returns:
      the value of the showSeriesName record component
    • showPercent

      public boolean showPercent()
      Returns the value of the showPercent record component.
      Returns:
      the value of the showPercent record component
    • showLegendKey

      public boolean showLegendKey()
      Returns the value of the showLegendKey record component.
      Returns:
      the value of the showLegendKey record component
    • position

      public String position()
      Returns the value of the position record component.
      Returns:
      the value of the position record component
    • numberFormat

      public String numberFormat()
      Returns the value of the numberFormat record component.
      Returns:
      the value of the numberFormat record component
    • rotation

      public Integer rotation()
      Returns the value of the rotation record component.
      Returns:
      the value of the rotation record component
    • textColor

      public Color textColor()
      Returns the value of the textColor record component.
      Returns:
      the value of the textColor record component
    • bold

      public Boolean bold()
      Returns the value of the bold record component.
      Returns:
      the value of the bold record component
    • fontSize

      public Double fontSize()
      Returns the value of the fontSize record component.
      Returns:
      the value of the fontSize record component