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 @@ -224,11 +224,6 @@ public void getBarBounds(BarEntry barEntry, RectF outputRect) {
RectF bounds = outputRect;
IBarDataSet set = mData.getDataSetForEntry(barEntry);

if (set == null) {
outputRect.set(Float.MIN_VALUE, Float.MIN_VALUE, Float.MIN_VALUE, Float.MIN_VALUE);
return;
}

float y = barEntry.getY();
float x = barEntry.getX();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import kotlin.collections.MutableList
import kotlin.collections.toTypedArray
import kotlin.math.max
import kotlin.math.min
import kotlin.requireNotNull

/**
* Class representing the legend of the chart. The legend will contain one entry
Expand Down Expand Up @@ -87,34 +86,21 @@ class Legend() : ComponentBase() {
var extraEntries: Array<LegendEntry> = arrayOf<LegendEntry>()
private set

/**
* @return true if a custom legend entries has been set default
* false (automatic legend)
*/
/**
* Are the legend labels/colors a custom value or auto calculated? If false,
* then it's auto, if true, then custom. default false (automatic legend)
*/
var isLegendCustom: Boolean = false
private set

/**
* returns the horizontal alignment of the legend
*/
/**
* sets the horizontal alignment of the legend
*/
var horizontalAlignment: LegendHorizontalAlignment? = LegendHorizontalAlignment.LEFT
/**
* returns the vertical alignment of the legend
*/
var horizontalAlignment: LegendHorizontalAlignment = LegendHorizontalAlignment.LEFT
/**
* sets the vertical alignment of the legend
*/
var verticalAlignment: LegendVerticalAlignment? = LegendVerticalAlignment.BOTTOM
/**
* returns the orientation of the legend
*/
var verticalAlignment: LegendVerticalAlignment = LegendVerticalAlignment.BOTTOM
/**
* sets the orientation of the legend
*/
Expand All @@ -126,106 +112,48 @@ class Legend() : ComponentBase() {
var isDrawInsideEnabled: Boolean = false
private set

/**
* returns the text direction of the legend
*/
/**
* sets the text direction of the legend
*/
/**
* the text direction for the legend
*/
var direction: LegendDirection? = LegendDirection.LEFT_TO_RIGHT
var direction: LegendDirection = LegendDirection.LEFT_TO_RIGHT

/**
* returns the current form/shape that is set for the legend
*/
/**
* sets the form/shape of the legend forms
*/
/**
* the shape/form the legend colors are drawn in
*/
var form: LegendForm? = LegendForm.SQUARE
var form: LegendForm = LegendForm.SQUARE

/**
* returns the size in dp of the legend forms
*/
/**
* sets the size in dp of the legend forms, default 8f
*/
/**
* the size of the legend forms/shapes
*/
var formSize: kotlin.Float = 8f

/**
* returns the line width in dp for drawing forms that consist of lines
*/
/**
* sets the line width in dp for forms that consist of lines, default 3f
*/
/**
* the size of the legend forms/shapes
*/
var formLineWidth: kotlin.Float = 3f

/**
* @return The line dash path effect used for shapes that consist of lines.
*/
/**
* Sets the line dash path effect used for shapes that consist of lines.
*/
/**
* Line dash path effect used for shapes that consist of lines.
*/
var formLineDashEffect: DashPathEffect? = null

/**
* returns the space between the legend entries on a horizontal axis in
* pixels
*/
/**
* sets the space between the legend entries on a horizontal axis in pixels,
* converts to dp internally
*/
/**
* the space between the legend entries on a horizontal axis, default 6f
*/
var xEntrySpace: kotlin.Float = 6f

/**
* returns the space between the legend entries on a vertical axis in pixels
*/
/**
* sets the space between the legend entries on a vertical axis in pixels,
* converts to dp internally
*/
/**
* the space between the legend entries on a vertical axis, default 5f
*/
var yEntrySpace: kotlin.Float = 0f

/**
* returns the space between the form and the actual label/text
*/
/**
* sets the space between the form and the actual label/text, converts to dp
* internally
*/
/**
* the space between the legend entries on a vertical axis, default 2f
* private float mYEntrySpace = 2f; / ** the space between the form and the
* actual label/text
*/
var formToTextSpace: kotlin.Float = 5f

/**
* returns the space that is left out between stacked forms (with no label)
*/
/**
* sets the space that is left out between stacked forms (with no label)
*/
/**
* the space that should be left between stacked forms
*/
Expand All @@ -239,23 +167,12 @@ class Legend() : ComponentBase() {
* piechart, then this defines the size of the rectangular bounds out of the
* size of the "hole". / default: 0.95f (95%)
*/
/**
* The maximum relative size out of the whole chart view. / If
* the legend is to the right/left of the chart, then this affects the width
* of the legend. / If the legend is to the top/bottom of the chart, then
* this affects the height of the legend. / default: 0.95f (95%)
*/
/**
* the maximum relative size out of the whole chart view in percent
*/
var maxSizePercent: kotlin.Float = 0.95f

/**
* Constructor. Provide entries for the legend.
*/
constructor(entries: Array<LegendEntry>) : this() {
requireNotNull(entries) { "entries array is NULL" }

this.entries = entries
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class LegendEntry {
*/
constructor(
label: String?,
form: LegendForm?,
form: LegendForm,
formSize: Float,
formLineWidth: Float,
formLineDashEffect: DashPathEffect?,
Expand All @@ -46,7 +46,7 @@ class LegendEntry {
* `EMPTY` will avoid drawing a form, but keep its space.
* `DEFAULT` will use the Legend's default.
*/
var form: LegendForm? = LegendForm.DEFAULT
var form: LegendForm = LegendForm.DEFAULT

/**
* Form size will be considered except for when .None is used
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class PieRadarChartTouchListener(chart: PieRadarChartBase<*>?) : ChartTouchListe
chart!!.disableScroll()
} else if (touchMode == ROTATE) {
updateGestureRotation(x, y)
chart!!.invalidate()
chart?.invalidate()
}

endAction(event)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import android.graphics.Canvas
import android.graphics.Paint
import android.graphics.Paint.Align
import android.graphics.Path
import android.util.Log
import androidx.core.graphics.withSave
import com.github.mikephil.charting.components.Legend
import com.github.mikephil.charting.components.Legend.LegendDirection
Expand Down Expand Up @@ -228,7 +227,7 @@ open class LegendRenderer(

val yOffset = legend.yOffset
val xOffset = legend.xOffset
var originPosX = 0f
var originPosX: Float

when (horizontalAlignment) {
LegendHorizontalAlignment.LEFT -> {
Expand Down Expand Up @@ -266,8 +265,6 @@ open class LegendRenderer(
legend.mNeededWidth / 2.0 - xOffset).toFloat()
}
}

null -> Log.e("Chart", "Legend horizontalAlignment is null")
}

when (orientation) {
Expand All @@ -282,10 +279,6 @@ open class LegendRenderer(
LegendVerticalAlignment.TOP -> yOffset
LegendVerticalAlignment.BOTTOM -> viewPortHandler.chartHeight - yOffset - legend.mNeededHeight
LegendVerticalAlignment.CENTER -> (viewPortHandler.chartHeight - legend.mNeededHeight) / 2f + yOffset
else -> {
Log.w("Chart", "Legend verticalAlignment not set")
0f
}
}

var lineIndex = 0
Expand Down Expand Up @@ -344,7 +337,7 @@ open class LegendRenderer(
// contains the stacked legend size in pixels
var stack = 0f
var wasStacked = false
var posY = 0f
var posY: Float

when (verticalAlignment) {
LegendVerticalAlignment.TOP -> {
Expand All @@ -366,8 +359,6 @@ open class LegendRenderer(
LegendVerticalAlignment.CENTER -> posY = (viewPortHandler.chartHeight / 2f
- legend.mNeededHeight / 2f
+ legend.yOffset)

null -> Log.w("Chart", "Legend verticalAlignment is null")
}

var i = 0
Expand Down Expand Up @@ -496,9 +487,6 @@ open class LegendRenderer(
mLineFormPath.lineTo(x + formSize, y)
canvas.drawPath(mLineFormPath, formPaint)
}

null -> Log.w( "Chart", "Legend form is null")

}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class AnotherBarActivity : DemoBase(), OnSeekBarChangeListener {
set1 = chart!!.data!!.getDataSetByIndex(0) as BarDataSet
set1.entries = values
chart!!.data!!.notifyDataChanged()
chart!!.notifyDataSetChanged()
chart?.notifyDataSetChanged()
} else {
set1 = BarDataSet(values, "Data Set")
set1.setColors(*ColorTemplate.VORDIPLOM_COLORS)
Expand All @@ -106,7 +106,7 @@ class AnotherBarActivity : DemoBase(), OnSeekBarChangeListener {
chart!!.setFitBars(true)
}

chart!!.invalidate()
chart?.invalidate()
}

override fun onCreateOptionsMenu(menu: Menu): Boolean {
Expand All @@ -128,32 +128,32 @@ class AnotherBarActivity : DemoBase(), OnSeekBarChangeListener {
it?.isDrawValues = !it.isDrawValues
}

chart!!.invalidate()
chart?.invalidate()
}

R.id.actionToggleHighlight -> {
if (chart!!.data != null) {
chart!!.data!!.isHighlightEnabled = !chart!!.data!!.isHighlightEnabled()
chart!!.invalidate()
chart?.invalidate()
}
}

R.id.actionTogglePinch -> {
if (chart!!.isPinchZoomEnabled) chart!!.setPinchZoom(false)
else chart!!.setPinchZoom(true)

chart!!.invalidate()
chart?.invalidate()
}

R.id.actionToggleAutoScaleMinMax -> {
chart!!.isAutoScaleMinMaxEnabled = !chart!!.isAutoScaleMinMaxEnabled
chart!!.notifyDataSetChanged()
chart?.notifyDataSetChanged()
}

R.id.actionToggleBarBorders -> {
for (set in chart!!.data!!.dataSets) (set as BarDataSet).barBorderWidth = if (set.barBorderWidth == 1f) 0f else 1f

chart!!.invalidate()
chart?.invalidate()
}

R.id.animateX -> {
Expand Down
Loading
Loading