Skip to content

Commit 333f53b

Browse files
committed
Add Mixed Chart list feature to demo app
Introduces MixedChartListActivity with a RecyclerView to display various mixed chart types. Adds MixedChartAdapter, supporting layouts, and updates MainActivity and AndroidManifest.xml to integrate the new activity.
1 parent 2e8bbf7 commit 333f53b

File tree

6 files changed

+155
-12
lines changed

6 files changed

+155
-12
lines changed

sample/src/main/AndroidManifest.xml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3-
xmlns:tools="http://schemas.android.com/tools"
4-
package="com.github.aachartmodel.aainfographics.demo">
3+
xmlns:tools="http://schemas.android.com/tools"
4+
package="com.github.aachartmodel.aainfographics.demo">
55

66
<application
7-
android:allowBackup="true"
8-
android:icon="@mipmap/ic_launcher"
9-
android:label="@string/app_name"
10-
android:roundIcon="@mipmap/ic_launcher_round"
11-
android:supportsRtl="true"
12-
android:theme="@style/AppTheme.EdgeToEdge.Material"
13-
android:resizeableActivity="true"
14-
tools:ignore="AllowBackup">
7+
android:allowBackup="true"
8+
android:icon="@mipmap/ic_launcher"
9+
android:label="@string/app_name"
10+
android:roundIcon="@mipmap/ic_launcher_round"
11+
android:supportsRtl="true"
12+
android:theme="@style/AppTheme.EdgeToEdge.Material"
13+
android:resizeableActivity="true"
14+
tools:ignore="AllowBackup">
1515

1616
<!-- 解决旧版系统(如 Android 8.x)可能出现的宽高比 letterboxing 黑边问题 -->
1717
<meta-data android:name="android.max_aspect" android:value="2.6" />
1818

1919
<activity android:name=".basiccontent.MainActivity"
20-
android:exported="true">
20+
android:exported="true">
2121
<intent-filter>
2222
<action android:name="android.intent.action.MAIN" />
2323

@@ -42,6 +42,7 @@
4242
<activity android:name=".additionalcontent.ScrollableChartActivity" />
4343
<activity android:name=".additionalcontent.AdvancedUpdatingFeatureActivity" />
4444
<activity android:name=".basiccontent.SpecialChartListActivity" />
45+
<activity android:name=".basiccontent.MixedChartListActivity" />
4546
</application>
4647

4748
</manifest>

sample/src/main/java/com/github/aachartmodel/aainfographics/demo/basiccontent/MainActivity.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,10 @@ class MainActivity : AppCompatActivity() {
541541
val intent = Intent(this, SpecialChartListActivity::class.java)
542542
startActivity(intent)
543543
}
544-
2 -> goToMixedChartActivity(chartType)
544+
2 -> {
545+
val intent = Intent(this, MixedChartListActivity::class.java)
546+
startActivity(intent)
547+
}
545548
3 -> goToCustomStyleChartActivity(chartType)
546549
4 -> goToDrawChartWithAAOptionsActivity(chartType)
547550
5 -> goToOnlyRefreshChartDataActivity(chartType)
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package com.github.aachartmodel.aainfographics.demo.basiccontent
2+
3+
import android.content.Context
4+
import android.view.LayoutInflater
5+
import android.view.View
6+
import android.view.ViewGroup
7+
import android.widget.TextView
8+
import androidx.recyclerview.widget.RecyclerView
9+
import com.github.aachartmodel.aainfographics.aachartcreator.AAChartModel
10+
import com.github.aachartmodel.aainfographics.aachartcreator.AAChartView
11+
import com.github.aachartmodel.aainfographics.demo.R
12+
import com.github.aachartmodel.aainfographics.demo.chartcomposer.MixedChartComposer
13+
14+
data class MixedChartItem(val name: String, val chartType: String)
15+
16+
class MixedChartAdapter(
17+
private val context: Context,
18+
private val chartItems: List<MixedChartItem>
19+
) : RecyclerView.Adapter<MixedChartAdapter.ViewHolder>() {
20+
21+
class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
22+
val nameTextView: TextView = view.findViewById(R.id.tv_chart_name)
23+
val aaChartView: AAChartView = view.findViewById(R.id.aa_chart_view)
24+
}
25+
26+
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
27+
val view = LayoutInflater.from(parent.context).inflate(R.layout.item_mixed_chart, parent, false)
28+
return ViewHolder(view)
29+
}
30+
31+
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
32+
val item = chartItems[position]
33+
holder.nameTextView.text = item.name
34+
val aaChartModel = getChartModel(item.chartType)
35+
holder.aaChartView.aa_drawChartWithChartModel(aaChartModel)
36+
}
37+
38+
override fun getItemCount(): Int = chartItems.size
39+
40+
private fun getChartModel(chartType: String): AAChartModel {
41+
return when (chartType) {
42+
"arearangeMixedLine" -> MixedChartComposer.arearangeMixedLine()
43+
"columnrangeMixedLine" -> MixedChartComposer.configureColumnrangeMixedLineChart()
44+
"stackingColumnMixedLine" -> MixedChartComposer.configureStackingColumnMixedLineChart()
45+
"dashStyleTypeMixed" -> MixedChartComposer.dashStyleTypeMixedChart()
46+
"negativeColorMixed" -> MixedChartComposer.negativeColorMixedChart()
47+
"scatterMixedLine" -> MixedChartComposer.scatterMixedLine()
48+
"negativeColorMixedBubble" -> MixedChartComposer.negativeColorMixedBubble()
49+
"polygonMixedScatter" -> MixedChartComposer.polygonMixedScatter()
50+
"polarChartMixed" -> MixedChartComposer.polarChartMixedChart()
51+
"configurePieMixedLineMixedColumnChart" -> MixedChartComposer.configurePieMixedLineMixedColumnChart()
52+
"configureNegativeColorMixedAreasplineChart" -> MixedChartComposer.configureNegativeColorMixedAreasplineChart()
53+
else -> MixedChartComposer.arearangeMixedLine()
54+
}
55+
}
56+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.github.aachartmodel.aainfographics.demo.basiccontent
2+
3+
import android.content.Intent
4+
import android.os.Bundle
5+
import androidx.appcompat.app.AppCompatActivity
6+
import androidx.recyclerview.widget.LinearLayoutManager
7+
import androidx.recyclerview.widget.RecyclerView
8+
import com.github.aachartmodel.aainfographics.demo.R
9+
10+
class MixedChartListActivity : AppCompatActivity() {
11+
12+
override fun onCreate(savedInstanceState: Bundle?) {
13+
super.onCreate(savedInstanceState)
14+
setContentView(R.layout.activity_mixed_chart_list)
15+
16+
val recyclerView = findViewById<RecyclerView>(R.id.recycler_view)
17+
val chartItems = getChartItems()
18+
recyclerView.layoutManager = LinearLayoutManager(this)
19+
recyclerView.adapter = MixedChartAdapter(this, chartItems)
20+
}
21+
22+
private fun getChartItems(): List<MixedChartItem> {
23+
return listOf(
24+
MixedChartItem("Arearange Mixed Line", "arearangeMixedLine"),
25+
MixedChartItem("Columnrange Mixed Line", "columnrangeMixedLine"),
26+
MixedChartItem("Stacking Column Mixed Line", "stackingColumnMixedLine"),
27+
MixedChartItem("Dash Style Type Mixed", "dashStyleTypeMixed"),
28+
MixedChartItem("Negative Color Mixed", "negativeColorMixed"),
29+
MixedChartItem("Scatter Mixed Line", "scatterMixedLine"),
30+
MixedChartItem("Negative Color Mixed Bubble", "negativeColorMixedBubble"),
31+
MixedChartItem("Polygon Mixed Scatter", "polygonMixedScatter"),
32+
MixedChartItem("Polar Chart Mixed", "polarChartMixed"),
33+
MixedChartItem("Pie Mixed Line Mixed Column", "configurePieMixedLineMixedColumnChart"),
34+
MixedChartItem("Negative Color Mixed Areaspline", "configureNegativeColorMixedAreasplineChart")
35+
)
36+
}
37+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
xmlns:tools="http://schemas.android.com/tools"
5+
android:layout_width="match_parent"
6+
android:layout_height="match_parent"
7+
tools:context=".basiccontent.MixedChartListActivity">
8+
9+
<androidx.recyclerview.widget.RecyclerView
10+
android:id="@+id/recycler_view"
11+
android:layout_width="0dp"
12+
android:layout_height="0dp"
13+
app:layout_constraintBottom_toBottomOf="parent"
14+
app:layout_constraintEnd_toEndOf="parent"
15+
app:layout_constraintStart_toStartOf="parent"
16+
app:layout_constraintTop_toTopOf="parent" />
17+
18+
</androidx.constraintlayout.widget.ConstraintLayout>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
android:layout_width="match_parent"
5+
android:layout_height="wrap_content"
6+
android:padding="8dp">
7+
8+
<TextView
9+
android:id="@+id/tv_chart_name"
10+
android:layout_width="0dp"
11+
android:layout_height="wrap_content"
12+
android:layout_marginBottom="8dp"
13+
android:textSize="16sp"
14+
android:textStyle="bold"
15+
app:layout_constraintEnd_toEndOf="parent"
16+
app:layout_constraintStart_toStartOf="parent"
17+
app:layout_constraintTop_toTopOf="parent" />
18+
19+
<com.github.aachartmodel.aainfographics.aachartcreator.AAChartView
20+
android:id="@+id/aa_chart_view"
21+
android:layout_width="0dp"
22+
android:layout_height="300dp"
23+
app:layout_constraintBottom_toBottomOf="parent"
24+
app:layout_constraintEnd_toEndOf="parent"
25+
app:layout_constraintStart_toStartOf="parent"
26+
app:layout_constraintTop_toBottomOf="@id/tv_chart_name" />
27+
28+
</androidx.constraintlayout.widget.ConstraintLayout>

0 commit comments

Comments
 (0)