Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="info.appdev.chartexample.LineChartActivity1" />
<activity android:name="info.appdev.chartexample.LineChartActivity" />
<activity android:name="info.appdev.chartexample.LineChartDualAxisActivity" />
<activity android:name="info.appdev.chartexample.LineChartTime" />
<activity android:name="info.appdev.chartexample.BarChartActivity" />
Expand Down
10 changes: 4 additions & 6 deletions app/src/main/java/info/appdev/chartexample/DrawChartActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import info.appdev.chartexample.notimportant.DemoBase
/**
* This Activity demonstrates drawing into the Chart with the finger. Both line,
* bar and scatter charts can be used for drawing.
*
* @author Philipp Jahoda
*/
class DrawChartActivity : DemoBase(), OnChartValueSelectedListener, OnDrawListener {
private lateinit var binding: ActivityDrawChartBinding
Expand Down Expand Up @@ -53,14 +51,14 @@ class DrawChartActivity : DemoBase(), OnChartValueSelectedListener, OnDrawListen
// add dummy-data to the chart
initWithDummyData()

val xl = binding.chart1.getXAxis()
val xl = binding.chart1.xAxis
xl.typeface = tfRegular
xl.setAvoidFirstLastClipping(true)

val yl = binding.chart1.getAxisLeft()
val yl = binding.chart1.axisLeft
yl.typeface = tfRegular

binding.chart1.getLegend().isEnabled = false
binding.chart1.legend.isEnabled = false

// chart.setYRange(-40f, 40f, true);
// call this to reset the changed y-range
Expand Down Expand Up @@ -89,7 +87,7 @@ class DrawChartActivity : DemoBase(), OnChartValueSelectedListener, OnDrawListen
override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
R.id.actionToggleValues -> {
val sets = binding.chart1.data!!.getDataSets()
val sets = binding.chart1.data!!.dataSets

for (iSet in sets) {
val set = iSet as LineDataSet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import info.appdev.chartexample.notimportant.DemoBase
/**
* Example of a heavily customized [LineChart] with limit lines, custom line shapes, etc.
*/
class LineChartActivity1 : DemoBase(), OnSeekBarChangeListener, OnChartValueSelectedListener {
class LineChartActivity : DemoBase(), OnSeekBarChangeListener, OnChartValueSelectedListener {

private lateinit var binding: ActivityLinechartBinding

Expand Down Expand Up @@ -82,40 +82,45 @@ class LineChartActivity1 : DemoBase(), OnSeekBarChangeListener, OnChartValueSele
// axis range
binding.chart1.axisLeft.axisMaximum = 200f
binding.chart1.axisLeft.axisMinimum = -50f
val llXAxis = LimitLine(9f, "Index 10")
llXAxis.lineWidth = 4f
llXAxis.enableDashedLine(10f, 10f, 0f)
llXAxis.labelPosition = LimitLabelPosition.RIGHT_BOTTOM
llXAxis.textSize = 10f
llXAxis.typeface = tfRegular
val limitLine1 = LimitLine(150f, "Upper Limit")
limitLine1.lineWidth = 4f
limitLine1.enableDashedLine(10f, 10f, 0f)
limitLine1.labelPosition = LimitLabelPosition.RIGHT_TOP
limitLine1.textSize = 10f
limitLine1.typeface = tfRegular
limitLine1.lineColor = Color.GREEN
val limitLine2 = LimitLine(-30f, "Lower Limit")
limitLine2.lineWidth = 4f
limitLine2.enableDashedLine(10f, 10f, 0f)
limitLine2.labelPosition = LimitLabelPosition.RIGHT_BOTTOM
limitLine2.textSize = 10f
limitLine2.typeface = tfRegular
limitLine2.lineColor = Color.GREEN
val llXAxis10 = LimitLine(9f, "Index 10").apply {
lineWidth = 4f
enableDashedLine(10f, 10f, 0f)
labelPosition = LimitLabelPosition.RIGHT_BOTTOM
textSize = 10f
typeface = tfRegular
}

val limitLineUpper = LimitLine(150f, "Upper Limit").apply {
lineWidth = 4f
enableDashedLine(10f, 10f, 0f)
labelPosition = LimitLabelPosition.RIGHT_TOP
textSize = 10f
typeface = tfRegular
lineColor = Color.GREEN
}

val limitLineLower = LimitLine(-30f, "Lower Limit").apply {
lineWidth = 4f
enableDashedLine(10f, 10f, 0f)
labelPosition = LimitLabelPosition.RIGHT_BOTTOM
textSize = 10f
typeface = tfRegular
lineColor = Color.GREEN
}

// draw limit lines behind data instead of on top
binding.chart1.axisLeft.setDrawLimitLinesBehindData(true)
binding.chart1.xAxis.setDrawLimitLinesBehindData(true)

// add limit lines
binding.chart1.axisLeft.addLimitLine(limitLine1)
binding.chart1.axisLeft.addLimitLine(limitLine2)
//xAxis.addLimitLine(llXAxis);
binding.chart1.axisLeft.addLimitLine(limitLineUpper)
binding.chart1.axisLeft.addLimitLine(limitLineLower)
// binding.chart1.axisLeft.addLimitLine(llXAxis10)

// add data
binding.seekBarX.progress = 45
binding.seekBarY.progress = 180
Log.d("setDataCreate", "\$count=45 range=180f")
Log.d("setDataCreate", "count=45 range=180f")
setData(this, binding.chart1, 45, 180f)

// draw points over time
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import info.appdev.chartexample.FilledLineActivity
import info.appdev.chartexample.HalfPieChartActivity
import info.appdev.chartexample.HorizontalBarChartActivity
import info.appdev.chartexample.InvertedLineChartActivity
import info.appdev.chartexample.LineChartActivity1
import info.appdev.chartexample.LineChartActivity
import info.appdev.chartexample.LineChartActivityColored
import info.appdev.chartexample.LineChartDualAxisActivity
import info.appdev.chartexample.LineChartTime
Expand Down Expand Up @@ -101,7 +101,7 @@ class MainActivity : AppCompatActivity(), OnItemClickListener {
val menuItems = ArrayList<ContentItem<out DemoBase>>().apply {
add(0, ContentItem("Line Charts"))
add(0, ContentItem("Line Charts"))
add(1, ContentItem("Basic", "Simple line chart.", LineChartActivity1::class.java))
add(1, ContentItem("Basic", "Simple line chart.", LineChartActivity::class.java))
add(2, ContentItem("Multiple", "Show multiple data sets.", MultiLineChartActivity::class.java))
add(3, ContentItem("Dual Axis", "Line chart with dual y-axes.", LineChartDualAxisActivity::class.java))
add(4, ContentItem("Inverted Axis", "Inverted y-axis.", InvertedLineChartActivity::class.java))
Expand Down
Loading