diff --git a/app/src/main/kotlin/info/appdev/chartexample/AnotherBarActivity.kt b/app/src/main/kotlin/info/appdev/chartexample/AnotherBarActivity.kt index 0dc19759c..ddacd99e1 100644 --- a/app/src/main/kotlin/info/appdev/chartexample/AnotherBarActivity.kt +++ b/app/src/main/kotlin/info/appdev/chartexample/AnotherBarActivity.kt @@ -55,7 +55,7 @@ class AnotherBarActivity : DemoBase(), OnSeekBarChangeListener { // add a nice and smooth animation binding.chart1.animateY(1500) - binding.chart1.legend?.isEnabled = false + binding.chart1.legend.isEnabled = false } override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) { diff --git a/app/src/main/kotlin/info/appdev/chartexample/BarChartActivity.kt b/app/src/main/kotlin/info/appdev/chartexample/BarChartActivity.kt index efe74040a..3d85c1aab 100644 --- a/app/src/main/kotlin/info/appdev/chartexample/BarChartActivity.kt +++ b/app/src/main/kotlin/info/appdev/chartexample/BarChartActivity.kt @@ -93,7 +93,7 @@ class BarChartActivity : DemoBase(), OnSeekBarChangeListener, OnChartValueSelect rightAxis.spaceTop = 15f rightAxis.axisMinimum = 0f// this replaces setStartAtZero(true) - binding.chart1.legend?.apply { + binding.chart1.legend.apply { verticalAlignment = Legend.LegendVerticalAlignment.BOTTOM horizontalAlignment = Legend.LegendHorizontalAlignment.LEFT orientation = Legend.LegendOrientation.HORIZONTAL diff --git a/app/src/main/kotlin/info/appdev/chartexample/BarChartActivityMultiDataset.kt b/app/src/main/kotlin/info/appdev/chartexample/BarChartActivityMultiDataset.kt index bc825244c..1bc09c3ca 100644 --- a/app/src/main/kotlin/info/appdev/chartexample/BarChartActivityMultiDataset.kt +++ b/app/src/main/kotlin/info/appdev/chartexample/BarChartActivityMultiDataset.kt @@ -65,7 +65,7 @@ class BarChartActivityMultiDataset : DemoBase(), OnSeekBarChangeListener, OnChar binding.seekBarX.progress = 10 binding.seekBarY.progress = 100 - binding.chart1.legend?.apply { + binding.chart1.legend.apply { verticalAlignment = Legend.LegendVerticalAlignment.TOP horizontalAlignment = Legend.LegendHorizontalAlignment.RIGHT orientation = Legend.LegendOrientation.VERTICAL diff --git a/app/src/main/kotlin/info/appdev/chartexample/BarChartActivitySinus.kt b/app/src/main/kotlin/info/appdev/chartexample/BarChartActivitySinus.kt index 464454339..8fa84a21a 100644 --- a/app/src/main/kotlin/info/appdev/chartexample/BarChartActivitySinus.kt +++ b/app/src/main/kotlin/info/appdev/chartexample/BarChartActivitySinus.kt @@ -72,7 +72,7 @@ class BarChartActivitySinus : DemoBase(), OnSeekBarChangeListener { binding.seekbarValues.setOnSeekBarChangeListener(this) binding.seekbarValues.progress = 150 // set data - binding.chart1.legend?.apply { + binding.chart1.legend.apply { verticalAlignment = Legend.LegendVerticalAlignment.BOTTOM horizontalAlignment = Legend.LegendHorizontalAlignment.LEFT orientation = Legend.LegendOrientation.HORIZONTAL diff --git a/app/src/main/kotlin/info/appdev/chartexample/BarChartPositiveNegative.kt b/app/src/main/kotlin/info/appdev/chartexample/BarChartPositiveNegative.kt index c415352fc..0207d00e4 100644 --- a/app/src/main/kotlin/info/appdev/chartexample/BarChartPositiveNegative.kt +++ b/app/src/main/kotlin/info/appdev/chartexample/BarChartPositiveNegative.kt @@ -67,7 +67,7 @@ class BarChartPositiveNegative : DemoBase() { left.zeroLineColor = Color.GRAY left.zeroLineWidth = 0.7f binding.chart1.axisRight.isEnabled = false - binding.chart1.legend?.isEnabled = false + binding.chart1.legend.isEnabled = false // THIS IS THE ORIGINAL DATA YOU WANT TO PLOT val data: MutableList = ArrayList() diff --git a/app/src/main/kotlin/info/appdev/chartexample/BubbleChartActivity.kt b/app/src/main/kotlin/info/appdev/chartexample/BubbleChartActivity.kt index 69fc15490..04c73abcf 100644 --- a/app/src/main/kotlin/info/appdev/chartexample/BubbleChartActivity.kt +++ b/app/src/main/kotlin/info/appdev/chartexample/BubbleChartActivity.kt @@ -54,7 +54,7 @@ class BubbleChartActivity : DemoBase(), OnSeekBarChangeListener, OnChartValueSel binding.seekBarX.progress = 10 binding.seekBarY.progress = 50 - binding.chart1.legend?.apply { + binding.chart1.legend.apply { verticalAlignment = Legend.LegendVerticalAlignment.TOP horizontalAlignment = Legend.LegendHorizontalAlignment.RIGHT orientation = Legend.LegendOrientation.VERTICAL diff --git a/app/src/main/kotlin/info/appdev/chartexample/CandleStickChartActivity.kt b/app/src/main/kotlin/info/appdev/chartexample/CandleStickChartActivity.kt index 6bc7f3ff1..6c1e21fb9 100644 --- a/app/src/main/kotlin/info/appdev/chartexample/CandleStickChartActivity.kt +++ b/app/src/main/kotlin/info/appdev/chartexample/CandleStickChartActivity.kt @@ -63,7 +63,7 @@ class CandleStickChartActivity : DemoBase(), OnSeekBarChangeListener { binding.seekBarX.progress = 40 binding.seekBarY.progress = 100 - binding.chart1.legend?.isEnabled = false + binding.chart1.legend.isEnabled = false } override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) { diff --git a/app/src/main/kotlin/info/appdev/chartexample/CombinedChartActivity.kt b/app/src/main/kotlin/info/appdev/chartexample/CombinedChartActivity.kt index 43eea9491..38dec93fb 100644 --- a/app/src/main/kotlin/info/appdev/chartexample/CombinedChartActivity.kt +++ b/app/src/main/kotlin/info/appdev/chartexample/CombinedChartActivity.kt @@ -55,7 +55,7 @@ class CombinedChartActivity : DemoBase() { DrawOrder.BAR, DrawOrder.BUBBLE, DrawOrder.CANDLE, DrawOrder.LINE, DrawOrder.SCATTER ) - binding.chart1.legend?.apply { + binding.chart1.legend.apply { isWordWrapEnabled = true verticalAlignment = Legend.LegendVerticalAlignment.BOTTOM horizontalAlignment = Legend.LegendHorizontalAlignment.CENTER diff --git a/app/src/main/kotlin/info/appdev/chartexample/CubicLineChartActivity.kt b/app/src/main/kotlin/info/appdev/chartexample/CubicLineChartActivity.kt index 07d8ddf98..e549aa5a8 100644 --- a/app/src/main/kotlin/info/appdev/chartexample/CubicLineChartActivity.kt +++ b/app/src/main/kotlin/info/appdev/chartexample/CubicLineChartActivity.kt @@ -74,7 +74,7 @@ class CubicLineChartActivity : DemoBase(), OnSeekBarChangeListener { binding.seekBarX.progress = 45 binding.seekBarY.progress = 100 - binding.chart1.legend?.isEnabled = false + binding.chart1.legend.isEnabled = false binding.chart1.animateXY(2000, 2000) diff --git a/app/src/main/kotlin/info/appdev/chartexample/DrawChartActivity.kt b/app/src/main/kotlin/info/appdev/chartexample/DrawChartActivity.kt index 0e52626df..712c502f7 100644 --- a/app/src/main/kotlin/info/appdev/chartexample/DrawChartActivity.kt +++ b/app/src/main/kotlin/info/appdev/chartexample/DrawChartActivity.kt @@ -49,7 +49,7 @@ class DrawChartActivity : DemoBase(), OnChartValueSelectedListener, OnDrawListen val yl = binding.chart1.axisLeft yl.typeface = tfRegular - binding.chart1.legend?.isEnabled = false + binding.chart1.legend.isEnabled = false // chart.setYRange(-40f, 40f, true); // call this to reset the changed y-range diff --git a/app/src/main/kotlin/info/appdev/chartexample/FilledLineActivity.kt b/app/src/main/kotlin/info/appdev/chartexample/FilledLineActivity.kt index 07c0c8216..9e9e1be00 100644 --- a/app/src/main/kotlin/info/appdev/chartexample/FilledLineActivity.kt +++ b/app/src/main/kotlin/info/appdev/chartexample/FilledLineActivity.kt @@ -46,7 +46,7 @@ class FilledLineActivity : DemoBase() { // if disabled, scaling can be done on x- and y-axis separately binding.chart1.setPinchZoom(false) - binding.chart1.legend?.apply { + binding.chart1.legend.apply { isEnabled = false } diff --git a/app/src/main/kotlin/info/appdev/chartexample/GradientActivity.kt b/app/src/main/kotlin/info/appdev/chartexample/GradientActivity.kt index a79d45a51..63a905aad 100644 --- a/app/src/main/kotlin/info/appdev/chartexample/GradientActivity.kt +++ b/app/src/main/kotlin/info/appdev/chartexample/GradientActivity.kt @@ -34,7 +34,7 @@ class GradientActivity : DemoBase() { // Minimal chart setup chart.description?.isEnabled = false - chart.legend?.isEnabled = false + chart.legend.isEnabled = false chart.axisRight.isEnabled = false chart.setDrawGridBackground(false) diff --git a/app/src/main/kotlin/info/appdev/chartexample/HalfPieChartActivity.kt b/app/src/main/kotlin/info/appdev/chartexample/HalfPieChartActivity.kt index 1f47847e2..f18f5fceb 100644 --- a/app/src/main/kotlin/info/appdev/chartexample/HalfPieChartActivity.kt +++ b/app/src/main/kotlin/info/appdev/chartexample/HalfPieChartActivity.kt @@ -65,7 +65,7 @@ class HalfPieChartActivity : DemoBase() { binding.chart1.animateY(1400, Easing.easeInOutQuad) - binding.chart1.legend?.apply { + binding.chart1.legend.apply { verticalAlignment = Legend.LegendVerticalAlignment.TOP horizontalAlignment = Legend.LegendHorizontalAlignment.CENTER orientation = Legend.LegendOrientation.HORIZONTAL diff --git a/app/src/main/kotlin/info/appdev/chartexample/HorizontalBarChartActivity.kt b/app/src/main/kotlin/info/appdev/chartexample/HorizontalBarChartActivity.kt index ac88bfef5..fdc944334 100644 --- a/app/src/main/kotlin/info/appdev/chartexample/HorizontalBarChartActivity.kt +++ b/app/src/main/kotlin/info/appdev/chartexample/HorizontalBarChartActivity.kt @@ -88,7 +88,7 @@ class HorizontalBarChartActivity : DemoBase(), OnSeekBarChangeListener, OnChartV binding.seekBarY.progress = 50 binding.seekBarX.progress = 12 - binding.chart1.legend?.apply { + binding.chart1.legend.apply { verticalAlignment = Legend.LegendVerticalAlignment.BOTTOM horizontalAlignment = Legend.LegendHorizontalAlignment.LEFT orientation = Legend.LegendOrientation.HORIZONTAL diff --git a/app/src/main/kotlin/info/appdev/chartexample/HorizontalBarNegativeChartActivity.kt b/app/src/main/kotlin/info/appdev/chartexample/HorizontalBarNegativeChartActivity.kt index e8b884b9c..a76983bb0 100644 --- a/app/src/main/kotlin/info/appdev/chartexample/HorizontalBarNegativeChartActivity.kt +++ b/app/src/main/kotlin/info/appdev/chartexample/HorizontalBarNegativeChartActivity.kt @@ -84,7 +84,7 @@ class HorizontalBarNegativeChartActivity : DemoBase(), OnSeekBarChangeListener, binding.seekBarY.progress = 50 binding.seekBarX.progress = 12 - binding.chart1.legend?.apply { + binding.chart1.legend.apply { verticalAlignment = Legend.LegendVerticalAlignment.BOTTOM horizontalAlignment = Legend.LegendHorizontalAlignment.LEFT orientation = Legend.LegendOrientation.HORIZONTAL diff --git a/app/src/main/kotlin/info/appdev/chartexample/InvertedLineChartActivity.kt b/app/src/main/kotlin/info/appdev/chartexample/InvertedLineChartActivity.kt index d53c2612b..adb79048a 100644 --- a/app/src/main/kotlin/info/appdev/chartexample/InvertedLineChartActivity.kt +++ b/app/src/main/kotlin/info/appdev/chartexample/InvertedLineChartActivity.kt @@ -83,7 +83,7 @@ class InvertedLineChartActivity : DemoBase(), OnSeekBarChangeListener, OnChartVa // chart.centerViewPort(10, 50); // get the legend (only possible after setting data) - binding.chart1.legend?.apply { + binding.chart1.legend.apply { form = LegendForm.LINE } diff --git a/app/src/main/kotlin/info/appdev/chartexample/LineChartActivity.kt b/app/src/main/kotlin/info/appdev/chartexample/LineChartActivity.kt index aee450764..a42ac5da8 100644 --- a/app/src/main/kotlin/info/appdev/chartexample/LineChartActivity.kt +++ b/app/src/main/kotlin/info/appdev/chartexample/LineChartActivity.kt @@ -137,7 +137,7 @@ class LineChartActivity : DemoBase(), OnSeekBarChangeListener, OnChartValueSelec // get the legend (only possible after setting data) val legend = binding.chart1.legend - legend?.form = LegendForm.LINE + legend.form = LegendForm.LINE } override fun onCreateOptionsMenu(menu: Menu): Boolean { diff --git a/app/src/main/kotlin/info/appdev/chartexample/LineChartActivityColored.kt b/app/src/main/kotlin/info/appdev/chartexample/LineChartActivityColored.kt index 1362629a7..199d89ada 100644 --- a/app/src/main/kotlin/info/appdev/chartexample/LineChartActivityColored.kt +++ b/app/src/main/kotlin/info/appdev/chartexample/LineChartActivityColored.kt @@ -76,7 +76,7 @@ class LineChartActivityColored : DemoBase() { chart.setData(data) // get the legend (only possible after setting data) - chart.legend?.apply { + chart.legend.apply { isEnabled = false } diff --git a/app/src/main/kotlin/info/appdev/chartexample/LineChartDualAxisActivity.kt b/app/src/main/kotlin/info/appdev/chartexample/LineChartDualAxisActivity.kt index e8fd0a2bb..1697925d1 100644 --- a/app/src/main/kotlin/info/appdev/chartexample/LineChartDualAxisActivity.kt +++ b/app/src/main/kotlin/info/appdev/chartexample/LineChartDualAxisActivity.kt @@ -73,7 +73,7 @@ class LineChartDualAxisActivity : DemoBase(), OnSeekBarChangeListener, OnChartVa binding.chart1.animateX(1500) // get the legend (only possible after setting data) - binding.chart1.legend?.apply { + binding.chart1.legend.apply { form = LegendForm.LINE typeface = tfLight textSize = 11f diff --git a/app/src/main/kotlin/info/appdev/chartexample/LineChartTimeActivity.kt b/app/src/main/kotlin/info/appdev/chartexample/LineChartTimeActivity.kt index 7f6877255..d14d7bbd7 100644 --- a/app/src/main/kotlin/info/appdev/chartexample/LineChartTimeActivity.kt +++ b/app/src/main/kotlin/info/appdev/chartexample/LineChartTimeActivity.kt @@ -62,7 +62,7 @@ class LineChartTimeActivity : DemoBase(), OnSeekBarChangeListener { binding.seekBarX.progress = 100 // get the legend (only possible after setting data) - binding.chart1.legend?.apply { + binding.chart1.legend.apply { isEnabled = false } diff --git a/app/src/main/kotlin/info/appdev/chartexample/MultiLineChartActivity.kt b/app/src/main/kotlin/info/appdev/chartexample/MultiLineChartActivity.kt index 4245a898a..af78458a2 100644 --- a/app/src/main/kotlin/info/appdev/chartexample/MultiLineChartActivity.kt +++ b/app/src/main/kotlin/info/appdev/chartexample/MultiLineChartActivity.kt @@ -61,7 +61,7 @@ class MultiLineChartActivity : DemoBase(), OnSeekBarChangeListener, OnChartGestu binding.seekBarX.progress = 20 binding.seekBarY.progress = 100 - binding.chart1.legend?.apply { + binding.chart1.legend.apply { verticalAlignment = Legend.LegendVerticalAlignment.TOP horizontalAlignment = Legend.LegendHorizontalAlignment.RIGHT orientation = Legend.LegendOrientation.VERTICAL diff --git a/app/src/main/kotlin/info/appdev/chartexample/PerformanceLineChart.kt b/app/src/main/kotlin/info/appdev/chartexample/PerformanceLineChart.kt index c512bd7b1..0cef87b71 100644 --- a/app/src/main/kotlin/info/appdev/chartexample/PerformanceLineChart.kt +++ b/app/src/main/kotlin/info/appdev/chartexample/PerformanceLineChart.kt @@ -78,7 +78,7 @@ class PerformanceLineChart : DemoBase(), OnSeekBarChangeListener { binding.chart1.setData(data) // get the legend (only possible after setting data) - binding.chart1.legend?.apply { + binding.chart1.legend.apply { isEnabled = false } } diff --git a/app/src/main/kotlin/info/appdev/chartexample/PieChartActivity.kt b/app/src/main/kotlin/info/appdev/chartexample/PieChartActivity.kt index 6465f4107..1310c1756 100644 --- a/app/src/main/kotlin/info/appdev/chartexample/PieChartActivity.kt +++ b/app/src/main/kotlin/info/appdev/chartexample/PieChartActivity.kt @@ -82,7 +82,7 @@ class PieChartActivity : DemoBase(), OnSeekBarChangeListener, OnChartValueSelect binding.chart1.animateY(1400, Easing.easeInOutQuad) // chart.spin(2000, 0, 360); - binding.chart1.legend?.apply { + binding.chart1.legend.apply { verticalAlignment = Legend.LegendVerticalAlignment.TOP horizontalAlignment = Legend.LegendHorizontalAlignment.RIGHT orientation = Legend.LegendOrientation.VERTICAL diff --git a/app/src/main/kotlin/info/appdev/chartexample/PieChartRoundedActivity.kt b/app/src/main/kotlin/info/appdev/chartexample/PieChartRoundedActivity.kt index 5c3dd3383..416bd1ea3 100644 --- a/app/src/main/kotlin/info/appdev/chartexample/PieChartRoundedActivity.kt +++ b/app/src/main/kotlin/info/appdev/chartexample/PieChartRoundedActivity.kt @@ -83,7 +83,7 @@ class PieChartRoundedActivity : DemoBase(), OnSeekBarChangeListener, OnChartValu binding.chart1.animateY(1400, Easing.easeInOutQuad) // chart.spin(2000, 0, 360); - binding.chart1.legend?.apply { + binding.chart1.legend.apply { verticalAlignment = Legend.LegendVerticalAlignment.TOP horizontalAlignment = Legend.LegendHorizontalAlignment.RIGHT orientation = Legend.LegendOrientation.VERTICAL diff --git a/app/src/main/kotlin/info/appdev/chartexample/PiePolylineChartActivity.kt b/app/src/main/kotlin/info/appdev/chartexample/PiePolylineChartActivity.kt index 6cf19f589..fa1bf7dcf 100644 --- a/app/src/main/kotlin/info/appdev/chartexample/PiePolylineChartActivity.kt +++ b/app/src/main/kotlin/info/appdev/chartexample/PiePolylineChartActivity.kt @@ -85,7 +85,7 @@ class PiePolylineChartActivity : DemoBase(), OnSeekBarChangeListener, OnChartVal binding.chart1.animateY(1400, Easing.easeInOutQuad) // chart.spin(2000, 0, 360); - binding.chart1.legend?.apply { + binding.chart1.legend.apply { verticalAlignment = Legend.LegendVerticalAlignment.TOP horizontalAlignment = Legend.LegendHorizontalAlignment.RIGHT orientation = Legend.LegendOrientation.VERTICAL diff --git a/app/src/main/kotlin/info/appdev/chartexample/RadarChartActivity.kt b/app/src/main/kotlin/info/appdev/chartexample/RadarChartActivity.kt index 3713bd775..63178d691 100644 --- a/app/src/main/kotlin/info/appdev/chartexample/RadarChartActivity.kt +++ b/app/src/main/kotlin/info/appdev/chartexample/RadarChartActivity.kt @@ -73,7 +73,7 @@ class RadarChartActivity : DemoBase() { yAxis.axisMaximum = 80f yAxis.setDrawLabels(false) - binding.chart1.legend?.apply { + binding.chart1.legend.apply { verticalAlignment = Legend.LegendVerticalAlignment.TOP horizontalAlignment = Legend.LegendHorizontalAlignment.CENTER orientation = Legend.LegendOrientation.HORIZONTAL diff --git a/app/src/main/kotlin/info/appdev/chartexample/RealtimeLineChartActivity.kt b/app/src/main/kotlin/info/appdev/chartexample/RealtimeLineChartActivity.kt index 0de1843a8..dca25a5bf 100644 --- a/app/src/main/kotlin/info/appdev/chartexample/RealtimeLineChartActivity.kt +++ b/app/src/main/kotlin/info/appdev/chartexample/RealtimeLineChartActivity.kt @@ -57,7 +57,7 @@ class RealtimeLineChartActivity : DemoBase(), OnChartValueSelectedListener { binding.chart1.setData(data) // get the legend (only possible after setting data) - binding.chart1.legend?.apply { + binding.chart1.legend.apply { form = LegendForm.LINE typeface = tfLight textColor = Color.WHITE diff --git a/app/src/main/kotlin/info/appdev/chartexample/ScatterChartActivity.kt b/app/src/main/kotlin/info/appdev/chartexample/ScatterChartActivity.kt index f1a30ee41..2058142a8 100644 --- a/app/src/main/kotlin/info/appdev/chartexample/ScatterChartActivity.kt +++ b/app/src/main/kotlin/info/appdev/chartexample/ScatterChartActivity.kt @@ -53,7 +53,7 @@ class ScatterChartActivity : DemoBase(), OnSeekBarChangeListener, OnChartValueSe binding.seekBarX.progress = 45 binding.seekBarY.progress = 100 - binding.chart1.legend?.apply { + binding.chart1.legend.apply { verticalAlignment = Legend.LegendVerticalAlignment.TOP horizontalAlignment = Legend.LegendHorizontalAlignment.RIGHT orientation = Legend.LegendOrientation.VERTICAL diff --git a/app/src/main/kotlin/info/appdev/chartexample/ScrollViewActivity.kt b/app/src/main/kotlin/info/appdev/chartexample/ScrollViewActivity.kt index e53b1a168..2636edf1a 100644 --- a/app/src/main/kotlin/info/appdev/chartexample/ScrollViewActivity.kt +++ b/app/src/main/kotlin/info/appdev/chartexample/ScrollViewActivity.kt @@ -37,7 +37,7 @@ class ScrollViewActivity : DemoBase() { binding.chart1.axisLeft.setDrawGridLines(false) - binding.chart1.legend?.isEnabled = false + binding.chart1.legend.isEnabled = false setData(10) binding.chart1.setFitBars(true) diff --git a/app/src/main/kotlin/info/appdev/chartexample/SpecificPositionsLineChartActivity.kt b/app/src/main/kotlin/info/appdev/chartexample/SpecificPositionsLineChartActivity.kt index 315e6153e..6707a01dd 100644 --- a/app/src/main/kotlin/info/appdev/chartexample/SpecificPositionsLineChartActivity.kt +++ b/app/src/main/kotlin/info/appdev/chartexample/SpecificPositionsLineChartActivity.kt @@ -115,7 +115,7 @@ class SpecificPositionsLineChartActivity : DemoBase(), OnSeekBarChangeListener, //mChart.invalidate(); // get the legend (only possible after setting data) - binding.chart1.legend?.apply { + binding.chart1.legend.apply { form = LegendForm.LINE } } diff --git a/app/src/main/kotlin/info/appdev/chartexample/StackedBarActivity.kt b/app/src/main/kotlin/info/appdev/chartexample/StackedBarActivity.kt index c4fb3a321..aa328b577 100644 --- a/app/src/main/kotlin/info/appdev/chartexample/StackedBarActivity.kt +++ b/app/src/main/kotlin/info/appdev/chartexample/StackedBarActivity.kt @@ -74,7 +74,7 @@ class StackedBarActivity : DemoBase(), OnSeekBarChangeListener, OnChartValueSele binding.seekBarX.progress = 12 binding.seekBarY.progress = 100 - binding.chart1.legend?.apply { + binding.chart1.legend.apply { verticalAlignment = Legend.LegendVerticalAlignment.BOTTOM horizontalAlignment = Legend.LegendHorizontalAlignment.RIGHT orientation = Legend.LegendOrientation.HORIZONTAL diff --git a/app/src/main/kotlin/info/appdev/chartexample/StackedBarActivityNegative.kt b/app/src/main/kotlin/info/appdev/chartexample/StackedBarActivityNegative.kt index 58c6263a2..4b14abbe0 100644 --- a/app/src/main/kotlin/info/appdev/chartexample/StackedBarActivityNegative.kt +++ b/app/src/main/kotlin/info/appdev/chartexample/StackedBarActivityNegative.kt @@ -76,7 +76,7 @@ class StackedBarActivityNegative : DemoBase(), OnChartValueSelectedListener { } } - binding.chart1.legend?.apply { + binding.chart1.legend.apply { verticalAlignment = Legend.LegendVerticalAlignment.BOTTOM horizontalAlignment = Legend.LegendHorizontalAlignment.RIGHT orientation = Legend.LegendOrientation.HORIZONTAL diff --git a/app/src/main/kotlin/info/appdev/chartexample/compose/HorizontalBarComposeActivity.kt b/app/src/main/kotlin/info/appdev/chartexample/compose/HorizontalBarComposeActivity.kt index 007b53e3b..2f4cb02e6 100644 --- a/app/src/main/kotlin/info/appdev/chartexample/compose/HorizontalBarComposeActivity.kt +++ b/app/src/main/kotlin/info/appdev/chartexample/compose/HorizontalBarComposeActivity.kt @@ -320,7 +320,7 @@ class HorizontalBarComposeActivity : DemoBaseCompose() { chart.setFitBars(true) chart.animateY(2500) - chart.legend?.apply { + chart.legend.apply { verticalAlignment = Legend.LegendVerticalAlignment.BOTTOM horizontalAlignment = Legend.LegendHorizontalAlignment.LEFT orientation = Legend.LegendOrientation.HORIZONTAL diff --git a/app/src/main/kotlin/info/appdev/chartexample/fragments/BarChartFrag.kt b/app/src/main/kotlin/info/appdev/chartexample/fragments/BarChartFrag.kt index 07ab80636..4ab89abc3 100644 --- a/app/src/main/kotlin/info/appdev/chartexample/fragments/BarChartFrag.kt +++ b/app/src/main/kotlin/info/appdev/chartexample/fragments/BarChartFrag.kt @@ -37,7 +37,7 @@ class BarChartFrag : SimpleFragment(), OnChartGestureListener { chart!!.setData(generateBarData(1, 20000f)) - chart!!.legend?.apply { + chart!!.legend.apply { typeface = tf } diff --git a/app/src/main/kotlin/info/appdev/chartexample/fragments/ComplexityFragment.kt b/app/src/main/kotlin/info/appdev/chartexample/fragments/ComplexityFragment.kt index 0464d4d96..8b245fbe2 100644 --- a/app/src/main/kotlin/info/appdev/chartexample/fragments/ComplexityFragment.kt +++ b/app/src/main/kotlin/info/appdev/chartexample/fragments/ComplexityFragment.kt @@ -26,7 +26,7 @@ class ComplexityFragment : SimpleFragment() { val tf = Typeface.createFromAsset(requireContext().assets, "OpenSans-Light.ttf") - chart!!.legend?.apply { + chart!!.legend.apply { typeface = tf } diff --git a/app/src/main/kotlin/info/appdev/chartexample/fragments/PieChartFrag.kt b/app/src/main/kotlin/info/appdev/chartexample/fragments/PieChartFrag.kt index 60ad4d337..d662c4305 100644 --- a/app/src/main/kotlin/info/appdev/chartexample/fragments/PieChartFrag.kt +++ b/app/src/main/kotlin/info/appdev/chartexample/fragments/PieChartFrag.kt @@ -34,7 +34,7 @@ class PieChartFrag : SimpleFragment() { chart!!.holeRadius = 45f chart!!.transparentCircleRadius = 50f - chart!!.legend?.apply { + chart!!.legend.apply { verticalAlignment = Legend.LegendVerticalAlignment.TOP horizontalAlignment = Legend.LegendHorizontalAlignment.RIGHT orientation = Legend.LegendOrientation.VERTICAL diff --git a/app/src/main/kotlin/info/appdev/chartexample/fragments/ScatterChartFrag.kt b/app/src/main/kotlin/info/appdev/chartexample/fragments/ScatterChartFrag.kt index 738c646b4..1abe4a4a2 100644 --- a/app/src/main/kotlin/info/appdev/chartexample/fragments/ScatterChartFrag.kt +++ b/app/src/main/kotlin/info/appdev/chartexample/fragments/ScatterChartFrag.kt @@ -40,7 +40,7 @@ class ScatterChartFrag : SimpleFragment() { rightAxis.typeface = tf rightAxis.setDrawGridLines(false) - chart!!.legend?.apply { + chart!!.legend.apply { isWordWrapEnabled = true typeface = tf formSize = 14f diff --git a/app/src/main/kotlin/info/appdev/chartexample/fragments/SineCosineFragment.kt b/app/src/main/kotlin/info/appdev/chartexample/fragments/SineCosineFragment.kt index a7082beda..1390d73d0 100644 --- a/app/src/main/kotlin/info/appdev/chartexample/fragments/SineCosineFragment.kt +++ b/app/src/main/kotlin/info/appdev/chartexample/fragments/SineCosineFragment.kt @@ -26,7 +26,7 @@ class SineCosineFragment : SimpleFragment() { val tf = Typeface.createFromAsset(requireContext().assets, "OpenSans-Light.ttf") - chart!!.legend?.apply { + chart!!.legend.apply { typeface = tf } diff --git a/app/src/main/kotlin/info/appdev/chartexample/listviewitems/PieChartItem.kt b/app/src/main/kotlin/info/appdev/chartexample/listviewitems/PieChartItem.kt index 8ba0b3ff4..4c41f76d3 100644 --- a/app/src/main/kotlin/info/appdev/chartexample/listviewitems/PieChartItem.kt +++ b/app/src/main/kotlin/info/appdev/chartexample/listviewitems/PieChartItem.kt @@ -62,7 +62,7 @@ class PieChartItem(cd: ChartData<*>, c: Context) : ChartItem(cd) { chartData.setValueTextSize(11f) chartData.setValueTextColor(Color.WHITE) // set data - holder.chart!!.setData(chartData as PieData?) + holder.chart?.setData(chartData as PieData?) holder.chart?.legend?.apply { verticalAlignment = Legend.LegendVerticalAlignment.TOP diff --git a/chartLib/src/main/kotlin/info/appdev/charting/charts/BarLineChartBase.kt b/chartLib/src/main/kotlin/info/appdev/charting/charts/BarLineChartBase.kt index fc6a0da41..b45fae6a6 100644 --- a/chartLib/src/main/kotlin/info/appdev/charting/charts/BarLineChartBase.kt +++ b/chartLib/src/main/kotlin/info/appdev/charting/charts/BarLineChartBase.kt @@ -338,7 +338,7 @@ abstract class BarLineChartBase - if (!legend.isEnabled || legend.isDrawInsideEnabled) { - return - } - - when (legend.orientation) { - LegendOrientation.VERTICAL -> when (legend.horizontalAlignment) { - LegendHorizontalAlignment.LEFT -> offsets.left += min( - legend.neededWidth, - viewPortHandler.chartWidth * legend.maxSizePercent - ) + legend.xOffset - - LegendHorizontalAlignment.RIGHT -> offsets.right += min( - legend.neededWidth, - viewPortHandler.chartWidth * legend.maxSizePercent - ) + legend.xOffset - - LegendHorizontalAlignment.CENTER -> when (legend.verticalAlignment) { - LegendVerticalAlignment.TOP -> offsets.top += min( - legend.neededHeight, - viewPortHandler.chartHeight * legend.maxSizePercent - ) + legend.yOffset - - LegendVerticalAlignment.BOTTOM -> offsets.bottom += min( - legend.neededHeight, - viewPortHandler.chartHeight * legend.maxSizePercent - ) + legend.yOffset - - else -> {} - } - } + if (!legend.isEnabled || legend.isDrawInsideEnabled) { + return + } - LegendOrientation.HORIZONTAL -> when (legend.verticalAlignment) { + when (legend.orientation) { + LegendOrientation.VERTICAL -> when (legend.horizontalAlignment) { + LegendHorizontalAlignment.LEFT -> offsets.left += min( + legend.neededWidth, + viewPortHandler.chartWidth * legend.maxSizePercent + ) + legend.xOffset + LegendHorizontalAlignment.RIGHT -> offsets.right += min( + legend.neededWidth, + viewPortHandler.chartWidth * legend.maxSizePercent + ) + legend.xOffset + LegendHorizontalAlignment.CENTER -> when (legend.verticalAlignment) { LegendVerticalAlignment.TOP -> offsets.top += min( legend.neededHeight, viewPortHandler.chartHeight * legend.maxSizePercent ) + legend.yOffset - - LegendVerticalAlignment.BOTTOM -> offsets.bottom += min( legend.neededHeight, viewPortHandler.chartHeight * legend.maxSizePercent ) + legend.yOffset - - else -> {} } } + + LegendOrientation.HORIZONTAL -> when (legend.verticalAlignment) { + LegendVerticalAlignment.TOP -> offsets.top += min( + legend.neededHeight, + viewPortHandler.chartHeight * legend.maxSizePercent + ) + legend.yOffset + LegendVerticalAlignment.BOTTOM -> offsets.bottom += min( + legend.neededHeight, + viewPortHandler.chartHeight * legend.maxSizePercent + ) + legend.yOffset + else -> {} + } } } @@ -499,9 +489,11 @@ abstract class BarLineChartBase { offsetBottom += xLabelHeight } + XAxisPosition.TOP -> { offsetTop += xLabelHeight } + XAxisPosition.BOTH_SIDED -> { offsetBottom += xLabelHeight offsetTop += xLabelHeight @@ -509,7 +501,7 @@ abstract class BarLineChartBase TODO() XAxisPosition.BOTTOM_INSIDE -> TODO() - null -> Timber.e( "calculateOffsets(): Cannot calculate offset for XAxisPosition.TOP_INSIDE or BOTTOM_INSIDE") + null -> Timber.e("calculateOffsets(): Cannot calculate offset for XAxisPosition.TOP_INSIDE or BOTTOM_INSIDE") } } diff --git a/chartLib/src/main/kotlin/info/appdev/charting/charts/Chart.kt b/chartLib/src/main/kotlin/info/appdev/charting/charts/Chart.kt index 945d18ea8..955337987 100644 --- a/chartLib/src/main/kotlin/info/appdev/charting/charts/Chart.kt +++ b/chartLib/src/main/kotlin/info/appdev/charting/charts/Chart.kt @@ -146,7 +146,7 @@ abstract class Chart>?> : ViewGroup, IBase /** * the legend object containing all data associated with the legend */ - var legend: Legend? = null + var legend: Legend = Legend() protected set /** @@ -272,7 +272,7 @@ abstract class Chart>?> : ViewGroup, IBase */ protected open fun init() { mMaxHighlightDistance = 500f.convertDpToPixel() - this.legendRenderer = LegendRenderer(this.viewPortHandler, this.legend!!) + this.legendRenderer = LegendRenderer(this.viewPortHandler, this.legend) } /** diff --git a/chartLib/src/main/kotlin/info/appdev/charting/charts/HorizontalBarChart.kt b/chartLib/src/main/kotlin/info/appdev/charting/charts/HorizontalBarChart.kt index 6817a0710..d323bae72 100644 --- a/chartLib/src/main/kotlin/info/appdev/charting/charts/HorizontalBarChart.kt +++ b/chartLib/src/main/kotlin/info/appdev/charting/charts/HorizontalBarChart.kt @@ -59,66 +59,57 @@ open class HorizontalBarChart : BarChart { offsets.top = 0f offsets.bottom = 0f - legend?.let { legend -> - if (!legend.isEnabled || legend.isDrawInsideEnabled) { - return + if (!legend.isEnabled || legend.isDrawInsideEnabled) { + return + } + when (legend.orientation) { + LegendOrientation.VERTICAL -> when (legend.horizontalAlignment) { + LegendHorizontalAlignment.LEFT -> offsets.left += min( + legend.neededWidth, + viewPortHandler.chartWidth * legend.maxSizePercent + ) + legend.xOffset + LegendHorizontalAlignment.RIGHT -> offsets.right += min( + legend.neededWidth, + viewPortHandler.chartWidth * legend.maxSizePercent + ) + legend.xOffset + LegendHorizontalAlignment.CENTER -> when (legend.verticalAlignment) { + LegendVerticalAlignment.TOP -> offsets.top += min( + legend.neededHeight, + viewPortHandler.chartHeight * legend.maxSizePercent + ) + legend.yOffset + LegendVerticalAlignment.BOTTOM -> offsets.bottom += min( + legend.neededHeight, + viewPortHandler.chartHeight * legend.maxSizePercent + ) + legend.yOffset + else -> {} + } } - when (legend.orientation) { - LegendOrientation.VERTICAL -> when (legend.horizontalAlignment) { - LegendHorizontalAlignment.LEFT -> offsets.left += min( - legend.neededWidth, - viewPortHandler.chartWidth * legend.maxSizePercent - ) + legend.xOffset - - LegendHorizontalAlignment.RIGHT -> offsets.right += min( - legend.neededWidth, - viewPortHandler.chartWidth * legend.maxSizePercent - ) + legend.xOffset - - LegendHorizontalAlignment.CENTER -> when (legend.verticalAlignment) { - LegendVerticalAlignment.TOP -> offsets.top += min( - legend.neededHeight, - viewPortHandler.chartHeight * legend.maxSizePercent - ) + legend.yOffset - - LegendVerticalAlignment.BOTTOM -> offsets.bottom += min( - legend.neededHeight, - viewPortHandler.chartHeight * legend.maxSizePercent - ) + legend.yOffset - - else -> {} + LegendOrientation.HORIZONTAL -> when (legend.verticalAlignment) { + LegendVerticalAlignment.TOP -> { + offsets.top += min( + legend.neededHeight, + viewPortHandler.chartHeight * legend.maxSizePercent + ) + legend.yOffset + + if (mAxisLeft.isEnabled && mAxisLeft.isDrawLabelsEnabled) { + offsets.top += mAxisLeft.getRequiredHeightSpace( + axisRendererLeft.paintAxisLabels + ) } } - - LegendOrientation.HORIZONTAL -> when (legend.verticalAlignment) { - LegendVerticalAlignment.TOP -> { - offsets.top += min( - legend.neededHeight, - viewPortHandler.chartHeight * legend.maxSizePercent - ) + legend.yOffset - - if (mAxisLeft.isEnabled && mAxisLeft.isDrawLabelsEnabled) { - offsets.top += mAxisLeft.getRequiredHeightSpace( - axisRendererLeft.paintAxisLabels - ) - } + LegendVerticalAlignment.BOTTOM -> { + offsets.bottom += min( + legend.neededHeight, + viewPortHandler.chartHeight * legend.maxSizePercent + ) + legend.yOffset + + if (mAxisRight.isEnabled && mAxisRight.isDrawLabelsEnabled) { + offsets.bottom += mAxisRight.getRequiredHeightSpace( + axisRendererRight.paintAxisLabels + ) } - - LegendVerticalAlignment.BOTTOM -> { - offsets.bottom += min( - legend.neededHeight, - viewPortHandler.chartHeight * legend.maxSizePercent - ) + legend.yOffset - - if (mAxisRight.isEnabled && mAxisRight.isDrawLabelsEnabled) { - offsets.bottom += mAxisRight.getRequiredHeightSpace( - axisRendererRight.paintAxisLabels - ) - } - } - - else -> {} } + else -> {} } } } diff --git a/chartLib/src/main/kotlin/info/appdev/charting/charts/PieRadarChartBase.kt b/chartLib/src/main/kotlin/info/appdev/charting/charts/PieRadarChartBase.kt index c859bcb47..6b5a50796 100644 --- a/chartLib/src/main/kotlin/info/appdev/charting/charts/PieRadarChartBase.kt +++ b/chartLib/src/main/kotlin/info/appdev/charting/charts/PieRadarChartBase.kt @@ -109,7 +109,7 @@ abstract class PieRadarChartBase>> calcMinMax() - if (legend != null) legendRenderer?.computeLegend(mData!!) + legendRenderer?.computeLegend(mData!!) calculateOffsets() } @@ -120,144 +120,138 @@ abstract class PieRadarChartBase>> var legendBottom = 0f var legendTop = 0f - legend?.let { legend -> - if (legend.isEnabled && !legend.isDrawInsideEnabled) { - val fullLegendWidth = min( - legend.neededWidth, - viewPortHandler.chartWidth * legend.maxSizePercent - ) - val fullLegendHeight = min( - legend.neededHeight, - viewPortHandler.chartHeight * legend.maxSizePercent - ) - - when (legend.orientation) { - LegendOrientation.VERTICAL -> { - when (legend.horizontalAlignment) { - LegendHorizontalAlignment.LEFT -> legendLeft = fullLegendWidth - LegendHorizontalAlignment.RIGHT -> legendRight = fullLegendWidth - LegendHorizontalAlignment.CENTER -> { - // do nothing for center - } + if (legend.isEnabled && !legend.isDrawInsideEnabled) { + val fullLegendWidth = min( + legend.neededWidth, + viewPortHandler.chartWidth * legend.maxSizePercent + ) + val fullLegendHeight = min( + legend.neededHeight, + viewPortHandler.chartHeight * legend.maxSizePercent + ) + + when (legend.orientation) { + LegendOrientation.VERTICAL -> { + when (legend.horizontalAlignment) { + LegendHorizontalAlignment.LEFT -> legendLeft = fullLegendWidth + LegendHorizontalAlignment.RIGHT -> legendRight = fullLegendWidth + LegendHorizontalAlignment.CENTER -> { + // do nothing for center } } - - LegendOrientation.HORIZONTAL -> { - when (legend.verticalAlignment) { - LegendVerticalAlignment.TOP -> legendTop = fullLegendHeight - LegendVerticalAlignment.BOTTOM -> legendBottom = fullLegendHeight - LegendVerticalAlignment.CENTER -> { - // do nothing for center - } + } + LegendOrientation.HORIZONTAL -> { + when (legend.verticalAlignment) { + LegendVerticalAlignment.TOP -> legendTop = fullLegendHeight + LegendVerticalAlignment.BOTTOM -> legendBottom = fullLegendHeight + LegendVerticalAlignment.CENTER -> { + // do nothing for center } } } } + } - if (legend.isEnabled && !legend.isDrawInsideEnabled) { - val fullLegendWidth = min( - legend.neededWidth, - viewPortHandler.chartWidth * legend.maxSizePercent - ) - - when (legend.orientation) { - LegendOrientation.VERTICAL -> { - var xLegendOffset = 0f - - if (legend.horizontalAlignment == LegendHorizontalAlignment.LEFT - || legend.horizontalAlignment == LegendHorizontalAlignment.RIGHT - ) { - if (legend.verticalAlignment == LegendVerticalAlignment.CENTER) { - // this is the space between the legend and the chart - val spacing = 13f.convertDpToPixel() - - xLegendOffset = fullLegendWidth + spacing - } else { - // this is the space between the legend and the chart - val spacing = 8f.convertDpToPixel() - - val legendWidth = fullLegendWidth + spacing - val legendHeight = legend.neededHeight + legend.mTextHeightMax - - val bottomX = if (legend.horizontalAlignment == - LegendHorizontalAlignment.RIGHT - ) - width - legendWidth + 15f - else - legendWidth - 15f - val bottomY = legendHeight + 15f - val distLegend = distanceToCenter(bottomX, bottomY) - - val reference = getPosition( - center, this.radius, - getAngleForPoint(bottomX, bottomY) - ) - - val distReference = distanceToCenter(reference.x, reference.y) - val minOffset = 5f.convertDpToPixel() - - if (bottomY >= center.y && height - legendWidth > width) { - xLegendOffset = legendWidth - } else if (distLegend < distReference) { - val diff = distReference - distLegend - xLegendOffset = minOffset + diff - } - - recycleInstance(center) - recycleInstance(reference) - } - } + if (legend.isEnabled && !legend.isDrawInsideEnabled) { + val fullLegendWidth = min( + legend.neededWidth, + viewPortHandler.chartWidth * legend.maxSizePercent + ) + + when (legend.orientation) { + LegendOrientation.VERTICAL -> { + var xLegendOffset = 0f + + if (legend.horizontalAlignment == LegendHorizontalAlignment.LEFT + || legend.horizontalAlignment == LegendHorizontalAlignment.RIGHT + ) { + if (legend.verticalAlignment == LegendVerticalAlignment.CENTER) { + // this is the space between the legend and the chart + val spacing = 13f.convertDpToPixel() + + xLegendOffset = fullLegendWidth + spacing + } else { + // this is the space between the legend and the chart + val spacing = 8f.convertDpToPixel() + + val legendWidth = fullLegendWidth + spacing + val legendHeight = legend.neededHeight + legend.mTextHeightMax + + val bottomX = if (legend.horizontalAlignment == + LegendHorizontalAlignment.RIGHT + ) + width - legendWidth + 15f + else + legendWidth - 15f + val bottomY = legendHeight + 15f + val distLegend = distanceToCenter(bottomX, bottomY) + + val reference = getPosition( + center, this.radius, + getAngleForPoint(bottomX, bottomY) + ) - when (legend.horizontalAlignment) { - LegendHorizontalAlignment.LEFT -> legendLeft = xLegendOffset - LegendHorizontalAlignment.RIGHT -> legendRight = xLegendOffset - LegendHorizontalAlignment.CENTER -> when (legend.verticalAlignment) { - LegendVerticalAlignment.TOP -> legendTop = min( - legend.neededHeight, - viewPortHandler.chartHeight * legend.maxSizePercent - ) - - LegendVerticalAlignment.BOTTOM -> legendBottom = min( - legend.neededHeight, - viewPortHandler.chartHeight * legend.maxSizePercent - ) - - LegendVerticalAlignment.CENTER -> Timber.e("LegendCenter/VerticalCenter not supported for PieRadarChart") + val distReference = distanceToCenter(reference.x, reference.y) + val minOffset = 5f.convertDpToPixel() + + if (bottomY >= center.y && height - legendWidth > width) { + xLegendOffset = legendWidth + } else if (distLegend < distReference) { + val diff = distReference - distLegend + xLegendOffset = minOffset + diff } + + recycleInstance(center) + recycleInstance(reference) } } - LegendOrientation.HORIZONTAL -> { - val yLegendOffset: Float + when (legend.horizontalAlignment) { + LegendHorizontalAlignment.LEFT -> legendLeft = xLegendOffset + LegendHorizontalAlignment.RIGHT -> legendRight = xLegendOffset + LegendHorizontalAlignment.CENTER -> when (legend.verticalAlignment) { + LegendVerticalAlignment.TOP -> legendTop = min( + legend.neededHeight, + viewPortHandler.chartHeight * legend.maxSizePercent + ) + LegendVerticalAlignment.BOTTOM -> legendBottom = min( + legend.neededHeight, + viewPortHandler.chartHeight * legend.maxSizePercent + ) + LegendVerticalAlignment.CENTER -> Timber.e("LegendCenter/VerticalCenter not supported for PieRadarChart") + } + } + } + LegendOrientation.HORIZONTAL -> { + val yLegendOffset: Float - if (legend.verticalAlignment == LegendVerticalAlignment.TOP || - legend.verticalAlignment == LegendVerticalAlignment.BOTTOM - ) { - // It's possible that we do not need this offset anymore as it - // is available through the extraOffsets, but changing it can mean - // changing default visibility for existing apps. + if (legend.verticalAlignment == LegendVerticalAlignment.TOP || + legend.verticalAlignment == LegendVerticalAlignment.BOTTOM + ) { + // It's possible that we do not need this offset anymore as it + // is available through the extraOffsets, but changing it can mean + // changing default visibility for existing apps. - val yOffset = this.requiredLegendOffset + val yOffset = this.requiredLegendOffset - yLegendOffset = min( - legend.neededHeight + yOffset, - viewPortHandler.chartHeight * legend.maxSizePercent - ) + yLegendOffset = min( + legend.neededHeight + yOffset, + viewPortHandler.chartHeight * legend.maxSizePercent + ) - when (legend.verticalAlignment) { - LegendVerticalAlignment.TOP -> legendTop = yLegendOffset - LegendVerticalAlignment.BOTTOM -> legendBottom = yLegendOffset - LegendVerticalAlignment.CENTER -> Timber.e("LegendCenter/HorizontalCenter not supported for PieRadarChart") - } + when (legend.verticalAlignment) { + LegendVerticalAlignment.TOP -> legendTop = yLegendOffset + LegendVerticalAlignment.BOTTOM -> legendBottom = yLegendOffset + LegendVerticalAlignment.CENTER -> Timber.e("LegendCenter/HorizontalCenter not supported for PieRadarChart") } } } - - legendLeft += this.requiredBaseOffset - legendRight += this.requiredBaseOffset - legendTop += this.requiredBaseOffset - legendBottom += this.requiredBaseOffset } + + legendLeft += this.requiredBaseOffset + legendRight += this.requiredBaseOffset + legendTop += this.requiredBaseOffset + legendBottom += this.requiredBaseOffset } var minOffset = minOffset.convertDpToPixel() diff --git a/chartLib/src/main/kotlin/info/appdev/charting/charts/RadarChart.kt b/chartLib/src/main/kotlin/info/appdev/charting/charts/RadarChart.kt index 8aa64232c..5a8fc765c 100644 --- a/chartLib/src/main/kotlin/info/appdev/charting/charts/RadarChart.kt +++ b/chartLib/src/main/kotlin/info/appdev/charting/charts/RadarChart.kt @@ -123,7 +123,7 @@ open class RadarChart : PieRadarChartBase { mYAxisRenderer!!.computeAxis(mYAxis!!.mAxisMinimum, mYAxis!!.mAxisMaximum, mYAxis!!.isInverted) mXAxisRenderer!!.computeAxis(mXAxis.mAxisMinimum, mXAxis.mAxisMaximum, false) - if (legend != null && !legend!!.isLegendCustom) + if (!legend.isLegendCustom) legendRenderer?.computeLegend(data) calculateOffsets()