Skip to content

Commit 2483f4d

Browse files
committed
Now as var with additional setter
1 parent be8966b commit 2483f4d

File tree

8 files changed

+21
-15
lines changed

8 files changed

+21
-15
lines changed

app/src/main/kotlin/info/appdev/chartexample/CombinedChartActivity.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class CombinedChartActivity : DemoBase() {
112112
set.lineMode = LineDataSet.Mode.CUBIC_BEZIER
113113
set.isDrawValues = true
114114
set.valueTextSize = 10f
115-
set.setValueTextColor(Color.rgb(240, 238, 70))
115+
set.valueTextColor = Color.rgb(240, 238, 70)
116116

117117
set.axisDependency = YAxis.AxisDependency.LEFT
118118
d.addDataSet(set)
@@ -133,14 +133,14 @@ class CombinedChartActivity : DemoBase() {
133133

134134
val set1 = BarDataSet(entries1, "Bar 1")
135135
set1.color = Color.rgb(60, 220, 78)
136-
set1.setValueTextColor(Color.rgb(60, 220, 78))
136+
set1.valueTextColor = Color.rgb(60, 220, 78)
137137
set1.valueTextSize = 10f
138138
set1.axisDependency = YAxis.AxisDependency.LEFT
139139

140140
val set2 = BarDataSet(entries2, "")
141141
set2.stackLabels = mutableListOf("Stack 1", "Stack 2")
142142
set2.setColors(Color.rgb(61, 165, 255), Color.rgb(23, 197, 255))
143-
set2.setValueTextColor(Color.rgb(61, 165, 255))
143+
set2.valueTextColor = Color.rgb(61, 165, 255)
144144
set2.valueTextSize = 10f
145145
set2.axisDependency = YAxis.AxisDependency.LEFT
146146

@@ -215,7 +215,7 @@ class CombinedChartActivity : DemoBase() {
215215
val set = BubbleDataSet(entries, "Bubble DataSet")
216216
set.setColors(*ColorTemplate.VORDIPLOM_COLORS)
217217
set.valueTextSize = 10f
218-
set.setValueTextColor(Color.WHITE)
218+
set.valueTextColor = Color.WHITE
219219
set.highlightCircleWidth = 1.5f
220220
set.isDrawValues = true
221221
bd.addDataSet(set)

app/src/main/kotlin/info/appdev/chartexample/DynamicalAddingActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ class DynamicalAddingActivity : DemoBase(), OnChartValueSelectedListener {
127127
set.setCircleColor(color)
128128
set.highLightColor = color
129129
set.valueTextSize = 10f
130-
set.setValueTextColor(color)
130+
set.valueTextColor = color
131131

132132
data.addDataSet(set)
133133
data.notifyDataChanged()

app/src/main/kotlin/info/appdev/chartexample/LineChartTimeActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ class LineChartTimeActivity : DemoBase(), OnSeekBarChangeListener {
126126
val set1 = LineDataSet(values, "DataSet 1")
127127
set1.axisDependency = AxisDependency.LEFT
128128
set1.color = holoBlue
129-
set1.setValueTextColor(holoBlue)
129+
set1.valueTextColor = holoBlue
130130
set1.lineWidth = 1.5f
131131
set1.isDrawCirclesEnabled = false
132132
set1.isDrawValues = false

app/src/main/kotlin/info/appdev/chartexample/RealtimeLineChartActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ class RealtimeLineChartActivity : DemoBase(), OnChartValueSelectedListener {
122122
set.fillAlpha = 65
123123
set.fillColor = ColorTemplate.holoBlue
124124
set.highLightColor = Color.rgb(244, 117, 117)
125-
set.setValueTextColor(Color.WHITE)
125+
set.valueTextColor = Color.WHITE
126126
set.valueTextSize = 9f
127127
set.isDrawValues = false
128128
return set

app/src/main/kotlin/info/appdev/chartexample/fragments/SimpleFragment.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ abstract class SimpleFragment : Fragment() {
101101
val ds1 = PieDataSet(entries1, "Quarterly Revenues 2015")
102102
ds1.setColors(*ColorTemplate.VORDIPLOM_COLORS)
103103
ds1.sliceSpace = 2f
104-
ds1.setValueTextColor(Color.WHITE)
104+
ds1.valueTextColor = Color.WHITE
105105
ds1.valueTextSize = 12f
106106

107107
val d = PieData(ds1)

chartLib/src/main/kotlin/info/appdev/charting/data/BaseDataSet.kt

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -272,15 +272,20 @@ abstract class BaseDataSet<T : Entry>() : IDataSet<T> {
272272
mValueColors = value
273273
}
274274

275+
override var valueTextColor: Int
276+
get() = if (mValueColors.isEmpty())
277+
0
278+
else
279+
mValueColors[0]
280+
set(value) {
281+
mValueColors.clear()
282+
mValueColors.add(value)
283+
}
284+
275285
override fun getValueTextColor(value: Int): Int {
276286
return mValueColors[value % mValueColors.size]
277287
}
278288

279-
override fun setValueTextColor(value: Int) {
280-
mValueColors.clear()
281-
mValueColors.add(value)
282-
}
283-
284289
override var valueTypeface: Typeface?
285290
get() = mValueTypeface
286291
set(value) {

chartLib/src/main/kotlin/info/appdev/charting/data/ChartData.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ abstract class ChartData<T : IDataSet<out Entry>> : Serializable {
551551
*/
552552
fun setValueTextColor(color: Int) {
553553
for (set in this.dataSets!!) {
554-
set.setValueTextColor(color)
554+
set.valueTextColor = color
555555
}
556556
}
557557

chartLib/src/main/kotlin/info/appdev/charting/interfaces/datasets/IDataSet.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,9 @@ interface IDataSet<T : Entry> {
228228
/**
229229
* Sets the color the value-labels of this DataSet should have.
230230
*/
231+
var valueTextColor: Int
232+
// This getter is necessary because of the parameter value
231233
fun getValueTextColor(value: Int): Int
232-
fun setValueTextColor(value: Int)
233234

234235
var valueTextColors: MutableList<Int>
235236

0 commit comments

Comments
 (0)