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 @@ -176,8 +176,7 @@ abstract class DataSet<T : Entry>(
}

/**
* Returns a simple string representation of the DataSet with the type and
* the number of Entries.
* Returns a simple string representation of the DataSet with the type and the number of Entries.
*/
fun toSimpleString() = "DataSet, label: $label, entries: ${mEntries!!.size}"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import com.github.mikephil.charting.utils.ColorTemplate

open class ScatterDataSet(yVals: MutableList<Entry>?, label: String = "") : LineScatterCandleRadarDataSet<Entry>(yVals, label), IScatterDataSet {
/**
* the size the scattershape will have, in density pixels
* the size the scatterShape will have, in density pixels
*/
private var shapeSize = 15f

Expand Down Expand Up @@ -56,18 +56,6 @@ open class ScatterDataSet(yVals: MutableList<Entry>?, label: String = "") : Line
scatterDataSet.mScatterShapeHoleColor = mScatterShapeHoleColor
}

/**
* Sets the size in density pixels the drawn scattershape will have. This
* only applies for non custom shapes.
*/
fun setScatterShapeSize(size: Float) {
shapeSize = size
}

override fun getScatterShapeSize(): Float {
return shapeSize
}

/**
* Sets the ScatterShape this DataSet should be drawn with. This will search for an available IShapeRenderer and set this
* renderer for the DataSet.
Expand All @@ -77,39 +65,34 @@ open class ScatterDataSet(yVals: MutableList<Entry>?, label: String = "") : Line
}

/**
* Sets a new IShapeRenderer responsible for drawing this DataSet.
* This can also be used to set a custom IShapeRenderer aside from the default ones.
*/
fun setShapeRenderer(shape: IShapeRenderer?) {
mShapeRenderer = shape
}

override fun getShapeRenderer(): IShapeRenderer? {
return mShapeRenderer
}

/**
* Sets the radius of the hole in the shape (applies to Square, Circle and Triangle)
* Set this to <= 0 to remove holes.
* Sets the size in density pixels the drawn scatterShape will have. This
* only applies for non custom shapes.
*/
fun setScatterShapeHoleRadius(holeRadius: Float) {
mScatterShapeHoleRadius = holeRadius
}

override fun getScatterShapeHoleRadius(): Float {
return mScatterShapeHoleRadius
}
override var scatterShapeSize: Float
get() = shapeSize
set(value) {
shapeSize = value
}
override var scatterShapeHoleRadius: Float
get() = mScatterShapeHoleRadius
set(value) {
mScatterShapeHoleRadius = value
}
override var scatterShapeHoleColor: Int
get() = mScatterShapeHoleColor
set(value) {
mScatterShapeHoleColor = value
}

/**
* Sets the color for the hole in the shape.
* Sets a new IShapeRenderer responsible for drawing this DataSet.
* This can also be used to set a custom IShapeRenderer aside from the default ones.
*/
fun setScatterShapeHoleColor(holeColor: Int) {
mScatterShapeHoleColor = holeColor
}

override fun getScatterShapeHoleColor(): Int {
return mScatterShapeHoleColor
}
override var shapeRenderer: IShapeRenderer?
get() = mShapeRenderer
set(value) {
mShapeRenderer = value
}

companion object {
fun getRendererForShape(shape: ScatterShape): IShapeRenderer? {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.github.mikephil.charting.interfaces.datasets

import com.github.mikephil.charting.data.Entry
import com.github.mikephil.charting.renderer.scatter.IShapeRenderer

interface IScatterDataSet : ILineScatterCandleRadarDataSet<Entry> {
/**
* the currently set scatter shape size
*/
val scatterShapeSize: Float

/**
* radius of the hole in the shape
*/
val scatterShapeHoleRadius: Float

/**
* the color for the hole in the shape
*/
val scatterShapeHoleColor: Int

/**
* the IShapeRenderer responsible for rendering this DataSet.
*/
val shapeRenderer: IShapeRenderer?
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ChevronDownShapeRenderer : IShapeRenderer {
canvas: Canvas, dataSet: IScatterDataSet, viewPortHandler: ViewPortHandler?,
posX: Float, posY: Float, renderPaint: Paint
) {
val shapeHalf = dataSet.getScatterShapeSize().convertDpToPixel() / 2f
val shapeHalf = dataSet.scatterShapeSize.convertDpToPixel() / 2f

renderPaint.style = Paint.Style.STROKE
renderPaint.strokeWidth = 1f.convertDpToPixel()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ChevronUpShapeRenderer : IShapeRenderer {
canvas: Canvas, dataSet: IScatterDataSet, viewPortHandler: ViewPortHandler?,
posX: Float, posY: Float, renderPaint: Paint
) {
val shapeHalf = dataSet.getScatterShapeSize().convertDpToPixel() / 2f
val shapeHalf = dataSet.scatterShapeSize.convertDpToPixel() / 2f

renderPaint.style = Paint.Style.STROKE
renderPaint.strokeWidth = 1f.convertDpToPixel()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ class CircleShapeRenderer : IShapeRenderer {
canvas: Canvas, dataSet: IScatterDataSet, viewPortHandler: ViewPortHandler?,
posX: Float, posY: Float, renderPaint: Paint
) {
val shapeSize = dataSet.getScatterShapeSize().convertDpToPixel()
val shapeSize = dataSet.scatterShapeSize.convertDpToPixel()
val shapeHalf = shapeSize / 2f
val shapeHoleSizeHalf = dataSet.getScatterShapeHoleRadius().convertDpToPixel()
val shapeHoleSizeHalf = dataSet.scatterShapeHoleRadius.convertDpToPixel()
val shapeHoleSize = shapeHoleSizeHalf * 2f
val shapeStrokeSize = (shapeSize - shapeHoleSize) / 2f
val shapeStrokeSizeHalf = shapeStrokeSize / 2f

val shapeHoleColor = dataSet.getScatterShapeHoleColor()
val shapeHoleColor = dataSet.scatterShapeHoleColor

if (shapeSize > 0.0) {
renderPaint.style = Paint.Style.STROKE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class CrossShapeRenderer : IShapeRenderer {
canvas: Canvas, dataSet: IScatterDataSet, viewPortHandler: ViewPortHandler?,
posX: Float, posY: Float, renderPaint: Paint
) {
val shapeHalf = dataSet.getScatterShapeSize().convertDpToPixel() / 2f
val shapeHalf = dataSet.scatterShapeSize.convertDpToPixel() / 2f

renderPaint.style = Paint.Style.STROKE
renderPaint.strokeWidth = 1f.convertDpToPixel()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ class SquareShapeRenderer : IShapeRenderer {
canvas: Canvas, dataSet: IScatterDataSet, viewPortHandler: ViewPortHandler?,
posX: Float, posY: Float, renderPaint: Paint
) {
val shapeSize = dataSet.getScatterShapeSize().convertDpToPixel()
val shapeSize = dataSet.scatterShapeSize.convertDpToPixel()
val shapeHalf = shapeSize / 2f
val shapeHoleSizeHalf = dataSet.getScatterShapeHoleRadius().convertDpToPixel()
val shapeHoleSizeHalf = dataSet.scatterShapeHoleRadius.convertDpToPixel()
val shapeHoleSize = shapeHoleSizeHalf * 2f
val shapeStrokeSize = (shapeSize - shapeHoleSize) / 2f
val shapeStrokeSizeHalf = shapeStrokeSize / 2f

val shapeHoleColor = dataSet.getScatterShapeHoleColor()
val shapeHoleColor = dataSet.scatterShapeHoleColor

if (shapeSize > 0.0) {
renderPaint.style = Paint.Style.STROKE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ open class TriangleShapeRenderer : IShapeRenderer {
canvas: Canvas, dataSet: IScatterDataSet, viewPortHandler: ViewPortHandler?,
posX: Float, posY: Float, renderPaint: Paint
) {
val shapeSize = dataSet.getScatterShapeSize().convertDpToPixel()
val shapeSize = dataSet.scatterShapeSize.convertDpToPixel()
val shapeHalf = shapeSize / 2f
val shapeHoleSizeHalf = dataSet.getScatterShapeHoleRadius().convertDpToPixel()
val shapeHoleSizeHalf = dataSet.scatterShapeHoleRadius.convertDpToPixel()
val shapeHoleSize = shapeHoleSizeHalf * 2f
val shapeStrokeSize = (shapeSize - shapeHoleSize) / 2f

val shapeHoleColor = dataSet.getScatterShapeHoleColor()
val shapeHoleColor = dataSet.scatterShapeHoleColor

renderPaint.style = Paint.Style.FILL

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class XShapeRenderer : IShapeRenderer {
canvas: Canvas, dataSet: IScatterDataSet, viewPortHandler: ViewPortHandler?,
posX: Float, posY: Float, renderPaint: Paint
) {
val shapeHalf = dataSet.getScatterShapeSize().convertDpToPixel() / 2f
val shapeHalf = dataSet.scatterShapeSize.convertDpToPixel() / 2f

renderPaint.style = Paint.Style.STROKE
renderPaint.strokeWidth = 1f.convertDpToPixel()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class CustomScatterShapeRenderer : IShapeRenderer {
canvas: Canvas, dataSet: IScatterDataSet, viewPortHandler: ViewPortHandler?,
posX: Float, posY: Float, renderPaint: Paint
) {
val shapeHalf = dataSet.getScatterShapeSize().convertDpToPixel() / 2f
val shapeHalf = dataSet.scatterShapeSize.convertDpToPixel() / 2f

canvas.drawLine(
posX - shapeHalf,
Expand Down
Loading