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

This file was deleted.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ abstract class Chart<T : ChartData<out IDataSet<out Entry>>?> : ViewGroup, IBase
*/
protected var mSelectionListener: OnChartValueSelectedListener? = null

@JvmField
protected var chartTouchListener: ChartTouchListener<*>? = null

/**
Expand Down Expand Up @@ -242,10 +241,8 @@ abstract class Chart<T : ChartData<out IDataSet<out Entry>>?> : ViewGroup, IBase
init()
}

/**
* initialize all paints and stuff
*/
protected open fun init() {
init {
mXAxis = XAxis()
setWillNotDraw(false)

// setLayerType(View.LAYER_TYPE_HARDWARE, null);
Expand All @@ -257,15 +254,10 @@ abstract class Chart<T : ChartData<out IDataSet<out Entry>>?> : ViewGroup, IBase
// initialize the utils
Utils.init(context)
context.initUtils()
mMaxHighlightDistance = 500f.convertDpToPixel()

this.description = Description()
this.legend = Legend()

this.legendRenderer = LegendRenderer(this.viewPortHandler, this.legend!!)

mXAxis = XAxis()

mDescPaint = Paint(Paint.ANTI_ALIAS_FLAG)

mInfoPaint = Paint(Paint.ANTI_ALIAS_FLAG)
Expand All @@ -281,6 +273,14 @@ abstract class Chart<T : ChartData<out IDataSet<out Entry>>?> : ViewGroup, IBase
}
}

/**
* initialize all paints and stuff
*/
protected open fun init() {
mMaxHighlightDistance = 500f.convertDpToPixel()
this.legendRenderer = LegendRenderer(this.viewPortHandler, this.legend!!)
}

// public void initWithDummyData() {
// ColorTemplate template = new ColorTemplate();
// template.addColorsForDataSets(ColorTemplate.COLORFUL_COLORS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ open class HorizontalBarChart : BarChart {

constructor(context: Context?, attrs: AttributeSet?, defStyle: Int) : super(context, attrs, defStyle)

override fun init() {
init {
viewPortHandler = HorizontalViewPortHandler()

super.init()
Expand All @@ -46,9 +46,9 @@ open class HorizontalBarChart : BarChart {
mRenderer = HorizontalBarChartRenderer(this, mAnimator, viewPortHandler)
setHighlighter(HorizontalBarHighlighter(this))

mAxisRendererLeft = YAxisRendererHorizontalBarChart(viewPortHandler, mAxisLeft, mLeftAxisTransformer)
mAxisRendererRight = YAxisRendererHorizontalBarChart(viewPortHandler, mAxisRight, mRightAxisTransformer)
mXAxisRenderer = XAxisRendererHorizontalBarChart(viewPortHandler, mXAxis, mLeftAxisTransformer)
axisRendererLeft = YAxisRendererHorizontalBarChart(viewPortHandler, mAxisLeft, mLeftAxisTransformer)
axisRendererRight = YAxisRendererHorizontalBarChart(viewPortHandler, mAxisRight, mRightAxisTransformer)
xAxisRenderer = XAxisRendererHorizontalBarChart(viewPortHandler, mXAxis, mLeftAxisTransformer)
}

private val mOffsetsBuffer = RectF()
Expand Down Expand Up @@ -99,7 +99,7 @@ open class HorizontalBarChart : BarChart {

if (mAxisLeft.isEnabled && mAxisLeft.isDrawLabelsEnabled) {
offsets.top += mAxisLeft.getRequiredHeightSpace(
mAxisRendererLeft.paintAxisLabels
axisRendererLeft.paintAxisLabels
)
}
}
Expand All @@ -112,7 +112,7 @@ open class HorizontalBarChart : BarChart {

if (mAxisRight.isEnabled && mAxisRight.isDrawLabelsEnabled) {
offsets.bottom += mAxisRight.getRequiredHeightSpace(
mAxisRendererRight.paintAxisLabels
axisRendererRight.paintAxisLabels
)
}
}
Expand All @@ -138,11 +138,11 @@ open class HorizontalBarChart : BarChart {

// offsets for y-labels
if (mAxisLeft.needsOffset()) {
offsetTop += mAxisLeft.getRequiredHeightSpace(mAxisRendererLeft.paintAxisLabels)
offsetTop += mAxisLeft.getRequiredHeightSpace(axisRendererLeft.paintAxisLabels)
}

if (mAxisRight.needsOffset()) {
offsetBottom += mAxisRight.getRequiredHeightSpace(mAxisRendererRight.paintAxisLabels)
offsetBottom += mAxisRight.getRequiredHeightSpace(axisRendererRight.paintAxisLabels)
}

val xLabelWidth = mXAxis.mLabelWidth.toFloat()
Expand Down Expand Up @@ -175,7 +175,7 @@ open class HorizontalBarChart : BarChart {
offsetBottom += extraBottomOffset
offsetLeft += extraLeftOffset

val minOffset = mMinOffset.convertDpToPixel()
val minOffset = minOffset.convertDpToPixel()

viewPortHandler.restrainViewPort(
max(minOffset, offsetLeft),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import kotlin.math.roundToInt

open class XAxisRenderer(
viewPortHandler: ViewPortHandler,
@JvmField protected var xAxis: XAxis,
protected var xAxis: XAxis,
transformer: Transformer?
) : AxisRenderer(viewPortHandler, transformer, xAxis) {
protected fun setupGridPaint() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class BubbleChartActivity : DemoBase(), OnSeekBarChangeListener, OnChartValueSel
binding.chart1.setTouchEnabled(true)

// enable scaling and dragging
binding.chart1.setDragEnabled(true)
binding.chart1.isDragEnabled = true
binding.chart1.setScaleEnabled(true)

binding.chart1.setMaxVisibleValueCount(200)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class CubicLineChartActivity : DemoBase(), OnSeekBarChangeListener {
binding.chart1.setTouchEnabled(true)

// enable scaling and dragging
binding.chart1.setDragEnabled(true)
binding.chart1.isDragEnabled = true
binding.chart1.setScaleEnabled(true)

// if disabled, scaling can be done on x- and y-axis separately
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class InvertedLineChartActivity : DemoBase(), OnSeekBarChangeListener, OnChartVa
binding.chart1.setTouchEnabled(true)

// enable scaling and dragging
binding.chart1.setDragEnabled(true)
binding.chart1.isDragEnabled = true
binding.chart1.setScaleEnabled(true)

// if disabled, scaling can be done on x- and y-axis separately
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class LineChartActivityColored : DemoBase() {
chart.setTouchEnabled(true)

// enable scaling and dragging
chart.setDragEnabled(true)
chart.isDragEnabled = true
chart.setScaleEnabled(true)

// if disabled, scaling can be done on x- and y-axis separately
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class LineChartDualAxisActivity : DemoBase(), OnSeekBarChangeListener, OnChartVa
binding.chart1.dragDecelerationFrictionCoef = 0.9f

// enable scaling and dragging
binding.chart1.setDragEnabled(true)
binding.chart1.isDragEnabled = true
binding.chart1.setScaleEnabled(true)
binding.chart1.setDrawGridBackground(false)
binding.chart1.isHighlightPerDragEnabled = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class LineChartTimeActivity : DemoBase(), OnSeekBarChangeListener {
binding.chart1.dragDecelerationFrictionCoef = 0.9f

// enable scaling and dragging
binding.chart1.setDragEnabled(true)
binding.chart1.isDragEnabled = true
binding.chart1.setScaleEnabled(true)
binding.chart1.setDrawGridBackground(false)
binding.chart1.isHighlightPerDragEnabled = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class MultiLineChartActivity : DemoBase(), OnSeekBarChangeListener, OnChartGestu
binding.chart1.setTouchEnabled(true)

// enable scaling and dragging
binding.chart1.setDragEnabled(true)
binding.chart1.isDragEnabled = true
binding.chart1.setScaleEnabled(true)

// if disabled, scaling can be done on x- and y-axis separately
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class PerformanceLineChart : DemoBase(), OnSeekBarChangeListener {
binding.chart1.setTouchEnabled(true)

// enable scaling and dragging
binding.chart1.setDragEnabled(true)
binding.chart1.isDragEnabled = true
binding.chart1.setScaleEnabled(true)

// if disabled, scaling can be done on x- and y-axis separately
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class RealtimeLineChartActivity : DemoBase(), OnChartValueSelectedListener {
binding.chart1.setTouchEnabled(true)

// enable scaling and dragging
binding.chart1.setDragEnabled(true)
binding.chart1.isDragEnabled = true
binding.chart1.setScaleEnabled(true)
binding.chart1.setDrawGridBackground(false)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class ScatterChartActivity : DemoBase(), OnSeekBarChangeListener, OnChartValueSe
binding.chart1.maxHighlightDistance = 50f

// enable scaling and dragging
binding.chart1.setDragEnabled(true)
binding.chart1.isDragEnabled = true
binding.chart1.setScaleEnabled(true)

binding.chart1.setMaxVisibleValueCount(200)
Expand Down
Loading