From 4695689c5ae24566555c60e09927c9204338f93b Mon Sep 17 00:00:00 2001 From: Evgeny Goncharov Date: Fri, 9 Jul 2021 02:16:47 +0300 Subject: [PATCH] =?UTF-8?q?release/0.0.1=20=D1=80=D0=B5=D0=B0=D0=BB=D0=B8?= =?UTF-8?q?=D0=B7=D0=BE=D0=B2=D0=B0=D0=BB=D0=B8=20circle=20chart=20=D0=B2?= =?UTF-8?q?=20=D0=B2=D0=B8=D0=B4=D0=B5=20=D0=BF=D0=B5=D1=80=D0=B2=D0=BE?= =?UTF-8?q?=D0=B9=20=D0=B2=D0=B5=D1=80=D1=81=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fragments/CircleChartFragment.kt | 16 ++++++++++ .../main/res/layout/fragment_circle_chart.xml | 17 +++++++++++ .../studio/circlechart/CircleChartView.kt | 29 ++++++++++--------- 3 files changed, 48 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/com/saradey/studio/uikitview/fragments/CircleChartFragment.kt b/app/src/main/java/com/saradey/studio/uikitview/fragments/CircleChartFragment.kt index 680c0ed..6c37ec9 100644 --- a/app/src/main/java/com/saradey/studio/uikitview/fragments/CircleChartFragment.kt +++ b/app/src/main/java/com/saradey/studio/uikitview/fragments/CircleChartFragment.kt @@ -104,5 +104,21 @@ class CircleChartFragment : Fragment(R.layout.fragment_circle_chart) { .addDataValue("Fuchsia", 50, colorTest3) .addDataValue("Harmonia", 96, colorTest4) .create() + + val crcExample11 = requireView().findViewById(R.id.crcExample11) + crcExample11.Builder() + .addDataValue("Android", 100, colorTest1) + .addDataValue("Ios", 100, colorTest2) + .addDataValue("Fuchsia", 50, colorTest3) + .addDataValue("Harmonia", 96, colorTest4) + .create() + + val crcExample12 = requireView().findViewById(R.id.crcExample12) + crcExample12.Builder() + .addDataValue("Android", 100, colorTest1) + .addDataValue("Ios", 100, colorTest2) + .addDataValue("Fuchsia", 50, colorTest3) + .addDataValue("Harmonia", 96, colorTest4) + .create() } } \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_circle_chart.xml b/app/src/main/res/layout/fragment_circle_chart.xml index 0c02c6b..f236c83 100644 --- a/app/src/main/res/layout/fragment_circle_chart.xml +++ b/app/src/main/res/layout/fragment_circle_chart.xml @@ -94,5 +94,22 @@ app:arcPieMode="stroke" app:arcPieSpacePixels="3dp" app:arcPieStrokeSize="30dp" /> + + + + \ No newline at end of file diff --git a/circleChart/src/main/java/com/saradey/studio/circlechart/CircleChartView.kt b/circleChart/src/main/java/com/saradey/studio/circlechart/CircleChartView.kt index 0c183c8..869b424 100644 --- a/circleChart/src/main/java/com/saradey/studio/circlechart/CircleChartView.kt +++ b/circleChart/src/main/java/com/saradey/studio/circlechart/CircleChartView.kt @@ -67,6 +67,7 @@ class CircleChartView : View { /** Для внешней отрисовки elevation */ private var rectOutsideElevation = RectF() + /** Радиус круга в пикселях */ private var radius = 0f init { @@ -88,8 +89,6 @@ class CircleChartView : View { if (arcPieElevation) { arcPieElevationF = resources.getDimensionPixelSize(R.dimen.max_size_elevation_circle).toFloat() - } - if (arcPieElevation) { paintElevation.isAntiAlias = true paintElevation.strokeWidth = arcPieElevationF paintElevation.style = Paint.Style.STROKE @@ -108,15 +107,15 @@ class CircleChartView : View { val heightSize = MeasureSpec.getSize(heightMeasureSpec) var width = 0 var height = 0 - val dimensionPixelSize = resources.getDimensionPixelSize(R.dimen.min_chart_size) + val dimensionMinSize = resources.getDimensionPixelSize(R.dimen.min_chart_size) //если у нас выставлено wrap_content для ширины //или у нас widthSize меньше минимальной ширины //то мы делаем ширины по умолчанию, иначе мы делаем ширины //как задано в dp width = if (widthMode == MeasureSpec.AT_MOST || - dimensionPixelSize > widthSize + dimensionMinSize > widthSize ) { - dimensionPixelSize + dimensionMinSize } else { widthSize } @@ -125,9 +124,9 @@ class CircleChartView : View { //то мы делаем высоту по умолчанию, иначе мы делаем высоту //как задано в dp height = if (heightMode == MeasureSpec.AT_MOST || - dimensionPixelSize > heightSize + dimensionMinSize > heightSize ) { - dimensionPixelSize + dimensionMinSize } else { heightSize } @@ -185,13 +184,15 @@ class CircleChartView : View { private fun drawElevationCircle(canvas: Canvas) { chartsInfo.forEach { model -> - canvas.drawArc( - rectInsideElevation, - model.startAngle, - model.endAngle, - useCenter, - paintElevation - ) + if (arcPieMode == ARC_MODE_STROKE) { + canvas.drawArc( + rectInsideElevation, + model.startAngle, + model.endAngle, + useCenter, + paintElevation + ) + } canvas.drawArc( rectOutsideElevation, model.startAngle,