@@ -11,6 +11,8 @@ import co.yml.charts.common.model.Point
1111import co.yml.charts.ui.barchart.models.BarChartType
1212import co.yml.charts.ui.barchart.models.BarData
1313import co.yml.charts.ui.barchart.models.GroupBar
14+ import co.yml.charts.ui.bubblechart.model.Bubble
15+ import co.yml.charts.ui.bubblechart.model.BubbleStyle
1416import co.yml.charts.ui.piechart.models.PieChartData
1517import kotlin.math.sin
1618import kotlin.random.Random
@@ -35,6 +37,77 @@ object DataUtils {
3537 return list
3638 }
3739
40+ /* *
41+ * Returns list of points
42+ * @param listSize: Size of total number of points needed.
43+ * @param start: X values to start from. ex: 50 to 100
44+ * @param maxRange: Max range of Y values
45+ */
46+ fun getRandomPoints (listSize : Int , start : Int = 0, maxRange : Int ): List <Point > {
47+ val list = arrayListOf<Point >()
48+ for (index in 0 until listSize) {
49+ list.add(
50+ Point (
51+ index.toFloat(),
52+ (start until maxRange).random().toFloat()
53+ )
54+ )
55+ }
56+ return list
57+ }
58+
59+ /* *
60+ * Returns list of points
61+ * @param listSize: Size of total number of points needed.
62+ * @param start: X values to start from. ex: 50 to 100
63+ * @param maxRange: Max range of Y values
64+ */
65+ fun getBubbleChartDataWithGradientStyle (
66+ points : List <Point >,
67+ minDensity : Float = 10F,
68+ maxDensity : Float = 100F
69+ ): List <Bubble > {
70+ val list = arrayListOf<Bubble >()
71+ points.forEachIndexed { index, point ->
72+ val bubbleColor = if (index % 2 == 0 ) Color .Red else Color .Blue
73+ list.add(
74+ Bubble (
75+ center = point,
76+ density = (minDensity.toInt() until maxDensity.toInt()).random().toFloat(),
77+ bubbleStyle = BubbleStyle (gradientColors = listOf (bubbleColor, Color .White ), useGradience = true )
78+ )
79+ )
80+
81+ }
82+ return list
83+ }
84+
85+ /* *
86+ * Returns list of points
87+ * @param listSize: Size of total number of points needed.
88+ * @param start: X values to start from. ex: 50 to 100
89+ * @param maxRange: Max range of Y values
90+ */
91+ fun getBubbleChartDataWithSolidStyle (
92+ points : List <Point >,
93+ minDensity : Float = 10F,
94+ maxDensity : Float = 100F
95+ ): List <Bubble > {
96+ val list = arrayListOf<Bubble >()
97+ points.forEachIndexed { index, point ->
98+ val bubbleColor = if (index % 2 == 0 ) Color .Red else Color .Blue
99+ list.add(
100+ Bubble (
101+ center = point,
102+ density = (minDensity.toInt() until maxDensity.toInt()).random().toFloat(),
103+ bubbleStyle = BubbleStyle (solidColor = bubbleColor, useGradience = false )
104+ )
105+ )
106+
107+ }
108+ return list
109+ }
110+
38111 /* *
39112 * Return the sample bar chart data
40113 * @param duration : Duration of the wave in seconds
@@ -71,6 +144,7 @@ object DataUtils {
71144 " %.2f" .format(Random .nextDouble(1.0 , maxRange.toDouble())).toFloat()
72145 )
73146 }
147+
74148 BarChartType .HORIZONTAL -> {
75149 Point (
76150 " %.2f" .format(Random .nextDouble(1.0 , maxRange.toDouble())).toFloat(),
0 commit comments