diff options
author | jacquarg <guillaume.jacquart@hoodbrains.com> | 2021-11-15 09:40:36 +0100 |
---|---|---|
committer | jacquarg <guillaume.jacquart@hoodbrains.com> | 2021-11-15 09:40:36 +0100 |
commit | 38a056495a7f6a85e57b0db62e8e350a22ef0148 (patch) | |
tree | 8b4c63bd722a3b5610b31272a1c64a83cfac356a /app/src/main/java/foundation/e/privacycentralapp/common | |
parent | 30ef837288e3a5df823b31d0ecee20276de157c5 (diff) | |
download | advanced-privacy-38a056495a7f6a85e57b0db62e8e350a22ef0148.tar.gz |
Update graph design
Diffstat (limited to 'app/src/main/java/foundation/e/privacycentralapp/common')
-rw-r--r-- | app/src/main/java/foundation/e/privacycentralapp/common/GraphStyle.kt | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/app/src/main/java/foundation/e/privacycentralapp/common/GraphStyle.kt b/app/src/main/java/foundation/e/privacycentralapp/common/GraphStyle.kt new file mode 100644 index 0000000..63a0f3f --- /dev/null +++ b/app/src/main/java/foundation/e/privacycentralapp/common/GraphStyle.kt @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2021 E FOUNDATION + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +package foundation.e.privacycentralapp.common + +import androidx.annotation.ColorInt +import com.github.mikephil.charting.charts.BarChart +import com.github.mikephil.charting.components.XAxis +import com.github.mikephil.charting.data.BarData +import com.github.mikephil.charting.data.BarDataSet +import com.github.mikephil.charting.data.BarEntry + +fun customizeBarChart(barChart: BarChart) { + barChart.apply { + description = null + setTouchEnabled(false) + setDrawGridBackground(false) + setDrawBorders(false) + axisLeft.isEnabled = false + axisRight.isEnabled = false + + legend.isEnabled = false + + xAxis.apply { + isEnabled = true + position = XAxis.XAxisPosition.BOTH_SIDED + setDrawGridLines(false) + yOffset = 32f + setDrawLabels(false) + // setDrawLimitLinesBehindData(true) + setDrawValueAboveBar(false) + } + } +} + +fun updateGraphData(values: List<Int>, graph: BarChart, @ColorInt graphColor: Int) { + + val trackersDataSet = BarDataSet( + values.mapIndexed { index, value -> BarEntry(index.toFloat(), value.toFloat()) }, + "" + ).apply { + color = graphColor + setDrawValues(false) + } + + graph.data = BarData(trackersDataSet) + graph.invalidate() +} |