@@ -33,12 +33,17 @@ import androidx.appcompat.app.AppCompatActivity
3333import com.github.aachartmodel.aainfographics.aachartcreator.AAChartModel
3434import com.github.aachartmodel.aainfographics.aachartcreator.AAChartType
3535import com.github.aachartmodel.aainfographics.aachartcreator.AAChartView
36+ import com.github.aachartmodel.aainfographics.aachartcreator.AAClickEventMessageModel
37+ import com.github.aachartmodel.aainfographics.aachartcreator.AAMoveOverEventMessageModel
3638import com.github.aachartmodel.aainfographics.demo.R
3739import com.github.aachartmodel.aainfographics.demo.chartcomposer.SpecialChartComposer
40+ import com.google.gson.Gson
41+ import com.google.gson.GsonBuilder
3842
39- class SpecialChartActivity : AppCompatActivity () {
43+ class SpecialChartActivity : AppCompatActivity (),
44+ AAChartView .AAChartViewCallBack {
4045
41- private var aaChartModel: AAChartModel ? = null
46+ // private var aaChartModel: AAChartModel? = null
4247
4348 override fun onCreate (savedInstanceState : Bundle ? ) {
4449 super .onCreate(savedInstanceState)
@@ -47,12 +52,16 @@ class SpecialChartActivity : AppCompatActivity() {
4752 val intent = intent
4853 val chartType = intent.getStringExtra(" chartType" )
4954
50- aaChartModel = configureChartModelWithChartType(chartType!! )
55+ val aaChartModel = configureChartModelWithChartType(chartType!! )
56+ aaChartModel.clickEventEnabled(true )
57+ .touchEventEnabled(true )
58+
5159 val aaChartView: AAChartView = findViewById(R .id.AAChartView )
52- aaChartView.aa_drawChartWithChartModel(aaChartModel!! )
60+ aaChartView.callBack = this
61+ aaChartView.aa_drawChartWithChartModel(aaChartModel)
5362 }
5463
55- private fun configureChartModelWithChartType (chartType : String ): AAChartModel ? {
64+ private fun configureChartModelWithChartType (chartType : String ): AAChartModel {
5665 when (chartType) {
5766 AAChartType .Column .value -> return SpecialChartComposer .configurePolarColumnChart()
5867 AAChartType .Bar .value -> return SpecialChartComposer .configurePolarBarChart()
@@ -76,6 +85,31 @@ class SpecialChartActivity : AppCompatActivity() {
7685 }
7786
7887 return SpecialChartComposer .configurePolarColumnChart()
88+
89+ }
90+
91+ override fun chartViewDidFinishLoad (aaChartView : AAChartView ) {
92+ // do nothing
7993 }
8094
95+ override fun chartViewClickEventMessage (
96+ aaChartView : AAChartView ,
97+ clickEventMessage : AAClickEventMessageModel
98+ ) {
99+ val gson = GsonBuilder ().setPrettyPrinting().create()
100+ val clickEventMessageModelJson = gson.toJson(clickEventMessage)
101+
102+ // 打印点击事件信息
103+ println (" 🖱🖱🖱获取点击事件 clickMessageModel = $clickEventMessageModelJson " )
104+ }
105+
106+
107+ override fun chartViewMoveOverEventMessage (
108+ aaChartView : AAChartView ,
109+ messageModel : AAMoveOverEventMessageModel
110+ ) {
111+ // do nothing
112+ }
113+
114+
81115}
0 commit comments