Skip to content

Commit

Permalink
Merge pull request #4 from tangem/feature/AND-7782-remove-split-lite-…
Browse files Browse the repository at this point in the history
…recreation

AND-7782 [Vico] Unnecessary recreation of the SplitLine component has been removed
  • Loading branch information
MasterBin authored Jul 31, 2024
2 parents f65f0b6 + 0dc47ff commit 68be19c
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 4 deletions.
4 changes: 4 additions & 0 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ android {
namespace "com.patrykandpatrick.vico"
}

composeCompiler {
enableStrongSkippingMode = true
}

dependencies {

implementation project(":vico:compose-m3")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,20 @@ private val x = timestampsReady.map { it.toDouble() }
private val redColor = Color(0xFFFF3333)
private val blueColor = Color(0xFF0099FF)

//val xx = listOf(
// 5656320.0,5669280.0,5696640.0,5721120.0,5771520.0,5791680.0,5810400.0,5888160.0,5912640.0,5414400.0,5456160.0,5503680.0,5505120.0,5542560.0,5578560.0,5603040.0,5627520.0,0.0,60480.0,82080.0,92160.0,151200.0,152640.0,182880.0,241920.0,259200.0,275040.0,311040.0,341280.0,364320.0,423360.0,436320.0,465120.0,499680.0,544320.0,555840.0,577440.0,609120.0,642240.0,686880.0,725760.0,756000.0,758880.0,810720.0,839520.0,869760.0,901440.0,908640.0,961920.0,983520.0,1013760.0,1058400.0,1090080.0,1108800.0,1137600.0,1159200.0,1182240.0,1221120.0,1251360.0,1283040.0,1324800.0,1347840.0,1383840.0,1398240.0,1428480.0,1455840.0,1487520.0,1520640.0,1572480.0,1604160.0,1615680.0,1648800.0,1671840.0,1716480.0,1735200.0,1758240.0,1808640.0,1831680.0,1848960.0,1887840.0,1928160.0,1939680.0,1961280.0,2011680.0,2023200.0,2053440.0,2099520.0,2128320.0,2141280.0,2167200.0,2217600.0,2221920.0,2262240.0,2285280.0,2315520.0,2347200.0,2388960.0,2404800.0,2424960.0,2468160.0,2481120.0,2512800.0,2553120.0,2592000.0,2599200.0,2640960.0,2662560.0,2697120.0,2718720.0,2756160.0,2770560.0,2816640.0,2835360.0,2865600.0,2908800.0,2933280.0,2952000.0,2999520.0,3028320.0,3041280.0,3064320.0,3108960.0,3116160.0,3157920.0,3180960.0,3216960.0,3241440.0,3260160.0,3288960.0,3319200.0,3363840.0,3378240.0,3418560.0,3432960.0,3461760.0,3492000.0,3519360.0,3574080.0,3576960.0,3615840.0,3640320.0,3673440.0,3696480.0,3732480.0,3762720.0,3803040.0,3820320.0,3843360.0,3875040.0,3896640.0,3931200.0,3954240.0,4006080.0,4010400.0,4050720.0,4078080.0,4114080.0,4142880.0,4152960.0,4190400.0,4223520.0,4245120.0,4276800.0,4322880.0,4328640.0,4363200.0,4397760.0,4429440.0,4461120.0,4488480.0,4498560.0,4534560.0,4559040.0,4596480.0,4631040.0,4651200.0,4691520.0,4700160.0,4753440.0,4763520.0,4792320.0,4826880.0,4867200.0,4887360.0,4923360.0,4932000.0,4982400.0,5009760.0,5032800.0,5073120.0,5094720.0,5103360.0,5132160.0,5188320.0,5189760.0,5220000.0,5270400.0,5297760.0,5328000.0,5333760.0,5369760.0,5918072.0
//)
//val x = run {
// val min = xx.min()
// val max = xx.max()
//
// xx.map { ((it - min) * 1000 / (max - min)).roundToInt().toDouble() }
//}
//
//val y = listOf(
// 0.57459880402,0.58913138779,0.707780710043,1.0,0.83815178279,0.79753441894,0.84181878841,0.764602731617,0.89437312525,0.40011053179,0.343256084151,0.36694570268,0.37087753949,0.510477262939,0.60307440876,0.6016741768,0.641832765814,0.001,0.001,0.001,0.0,0.0,0.001,0.001,0.001,0.001,0.002,0.015,0.007,0.012,0.007,0.006,0.008,0.004,0.005,0.005,0.0082,0.0067603983617,0.007658024428,0.0053692505765,0.006,0.003523574414,0.0036,0.0048,0.0042941126429,0.004,0.0014,0.002,0.002,0.0031,0.003,0.002,0.002,0.0021,0.003,0.003319275866,0.0031,0.0019485083319,0.002,0.002,0.0046,0.003,0.0054392657685,0.0053124970099,0.004,0.004,0.005,0.0046414319266,0.0053697531598,0.005,0.005,0.0095539301605,0.0085622388543,0.0061532343386,0.0068461604829,0.0069012666037,0.0074,0.0076949992198,0.0091,0.009,0.0117950407664,0.0145576673404,0.011,0.0153081908183,0.0167308414949,0.0119443864227,0.016,0.022,0.0326,0.0403,0.02546180117,0.03022089921,0.0574444446,0.06566975076,0.0486749038,0.07684467185,0.07940958451,0.11023767626,0.2522964316,0.2502762514,0.1964345895,0.09290592544,0.1569184411,0.09269393152,0.08984799725,0.13281393828,0.1146965061,0.08581287591,0.07959412768,0.11441048113,0.10056948078,0.099854588382,0.084662861572,0.090181249609,0.089109141273,0.0524224191038,0.0457489731835,0.0536054631717,0.0458154164217,0.0455502820994,0.0554283479907,0.053008852041,0.055266532768,0.070278753871,0.111258711737,0.104080213233,0.177045099545,0.170855833249,0.129312960482,0.14828483974,0.139482929327,0.109507994296,0.129195552676,0.126977455963,0.09709136274,0.089826196619,0.099724618635,0.140519116251,0.140399421655,0.069501399277,0.080078198652,0.092768788636,0.135455882067,0.13831477677,0.13161484199,0.124555073058,0.160830557283,0.167135053734,0.137727072896,0.139079653923,0.154719032607,0.184744585762,0.250178365273,0.246364658682,0.5580201741,0.41600361406,0.7888160261,0.838744243387,0.79849595734,0.864278411728,0.80391513646,0.478066513424,0.55539840388,0.429069783309,0.409517659292,0.65252923028,0.721309596186,0.56068254185,0.90615229645,0.9250436488,0.874604827408,0.6468637832,0.694390135,0.480845205471,0.609488519,0.60791737871,0.648995956279,0.63753889901,0.39502332972,0.393088481828,0.427232220361,0.264844113116,0.32564896507,0.333369802171,0.257340320917,0.30499905303,0.26690440492,0.290528415077,0.215638715406,0.223967999273,0.227461212078,0.23454480358,0.32496257018,0.278112210105,0.2756322826,0.389590724426,0.403333536141,0.359766641186,0.34290621483,0.359686441256,0.4297046794,0.93340870948
//)

@Composable
fun MarketDetailsChart() {
sorted
Expand Down Expand Up @@ -185,8 +199,11 @@ fun MarketDetailsChart() {
CartesianChartHost(
modifier = Modifier
.fillMaxWidth()
// .width(1000.dp)
.onGloballyPositioned {
maxCanvasX = it.size.width
// if (maxCanvasX == 0) {
maxCanvasX = it.size.width
// }
},
chart = chart,
modelProducer = modelProducer,
Expand Down
4 changes: 4 additions & 0 deletions vico/compose-m2/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ android {
}
}

composeCompiler {
enableStrongSkippingMode = true
}

dependencies {

api project(":vico:compose")
Expand Down
4 changes: 4 additions & 0 deletions vico/compose-m3/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ android {
}
}

composeCompiler {
enableStrongSkippingMode = true
}

dependencies {

api project(":vico:compose")
Expand Down
4 changes: 4 additions & 0 deletions vico/compose/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ android {
}
}

composeCompiler {
enableStrongSkippingMode = true
}

dependencies {

api project(":vico:core")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ public fun rememberSplitLine(
dataLabelRotationDegrees,
dataLabelRotationDegrees,
pointConnector,
xSplitFraction
) {
SplitLine(
shader = shader,
Expand All @@ -76,4 +75,6 @@ public fun rememberSplitLine(
pointConnector = pointConnector,
xSplitFraction = xSplitFraction
)
}.apply {
this.xSplitFraction = xSplitFraction
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import kotlinx.coroutines.sync.withLock
import kotlinx.coroutines.withContext

/** Creates [CartesianChartModel]s and handles difference animations. */
public class CartesianChartModelProducer private constructor(dispatcher: CoroutineDispatcher) {
public class CartesianChartModelProducer (dispatcher: CoroutineDispatcher) {
private var partials = emptyList<CartesianLayerModel.Partial>()
private var extraStore = MutableExtraStore()
private var cachedModel: CartesianChartModel? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class SplitLine(
dataLabelValueFormatter: CartesianValueFormatter = CartesianValueFormatter.decimal(),
dataLabelRotationDegrees: Float = 0f,
pointConnector: LineCartesianLayer.PointConnector = LineCartesianLayer.PointConnector.cubic(),
@FloatRange(from = 0.0, to = 1.0) public val xSplitFraction: Float = 1f,
@FloatRange(from = 0.0, to = 1.0) public var xSplitFraction: Float = 1f,
) : LineCartesianLayer.Line(
shader = shader,
thicknessDp = thicknessDp,
Expand All @@ -63,6 +63,7 @@ public class SplitLine(
opacity: Float,
) {
backgroundShader = backgroundShaderFirst
val xSplitFraction = xSplitFraction
when {
xSplitFraction <= 0f -> {
backgroundShader = backgroundShaderSecond
Expand Down

0 comments on commit 68be19c

Please sign in to comment.