Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ open class LineDataSet(yVals: MutableList<Entry>?, label: String = "") : LineRad
/**
* List representing all colors that are used for the circles
*/
var circleColors: MutableList<Int?>? = null
var circleColors: MutableList<Int>? = null

/**
* the color of the inner circles
Expand Down Expand Up @@ -73,7 +73,7 @@ open class LineDataSet(yVals: MutableList<Entry>?, label: String = "") : LineRad
// mCircleRadius = UtilsKtKt.convertDpToPixel(4f);
// mLineWidth = UtilsKtKt.convertDpToPixel(1f);
if (this.circleColors == null) {
this.circleColors = ArrayList<Int?>()
this.circleColors = ArrayList<Int>()
}
circleColors!!.clear()

Expand Down Expand Up @@ -198,7 +198,7 @@ open class LineDataSet(yVals: MutableList<Entry>?, label: String = "") : LineRad
}

override fun getCircleColor(index: Int): Int {
return circleColors!![index]!!
return circleColors!![index]
}

override val circleColorCount: Int
Expand Down Expand Up @@ -267,15 +267,15 @@ open class LineDataSet(yVals: MutableList<Entry>?, label: String = "") : LineRad
* this method. Internally, the colors are resolved using
* getResources().getColor(...)
*/
fun setCircleColors(colors: IntArray, c: Context) {
fun setCircleColors(colors: IntArray, context: Context) {
var clrs = this.circleColors
if (clrs == null) {
clrs = ArrayList()
}
clrs.clear()

for (color in colors) {
clrs.add(c.resources.getColor(color))
clrs.add(context.resources.getColor(color))
}

this.circleColors = clrs
Expand All @@ -295,7 +295,7 @@ open class LineDataSet(yVals: MutableList<Entry>?, label: String = "") : LineRad
*/
fun resetCircleColors() {
if (this.circleColors == null) {
this.circleColors = ArrayList<Int?>()
this.circleColors = ArrayList()
}
circleColors!!.clear()
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package com.github.mikephil.charting.utils

import android.graphics.Color

/**
* Class that holds predefined color integer arrays (e.g.
* ColorTemplate.VORDIPLOM_COLORS) and convenience methods for loading colors
* from resources.
*/
object ColorTemplate {
/**
* an "invalid" color that indicates that no color is set
*/
const val COLOR_NONE: Int = 0x00112233

/**
* this "color" is used for the Legend creation and indicates that the next
* form should be skipped
*/
const val COLOR_SKIP: Int = 0x00112234

/**
* THE COLOR THEMES ARE PREDEFINED (predefined color integer arrays), FEEL
* FREE TO CREATE YOUR OWN WITH AS MANY DIFFERENT COLORS AS YOU WANT
*/
val LIBERTY_COLORS: IntArray = intArrayOf(
Color.rgb(207, 248, 246), Color.rgb(148, 212, 212), Color.rgb(136, 180, 187),
Color.rgb(118, 174, 175), Color.rgb(42, 109, 130)
)
val JOYFUL_COLORS: IntArray = intArrayOf(
Color.rgb(217, 80, 138), Color.rgb(254, 149, 7), Color.rgb(254, 247, 120),
Color.rgb(106, 167, 134), Color.rgb(53, 194, 209)
)
val PASTEL_COLORS: IntArray = intArrayOf(
Color.rgb(64, 89, 128), Color.rgb(149, 165, 124), Color.rgb(217, 184, 162),
Color.rgb(191, 134, 134), Color.rgb(179, 48, 80)
)
val COLORFUL_COLORS: IntArray = intArrayOf(
Color.rgb(193, 37, 82), Color.rgb(255, 102, 0), Color.rgb(245, 199, 0),
Color.rgb(106, 150, 31), Color.rgb(179, 100, 53)
)
val VORDIPLOM_COLORS: IntArray = intArrayOf(
Color.rgb(192, 255, 140), Color.rgb(255, 247, 140), Color.rgb(255, 208, 140),
Color.rgb(140, 234, 255), Color.rgb(255, 140, 157)
)
val MATERIAL_COLORS: IntArray = intArrayOf(
rgb("#2ecc71"), rgb("#f1c40f"), rgb("#e74c3c"), rgb("#3498db")
)

/**
* Converts the given hex-color-string to rgb.
*/
fun rgb(hex: String): Int {
val color = hex.replace("#", "").toLong(16).toInt()
val r = (color shr 16) and 0xFF
val g = (color shr 8) and 0xFF
val b = (color) and 0xFF
return Color.rgb(r, g, b)
}

val holoBlue: Int
/**
* Returns the Android ICS holo blue light color.
*/
get() = Color.rgb(51, 181, 229)

/**
* Sets the alpha component of the given color.
* @param alpha 0 - 255
*/
fun colorWithAlpha(color: Int, alpha: Int): Int {
return (color and 0xffffff) or ((alpha and 0xff) shl 24)
}

/**
* Turns an array of colors (integer color values) into an ArrayList of colors.
*/
fun createColors(colors: IntArray): MutableList<Int> {
val result: MutableList<Int> = ArrayList()

for (i in colors) {
result.add(i)
}

return result
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import android.text.SpannableString
import android.text.style.ForegroundColorSpan
import android.text.style.RelativeSizeSpan
import android.text.style.StyleSpan
import android.util.DisplayMetrics
import android.view.Menu
import android.view.MenuItem
import android.widget.RelativeLayout
Expand Down Expand Up @@ -113,7 +112,7 @@ class HalfPieChartActivity : DemoBase() {
s.setSpan(ForegroundColorSpan(Color.GRAY), 14, s.length - 15, 0)
s.setSpan(RelativeSizeSpan(.8f), 14, s.length - 15, 0)
s.setSpan(StyleSpan(Typeface.ITALIC), s.length - 14, s.length, 0)
s.setSpan(ForegroundColorSpan(ColorTemplate.getHoloBlue()), s.length - 14, s.length, 0)
s.setSpan(ForegroundColorSpan(ColorTemplate.holoBlue), s.length - 14, s.length, 0)
return s
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class LineChartDualAxisActivity : DemoBase(), OnSeekBarChangeListener, OnChartVa

val leftAxis = chart!!.axisLeft
leftAxis.typeface = tfLight
leftAxis.textColor = ColorTemplate.getHoloBlue()
leftAxis.textColor = ColorTemplate.holoBlue
leftAxis.axisMaximum = 200f
leftAxis.axisMinimum = 0f
leftAxis.setDrawGridLines(true)
Expand Down Expand Up @@ -163,12 +163,12 @@ class LineChartDualAxisActivity : DemoBase(), OnSeekBarChangeListener, OnChartVa
set1 = LineDataSet(values1, "DataSet 1")

set1.axisDependency = AxisDependency.LEFT
set1.color = ColorTemplate.getHoloBlue()
set1.color = ColorTemplate.holoBlue
set1.setCircleColor(Color.WHITE)
set1.lineWidth = 2f
set1.circleRadius = 3f
set1.fillAlpha = 65
set1.fillColor = ColorTemplate.getHoloBlue()
set1.fillColor = ColorTemplate.holoBlue
set1.highLightColor = Color.rgb(244, 117, 117)
set1.isDrawCircleHoleEnabled = false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class LineChartTimeActivity : DemoBase(), OnSeekBarChangeListener {
val leftAxis = chart!!.axisLeft
leftAxis.setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART)
leftAxis.typeface = tfLight
leftAxis.textColor = ColorTemplate.getHoloBlue()
leftAxis.textColor = ColorTemplate.holoBlue
leftAxis.setDrawGridLines(true)
leftAxis.isGranularityEnabled = true
leftAxis.axisMinimum = 0f
Expand All @@ -118,10 +118,9 @@ class LineChartTimeActivity : DemoBase(), OnSeekBarChangeListener {
// increment by 1 hour
var x = now.toFloat()
while (x < to) {
val y: Float
if (count == 100) // initial
y = (valuesData[x.roundToInt()])!!.toFloat() * 50 + 50
else y = (Math.random() * 50 + 50).toFloat() // manually triggered
val y: Float = if (count == 100) // initial
(valuesData[x.roundToInt()])!!.toFloat() * 50 + 50
else (Math.random() * 50 + 50).toFloat() // manually triggered

values.add(Entry(x, y)) // add one entry per hour
x++
Expand All @@ -130,13 +129,13 @@ class LineChartTimeActivity : DemoBase(), OnSeekBarChangeListener {
// create a dataset and give it a type
val set1 = LineDataSet(values, "DataSet 1")
set1.axisDependency = AxisDependency.LEFT
set1.color = ColorTemplate.getHoloBlue()
set1.setSingleValueTextColor(ColorTemplate.getHoloBlue())
set1.color = ColorTemplate.holoBlue
set1.setSingleValueTextColor(ColorTemplate.holoBlue)
set1.lineWidth = 1.5f
set1.isDrawCirclesEnabled = false
set1.isDrawValues = false
set1.fillAlpha = 65
set1.fillColor = ColorTemplate.getHoloBlue()
set1.fillColor = ColorTemplate.holoBlue
set1.highLightColor = Color.rgb(244, 117, 117)
set1.isDrawCircleHoleEnabled = false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class PieChartActivity : DemoBase(), OnSeekBarChangeListener, OnChartValueSelect

for (c in ColorTemplate.PASTEL_COLORS) colors.add(c)

colors.add(ColorTemplate.getHoloBlue())
colors.add(ColorTemplate.holoBlue)

dataSet.setColors(colors)

Expand Down Expand Up @@ -274,7 +274,7 @@ class PieChartActivity : DemoBase(), OnSeekBarChangeListener, OnChartValueSelect
s.setSpan(ForegroundColorSpan(Color.GRAY), 14, s.length - 15, 0)
s.setSpan(RelativeSizeSpan(.8f), 14, s.length - 15, 0)
s.setSpan(StyleSpan(Typeface.ITALIC), s.length - 14, s.length, 0)
s.setSpan(ForegroundColorSpan(ColorTemplate.getHoloBlue()), s.length - 14, s.length, 0)
s.setSpan(ForegroundColorSpan(ColorTemplate.holoBlue), s.length - 14, s.length, 0)
return s
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class PieChartRoundedActivity : DemoBase(), OnSeekBarChangeListener, OnChartValu

for (c in ColorTemplate.PASTEL_COLORS) colors.add(c)

colors.add(ColorTemplate.getHoloBlue())
colors.add(ColorTemplate.holoBlue)

dataSet.setColors(colors)

Expand Down Expand Up @@ -279,7 +279,7 @@ class PieChartRoundedActivity : DemoBase(), OnSeekBarChangeListener, OnChartValu
s.setSpan(ForegroundColorSpan(Color.GRAY), 14, s.length - 15, 0)
s.setSpan(RelativeSizeSpan(.8f), 14, s.length - 15, 0)
s.setSpan(StyleSpan(Typeface.ITALIC), s.length - 14, s.length, 0)
s.setSpan(ForegroundColorSpan(ColorTemplate.getHoloBlue()), s.length - 14, s.length, 0)
s.setSpan(ForegroundColorSpan(ColorTemplate.holoBlue), s.length - 14, s.length, 0)
return s
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class PiePolylineChartActivity : DemoBase(), OnSeekBarChangeListener, OnChartVal

for (c in ColorTemplate.PASTEL_COLORS) colors.add(c)

colors.add(ColorTemplate.getHoloBlue())
colors.add(ColorTemplate.holoBlue)

dataSet.setColors(colors)

Expand Down Expand Up @@ -261,7 +261,7 @@ class PiePolylineChartActivity : DemoBase(), OnSeekBarChangeListener, OnChartVal
s.setSpan(ForegroundColorSpan(Color.GRAY), 12, s.length - 10, 0)
s.setSpan(RelativeSizeSpan(.65f), 12, s.length - 10, 0)
s.setSpan(StyleSpan(Typeface.ITALIC), s.length - 10, s.length, 0)
s.setSpan(ForegroundColorSpan(ColorTemplate.getHoloBlue()), s.length - 10, s.length, 0)
s.setSpan(ForegroundColorSpan(ColorTemplate.holoBlue), s.length - 10, s.length, 0)
return s
}

Expand Down
Loading
Loading