1
1
# YCharts
2
2
3
- YCharts is a light and extensible chart library for Jetpack Compose system. It comprises two main modules:
3
+ YCharts is a Jetpack-compose based charts library which enables developers to easily integrate various types of charts/graphs into their existing ui to visually represent statistical data. YCharts supports both cartesian(XY-charts) and polar charts(Radial charts), which include:
4
+
5
+ A. Cartesian charts:
6
+ 1 . Line chart
7
+ <div >
8
+ <figure >
9
+ <img width =100 src =" https://github.com/AkYML/YCharts/assets/102035914/58352fc4-8039-46e6-9248-1f338efc705d " />
10
+ </figure >
11
+ </div >
12
+
13
+ 2 . Bar chart
14
+ <div >
15
+ <figure >
16
+ <img width =100 src =" https://github.com/AkYML/YCharts/assets/102035914/5af22ba1-232f-4d1a-8067-c08f56a61b13 " />
17
+ </figure >
18
+ </div >
19
+
20
+ 3 . Wave chart
21
+ <div >
22
+ <figure >
23
+ <img width =100 src =" https://github.com/AkYML/YCharts/assets/102035914/be694054-d5cc-49ec-b7ee-be80c1562df7 " />
24
+ </figure >
25
+ </div >
26
+
27
+ 4 . Bubble chart
28
+ <div >
29
+ <figure >
30
+ <img width =100 src =" https://github.com/AkYML/YCharts/assets/102035914/cb177d4d-3fa8-4171-b3bd-7064458b1964 " />
31
+ </figure >
32
+ </div >
33
+ 5 . Combined chart
34
+ <div >
35
+ <figure >
36
+ <img width =100 src =" https://github.com/AkYML/YCharts/assets/102035914/809bff58-a857-4ed1-8415-cd1d97be300f " />
37
+ </figure >
38
+ </div >
39
+
40
+ B.Radial charts:
41
+ 1 . Pie chart
42
+ <div >
43
+ <figure >
44
+ <img width =100 src =" https://github.com/AkYML/YCharts/assets/102035914/ac6eb6c7-033d-439b-b416-d6083ba0ee83 " />
45
+ </figure >
46
+ </div >
47
+ 2 . Donut chart
48
+ <div >
49
+ <figure >
50
+ <img width =100 src =" https://github.com/AkYML/YCharts/assets/102035914/3296d983-4a9a-4b91-8b46-49f84a80041c " />
51
+ </figure >
52
+ </div >
53
+
54
+
55
+
56
+
57
+ It comprises two main modules:
4
58
5
59
- ` YChartslib ` (Chart components for Jetpack Compose)
6
60
- ` app ` (sample app to showcase chart components)
@@ -12,7 +66,7 @@ You can add the library via Maven:
12
66
Gradle:
13
67
14
68
``` groovy
15
- implementation 'co.yml:ycharts:2.0 .0'
69
+ implementation 'co.yml:ycharts:2.1 .0'
16
70
```
17
71
18
72
## Modules
@@ -100,11 +154,18 @@ Let's see how we can use the chart components and style them with available cust
100
154
101
155
<figure >
102
156
<div align = " center " >
103
- <img width=317 src="https://user-images.githubusercontent.com/107846675/189699724-c8064338-8894-45e2-b60b-3d830123e813.png" />
104
- <p> Line chart looks like this!</p>
157
+ <img width=317 src="https://github.com/AkYML/YCharts/assets/102035914/58352fc4-8039-46e6-9248-1f338efc705d"/>
158
+ <p> Line chart looks like this! </p>
159
+
160
+ <img width =317 src =" https://github.com/AkYML/YCharts/assets/102035914/a5d5c153-c2df-43d7-8d05-41548ed64e5c " />
161
+ <p> Line chart with dots looks like this! </p>
162
+
105
163
</div >
106
164
</figure >
107
165
166
+
167
+
168
+
108
169
### 2. Bar Chart:
109
170
110
171
- Create list of barChartData using the random generator extension and ` BarData ` data class.
@@ -152,11 +213,15 @@ Let's see how we can use the chart components and style them with available cust
152
213
153
214
<figure >
154
215
<div align = " center " >
155
- <img width=347 src="https://user-images.githubusercontent. com/107846675/189836621-eeac8181-f7de-491e-8fd8-7e1276e2fb9f.png " />
216
+ <img width=347 src="https://github. com/AkYML/YCharts/assets/102035914/0d2a6cfd-98c4-46ee-92a7-b88814f8d186 " />
156
217
<p> Bar chart looks like this!</p>
218
+ <img width=347 src="https://github.com/AkYML/YCharts/assets/102035914/6dec92d7-95ed-4892-89b7-44a03d0711b9" />
219
+ <p> Horizontal Bar chart looks like this!</p>
220
+
157
221
</div >
158
222
</figure >
159
223
224
+
160
225
### 3. Grouped Bar Chart:
161
226
162
227
- Create list of grouped combinations of bar chart data using the random generator extension and ` BarPlotData ` data class.
@@ -208,8 +273,10 @@ Let's see how we can use the chart components and style them with available cust
208
273
209
274
<figure >
210
275
<div align = " center " >
211
- <img width=338 src="https://user-images.githubusercontent. com/107846675/189845009-6ef2ccc6-3c75-446e-9273-fe1b1e1e94d0.png " />
276
+ <img width=338 src="https://github. com/AkYML/YCharts/assets/102035914/55df945d-bcd9-4b08-b47e-5d439a7abf39 " />
212
277
<p> Grouped Bar chart looks like this!</p>
278
+ <img width=338 src="https://github.com/AkYML/YCharts/assets/102035914/00af9045-4054-4544-b4c5-93b568df2b85" />
279
+ <p> Stacked Bar chart looks like this!</p>
213
280
</div >
214
281
</figure >
215
282
@@ -253,11 +320,20 @@ Let's see how we can use the chart components and style them with available cust
253
320
254
321
<figure >
255
322
<div align = " center " >
256
- <img width=238 src="https://user-images.githubusercontent. com/107846675/189865767-377f3b12-1568-46c9-a248-6454ed9bb96e.png " />
323
+ <img width=238 src="https://github. com/AkYML/YCharts/assets/102035914/457b6034-eef0-4f70-bd40-0fc0e950298a " />
257
324
<p> Pie chart looks like this!</p>
325
+
326
+ <img width=238 src="https://github.com/AkYML/YCharts/assets/102035914/ac6eb6c7-033d-439b-b416-d6083ba0ee83" />
327
+ <p> Pie chart with lables like this!</p>
328
+
258
329
</div >
259
330
</figure >
260
331
332
+
333
+
334
+
335
+
336
+
261
337
### 5. Donut Chart:
262
338
263
339
- Similar to pie chart here we need create list of slices using the ` PieChartData ` data class.
@@ -300,11 +376,14 @@ Let's see how we can use the chart components and style them with available cust
300
376
301
377
<figure >
302
378
<div align = " center " >
303
- <img width=233 src="https://user-images.githubusercontent. com/107846675/189868490-cbaecf87-2beb-4788-ba8e-f57b667cbf10.png " />
379
+ <img width=233 src="https://github. com/AkYML/YCharts/assets/102035914/3296d983-4a9a-4b91-8b46-49f84a80041c " />
304
380
<p> Donut chart looks like this!</p>
305
381
</div >
306
382
</figure >
307
383
384
+
385
+
386
+
308
387
### 6. Combined Chart:
309
388
310
389
- Similar to line and bar chart we can combine both entities in one chart, just need to initialize the line and bar plot data using the random generator extension and add styling related to individual component.
@@ -374,12 +453,162 @@ Let's see how we can use the chart components and style them with available cust
374
453
_ Note_ : To show legends infomartion related to bar, ` Legends ` component can be used.
375
454
<figure >
376
455
<div align = " center " >
377
- <img width=292 src="https://user-images.githubusercontent. com/107846675/192773924-74421edd-7314-4b44-bdb1-13aaf3598796.png " />
456
+ <img width=292 src="https://github. com/AkYML/YCharts/assets/102035914/809bff58-a857-4ed1-8415-cd1d97be300f " />
378
457
<p> Combined bar with line chart looks like this!</p>
379
458
</div >
380
459
</figure >
381
460
<br >
382
461
462
+
463
+
464
+ ### 7. Wave Chart:
465
+
466
+ - Wave charts, also referred to as waveform charts or waveform displays, are specialized visualizations used primarily in the field of signal processing and electronics. These charts illustrate the amplitude (vertical axis) and time (horizontal axis) of a waveform.
467
+
468
+ ``` kotlin
469
+ val waveChartData = WaveChartData (
470
+ wavePlotData = WavePlotData (
471
+ lines = listOf (
472
+ Wave (
473
+ dataPoints = pointsData,
474
+ waveStyle = LineStyle (color = Color .Black ),
475
+ selectionHighlightPoint = SelectionHighlightPoint (),
476
+ shadowUnderLine = ShadowUnderLine (),
477
+ selectionHighlightPopUp = SelectionHighlightPopUp (),
478
+ waveFillColor = WaveFillColor (topColor = Color .Green , bottomColor = Color .Red ),
479
+ )
480
+ )
481
+ ),
482
+ xAxisData = xAxisData,
483
+ yAxisData = yAxisData,
484
+ gridLines = GridLines ()
485
+ )
486
+ ```
487
+
488
+ - Initialize X and Y Axis builders using the ` AxisData ` data class.
489
+
490
+ ``` kotlin
491
+ val xAxisData = AxisData .Builder ()
492
+ .axisStepSize(30 .dp)
493
+ .steps(maxOf(barChartData.size - 1 , lineChartData.size - 1 ))
494
+ .bottomPadding(40 .dp)
495
+ .labelData { index -> index.toString() }
496
+ .build()
497
+
498
+ val yAxisData = AxisData .Builder ()
499
+ .steps(yStepSize)
500
+ .labelAndAxisLinePadding(20 .dp)
501
+ .axisOffset(20 .dp)
502
+ .labelData { index -> (index * (maxRange / yStepSize)).toString() }
503
+ .build()
504
+ ```
505
+
506
+ - Initialize the Wave chart config data with ` WaveChartData ` data class in order to achieve styling and configurations related to same.
507
+
508
+ ``` kotlin
509
+ val waveChartData = WaveChartData (
510
+ wavePlotData = WavePlotData (
511
+ lines = listOf (
512
+ Wave (
513
+ dataPoints = pointsData,
514
+ waveStyle = LineStyle (color = Color .Black ),
515
+ selectionHighlightPoint = SelectionHighlightPoint (),
516
+ shadowUnderLine = ShadowUnderLine (),
517
+ selectionHighlightPopUp = SelectionHighlightPopUp (),
518
+ waveFillColor = WaveFillColor (topColor = Color .Green , bottomColor = Color .Red ),
519
+ )
520
+ )
521
+ ),
522
+ xAxisData = xAxisData,
523
+ yAxisData = yAxisData,
524
+ gridLines = GridLines ()
525
+ )
526
+ ```
527
+
528
+ - Finally, use the _ ** ` WaveChart ` ** _ component to render the chart.
529
+ ``` kotlin
530
+ WaveChart (
531
+ modifier = Modifier
532
+ .fillMaxWidth()
533
+ .height(300 .dp),
534
+ waveChartData = data
535
+ )
536
+ ```
537
+ _ Note_ : To show legends infomartion related to bar, ` Legends ` component can be used.
538
+ <figure >
539
+ <div align = " center " >
540
+ <img width=292 src="https://github.com/AkYML/YCharts/assets/102035914/be694054-d5cc-49ec-b7ee-be80c1562df7" />
541
+ <p> Wavechart looks like this!</p>
542
+ <img width=292 src="https://github.com/AkYML/YCharts/assets/102035914/2d8b02af-1252-44fb-83e1-06d1f6230733" />
543
+ <p> Sinewavechart looks like this!</p>
544
+ </div >
545
+ </figure >
546
+ <br >
547
+
548
+ ### 8. Bubble Chart:
549
+
550
+ - Bubble charts are a variation of the scatter plot, where the data points are represented as bubbles or circles instead of simple dots. The bubbles' size represents the value of a third variable, in addition to the x-axis and y-axis variables. Bubble charts are effective in visualizing and comparing three different dimensions of data simultaneously.
551
+
552
+ ``` kotlin
553
+ val bubbleChartData = BubbleChartData (
554
+ DataUtils .getBubbleChartDataWithGradientStyle(pointsData),
555
+ xAxisData = xAxisData,
556
+ yAxisData = yAxisData,
557
+ gridLines = GridLines ()
558
+ )
559
+ ```
560
+
561
+ - Initialize X and Y Axis builders using the ` AxisData ` data class.
562
+
563
+ ``` kotlin
564
+ val xAxisData = AxisData .Builder ()
565
+ .axisStepSize(30 .dp)
566
+ .steps(maxOf(barChartData.size - 1 , lineChartData.size - 1 ))
567
+ .bottomPadding(40 .dp)
568
+ .labelData { index -> index.toString() }
569
+ .build()
570
+
571
+ val yAxisData = AxisData .Builder ()
572
+ .steps(yStepSize)
573
+ .labelAndAxisLinePadding(20 .dp)
574
+ .axisOffset(20 .dp)
575
+ .labelData { index -> (index * (maxRange / yStepSize)).toString() }
576
+ .build()
577
+ ```
578
+
579
+ - Initialize the Bubble chart config data with ` BubbleChartData ` data class in order to achieve styling and configurations related to same.
580
+
581
+ ``` kotlin
582
+ val bubbleChartData = BubbleChartData (
583
+ DataUtils .getBubbleChartDataWithGradientStyle(pointsData),
584
+ xAxisData = xAxisData,
585
+ yAxisData = yAxisData,
586
+ gridLines = GridLines ()
587
+ )
588
+
589
+ ```
590
+
591
+ - Finally, use the _ ** ` BubbleChart ` ** _ component to render the chart.
592
+ ``` kotlin
593
+ BubbleChart (
594
+ modifier = Modifier
595
+ .fillMaxWidth()
596
+ .height(500 .dp),
597
+ bubbleChartData = data
598
+ )
599
+ ```
600
+ _ Note_ : To show legends infomartion related to bar, ` Legends ` component can be used.
601
+ <figure >
602
+ <div align = " center " >
603
+ <img width=292 src="https://github.com/AkYML/YCharts/assets/102035914/be103f93-8562-4939-add8-1693d76441ef" />
604
+ <p> Gradient-Bubble chart looks like this!</p>
605
+ <img width=292 src="https://github.com/AkYML/YCharts/assets/102035914/cb177d4d-3fa8-4171-b3bd-7064458b1964" />
606
+ <p> Bubble chart looks like this!</p>
607
+ </div >
608
+ </figure >
609
+ <br >
610
+
611
+
383
612
## Accessibility Support
384
613
385
614
To interact with your device with touch and spoken feedback, you can turn on the TalkBack screen reader. TalkBack describes the graphs/charts when tapped on the graph container.
0 commit comments