Skip to main content
Version: Next

Android

Library that provides a set of Charts components required to build new products.

Getting Started

For creating LineChart you should create data provider which extended BaseLineChartDataProvider and pass it to ChartContainerView.
Example of creating data provider for LineChart:

class LineChartDataProvider(/*..*/) : BaseLineChartDataProvider(/*..*/) {

// function for providing list of RawRecord values
override fun getRawRecords(result: (unit: String, List<RawRecord>) -> Unit) {

// get raw records values here

result("subtitle", listOf(RawRecord(/*..*/)))
}

// function for providing input data to chart
override fun getData(
chartRange: ChartRangeType, // type of time range on chart
accuracyCoefficient: Long, // timeline accuracy factor on chart
chartSubcategoryId: ChartSubcategoryId, // ID value of chart subcategory
result: (InitialChartData) -> Unit // lambda should be invoked to provide result of input data
) {

// set data for chart here and convert it to List<LineChartData> type

result(InitialChartData.LineChart(listOf(LineChartData(/*..*/))))
}
}

For BarChart you should create the same data provider extended from BaseBarChartDataProvider.
Creating view of LineChart or BarChart will be depend on type of data provider that you pass to ChartContainerView.

Adding ChartContainerView component in the layout:

<com.huma.sdk.charts.chart_container.ChartContainerView
android:id="@+id/chartContainer"
android:layout_width="0dp"
android:layout_height="65dp"
app:layout_constraintWidth_percent="0.5" />

Creating instance of ChartContainerView component from code:

return ChartContainerView(context).apply {
this.chartDataProvider = dataProvider // instance of your ChartDataProvider implementation class
this.config = chartConfig // instance of ChartConfig class with configuration chart view
this.configs = chartUnitConfig // instance of ChartUnitConfig class with configuration of chart subcategory item
}