@@ -29,7 +29,7 @@ import info.appdev.chartexample.notimportant.DemoBase
2929/* *
3030 * Example of a heavily customized [LineChart] with limit lines, custom line shapes, etc.
3131 */
32- class LineChartActivity1 : DemoBase (), OnSeekBarChangeListener, OnChartValueSelectedListener {
32+ class LineChartActivity : DemoBase (), OnSeekBarChangeListener, OnChartValueSelectedListener {
3333
3434 private lateinit var binding: ActivityLinechartBinding
3535
@@ -82,40 +82,45 @@ class LineChartActivity1 : DemoBase(), OnSeekBarChangeListener, OnChartValueSele
8282 // axis range
8383 binding.chart1.axisLeft.axisMaximum = 200f
8484 binding.chart1.axisLeft.axisMinimum = - 50f
85- val llXAxis = LimitLine (9f , " Index 10" )
86- llXAxis.lineWidth = 4f
87- llXAxis.enableDashedLine(10f , 10f , 0f )
88- llXAxis.labelPosition = LimitLabelPosition .RIGHT_BOTTOM
89- llXAxis.textSize = 10f
90- llXAxis.typeface = tfRegular
91- val limitLine1 = LimitLine (150f , " Upper Limit" )
92- limitLine1.lineWidth = 4f
93- limitLine1.enableDashedLine(10f , 10f , 0f )
94- limitLine1.labelPosition = LimitLabelPosition .RIGHT_TOP
95- limitLine1.textSize = 10f
96- limitLine1.typeface = tfRegular
97- limitLine1.lineColor = Color .GREEN
98- val limitLine2 = LimitLine (- 30f , " Lower Limit" )
99- limitLine2.lineWidth = 4f
100- limitLine2.enableDashedLine(10f , 10f , 0f )
101- limitLine2.labelPosition = LimitLabelPosition .RIGHT_BOTTOM
102- limitLine2.textSize = 10f
103- limitLine2.typeface = tfRegular
104- limitLine2.lineColor = Color .GREEN
85+ val llXAxis10 = LimitLine (9f , " Index 10" ).apply {
86+ lineWidth = 4f
87+ enableDashedLine(10f , 10f , 0f )
88+ labelPosition = LimitLabelPosition .RIGHT_BOTTOM
89+ textSize = 10f
90+ typeface = tfRegular
91+ }
92+
93+ val limitLineUpper = LimitLine (150f , " Upper Limit" ).apply {
94+ lineWidth = 4f
95+ enableDashedLine(10f , 10f , 0f )
96+ labelPosition = LimitLabelPosition .RIGHT_TOP
97+ textSize = 10f
98+ typeface = tfRegular
99+ lineColor = Color .GREEN
100+ }
101+
102+ val limitLineLower = LimitLine (- 30f , " Lower Limit" ).apply {
103+ lineWidth = 4f
104+ enableDashedLine(10f , 10f , 0f )
105+ labelPosition = LimitLabelPosition .RIGHT_BOTTOM
106+ textSize = 10f
107+ typeface = tfRegular
108+ lineColor = Color .GREEN
109+ }
105110
106111 // draw limit lines behind data instead of on top
107112 binding.chart1.axisLeft.setDrawLimitLinesBehindData(true )
108113 binding.chart1.xAxis.setDrawLimitLinesBehindData(true )
109114
110115 // add limit lines
111- binding.chart1.axisLeft.addLimitLine(limitLine1 )
112- binding.chart1.axisLeft.addLimitLine(limitLine2 )
113- // xAxis. addLimitLine(llXAxis);
116+ binding.chart1.axisLeft.addLimitLine(limitLineUpper )
117+ binding.chart1.axisLeft.addLimitLine(limitLineLower )
118+ // binding.chart1.axisLeft. addLimitLine(llXAxis10)
114119
115120 // add data
116121 binding.seekBarX.progress = 45
117122 binding.seekBarY.progress = 180
118- Log .d(" setDataCreate" , " \$ count=45 range=180f" )
123+ Log .d(" setDataCreate" , " count=45 range=180f" )
119124 setData(this , binding.chart1, 45 , 180f )
120125
121126 // draw points over time
0 commit comments