ChartEntryModelProducer

class ChartEntryModelProducer(entryCollections: List<List<ChartEntry>>? = null, dispatcher: CoroutineDispatcher = Dispatchers.Default) : ChartModelProducer<ChartEntryModel>

A ChartModelProducer implementation that generates ChartEntryModel instances.

Parameters

entryCollections

the initial data set (list of series).

dispatcher

the CoroutineDispatcher to be used for update handling.

See also

Constructors

Link copied to clipboard
constructor(vararg entryCollections: List<ChartEntry>, dispatcher: CoroutineDispatcher = Dispatchers.Default)
constructor(entryCollections: List<List<ChartEntry>>? = null, dispatcher: CoroutineDispatcher = Dispatchers.Default)

Functions

Link copied to clipboard
open override fun getModel(): ChartEntryModel?

Returns the ChartEntryModel or, if no ChartEntryModel is available, null.

Link copied to clipboard
open override fun isRegistered(key: Any): Boolean

Checks if an update listener with the given key is registered.

Link copied to clipboard
open override fun registerForUpdates(key: Any, cancelAnimation: () -> Unit, startAnimation: (transformModel: suspend (chartKey: Any, fraction: Float) -> Unit) -> Unit, getOldModel: () -> ChartEntryModel?, modelTransformerProvider: Chart.ModelTransformerProvider?, extraStore: MutableExtraStore, updateChartValues: (ChartEntryModel?) -> ChartValuesProvider, onModelCreated: (ChartEntryModel?) -> Unit)

Registers an update listener associated with a key. cancelAnimation and startAnimation are called after a data update is requested, with cancelAnimation being called before the update starts being processed (at which point transformModel should stop being used), and startAnimation being called once the update has been processed (at which point it’s safe to use transformModel). updateChartValues updates the chart’s ChartValues and returns its ChartValuesProvider. onModelCreated is called when a new Model has been generated.

open override fun registerForUpdates(key: Any, cancelAnimation: () -> Unit, startAnimation: (transformModel: suspend (key: Any, fraction: Float) -> Unit) -> Unit, getOldModel: () -> ChartEntryModel?, modelTransformerProvider: Chart.ModelTransformerProvider?, extraStore: MutableExtraStore, updateChartValues: (ChartEntryModel?) -> ChartValuesProvider, onModelCreated: (ChartEntryModel?, ChartValuesProvider) -> Unit)

Registers an update listener associated with a key. cancelAnimation and startAnimation are called after a data update is requested, with cancelAnimation being called before the update starts being processed, and startAnimation being called once the update has been processed. updateChartValues updates the chart’s ChartValues and returns its ChartValuesProvider. onModelCreated is called when a new Model has been generated.

Link copied to clipboard
fun setEntries(vararg entries: List<ChartEntry>, updateExtras: (MutableExtraStore) -> Unit = {}): Boolean
fun setEntries(entries: List<List<ChartEntry>>, updateExtras: (MutableExtraStore) -> Unit = {}): Boolean

Requests that the data set be updated to the provided one. If the update is accepted, true is returned. If the update is rejected, which occurs when there’s already an update in progress, false is returned. For suspending behavior, use setEntriesSuspending. updateExtras allows for adding auxiliary data, which can later be retrieved via ChartEntryModel.extraStore.

Link copied to clipboard
suspend fun setEntriesSuspending(vararg entries: List<ChartEntry>, updateExtras: (MutableExtraStore) -> Unit = {}): Deferred<Unit>
suspend fun setEntriesSuspending(entries: List<List<ChartEntry>>, updateExtras: (MutableExtraStore) -> Unit = {}): Deferred<Unit>

Updates the data set. Unlike setEntries, this function suspends the current coroutine and waits until an update can be run, meaning the update cannot be rejected. The returned Deferred implementation is marked as completed once the update has been processed. updateExtras allows for adding auxiliary data, which can later be retrieved via ChartEntryModel.extraStore.

Link copied to clipboard
open suspend override fun transformModel(key: Any, fraction: Float)

Creates an intermediate ChartEntryModel for difference animations. fraction is the balance between the initial and target ChartEntryModels.

Link copied to clipboard
open override fun unregisterFromUpdates(key: Any)

Unregisters the update listener associated with the given key.