# WeightedElementsComplicationData

Artifact: [androidx.wear.watchface:watchface-complications-data](https://developer.android.com/jetpack/androidx/releases/wear-watchface) [View Source](https://cs.android.com/search?q=file:androidx/wear/watchface/complications/data/Data.kt+class:androidx.wear.watchface.complications.data.WeightedElementsComplicationData) Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.2.0)

*** ** * ** ***

<br />

```
@RequiresApi(value = 33)
class WeightedElementsComplicationData : ComplicationData
```

<br />

|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html) |||
| ↳ | [androidx.wear.watchface.complications.data.ComplicationData](https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/ComplicationData) ||
|   | ↳ | [androidx.wear.watchface.complications.data.WeightedElementsComplicationData](https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData) |

*** ** * ** ***

Type used for complications which want to display the breakdown of something (e.g. nutrition data) perhaps as a pie chart, or as a stacked bar chart etc. The breakdown may be accompanied by an icon and/or short text and title.

The `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData#elements()` field is required for this type and is expected to always be displayed.

The `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData#monochromaticImage()`, `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData#smallImage()`, `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData#title()`, and `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData#text()` fields are optional but at least one of them must be set. The watch face may choose which of these fields to display, if any.

If a `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData#monochromaticImage()` and a `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData#smallImage()` are both specified then only one should be displayed. If the complication is drawn with a single color it's recommended to choose `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData#monochromaticImage()` and apply a tint. If the complication is rendered with multiple colors it's recommended to choose the `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData#smallImage()`. It's best practice for a ComplicationDataSource to specify both a `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData#monochromaticImage()` and a `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData#smallImage()`.

A data source that wants to serve a SmallImageComplicationData must include the following meta data in its manifest (NB the value is a comma separated list):

```kotlin
<meta-data android:name="android.support.wearable.complications.SUPPORTED_TYPES"
   android:value="WEIGHTED_ELEMENTS"/>
```

## Summary

| ### Nested types |
|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/RequiresApi(value = 33) class https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Builder` Builder for `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData`. |
| `class https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Element` Describes a single value within a `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData`. |

| ### Public companion functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData#getMaxElements()()` Returns the maximum size for `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData#elements()`. |

| ### Public companion properties |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Element>` | `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData#PLACEHOLDER()` Used to signal the range should be rendered as a placeholder. |
| `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/ComplicationType` | `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData#TYPE()` The `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/ComplicationType` corresponding to objects of this type. |

| ### Public functions |
|---|---|
| `open https://developer.android.com/reference/java/time/Instant.html` | `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData#getNextChangeInstant(java.time.Instant)(afterInstant: https://developer.android.com/reference/java/time/Instant.html)` Returns the next `https://developer.android.com/reference/java/time/Instant.html` after `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/ComplicationData#getNextChangeInstant(java.time.Instant)` at which any field of the complication may change. |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData#hasPlaceholderFields()()` Returns `true` if any of the fields of this ComplicationData are placeholders. |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData#toString()()` |

| ### Public properties |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/ComplicationText?` | `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData#contentDescription()` The content description field for accessibility. |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/ColorInt https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData#elementBackgroundColor()` If elements are draw as segments then this is the background color to use in between them. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Element>` | `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData#elements()` The breakdown of the subject into various `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Element`s (e.g. the proportion of calories consumed which were carbohydrates, fats, etc.). |
| `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/MonochromaticImage?` | `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData#monochromaticImage()` A simple `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/MonochromaticImage` image that can be tinted by the watch face. |
| `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/SmallImage?` | `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData#smallImage()` A `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/SmallImage` that is expected to cover a small fraction of a watch face occupied by a single complication. |
| `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/ComplicationText?` | `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData#text()` The body `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/ComplicationText` of the complication. |
| `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/ComplicationText?` | `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData#title()` The optional title `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/ComplicationText`. |

### Inherited functions

From [androidx.wear.watchface.complications.data.ComplicationData](https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/ComplicationData) `open operator https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/ComplicationData#equals(kotlin.Any)(other: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?)` `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/ComplicationData#hashCode()()`

### Inherited properties

From [androidx.wear.watchface.complications.data.ComplicationData](https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/ComplicationData) `https://developer.android.com/reference/android/content/ComponentName.html?` `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/ComplicationData#dataSource()`

The `https://developer.android.com/reference/android/content/ComponentName.html` of the `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/datasource/ComplicationDataSourceService` that provided the ComplicationData.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/ComplicationData#displayPolicy()`

The `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/ComplicationDisplayPolicies` for this complication.
`https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/ComplicationData?` `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/ComplicationData#dynamicValueInvalidationFallback()`

Used in case any dynamic value has been invalidated.
`https://developer.android.com/reference/android/os/PersistableBundle.html` `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/ComplicationData#extras()`

A copy of any extras set by a complication provider with the privileged permission `com.google.wear.permission.SET_COMPLICATION_EXTRAS` or `https://developer.android.com/reference/android/os/PersistableBundle.html#EMPTY`.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/ComplicationData#persistencePolicy()`

The `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/ComplicationPersistencePolicies` for this complication.
`https://developer.android.com/reference/android/app/PendingIntent.html?` `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/ComplicationData#tapAction()`

The `https://developer.android.com/reference/android/app/PendingIntent.html` to send when the complication is tapped on.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/ComplicationData#tapActionLostDueToSerialization()`

`https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/ComplicationData#tapAction()` which is a `https://developer.android.com/reference/android/app/PendingIntent.html` unfortunately can't be serialized.
`https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/ComplicationType` `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/ComplicationData#type()`

The `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/ComplicationType` of this complication data.
`https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/TimeRange` `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/ComplicationData#validTimeRange()`

The `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/TimeRange` within which the complication should be displayed.

## Public companion functions

### getMaxElements

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.2.0)

```
fun getMaxElements(): Int
```

Returns the maximum size for `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData#elements()`. Complications are small and if we have a very large number of elements we likely won't be able to render them properly because the individual elements will be too small on screen.

## Public companion properties

### PLACEHOLDER

```
val PLACEHOLDER: List<WeightedElementsComplicationData.Element>
```

Used to signal the range should be rendered as a placeholder. It's suggested that a placeholder ranged value be drawn as a grey arc with a percentage value selected by the renderer.

Note a placeholder may only be used in the context of `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/NoDataComplicationData#placeholder()`.

### TYPE

```
val TYPE: ComplicationType
```

The `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/ComplicationType` corresponding to objects of this type.

## Public functions

### getNextChangeInstant

```
open fun getNextChangeInstant(afterInstant: Instant): Instant
```

Returns the next `https://developer.android.com/reference/java/time/Instant.html` after `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/ComplicationData#getNextChangeInstant(java.time.Instant)` at which any field of the complication may change. If there's no scheduled changes then `https://developer.android.com/reference/java/time/Instant.html#MAX` will be returned.

See `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/ComplicationText#getNextChangeTime(java.time.Instant)`

| Parameters |
|---|---|
| `afterInstant: https://developer.android.com/reference/java/time/Instant.html` | The reference `https://developer.android.com/reference/java/time/Instant.html`, after which changes will be reported. |

### hasPlaceholderFields

```
open fun hasPlaceholderFields(): Boolean
```

Returns `true` if any of the fields of this ComplicationData are placeholders. I.e. if any fields are equal to: `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/ComplicationText#PLACEHOLDER()`, `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/SmallImage#PLACEHOLDER()`, `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/MonochromaticImage#PLACEHOLDER()`, `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/PhotoImageComplicationData#PLACEHOLDER()`, or `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/RangedValueComplicationData#PLACEHOLDER()`.

### toString

```
open fun toString(): String
```

## Public properties

### contentDescription

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.2.0)

```
val contentDescription: ComplicationText?
```

The content description field for accessibility.

### elementBackgroundColor

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.2.0)

```
val elementBackgroundColor: @ColorInt Int
```

If elements are draw as segments then this is the background color to use in between them.

### elements

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.2.0)

```
val elements: List<WeightedElementsComplicationData.Element>
```

The breakdown of the subject into various `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Element`s (e.g. the proportion of calories consumed which were carbohydrates, fats, etc.). The colors need to be meaningful to the user (e.g. blue is cold, yellow/red is worm), and should be consistent with the experience launched by tapping on the complication. If this is equal to `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData#PLACEHOLDER()` then the renderer must display this in a visually distinct way to suggest to the user that it's placeholder data. E.g. each element is rendered in light grey. The maximum valid size of this list is provided by `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/WeightedElementsComplicationData#getMaxElements()` and it will be truncated if its larger.

### monochromaticImage

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.2.0)

```
val monochromaticImage: MonochromaticImage?
```

A simple `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/MonochromaticImage` image that can be tinted by the watch face. If the monochromaticImage is equal to `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/MonochromaticImage#PLACEHOLDER()` the renderer must treat it as a placeholder rather than rendering normally, its suggested it should be rendered as a light grey box.

### smallImage

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.2.0)

```
val smallImage: SmallImage?
```

A `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/SmallImage` that is expected to cover a small fraction of a watch face occupied by a single complication. If the smallImage is equal to `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/SmallImage#PLACEHOLDER()` the renderer must treat it as a placeholder rather than rendering normally, its suggested it should be rendered as a light grey box.

### text

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.2.0)

```
val text: ComplicationText?
```

The body `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/ComplicationText` of the complication. The length of the text, including any time-dependent values at any valid time, is expected to not exceed seven characters. When using this text, the watch face should be able to display any string of up to seven characters (reducing the text size appropriately if the string is very wide). Although not expected, it is possible that strings of more than seven characters might be seen, in which case they may be truncated. If the text is equal to `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/ComplicationText#PLACEHOLDER()` the renderer must treat it as a placeholder rather than rendering normally, its suggested it should be rendered as a light grey box.

### title

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.2.0)

```
val title: ComplicationText?
```

The optional title `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/ComplicationText`. The length of the title, including any time-dependent values at any valid time, is expected to not exceed seven characters. When using this text, the watch face should be able to display any string of up to seven characters (reducing the text size appropriately if the string is very wide). Although not expected, it is possible that strings of more than seven characters might be seen, in which case they may be truncated. If the title is equal to `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/ComplicationText#PLACEHOLDER()` the renderer must treat it as a placeholder rather than rendering normally, its suggested it should be rendered as a light grey box.