Skip to content

Commit e1f8e05

Browse files
committed
Add Custom Style Chart List feature
Introduces CustomStyleChartListActivity and CustomStyleChartAdapter to display a list of custom styled charts using RecyclerView. Updates AndroidManifest.xml to register the new activity and modifies MainActivity to launch it. Adds corresponding layout files for the activity and chart items.
1 parent 333f53b commit e1f8e05

File tree

6 files changed

+213
-1
lines changed

6 files changed

+213
-1
lines changed

sample/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
<activity android:name=".additionalcontent.AdvancedUpdatingFeatureActivity" />
4444
<activity android:name=".basiccontent.SpecialChartListActivity" />
4545
<activity android:name=".basiccontent.MixedChartListActivity" />
46+
<activity android:name=".basiccontent.CustomStyleChartListActivity" />
4647
</application>
4748

4849
</manifest>
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
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.CustomStyleChartComposer
13+
14+
class CustomStyleChartAdapter(
15+
private val context: Context,
16+
private val chartItems: List<ChartItem>
17+
) : RecyclerView.Adapter<CustomStyleChartAdapter.ViewHolder>() {
18+
19+
class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
20+
val nameTextView: TextView = view.findViewById(R.id.tv_chart_name)
21+
val aaChartView: AAChartView = view.findViewById(R.id.aa_chart_view)
22+
}
23+
24+
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
25+
val view = LayoutInflater.from(parent.context).inflate(R.layout.item_custom_style_chart, parent, false)
26+
return ViewHolder(view)
27+
}
28+
29+
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
30+
val item = chartItems[position]
31+
holder.nameTextView.text = item.name
32+
val aaChartModel = getChartModel(item.chartType)
33+
holder.aaChartView.aa_drawChartWithChartModel(aaChartModel)
34+
}
35+
36+
override fun getItemCount(): Int = chartItems.size
37+
38+
private fun getChartModel(chartType: String): AAChartModel {
39+
return when (chartType) {
40+
"configureColorfulChart" -> CustomStyleChartComposer.configureColorfulChart()
41+
"configureColorfulGradientColorChart" -> CustomStyleChartComposer.configureColorfulGradientColorChart()
42+
"configureDiscontinuousDataChart" -> CustomStyleChartComposer.configureDiscontinuousDataChart()
43+
"configureColorfulColumnChart" -> CustomStyleChartComposer.configureColorfulColumnChart()
44+
"configureNightingaleRoseChart" -> CustomStyleChartComposer.configureNightingaleRoseChart()
45+
"configureChartWithShadowStyle" -> CustomStyleChartComposer.configureChartWithShadowStyle()
46+
"configureColorfulGradientAreaChart" -> CustomStyleChartComposer.configureColorfulGradientAreaChart()
47+
"configureColorfulGradientSplineChart" -> CustomStyleChartComposer.configureColorfulGradientSplineChart()
48+
"configureGradientColorAreasplineChart" -> CustomStyleChartComposer.configureGradientColorAreasplineChart()
49+
"configureSpecialStyleMarkerOfSingleDataElementChart" -> CustomStyleChartComposer.configureSpecialStyleMarkerOfSingleDataElementChart()
50+
"configureSpecialStyleColumnOfSingleDataElementChart" -> CustomStyleChartComposer.configureSpecialStyleColumnOfSingleDataElementChart()
51+
"configureAreaChartThreshold" -> CustomStyleChartComposer.configureAreaChartThreshold()
52+
"customScatterChartMarkerSymbolContent" -> CustomStyleChartComposer.customScatterChartMarkerSymbolContent()
53+
"customLineChartMarkerSymbolContent" -> CustomStyleChartComposer.customLineChartMarkerSymbolContent()
54+
"configureTriangleRadarChart" -> CustomStyleChartComposer.configureTriangleRadarChart()
55+
"configureQuadrangleRadarChart" -> CustomStyleChartComposer.configureQuadrangleRadarChart()
56+
"configurePentagonRadarChart" -> CustomStyleChartComposer.configurePentagonRadarChart()
57+
"configureHexagonRadarChart" -> CustomStyleChartComposer.configureHexagonRadarChart()
58+
"adjustYAxisMaxAndMinValues" -> CustomStyleChartComposer.adjustYAxisMaxAndMinValues()
59+
"customSpecialStyleDataLabelOfSingleDataElementChart" -> CustomStyleChartComposer.customSpecialStyleDataLabelOfSingleDataElementChart()
60+
"customBarChartHoverColorAndSelectColor" -> CustomStyleChartComposer.customBarChartHoverColorAndSelectColor()
61+
"customChartHoverAndSelectHaloStyle" -> CustomStyleChartComposer.customChartHoverAndSelectHaloStyle()
62+
"customSplineChartMarkerStatesHoverStyle" -> CustomStyleChartComposer.customSplineChartMarkerStatesHoverStyle()
63+
"splineChartHoverLineWithNoChangeAndCustomMarkerStatesHoverStyle" -> CustomStyleChartComposer.splineChartHoverLineWithNoChangeAndCustomMarkerStatesHoverStyle()
64+
"customNormalStackingChartDataLabelsContentAndStyle" -> CustomStyleChartComposer.customNormalStackingChartDataLabelsContentAndStyle()
65+
"upsideDownPyramidChart" -> CustomStyleChartComposer.upsideDownPyramidChart()
66+
"doubleLayerPieChart" -> CustomStyleChartComposer.doubleLayerPieChart()
67+
"disableSomeOfLinesMouseTrackingEffect" -> CustomStyleChartComposer.disableSomeOfLinesMouseTrackingEffect()
68+
"configureColorfulShadowChart" -> CustomStyleChartComposer.configureColorfulShadowSplineChart()
69+
"configureColorfulDataLabelsStepLineChart" -> CustomStyleChartComposer.configureColorfulDataLabelsStepLineChart()
70+
"configureColorfulGradientColorAndColorfulDataLabelsStepAreaChart" -> CustomStyleChartComposer.configureColorfulGradientColorAndColorfulDataLabelsStepAreaChart()
71+
"disableSplineChartMarkerHoverEffect" -> CustomStyleChartComposer.disableSplineChartMarkerHoverEffect()
72+
"configureMaxAndMinDataLabelsForChart" -> CustomStyleChartComposer.configureMaxAndMinDataLabelsForChart()
73+
"customVerticalXAxisCategoriesLabelsByHTMLBreakLineTag" -> CustomStyleChartComposer.customVerticalXAxisCategoriesLabelsByHTMLBreakLineTag()
74+
"noMoreGroupingAndOverlapEachOtherColumnChart" -> CustomStyleChartComposer.noMoreGroupingAndOverlapEachOtherColumnChart()
75+
"noMoreGroupingAndNestedColumnChart" -> CustomStyleChartComposer.noMoreGroupingAndNestedColumnChart()
76+
"topRoundedCornersStackingColumnChart" -> CustomStyleChartComposer.topRoundedCornersStackingColumnChart()
77+
"freeStyleRoundedCornersStackingColumnChart" -> CustomStyleChartComposer.freeStyleRoundedCornersStackingColumnChart()
78+
"customColumnChartBorderStyleAndStatesHoverColor" -> CustomStyleChartComposer.customColumnChartBorderStyleAndStatesHoverColor()
79+
"customLineChartWithColorfulMarkersAndLines" -> CustomStyleChartComposer.customLineChartWithColorfulMarkersAndLines()
80+
"customLineChartWithColorfulMarkersAndLines2" -> CustomStyleChartComposer.customLineChartWithColorfulMarkersAndLines2()
81+
"drawLineChartWithPointsCoordinates" -> CustomStyleChartComposer.drawLineChartWithPointsCoordinates()
82+
"configureSpecialStyleColumnForNegativeDataMixedPositiveData" -> CustomStyleChartComposer.configureSpecialStyleColumnForNegativeDataMixedPositiveData()
83+
"configureMultiLevelStopsArrGradientColorAreasplineMixedLineChart" -> CustomStyleChartComposer.configureMultiLevelStopsArrGradientColorAreasplineMixedLineChart()
84+
"connectNullsForSingleAASeriesElement" -> CustomStyleChartComposer.connectNullsForSingleAASeriesElement()
85+
"lineChartsWithLargeDifferencesInTheNumberOfDataInDifferentSeriesElement" -> CustomStyleChartComposer.lineChartsWithLargeDifferencesInTheNumberOfDataInDifferentSeriesElement()
86+
"customAreasplineChartWithColorfulGradientColorZones" -> CustomStyleChartComposer.customAreasplineChartWithColorfulGradientColorZones()
87+
else -> CustomStyleChartComposer.configureColorfulChart()
88+
}
89+
}
90+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
package com.github.aachartmodel.aainfographics.demo.basiccontent
2+
3+
import android.os.Bundle
4+
import androidx.appcompat.app.AppCompatActivity
5+
import androidx.recyclerview.widget.LinearLayoutManager
6+
import androidx.recyclerview.widget.RecyclerView
7+
import com.github.aachartmodel.aainfographics.demo.R
8+
9+
class CustomStyleChartListActivity : AppCompatActivity() {
10+
11+
override fun onCreate(savedInstanceState: Bundle?) {
12+
super.onCreate(savedInstanceState)
13+
setContentView(R.layout.activity_custom_style_chart_list)
14+
15+
val recyclerView = findViewById<RecyclerView>(R.id.recycler_view)
16+
val chartItems = getChartItems()
17+
recyclerView.layoutManager = LinearLayoutManager(this)
18+
recyclerView.adapter = CustomStyleChartAdapter(this, chartItems)
19+
}
20+
21+
private fun getChartItems(): List<ChartItem> {
22+
return listOf(
23+
ChartItem("Colorful Chart", "configureColorfulChart"),
24+
ChartItem("Colorful Gradient Color Chart", "configureColorfulGradientColorChart"),
25+
ChartItem("Discontinuous Data Chart", "configureDiscontinuousDataChart"),
26+
ChartItem("Colorful Column Chart", "configureColorfulColumnChart"),
27+
ChartItem("Nightingale Rose Chart", "configureNightingaleRoseChart"),
28+
ChartItem("Chart With Shadow Style", "configureChartWithShadowStyle"),
29+
ChartItem("Colorful Gradient Area Chart", "configureColorfulGradientAreaChart"),
30+
ChartItem("Colorful Gradient Spline Chart", "configureColorfulGradientSplineChart"),
31+
ChartItem("Gradient Color Areaspline Chart", "configureGradientColorAreasplineChart"),
32+
ChartItem("Special Style Marker Of Single Data Element Chart", "configureSpecialStyleMarkerOfSingleDataElementChart"),
33+
ChartItem("Special Style Column Of Single Data Element Chart", "configureSpecialStyleColumnOfSingleDataElementChart"),
34+
ChartItem("Area Chart Threshold", "configureAreaChartThreshold"),
35+
ChartItem("Custom Scatter Chart Marker Symbol Content", "customScatterChartMarkerSymbolContent"),
36+
ChartItem("Custom Line Chart Marker Symbol Content", "customLineChartMarkerSymbolContent"),
37+
ChartItem("Triangle Radar Chart", "configureTriangleRadarChart"),
38+
ChartItem("Quadrangle Radar Chart", "configureQuadrangleRadarChart"),
39+
ChartItem("Pentagon Radar Chart", "configurePentagonRadarChart"),
40+
ChartItem("Hexagon Radar Chart", "configureHexagonRadarChart"),
41+
ChartItem("Adjust YAxis Max And Min Values", "adjustYAxisMaxAndMinValues"),
42+
ChartItem("Custom Special Style Data Label Of Single Data Element Chart", "customSpecialStyleDataLabelOfSingleDataElementChart"),
43+
ChartItem("Custom Bar Chart Hover Color And Select Color", "customBarChartHoverColorAndSelectColor"),
44+
ChartItem("Custom Chart Hover And Select Halo Style", "customChartHoverAndSelectHaloStyle"),
45+
ChartItem("Custom Spline Chart Marker States Hover Style", "customSplineChartMarkerStatesHoverStyle"),
46+
ChartItem("Spline Chart Hover Line With No Change And Custom Marker States Hover Style", "splineChartHoverLineWithNoChangeAndCustomMarkerStatesHoverStyle"),
47+
ChartItem("Custom Normal Stacking Chart Data Labels Content And Style", "customNormalStackingChartDataLabelsContentAndStyle"),
48+
ChartItem("Upside Down Pyramid Chart", "upsideDownPyramidChart"),
49+
ChartItem("Double Layer Pie Chart", "doubleLayerPieChart"),
50+
ChartItem("Disable Some Of Lines Mouse Tracking Effect", "disableSomeOfLinesMouseTrackingEffect"),
51+
ChartItem("Configure Colorful Shadow Chart", "configureColorfulShadowChart"),
52+
ChartItem("Configure Colorful Data Labels Step Line Chart", "configureColorfulDataLabelsStepLineChart"),
53+
ChartItem("Configure Colorful Gradient Color And Colorful Data Labels Step Area Chart", "configureColorfulGradientColorAndColorfulDataLabelsStepAreaChart"),
54+
ChartItem("Disable Spline Chart Marker Hover Effect", "disableSplineChartMarkerHoverEffect"),
55+
ChartItem("Configure Max And Min Data Labels For Chart", "configureMaxAndMinDataLabelsForChart"),
56+
ChartItem("Custom Vertical XAxis Categories Labels By HTML Break Line Tag", "customVerticalXAxisCategoriesLabelsByHTMLBreakLineTag"),
57+
ChartItem("No More Grouping And Overlap Each Other Column Chart", "noMoreGroupingAndOverlapEachOtherColumnChart"),
58+
ChartItem("No More Grouping And Nested Column Chart", "noMoreGroupingAndNestedColumnChart"),
59+
ChartItem("Top Rounded Corners Stacking Column Chart", "topRoundedCornersStackingColumnChart"),
60+
ChartItem("Free Style Rounded Corners Stacking Column Chart", "freeStyleRoundedCornersStackingColumnChart"),
61+
ChartItem("Custom Column Chart Border Style And States Hover Color", "customColumnChartBorderStyleAndStatesHoverColor"),
62+
ChartItem("Custom Line Chart With Colorful Markers And Lines", "customLineChartWithColorfulMarkersAndLines"),
63+
ChartItem("Custom Line Chart With Colorful Markers And Lines 2", "customLineChartWithColorfulMarkersAndLines2"),
64+
ChartItem("Draw Line Chart With Points Coordinates", "drawLineChartWithPointsCoordinates"),
65+
ChartItem("Configure Special Style Column For Negative Data Mixed Positive Data", "configureSpecialStyleColumnForNegativeDataMixedPositiveData"),
66+
ChartItem("Configure Multi Level Stops Arr Gradient Color Areaspline Mixed Line Chart", "configureMultiLevelStopsArrGradientColorAreasplineMixedLineChart"),
67+
ChartItem("Connect Nulls For Single AASeries Element", "connectNullsForSingleAASeriesElement"),
68+
ChartItem("Line Charts With Large Differences In The Number Of Data In Different Series Element", "lineChartsWithLargeDifferencesInTheNumberOfDataInDifferentSeriesElement"),
69+
ChartItem("Custom Areaspline Chart With Colorful Gradient Color Zones", "customAreasplineChartWithColorfulGradientColorZones")
70+
)
71+
}
72+
}

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
@@ -545,7 +545,10 @@ class MainActivity : AppCompatActivity() {
545545
val intent = Intent(this, MixedChartListActivity::class.java)
546546
startActivity(intent)
547547
}
548-
3 -> goToCustomStyleChartActivity(chartType)
548+
3 -> {
549+
val intent = Intent(this, CustomStyleChartListActivity::class.java)
550+
startActivity(intent)
551+
}
549552
4 -> goToDrawChartWithAAOptionsActivity(chartType)
550553
5 -> goToOnlyRefreshChartDataActivity(chartType)
551554
6 -> goToCustomTooltipWithJSFunctionActivity(chartType)
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.CustomStyleChartListActivity">
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)