├── app
├── .gitignore
├── testDemoKey.jks
├── src
│ ├── main
│ │ ├── assets
│ │ │ ├── stacked_bars.txt
│ │ │ ├── OpenSans-Bold.ttf
│ │ │ ├── OpenSans-Light.ttf
│ │ │ ├── OpenSans-Italic.ttf
│ │ │ ├── OpenSans-Regular.ttf
│ │ │ ├── OpenSans-BoldItalic.ttf
│ │ │ ├── OpenSans-ExtraBold.ttf
│ │ │ ├── OpenSans-Semibold.ttf
│ │ │ ├── OpenSans-LightItalic.ttf
│ │ │ ├── OpenSans-ExtraBoldItalic.ttf
│ │ │ ├── OpenSans-SemiboldItalic.ttf
│ │ │ └── n.txt
│ │ ├── res
│ │ │ ├── drawable
│ │ │ │ ├── star.png
│ │ │ │ ├── marker2.png
│ │ │ │ ├── radar_marker.png
│ │ │ │ └── fade_red.xml
│ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── values-night
│ │ │ │ └── colors.xml
│ │ │ ├── menu
│ │ │ │ ├── only_github.xml
│ │ │ │ ├── menu_right.xml
│ │ │ │ ├── main.xml
│ │ │ │ ├── combined.xml
│ │ │ │ ├── realtime.xml
│ │ │ │ ├── dynamical.xml
│ │ │ │ ├── draw.xml
│ │ │ │ ├── bubble.xml
│ │ │ │ ├── scatter.xml
│ │ │ │ ├── bar.xml
│ │ │ │ ├── candle.xml
│ │ │ │ ├── pie.xml
│ │ │ │ ├── radar.xml
│ │ │ │ └── line.xml
│ │ │ ├── anim
│ │ │ │ ├── move_left_in_activity.xml
│ │ │ │ ├── move_right_in_activity.xml
│ │ │ │ ├── move_left_out_activity.xml
│ │ │ │ └── move_right_out_activity.xml
│ │ │ ├── mipmap-anydpi-v26
│ │ │ │ ├── ic_launcher.xml
│ │ │ │ └── ic_launcher_round.xml
│ │ │ ├── layout
│ │ │ │ ├── activity_mpmain.xml
│ │ │ │ ├── frag_simple_bar.xml
│ │ │ │ ├── activity_combined.xml
│ │ │ │ ├── activity_draw_chart.xml
│ │ │ │ ├── activity_piechart_half.xml
│ │ │ │ ├── activity_radarchart.xml
│ │ │ │ ├── activity_barchart_noseekbar.xml
│ │ │ │ ├── activity_realtime_linechart.xml
│ │ │ │ ├── activity_linechart_noseekbar.xml
│ │ │ │ ├── activity_listview_chart.xml
│ │ │ │ ├── list_item_barchart.xml
│ │ │ │ ├── list_item_piechart.xml
│ │ │ │ ├── list_item_linechart.xml
│ │ │ │ ├── frag_simple_line.xml
│ │ │ │ ├── frag_simple_pie.xml
│ │ │ │ ├── fragment_kline.xml
│ │ │ │ ├── frag_simple_scatter.xml
│ │ │ │ ├── fragment_one_day.xml
│ │ │ │ ├── fragment_five_day.xml
│ │ │ │ ├── activity_age_distribution.xml
│ │ │ │ ├── activity_awesomedesign.xml
│ │ │ │ ├── activity_main.xml
│ │ │ │ ├── activity_stock_detail_land.xml
│ │ │ │ ├── custom_marker_view.xml
│ │ │ │ ├── list_item_section.xml
│ │ │ │ ├── radar_markerview.xml
│ │ │ │ ├── list_item.xml
│ │ │ │ ├── activity_colored_lines.xml
│ │ │ │ ├── activity_linechart_time.xml
│ │ │ │ ├── activity_scrollview.xml
│ │ │ │ ├── activity_barchart_sinus.xml
│ │ │ │ ├── activity_performance_linechart.xml
│ │ │ │ └── activity_stock_detail.xml
│ │ │ ├── values
│ │ │ │ ├── colors.xml
│ │ │ │ └── styles.xml
│ │ │ └── drawable-v24
│ │ │ │ └── ic_launcher_foreground.xml
│ │ └── java
│ │ │ └── com
│ │ │ └── android
│ │ │ └── stockapp
│ │ │ ├── common
│ │ │ ├── data
│ │ │ │ └── Constants.java
│ │ │ ├── viewpager
│ │ │ │ └── NoTouchScrollViewpager.java
│ │ │ └── adapter
│ │ │ │ └── SimpleFragmentPagerAdapter.java
│ │ │ ├── ui
│ │ │ ├── mpchartexample
│ │ │ │ ├── notimportant
│ │ │ │ │ └── ContentItem.java
│ │ │ │ ├── listviewitems
│ │ │ │ │ └── ChartItem.java
│ │ │ │ ├── custom
│ │ │ │ │ ├── MyFillFormatter.java
│ │ │ │ │ ├── YearXAxisFormatter.java
│ │ │ │ │ ├── CustomScatterShapeRenderer.java
│ │ │ │ │ ├── MyValueFormatter.java
│ │ │ │ │ ├── MyCustomXAxisValueFormatter.java
│ │ │ │ │ ├── RadarMarkerView.java
│ │ │ │ │ ├── MyMarkerView.java
│ │ │ │ │ ├── XYMarkerView.java
│ │ │ │ │ └── StackedBarsMarkerView.java
│ │ │ │ └── fragments
│ │ │ │ │ ├── ComplexityFragment.java
│ │ │ │ │ └── SineCosineFragment.java
│ │ │ ├── base
│ │ │ │ ├── BaseApp.java
│ │ │ │ └── BaseFragment.java
│ │ │ ├── main
│ │ │ │ └── MainActivity.java
│ │ │ └── market
│ │ │ │ └── activity
│ │ │ │ └── StockDetailLandActivity.java
│ │ │ └── application
│ │ │ └── MyApplication.java
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── android
│ │ │ └── stockapp
│ │ │ └── ExampleUnitTest.kt
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── android
│ │ └── stockapp
│ │ └── ExampleInstrumentedTest.kt
├── stockChartKey.jks
├── proguard-rules.pro
└── build.gradle
├── MPChartLib
├── .gitignore
├── ic_launcher-web.png
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── dot.png
│ │ │ │ └── ring.png
│ │ │ ├── drawable
│ │ │ │ └── fade_fill_color.xml
│ │ │ ├── drawable-night
│ │ │ │ └── fade_fill_color.xml
│ │ │ ├── values-night
│ │ │ │ └── colors.xml
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ └── colors.xml
│ │ │ ├── values-zh-rTW
│ │ │ │ └── strings.xml
│ │ │ └── layout
│ │ │ │ ├── my_markerview.xml
│ │ │ │ ├── view_kline.xml
│ │ │ │ └── view_time.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── github
│ │ │ │ └── mikephil
│ │ │ │ └── charting
│ │ │ │ ├── stockChart
│ │ │ │ ├── enums
│ │ │ │ │ ├── TimeType.java
│ │ │ │ │ └── ChartType.java
│ │ │ │ ├── model
│ │ │ │ │ ├── CirclePositionTime.java
│ │ │ │ │ └── bean
│ │ │ │ │ │ ├── EXPMAEntity.java
│ │ │ │ │ │ ├── SMAEntity.java
│ │ │ │ │ │ ├── KMAEntity.java
│ │ │ │ │ │ └── CCIEntity.java
│ │ │ │ ├── charts
│ │ │ │ │ └── TimeXAxis.java
│ │ │ │ ├── markerView
│ │ │ │ │ ├── BarBottomMarkerView.java
│ │ │ │ │ ├── TimeRightMarkerView.java
│ │ │ │ │ ├── LeftMarkerView.java
│ │ │ │ │ └── KRightMarkerView.java
│ │ │ │ └── event
│ │ │ │ │ └── BaseEvent.java
│ │ │ │ ├── interfaces
│ │ │ │ ├── dataprovider
│ │ │ │ │ ├── BubbleDataProvider.java
│ │ │ │ │ ├── CandleDataProvider.java
│ │ │ │ │ ├── ScatterDataProvider.java
│ │ │ │ │ ├── LineDataProvider.java
│ │ │ │ │ ├── CombinedDataProvider.java
│ │ │ │ │ ├── BarDataProvider.java
│ │ │ │ │ ├── BarLineScatterCandleBubbleDataProvider.java
│ │ │ │ │ └── ChartInterface.java
│ │ │ │ └── datasets
│ │ │ │ │ ├── IBarLineScatterCandleBubbleDataSet.java
│ │ │ │ │ ├── IBubbleDataSet.java
│ │ │ │ │ ├── IRadarDataSet.java
│ │ │ │ │ ├── IScatterDataSet.java
│ │ │ │ │ ├── ILineScatterCandleRadarDataSet.java
│ │ │ │ │ ├── ILineRadarDataSet.java
│ │ │ │ │ ├── ICandleDataSet.java
│ │ │ │ │ └── IPieDataSet.java
│ │ │ │ ├── highlight
│ │ │ │ ├── IHighlighter.java
│ │ │ │ ├── PieHighlighter.java
│ │ │ │ ├── Range.java
│ │ │ │ └── PieRadarHighlighter.java
│ │ │ │ ├── exception
│ │ │ │ └── DrawingDataSetNotCreatedException.java
│ │ │ │ ├── animation
│ │ │ │ └── EasingFunction.java
│ │ │ │ ├── listener
│ │ │ │ ├── OnDrawLineChartTouchListener.java
│ │ │ │ ├── OnChartValueSelectedListener.java
│ │ │ │ └── OnDrawListener.java
│ │ │ │ ├── data
│ │ │ │ ├── CandleData.java
│ │ │ │ ├── LineData.java
│ │ │ │ ├── BarLineScatterCandleBubbleData.java
│ │ │ │ ├── BubbleData.java
│ │ │ │ ├── ScatterData.java
│ │ │ │ ├── RadarEntry.java
│ │ │ │ ├── RadarData.java
│ │ │ │ ├── BarLineScatterCandleBubbleDataSet.java
│ │ │ │ └── BubbleDataSet.java
│ │ │ │ ├── renderer
│ │ │ │ ├── Renderer.java
│ │ │ │ └── scatter
│ │ │ │ │ ├── IShapeRenderer.java
│ │ │ │ │ ├── CrossShapeRenderer.java
│ │ │ │ │ ├── ChevronDownShapeRenderer.java
│ │ │ │ │ ├── ChevronUpShapeRenderer.java
│ │ │ │ │ └── XShapeRenderer.java
│ │ │ │ ├── utils
│ │ │ │ ├── EntryXComparator.java
│ │ │ │ ├── HorizontalViewPortHandler.java
│ │ │ │ ├── MPPointD.java
│ │ │ │ ├── TransformerHorizontalBarChart.java
│ │ │ │ └── FSize.java
│ │ │ │ ├── model
│ │ │ │ └── GradientColor.java
│ │ │ │ ├── formatter
│ │ │ │ ├── ColorFormatter.java
│ │ │ │ ├── IFillFormatter.java
│ │ │ │ ├── IAxisValueFormatter.java
│ │ │ │ ├── IValueFormatter.java
│ │ │ │ ├── DefaultFillFormatter.java
│ │ │ │ ├── DefaultAxisValueFormatter.java
│ │ │ │ ├── IndexAxisValueFormatter.java
│ │ │ │ ├── PercentFormatter.java
│ │ │ │ ├── DefaultValueFormatter.java
│ │ │ │ └── VolFormatter.java
│ │ │ │ ├── charts
│ │ │ │ ├── CandleStickChart.java
│ │ │ │ ├── BubbleChart.java
│ │ │ │ └── LineChart.java
│ │ │ │ ├── jobs
│ │ │ │ ├── ViewPortJob.java
│ │ │ │ └── MoveViewJob.java
│ │ │ │ └── components
│ │ │ │ └── IMarker.java
│ │ └── AndroidManifest.xml
│ └── test
│ │ └── java
│ │ └── com
│ │ └── github
│ │ └── mikephil
│ │ └── charting
│ │ └── test
│ │ └── ApproximatorTest.java
├── .settings
│ └── gradle
│ │ └── org.springsource.ide.eclipse.gradle.core.prefs
├── project.properties
└── proguard-project.txt
├── settings.gradle
├── screenshot
├── kline.jpg
├── stock.png
├── fiveday.jpg
├── oneday.jpg
├── record.gif
├── record.mp4
├── kline-land.jpg
├── stockChart.png
└── oneday-land.jpg
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .idea
├── caches
│ └── build_file_checksums.ser
├── vcs.xml
├── runConfigurations.xml
├── modules.xml
├── gradle.xml
├── codeStyles
│ └── Project.xml
└── misc.xml
├── .gitignore
├── gradle.properties
└── LICENSE
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/MPChartLib/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 | /.idea
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app',':MPChartLib'
2 |
--------------------------------------------------------------------------------
/app/testDemoKey.jks:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LambdaXiao/StockChart-MPAndroidChart/HEAD/app/testDemoKey.jks
--------------------------------------------------------------------------------
/screenshot/kline.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LambdaXiao/StockChart-MPAndroidChart/HEAD/screenshot/kline.jpg
--------------------------------------------------------------------------------
/screenshot/stock.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LambdaXiao/StockChart-MPAndroidChart/HEAD/screenshot/stock.png
--------------------------------------------------------------------------------
/app/src/main/assets/stacked_bars.txt:
--------------------------------------------------------------------------------
1 | 4#2#6#0
2 | 0#2#8#1
3 | 3#8#2#2
4 | 0#7#0#3
5 | 5#5#2#4
6 | 9#0#0#5
7 | 3#3#6#6
--------------------------------------------------------------------------------
/app/stockChartKey.jks:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LambdaXiao/StockChart-MPAndroidChart/HEAD/app/stockChartKey.jks
--------------------------------------------------------------------------------
/screenshot/fiveday.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LambdaXiao/StockChart-MPAndroidChart/HEAD/screenshot/fiveday.jpg
--------------------------------------------------------------------------------
/screenshot/oneday.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LambdaXiao/StockChart-MPAndroidChart/HEAD/screenshot/oneday.jpg
--------------------------------------------------------------------------------
/screenshot/record.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LambdaXiao/StockChart-MPAndroidChart/HEAD/screenshot/record.gif
--------------------------------------------------------------------------------
/screenshot/record.mp4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LambdaXiao/StockChart-MPAndroidChart/HEAD/screenshot/record.mp4
--------------------------------------------------------------------------------
/screenshot/kline-land.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LambdaXiao/StockChart-MPAndroidChart/HEAD/screenshot/kline-land.jpg
--------------------------------------------------------------------------------
/screenshot/stockChart.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LambdaXiao/StockChart-MPAndroidChart/HEAD/screenshot/stockChart.png
--------------------------------------------------------------------------------
/screenshot/oneday-land.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LambdaXiao/StockChart-MPAndroidChart/HEAD/screenshot/oneday-land.jpg
--------------------------------------------------------------------------------
/MPChartLib/ic_launcher-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LambdaXiao/StockChart-MPAndroidChart/HEAD/MPChartLib/ic_launcher-web.png
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LambdaXiao/StockChart-MPAndroidChart/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/drawable/star.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LambdaXiao/StockChart-MPAndroidChart/HEAD/app/src/main/res/drawable/star.png
--------------------------------------------------------------------------------
/.idea/caches/build_file_checksums.ser:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LambdaXiao/StockChart-MPAndroidChart/HEAD/.idea/caches/build_file_checksums.ser
--------------------------------------------------------------------------------
/app/src/main/assets/OpenSans-Bold.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LambdaXiao/StockChart-MPAndroidChart/HEAD/app/src/main/assets/OpenSans-Bold.ttf
--------------------------------------------------------------------------------
/app/src/main/assets/OpenSans-Light.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LambdaXiao/StockChart-MPAndroidChart/HEAD/app/src/main/assets/OpenSans-Light.ttf
--------------------------------------------------------------------------------
/app/src/main/res/drawable/marker2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LambdaXiao/StockChart-MPAndroidChart/HEAD/app/src/main/res/drawable/marker2.png
--------------------------------------------------------------------------------
/app/src/main/assets/OpenSans-Italic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LambdaXiao/StockChart-MPAndroidChart/HEAD/app/src/main/assets/OpenSans-Italic.ttf
--------------------------------------------------------------------------------
/app/src/main/assets/OpenSans-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LambdaXiao/StockChart-MPAndroidChart/HEAD/app/src/main/assets/OpenSans-Regular.ttf
--------------------------------------------------------------------------------
/app/src/main/assets/OpenSans-BoldItalic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LambdaXiao/StockChart-MPAndroidChart/HEAD/app/src/main/assets/OpenSans-BoldItalic.ttf
--------------------------------------------------------------------------------
/app/src/main/assets/OpenSans-ExtraBold.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LambdaXiao/StockChart-MPAndroidChart/HEAD/app/src/main/assets/OpenSans-ExtraBold.ttf
--------------------------------------------------------------------------------
/app/src/main/assets/OpenSans-Semibold.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LambdaXiao/StockChart-MPAndroidChart/HEAD/app/src/main/assets/OpenSans-Semibold.ttf
--------------------------------------------------------------------------------
/app/src/main/res/drawable/radar_marker.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LambdaXiao/StockChart-MPAndroidChart/HEAD/app/src/main/res/drawable/radar_marker.png
--------------------------------------------------------------------------------
/MPChartLib/src/main/res/mipmap-xhdpi/dot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LambdaXiao/StockChart-MPAndroidChart/HEAD/MPChartLib/src/main/res/mipmap-xhdpi/dot.png
--------------------------------------------------------------------------------
/MPChartLib/src/main/res/mipmap-xhdpi/ring.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LambdaXiao/StockChart-MPAndroidChart/HEAD/MPChartLib/src/main/res/mipmap-xhdpi/ring.png
--------------------------------------------------------------------------------
/app/src/main/assets/OpenSans-LightItalic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LambdaXiao/StockChart-MPAndroidChart/HEAD/app/src/main/assets/OpenSans-LightItalic.ttf
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LambdaXiao/StockChart-MPAndroidChart/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LambdaXiao/StockChart-MPAndroidChart/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LambdaXiao/StockChart-MPAndroidChart/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/assets/OpenSans-ExtraBoldItalic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LambdaXiao/StockChart-MPAndroidChart/HEAD/app/src/main/assets/OpenSans-ExtraBoldItalic.ttf
--------------------------------------------------------------------------------
/app/src/main/assets/OpenSans-SemiboldItalic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LambdaXiao/StockChart-MPAndroidChart/HEAD/app/src/main/assets/OpenSans-SemiboldItalic.ttf
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LambdaXiao/StockChart-MPAndroidChart/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LambdaXiao/StockChart-MPAndroidChart/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LambdaXiao/StockChart-MPAndroidChart/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LambdaXiao/StockChart-MPAndroidChart/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LambdaXiao/StockChart-MPAndroidChart/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LambdaXiao/StockChart-MPAndroidChart/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LambdaXiao/StockChart-MPAndroidChart/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values-night/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #1d1d1f
4 | #242426
5 | #FFFFFF
6 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/only_github.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/move_left_in_activity.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/move_right_in_activity.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/stockChart/enums/TimeType.java:
--------------------------------------------------------------------------------
1 | package com.github.mikephil.charting.stockChart.enums;
2 |
3 | /**
4 | * Created by Administrator on 2018/4/22.
5 | */
6 |
7 | public enum TimeType {
8 | TIME_HOUR,
9 | TIME_DATE
10 | }
11 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/move_left_out_activity.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/move_right_out_activity.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/fade_red.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Thu May 24 18:32:06 CST 2018
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
7 |
--------------------------------------------------------------------------------
/MPChartLib/.settings/gradle/org.springsource.ide.eclipse.gradle.core.prefs:
--------------------------------------------------------------------------------
1 | #org.springsource.ide.eclipse.gradle.core.preferences.GradleProjectPreferences
2 | #Mon Jan 18 23:02:46 CET 2016
3 | org.springsource.ide.eclipse.gradle.linkedresources=
4 | org.springsource.ide.eclipse.gradle.rootprojectloc=..
5 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/res/drawable/fade_fill_color.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/res/drawable-night/fade_fill_color.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/java/com/android/stockapp/common/data/Constants.java:
--------------------------------------------------------------------------------
1 | package com.android.stockapp.common.data;
2 |
3 | /**
4 | * 公共常量
5 | */
6 | public class Constants {
7 | public static String SP_FILE = "dayNightModeFile";//SharedPreferences存储文件名
8 | public static String DAY_NIGHT_MODE = "dayNightMode";//夜间模式key
9 | }
10 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_mpmain.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_right.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/interfaces/dataprovider/BubbleDataProvider.java:
--------------------------------------------------------------------------------
1 | package com.github.mikephil.charting.interfaces.dataprovider;
2 |
3 | import com.github.mikephil.charting.data.BubbleData;
4 |
5 | public interface BubbleDataProvider extends BarLineScatterCandleBubbleDataProvider {
6 |
7 | BubbleData getBubbleData();
8 | }
9 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/interfaces/dataprovider/CandleDataProvider.java:
--------------------------------------------------------------------------------
1 | package com.github.mikephil.charting.interfaces.dataprovider;
2 |
3 | import com.github.mikephil.charting.data.CandleData;
4 |
5 | public interface CandleDataProvider extends BarLineScatterCandleBubbleDataProvider {
6 |
7 | CandleData getCandleData();
8 | }
9 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/interfaces/dataprovider/ScatterDataProvider.java:
--------------------------------------------------------------------------------
1 | package com.github.mikephil.charting.interfaces.dataprovider;
2 |
3 | import com.github.mikephil.charting.data.ScatterData;
4 |
5 | public interface ScatterDataProvider extends BarLineScatterCandleBubbleDataProvider {
6 |
7 | ScatterData getScatterData();
8 | }
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #3F51B5
5 | #3F51B5
6 |
7 | #F5F5F5
8 | #FFFFFF
9 | #333333
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/frag_simple_bar.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/test/java/com/android/stockapp/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.android.stockapp
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
12 |
13 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/interfaces/dataprovider/LineDataProvider.java:
--------------------------------------------------------------------------------
1 | package com.github.mikephil.charting.interfaces.dataprovider;
2 |
3 | import com.github.mikephil.charting.components.YAxis;
4 | import com.github.mikephil.charting.data.LineData;
5 |
6 | public interface LineDataProvider extends BarLineScatterCandleBubbleDataProvider {
7 |
8 | LineData getLineData();
9 |
10 | YAxis getAxis(YAxis.AxisDependency dependency);
11 | }
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_combined.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_draw_chart.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_piechart_half.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_radarchart.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/highlight/IHighlighter.java:
--------------------------------------------------------------------------------
1 | package com.github.mikephil.charting.highlight;
2 |
3 | /**
4 | * Created by philipp on 10/06/16.
5 | */
6 | public interface IHighlighter {
7 |
8 | /**
9 | * Returns a Highlight object corresponding to the given x- and y- touch positions in pixels.
10 | *
11 | * @param x
12 | * @param y
13 | * @return
14 | */
15 | Highlight getHighlight(float x, float y);
16 | }
17 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/interfaces/dataprovider/CombinedDataProvider.java:
--------------------------------------------------------------------------------
1 | package com.github.mikephil.charting.interfaces.dataprovider;
2 |
3 | import com.github.mikephil.charting.data.CombinedData;
4 |
5 | /**
6 | * Created by philipp on 11/06/16.
7 | */
8 | public interface CombinedDataProvider extends LineDataProvider, BarDataProvider, BubbleDataProvider, CandleDataProvider, ScatterDataProvider {
9 |
10 | CombinedData getCombinedData();
11 | }
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_barchart_noseekbar.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_realtime_linechart.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_linechart_noseekbar.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/res/values-night/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | #ffffff
5 | #323232
6 | #323232
7 | #A7ADBC
8 | #ffffff
9 | #ffffff
10 | #7F2C3840
11 |
12 |
13 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/interfaces/dataprovider/BarDataProvider.java:
--------------------------------------------------------------------------------
1 | package com.github.mikephil.charting.interfaces.dataprovider;
2 |
3 | import com.github.mikephil.charting.data.BarData;
4 |
5 | public interface BarDataProvider extends BarLineScatterCandleBubbleDataProvider {
6 |
7 | BarData getBarData();
8 |
9 | boolean isDrawBarShadowEnabled();
10 |
11 | boolean isDrawValueAboveBarEnabled();
12 |
13 | boolean isHighlightFullBarEnabled();
14 | }
15 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_listview_chart.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/list_item_barchart.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/list_item_piechart.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/list_item_linechart.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/frag_simple_line.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/frag_simple_pie.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/stockChart/model/CirclePositionTime.java:
--------------------------------------------------------------------------------
1 | package com.github.mikephil.charting.stockChart.model;
2 |
3 | /**
4 | * Created by Administrator on 2016/9/18.
5 | */
6 | public class CirclePositionTime {
7 | public float cx;
8 | public float cy;
9 |
10 | @Override
11 | public String toString() {
12 | return "CirclePositionTime{" +
13 | "cx=" + cx +
14 | ", cy=" + cy +
15 | '}';
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_kline.xml:
--------------------------------------------------------------------------------
1 |
6 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/main.xml:
--------------------------------------------------------------------------------
1 |
2 |
18 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/exception/DrawingDataSetNotCreatedException.java:
--------------------------------------------------------------------------------
1 | package com.github.mikephil.charting.exception;
2 |
3 | public class DrawingDataSetNotCreatedException extends RuntimeException {
4 |
5 | /**
6 | *
7 | */
8 | private static final long serialVersionUID = 1L;
9 |
10 | public DrawingDataSetNotCreatedException() {
11 | super("Have to create a new drawing set first. Call ChartData's createNewDrawingDataSet() method");
12 | }
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/frag_simple_scatter.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_one_day.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | StockApp
3 | 加载中...
4 | 暂无数据
5 | 成交量
6 | 亿手
7 | 万手
8 | 手
9 | 亿股
10 | 万股
11 | 股
12 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_five_day.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/animation/EasingFunction.java:
--------------------------------------------------------------------------------
1 | package com.github.mikephil.charting.animation;
2 |
3 | import android.animation.TimeInterpolator;
4 | import android.annotation.SuppressLint;
5 |
6 | /**
7 | * Interface for creating custom made easing functions. Uses the
8 | * TimeInterpolator interface provided by Android.
9 | */
10 | @SuppressLint("NewApi")
11 | public interface EasingFunction extends TimeInterpolator {
12 |
13 | @Override
14 | float getInterpolation(float input);
15 | }
16 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_age_distribution.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_awesomedesign.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/listener/OnDrawLineChartTouchListener.java:
--------------------------------------------------------------------------------
1 | package com.github.mikephil.charting.listener;
2 |
3 | import android.view.GestureDetector.SimpleOnGestureListener;
4 | import android.view.MotionEvent;
5 | import android.view.View;
6 | import android.view.View.OnTouchListener;
7 |
8 | public class OnDrawLineChartTouchListener extends SimpleOnGestureListener implements OnTouchListener {
9 |
10 | @Override
11 | public boolean onTouch(View v, MotionEvent event) {
12 | return false;
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/res/values-zh-rTW/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | StockApp
4 | 加載中...
5 | 暫無數據
6 | 成交量
7 | 億手
8 | 萬手
9 | 手
10 | 億股
11 | 萬股
12 | 股
13 |
--------------------------------------------------------------------------------
/app/src/main/java/com/android/stockapp/ui/mpchartexample/notimportant/ContentItem.java:
--------------------------------------------------------------------------------
1 | package com.android.stockapp.ui.mpchartexample.notimportant;
2 |
3 | /**
4 | * Created by Philipp Jahoda on 07/12/15.
5 | */
6 | class ContentItem {
7 |
8 | final String name;
9 | final String desc;
10 | boolean isSection = false;
11 |
12 | ContentItem(String n) {
13 | name = n;
14 | desc = "";
15 | isSection = true;
16 | }
17 |
18 | ContentItem(String n, String d) {
19 | name = n;
20 | desc = d;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/stockChart/charts/TimeXAxis.java:
--------------------------------------------------------------------------------
1 | package com.github.mikephil.charting.stockChart.charts;
2 |
3 | import android.util.SparseArray;
4 |
5 | import com.github.mikephil.charting.components.XAxis;
6 |
7 | /**
8 | * Created by loro on 2017/2/8.
9 | */
10 | public class TimeXAxis extends XAxis {
11 | private SparseArray labels;
12 |
13 | public SparseArray getXLabels() {
14 | return labels;
15 | }
16 |
17 | public void setXLabels(SparseArray labels) {
18 | this.labels = labels;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/data/CandleData.java:
--------------------------------------------------------------------------------
1 | package com.github.mikephil.charting.data;
2 |
3 | import com.github.mikephil.charting.interfaces.datasets.ICandleDataSet;
4 |
5 | import java.util.ArrayList;
6 | import java.util.List;
7 |
8 | public class CandleData extends BarLineScatterCandleBubbleData {
9 |
10 | public CandleData() {
11 | super();
12 | }
13 |
14 | public CandleData(List dataSets) {
15 | super(dataSets);
16 | }
17 |
18 | public CandleData(ICandleDataSet... dataSets) {
19 | super(dataSets);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/Renderer.java:
--------------------------------------------------------------------------------
1 |
2 | package com.github.mikephil.charting.renderer;
3 |
4 | import com.github.mikephil.charting.utils.ViewPortHandler;
5 |
6 | /**
7 | * Abstract baseclass of all Renderers.
8 | *
9 | * @author Philipp Jahoda
10 | */
11 | public abstract class Renderer {
12 |
13 | /**
14 | * the component that handles the drawing area of the chart and it's offsets
15 | */
16 | protected ViewPortHandler mViewPortHandler;
17 |
18 | public Renderer(ViewPortHandler viewPortHandler) {
19 | this.mViewPortHandler = viewPortHandler;
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/res/layout/my_markerview.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
15 |
16 |
--------------------------------------------------------------------------------
/MPChartLib/project.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system edit
7 | # "ant.properties", and override values to adapt the script to your
8 | # project structure.
9 | #
10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
12 |
13 | # Project target.
14 | target=android-23
15 | android.library=true
16 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/utils/EntryXComparator.java:
--------------------------------------------------------------------------------
1 | package com.github.mikephil.charting.utils;
2 |
3 | import com.github.mikephil.charting.data.Entry;
4 |
5 | import java.util.Comparator;
6 |
7 | /**
8 | * Comparator for comparing Entry-objects by their x-value.
9 | * Created by philipp on 17/06/15.
10 | */
11 | public class EntryXComparator implements Comparator {
12 | @Override
13 | public int compare(Entry entry1, Entry entry2) {
14 | float diff = entry1.getX() - entry2.getX();
15 |
16 | if (diff == 0f) return 0;
17 | else {
18 | if (diff > 0f) return 1;
19 | else return -1;
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/combined.xml:
--------------------------------------------------------------------------------
1 |
2 |
22 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/interfaces/datasets/IBarLineScatterCandleBubbleDataSet.java:
--------------------------------------------------------------------------------
1 | package com.github.mikephil.charting.interfaces.datasets;
2 |
3 | import com.github.mikephil.charting.data.Entry;
4 |
5 | /**
6 | * Created by philipp on 21/10/15.
7 | */
8 | public interface IBarLineScatterCandleBubbleDataSet extends IDataSet {
9 |
10 | /**
11 | * Returns the color that is used for drawing the highlight indicators.
12 | *
13 | * @return
14 | */
15 | int getHighLightColor();
16 |
17 | /**
18 | * Returns the line-width in which highlight lines are to be drawn.
19 | *
20 | * @return
21 | */
22 | float getHighlightLineWidth();
23 | }
24 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/data/LineData.java:
--------------------------------------------------------------------------------
1 |
2 | package com.github.mikephil.charting.data;
3 |
4 | import com.github.mikephil.charting.interfaces.datasets.ILineDataSet;
5 |
6 | import java.util.ArrayList;
7 | import java.util.List;
8 |
9 | /**
10 | * Data object that encapsulates all data associated with a LineChart.
11 | *
12 | * @author Philipp Jahoda
13 | */
14 | public class LineData extends BarLineScatterCandleBubbleData {
15 |
16 | public LineData() {
17 | super();
18 | }
19 |
20 | public LineData(ILineDataSet... dataSets) {
21 | super(dataSets);
22 | }
23 |
24 | public LineData(List dataSets) {
25 | super(dataSets);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/interfaces/dataprovider/BarLineScatterCandleBubbleDataProvider.java:
--------------------------------------------------------------------------------
1 | package com.github.mikephil.charting.interfaces.dataprovider;
2 |
3 | import com.github.mikephil.charting.components.YAxis.AxisDependency;
4 | import com.github.mikephil.charting.data.BarLineScatterCandleBubbleData;
5 | import com.github.mikephil.charting.utils.Transformer;
6 |
7 | public interface BarLineScatterCandleBubbleDataProvider extends ChartInterface {
8 |
9 | Transformer getTransformer(AxisDependency axis);
10 |
11 | boolean isInverted(AxisDependency axis);
12 |
13 | float getLowestVisibleX();
14 |
15 | float getHighestVisibleX();
16 |
17 | @Override
18 | BarLineScatterCandleBubbleData getData();
19 | }
20 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/model/GradientColor.java:
--------------------------------------------------------------------------------
1 | package com.github.mikephil.charting.model;
2 |
3 | public class GradientColor {
4 |
5 | private int startColor;
6 | private int endColor;
7 |
8 | public GradientColor(int startColor, int endColor) {
9 | this.startColor = startColor;
10 | this.endColor = endColor;
11 | }
12 |
13 | public int getStartColor() {
14 | return startColor;
15 | }
16 |
17 | public void setStartColor(int startColor) {
18 | this.startColor = startColor;
19 | }
20 |
21 | public int getEndColor() {
22 | return endColor;
23 | }
24 |
25 | public void setEndColor(int endColor) {
26 | this.endColor = endColor;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/realtime.xml:
--------------------------------------------------------------------------------
1 |
2 |
26 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/android/stockapp/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.android.stockapp
2 |
3 | import android.support.test.InstrumentationRegistry
4 | import android.support.test.runner.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getTargetContext()
22 | assertEquals("com.android.stockapp", appContext.packageName)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/java/com/android/stockapp/common/viewpager/NoTouchScrollViewpager.java:
--------------------------------------------------------------------------------
1 | package com.android.stockapp.common.viewpager;
2 |
3 | import android.content.Context;
4 | import androidx.viewpager.widget.ViewPager;
5 | import android.util.AttributeSet;
6 | import android.view.MotionEvent;
7 |
8 | public class NoTouchScrollViewpager extends ViewPager{
9 | public NoTouchScrollViewpager(Context context) {
10 | this(context, null);
11 | }
12 |
13 | public NoTouchScrollViewpager(Context context, AttributeSet attrs) {
14 | super(context, attrs);
15 | }
16 |
17 | @Override
18 | public boolean onTouchEvent(MotionEvent ev) {
19 | return false;
20 | }
21 |
22 | @Override
23 | public boolean onInterceptTouchEvent(MotionEvent arg0) {
24 | return false;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/interfaces/datasets/IBubbleDataSet.java:
--------------------------------------------------------------------------------
1 | package com.github.mikephil.charting.interfaces.datasets;
2 |
3 | import com.github.mikephil.charting.data.BubbleEntry;
4 |
5 | /**
6 | * Created by philipp on 21/10/15.
7 | */
8 | public interface IBubbleDataSet extends IBarLineScatterCandleBubbleDataSet {
9 |
10 | /**
11 | * Sets the width of the circle that surrounds the bubble when highlighted,
12 | * in dp.
13 | *
14 | * @param width
15 | */
16 | void setHighlightCircleWidth(float width);
17 |
18 | float getMaxSize();
19 |
20 | boolean isNormalizeSizeEnabled();
21 |
22 | /**
23 | * Returns the width of the highlight-circle that surrounds the bubble
24 | * @return
25 | */
26 | float getHighlightCircleWidth();
27 | }
28 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/data/BarLineScatterCandleBubbleData.java:
--------------------------------------------------------------------------------
1 |
2 | package com.github.mikephil.charting.data;
3 |
4 | import com.github.mikephil.charting.interfaces.datasets.IBarLineScatterCandleBubbleDataSet;
5 |
6 | import java.util.List;
7 |
8 | /**
9 | * Baseclass for all Line, Bar, Scatter, Candle and Bubble data.
10 | *
11 | * @author Philipp Jahoda
12 | */
13 | public abstract class BarLineScatterCandleBubbleData>
14 | extends ChartData {
15 |
16 | public BarLineScatterCandleBubbleData() {
17 | super();
18 | }
19 |
20 | public BarLineScatterCandleBubbleData(T... sets) {
21 | super(sets);
22 | }
23 |
24 | public BarLineScatterCandleBubbleData(List sets) {
25 | super(sets);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/utils/HorizontalViewPortHandler.java:
--------------------------------------------------------------------------------
1 |
2 | package com.github.mikephil.charting.utils;
3 |
4 | /**
5 | * ViewPortHandler for HorizontalBarChart.
6 | */
7 | public class HorizontalViewPortHandler extends ViewPortHandler {
8 |
9 |
10 | @Override
11 | public void setMinimumScaleX(float xScale) {
12 | setMinimumScaleY(xScale);
13 | }
14 |
15 | @Override
16 | public void setMinimumScaleY(float yScale) {
17 | setMinimumScaleX(yScale);
18 | }
19 |
20 | @Override
21 | public void setMinMaxScaleX(float minScaleX, float maxScaleX) {
22 | setMinMaxScaleY(minScaleX, maxScaleX);
23 | }
24 |
25 | @Override
26 | public void setMinMaxScaleY(float minScaleY, float maxScaleY) {
27 | setMinMaxScaleX(minScaleY, maxScaleY);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/app/src/main/java/com/android/stockapp/ui/mpchartexample/listviewitems/ChartItem.java:
--------------------------------------------------------------------------------
1 | package com.android.stockapp.ui.mpchartexample.listviewitems;
2 |
3 | import android.content.Context;
4 | import android.view.View;
5 |
6 | import com.github.mikephil.charting.data.ChartData;
7 |
8 | /**
9 | * Base class of the Chart ListView items
10 | * @author philipp
11 | *
12 | */
13 | @SuppressWarnings("unused")
14 | public abstract class ChartItem {
15 |
16 | static final int TYPE_BARCHART = 0;
17 | static final int TYPE_LINECHART = 1;
18 | static final int TYPE_PIECHART = 2;
19 |
20 | ChartData> mChartData;
21 |
22 | ChartItem(ChartData> cd) {
23 | this.mChartData = cd;
24 | }
25 |
26 | public abstract int getItemType();
27 |
28 | public abstract View getView(int position, View convertView, Context c);
29 | }
30 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | android.enableJetifier=true
13 | android.useAndroidX=true
14 | org.gradle.jvmargs=-Xmx1536m
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
19 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/res/layout/view_kline.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
13 |
14 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/java/com/android/stockapp/ui/mpchartexample/custom/MyFillFormatter.java:
--------------------------------------------------------------------------------
1 | package com.android.stockapp.ui.mpchartexample.custom;
2 |
3 | import com.github.mikephil.charting.formatter.IFillFormatter;
4 | import com.github.mikephil.charting.interfaces.dataprovider.LineDataProvider;
5 | import com.github.mikephil.charting.interfaces.datasets.ILineDataSet;
6 |
7 | /**
8 | * Created by Philipp Jahoda on 12/09/15.
9 | */
10 | @SuppressWarnings("unused")
11 | public class MyFillFormatter implements IFillFormatter
12 | {
13 |
14 | private float fillPos;
15 |
16 | public MyFillFormatter(float fillPos) {
17 | this.fillPos = fillPos;
18 | }
19 |
20 | @Override
21 | public float getFillLinePosition(ILineDataSet dataSet, LineDataProvider dataProvider) {
22 | // your logic could be here
23 | return fillPos;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/stockChart/enums/ChartType.java:
--------------------------------------------------------------------------------
1 | package com.github.mikephil.charting.stockChart.enums;
2 |
3 | /**
4 | * 画图类型
5 | */
6 | public enum ChartType {
7 | ONE_DAY(241),//沪深股票当日分时线总点数
8 | FIVE_DAY(305),//沪深股票五日分时线总点数
9 | HK_ONE_DAY(331),//港股当日分时线总点数
10 | HK_FIVE_DAY(415),//港股五日分时线总点数
11 | US_ONE_DAY(390),//美股当日分时线总点数
12 | US_FIVE_DAY(488),//美股五日分时线总点数
13 | K_DAY_SMALL(100),//竖屏日K展示的总数据条数
14 | K_WEEK_SMALL(100),//竖屏周K展示的总数据条数
15 | K_MONTH_SMALL(100),//竖屏月K展示的总数据条数
16 | K_DAY_BIG(1000),//横屏日K展示的总数据条数
17 | K_WEEK_BIG(1000),//横屏周K展示的总数据条数
18 | K_MONTH_BIG(1000);//横屏月K展示的总数据条数
19 |
20 |
21 | private int pointNum = 0;
22 |
23 | ChartType(int num) {
24 | this.pointNum = num;
25 | }
26 |
27 | public int getPointNum() {
28 | return pointNum;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/MPChartLib/proguard-project.txt:
--------------------------------------------------------------------------------
1 | # To enable ProGuard in your project, edit project.properties
2 | # to define the proguard.config property as described in that file.
3 | #
4 | # Add project specific ProGuard rules here.
5 | # By default, the flags in this file are appended to flags specified
6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt
7 | # You can edit the include path and order by changing the ProGuard
8 | # include property in project.properties.
9 | #
10 | # For more details, see
11 | # http://developer.android.com/guide/developing/tools/proguard.html
12 |
13 | # Add any project specific keep options here:
14 |
15 | # If your project uses WebView with JS, uncomment the following
16 | # and specify the fully qualified class name to the JavaScript interface
17 | # class:
18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
19 | # public *;
20 | #}
21 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/highlight/PieHighlighter.java:
--------------------------------------------------------------------------------
1 | package com.github.mikephil.charting.highlight;
2 |
3 | import com.github.mikephil.charting.charts.PieChart;
4 | import com.github.mikephil.charting.data.Entry;
5 | import com.github.mikephil.charting.interfaces.datasets.IPieDataSet;
6 |
7 | /**
8 | * Created by philipp on 12/06/16.
9 | */
10 | public class PieHighlighter extends PieRadarHighlighter {
11 |
12 | public PieHighlighter(PieChart chart) {
13 | super(chart);
14 | }
15 |
16 | @Override
17 | protected Highlight getClosestHighlight(int index, float x, float y) {
18 |
19 | IPieDataSet set = mChart.getData().getDataSet();
20 |
21 | final Entry entry = set.getEntryForIndex(index);
22 |
23 | return new Highlight(index, entry.getY(), x, y, 0, set.getAxisDependency());
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/formatter/ColorFormatter.java:
--------------------------------------------------------------------------------
1 | package com.github.mikephil.charting.formatter;
2 |
3 | import com.github.mikephil.charting.data.DataSet;
4 | import com.github.mikephil.charting.data.Entry;
5 | import com.github.mikephil.charting.interfaces.datasets.IDataSet;
6 |
7 | /**
8 | * Interface that can be used to return a customized color instead of setting
9 | * colors via the setColor(...) method of the DataSet.
10 | *
11 | * @author Philipp Jahoda
12 | */
13 | public interface ColorFormatter {
14 |
15 | /**
16 | * Returns the color to be used for the given Entry at the given index (in the entries array)
17 | *
18 | * @param index index in the entries array
19 | * @param e the entry to color
20 | * @param set the DataSet the entry belongs to
21 | * @return
22 | */
23 | int getColor(int index, Entry e, IDataSet set);
24 | }
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/formatter/IFillFormatter.java:
--------------------------------------------------------------------------------
1 | package com.github.mikephil.charting.formatter;
2 |
3 | import com.github.mikephil.charting.interfaces.datasets.ILineDataSet;
4 | import com.github.mikephil.charting.interfaces.dataprovider.LineDataProvider;
5 |
6 | /**
7 | * Interface for providing a custom logic to where the filling line of a LineDataSet
8 | * should end. This of course only works if setFillEnabled(...) is set to true.
9 | *
10 | * @author Philipp Jahoda
11 | */
12 | public interface IFillFormatter {
13 |
14 | /**
15 | * Returns the vertical (y-axis) position where the filled-line of the
16 | * LineDataSet should end.
17 | *
18 | * @param dataSet the ILineDataSet that is currently drawn
19 | * @param dataProvider
20 | * @return
21 | */
22 | float getFillLinePosition(ILineDataSet dataSet, LineDataProvider dataProvider);
23 | }
24 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
12 |
17 |
18 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/java/com/android/stockapp/ui/mpchartexample/custom/YearXAxisFormatter.java:
--------------------------------------------------------------------------------
1 | package com.android.stockapp.ui.mpchartexample.custom;
2 |
3 | import com.github.mikephil.charting.components.AxisBase;
4 | import com.github.mikephil.charting.formatter.ValueFormatter;
5 |
6 | /**
7 | * Created by Philipp Jahoda on 14/09/15.
8 | */
9 | @SuppressWarnings("unused")
10 | public class YearXAxisFormatter extends ValueFormatter
11 | {
12 |
13 | private final String[] mMonths = new String[]{
14 | "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dec"
15 | };
16 |
17 | public YearXAxisFormatter() {
18 | // take parameters to change behavior of formatter
19 | }
20 |
21 | @Override
22 | public String getAxisLabel(float value, AxisBase axis) {
23 |
24 | float percent = value / axis.mAxisRange;
25 | return mMonths[(int) (mMonths.length * percent)];
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/listener/OnChartValueSelectedListener.java:
--------------------------------------------------------------------------------
1 | package com.github.mikephil.charting.listener;
2 |
3 | import com.github.mikephil.charting.data.Entry;
4 | import com.github.mikephil.charting.highlight.Highlight;
5 |
6 | /**
7 | * Listener for callbacks when selecting values inside the chart by
8 | * touch-gesture.
9 | *
10 | * @author Philipp Jahoda
11 | */
12 | public interface OnChartValueSelectedListener {
13 |
14 | /**
15 | * Called when a value has been selected inside the chart.
16 | *
17 | * @param e The selected Entry
18 | * @param h The corresponding highlight object that contains information
19 | * about the highlighted position such as dataSetIndex, ...
20 | */
21 | void onValueSelected(Entry e, Highlight h);
22 |
23 | /**
24 | * Called when nothing has been selected or an "un-select" has been made.
25 | */
26 | void onNothingSelected();
27 | }
28 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_stock_detail_land.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
14 |
15 |
21 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/data/BubbleData.java:
--------------------------------------------------------------------------------
1 |
2 | package com.github.mikephil.charting.data;
3 |
4 | import com.github.mikephil.charting.interfaces.datasets.IBubbleDataSet;
5 |
6 | import java.util.List;
7 |
8 | public class BubbleData extends BarLineScatterCandleBubbleData {
9 |
10 | public BubbleData() {
11 | super();
12 | }
13 |
14 | public BubbleData(IBubbleDataSet... dataSets) {
15 | super(dataSets);
16 | }
17 |
18 | public BubbleData(List dataSets) {
19 | super(dataSets);
20 | }
21 |
22 |
23 | /**
24 | * Sets the width of the circle that surrounds the bubble when highlighted
25 | * for all DataSet objects this data object contains, in dp.
26 | *
27 | * @param width
28 | */
29 | public void setHighlightCircleWidth(float width) {
30 | for (IBubbleDataSet set : mDataSets) {
31 | set.setHighlightCircleWidth(width);
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/custom_marker_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/list_item_section.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
15 |
16 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/interfaces/datasets/IRadarDataSet.java:
--------------------------------------------------------------------------------
1 | package com.github.mikephil.charting.interfaces.datasets;
2 |
3 | import com.github.mikephil.charting.data.RadarEntry;
4 |
5 | /**
6 | * Created by Philipp Jahoda on 03/11/15.
7 | */
8 | public interface IRadarDataSet extends ILineRadarDataSet {
9 |
10 | /// flag indicating whether highlight circle should be drawn or not
11 | boolean isDrawHighlightCircleEnabled();
12 |
13 | /// Sets whether highlight circle should be drawn or not
14 | void setDrawHighlightCircleEnabled(boolean enabled);
15 |
16 | int getHighlightCircleFillColor();
17 |
18 | /// The stroke color for highlight circle.
19 | /// If Utils.COLOR_NONE, the color of the dataset is taken.
20 | int getHighlightCircleStrokeColor();
21 |
22 | int getHighlightCircleStrokeAlpha();
23 |
24 | float getHighlightCircleInnerRadius();
25 |
26 | float getHighlightCircleOuterRadius();
27 |
28 | float getHighlightCircleStrokeWidth();
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/data/ScatterData.java:
--------------------------------------------------------------------------------
1 |
2 | package com.github.mikephil.charting.data;
3 |
4 | import com.github.mikephil.charting.interfaces.datasets.IScatterDataSet;
5 |
6 | import java.util.List;
7 |
8 | public class ScatterData extends BarLineScatterCandleBubbleData {
9 |
10 | public ScatterData() {
11 | super();
12 | }
13 |
14 | public ScatterData(List dataSets) {
15 | super(dataSets);
16 | }
17 |
18 | public ScatterData(IScatterDataSet... dataSets) {
19 | super(dataSets);
20 | }
21 |
22 | /**
23 | * Returns the maximum shape-size across all DataSets.
24 | *
25 | * @return
26 | */
27 | public float getGreatestShapeSize() {
28 |
29 | float max = 0f;
30 |
31 | for (IScatterDataSet set : mDataSets) {
32 | float size = set.getScatterShapeSize();
33 |
34 | if (size > max)
35 | max = size;
36 | }
37 |
38 | return max;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/dynamical.xml:
--------------------------------------------------------------------------------
1 |
2 |
34 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/formatter/IAxisValueFormatter.java:
--------------------------------------------------------------------------------
1 | package com.github.mikephil.charting.formatter;
2 |
3 | import com.github.mikephil.charting.components.AxisBase;
4 |
5 | /**
6 | * Created by Philipp Jahoda on 20/09/15.
7 | * Custom formatter interface that allows formatting of
8 | * axis labels before they are being drawn.
9 | *
10 | * @deprecated Extend {@link ValueFormatter} instead
11 | */
12 | @Deprecated
13 | public interface IAxisValueFormatter
14 | {
15 |
16 | /**
17 | * Called when a value from an axis is to be formatted
18 | * before being drawn. For performance reasons, avoid excessive calculations
19 | * and memory allocations inside this method.
20 | *
21 | * @param value the value to be formatted
22 | * @param axis the axis the value belongs to
23 | * @return
24 | *
25 | * @deprecated Extend {@link ValueFormatter} and use {@link ValueFormatter#getAxisLabel(float, AxisBase)}
26 | */
27 | @Deprecated
28 | String getFormattedValue(float value, AxisBase axis);
29 | }
30 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/interfaces/datasets/IScatterDataSet.java:
--------------------------------------------------------------------------------
1 | package com.github.mikephil.charting.interfaces.datasets;
2 |
3 | import com.github.mikephil.charting.data.Entry;
4 | import com.github.mikephil.charting.renderer.scatter.IShapeRenderer;
5 |
6 | /**
7 | * Created by philipp on 21/10/15.
8 | */
9 | public interface IScatterDataSet extends ILineScatterCandleRadarDataSet {
10 |
11 | /**
12 | * Returns the currently set scatter shape size
13 | *
14 | * @return
15 | */
16 | float getScatterShapeSize();
17 |
18 | /**
19 | * Returns radius of the hole in the shape
20 | *
21 | * @return
22 | */
23 | float getScatterShapeHoleRadius();
24 |
25 | /**
26 | * Returns the color for the hole in the shape
27 | *
28 | * @return
29 | */
30 | int getScatterShapeHoleColor();
31 |
32 | /**
33 | * Returns the IShapeRenderer responsible for rendering this DataSet.
34 | *
35 | * @return
36 | */
37 | IShapeRenderer getShapeRenderer();
38 | }
39 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/radar_markerview.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/draw.xml:
--------------------------------------------------------------------------------
1 |
2 |
33 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/data/RadarEntry.java:
--------------------------------------------------------------------------------
1 | package com.github.mikephil.charting.data;
2 |
3 | import android.annotation.SuppressLint;
4 |
5 | /**
6 | * Created by philipp on 13/06/16.
7 | */
8 | @SuppressLint("ParcelCreator")
9 | public class RadarEntry extends Entry {
10 |
11 | public RadarEntry(float value) {
12 | super(0f, value);
13 | }
14 |
15 | public RadarEntry(float value, Object data) {
16 | super(0f, value, data);
17 | }
18 |
19 | /**
20 | * This is the same as getY(). Returns the value of the RadarEntry.
21 | *
22 | * @return
23 | */
24 | public float getValue() {
25 | return getY();
26 | }
27 |
28 | @Override
29 | public RadarEntry copy() {
30 | RadarEntry e = new RadarEntry(getY(), getData());
31 | return e;
32 | }
33 |
34 | @Deprecated
35 | @Override
36 | public void setX(float x) {
37 | super.setX(x);
38 | }
39 |
40 | @Deprecated
41 | @Override
42 | public float getX() {
43 | return super.getX();
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/app/src/main/java/com/android/stockapp/application/MyApplication.java:
--------------------------------------------------------------------------------
1 | package com.android.stockapp.application;
2 |
3 | import android.content.Context;
4 | import android.content.SharedPreferences;
5 | import androidx.appcompat.app.AppCompatDelegate;
6 |
7 | import com.android.stockapp.common.data.Constants;
8 | import com.android.stockapp.ui.base.BaseApp;
9 |
10 |
11 | public class MyApplication extends BaseApp {
12 | @Override
13 | public void onCreate() {
14 | super.onCreate();
15 | initDayNight();
16 | }
17 |
18 | public static MyApplication getApplication() {
19 | return (MyApplication) getApp();
20 | }
21 |
22 | public void initDayNight(){
23 | //初始化夜间模式
24 | SharedPreferences sp = getSharedPreferences(Constants.SP_FILE,Context.MODE_PRIVATE);
25 | if(sp.getBoolean(Constants.DAY_NIGHT_MODE,false)){
26 | AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
27 | }else {
28 | AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/highlight/Range.java:
--------------------------------------------------------------------------------
1 | package com.github.mikephil.charting.highlight;
2 |
3 | /**
4 | * Created by Philipp Jahoda on 24/07/15. Class that represents the range of one value in a stacked bar entry. e.g.
5 | * stack values are -10, 5, 20 -> then ranges are (-10 - 0, 0 - 5, 5 - 25).
6 | */
7 | public final class Range {
8 |
9 | public float from;
10 | public float to;
11 |
12 | public Range(float from, float to) {
13 | this.from = from;
14 | this.to = to;
15 | }
16 |
17 | /**
18 | * Returns true if this range contains (if the value is in between) the given value, false if not.
19 | *
20 | * @param value
21 | * @return
22 | */
23 | public boolean contains(float value) {
24 |
25 | if (value > from && value <= to)
26 | return true;
27 | else
28 | return false;
29 | }
30 |
31 | public boolean isLarger(float value) {
32 | return value > to;
33 | }
34 |
35 | public boolean isSmaller(float value) {
36 | return value < from;
37 | }
38 | }
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/listener/OnDrawListener.java:
--------------------------------------------------------------------------------
1 | package com.github.mikephil.charting.listener;
2 |
3 | import com.github.mikephil.charting.data.DataSet;
4 | import com.github.mikephil.charting.data.Entry;
5 |
6 | /**
7 | * Listener for callbacks when drawing on the chart.
8 | *
9 | * @author Philipp
10 | */
11 | public interface OnDrawListener {
12 |
13 | /**
14 | * Called whenever an entry is added with the finger. Note this is also called for entries that are generated by the
15 | * library, when the touch gesture is too fast and skips points.
16 | *
17 | * @param entry the last drawn entry
18 | */
19 | void onEntryAdded(Entry entry);
20 |
21 | /**
22 | * Called whenever an entry is moved by the user after beeing highlighted
23 | *
24 | * @param entry
25 | */
26 | void onEntryMoved(Entry entry);
27 |
28 | /**
29 | * Called when drawing finger is lifted and the draw is finished.
30 | *
31 | * @param dataSet the last drawn DataSet
32 | */
33 | void onDrawFinished(DataSet> dataSet);
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/app/src/main/java/com/android/stockapp/ui/mpchartexample/custom/CustomScatterShapeRenderer.java:
--------------------------------------------------------------------------------
1 | package com.android.stockapp.ui.mpchartexample.custom;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Paint;
5 |
6 | import com.github.mikephil.charting.interfaces.datasets.IScatterDataSet;
7 | import com.github.mikephil.charting.renderer.scatter.IShapeRenderer;
8 | import com.github.mikephil.charting.utils.ViewPortHandler;
9 |
10 | /**
11 | * Custom shape renderer that draws a single line.
12 | * Created by philipp on 26/06/16.
13 | */
14 | public class CustomScatterShapeRenderer implements IShapeRenderer
15 | {
16 |
17 | @Override
18 | public void renderShape(Canvas c, IScatterDataSet dataSet, ViewPortHandler viewPortHandler,
19 | float posX, float posY, Paint renderPaint) {
20 |
21 | final float shapeHalf = dataSet.getScatterShapeSize() / 2f;
22 |
23 | c.drawLine(
24 | posX - shapeHalf,
25 | posY - shapeHalf,
26 | posX + shapeHalf,
27 | posY + shapeHalf,
28 | renderPaint);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Lambda Xiao
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/list_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
17 |
18 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/scatter/IShapeRenderer.java:
--------------------------------------------------------------------------------
1 | package com.github.mikephil.charting.renderer.scatter;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Paint;
5 |
6 | import com.github.mikephil.charting.interfaces.datasets.IScatterDataSet;
7 | import com.github.mikephil.charting.utils.ViewPortHandler;
8 |
9 | /**
10 | * Created by wajdic on 15/06/2016.
11 | * Created at Time 09:07
12 | */
13 | public interface IShapeRenderer {
14 |
15 | /**
16 | * Renders the provided ScatterDataSet with a shape.
17 | *
18 | * @param c Canvas object for drawing the shape
19 | * @param dataSet The DataSet to be drawn
20 | * @param viewPortHandler Contains information about the current state of the view
21 | * @param posX Position to draw the shape at
22 | * @param posY Position to draw the shape at
23 | * @param renderPaint Paint object used for styling and drawing
24 | */
25 | void renderShape(Canvas c, IScatterDataSet dataSet, ViewPortHandler viewPortHandler,
26 | float posX, float posY, Paint renderPaint);
27 | }
28 |
--------------------------------------------------------------------------------
/app/src/main/java/com/android/stockapp/ui/mpchartexample/custom/MyValueFormatter.java:
--------------------------------------------------------------------------------
1 | package com.android.stockapp.ui.mpchartexample.custom;
2 |
3 | import com.github.mikephil.charting.components.AxisBase;
4 | import com.github.mikephil.charting.components.XAxis;
5 | import com.github.mikephil.charting.formatter.ValueFormatter;
6 |
7 | import java.text.DecimalFormat;
8 |
9 | public class MyValueFormatter extends ValueFormatter
10 | {
11 |
12 | private final DecimalFormat mFormat;
13 | private String suffix;
14 |
15 | public MyValueFormatter(String suffix) {
16 | mFormat = new DecimalFormat("###,###,###,##0.0");
17 | this.suffix = suffix;
18 | }
19 |
20 | @Override
21 | public String getFormattedValue(float value) {
22 | return mFormat.format(value) + suffix;
23 | }
24 |
25 | @Override
26 | public String getAxisLabel(float value, AxisBase axis) {
27 | if (axis instanceof XAxis) {
28 | return mFormat.format(value);
29 | } else if (value > 0) {
30 | return mFormat.format(value) + suffix;
31 | } else {
32 | return mFormat.format(value);
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/interfaces/datasets/ILineScatterCandleRadarDataSet.java:
--------------------------------------------------------------------------------
1 | package com.github.mikephil.charting.interfaces.datasets;
2 |
3 | import android.graphics.DashPathEffect;
4 |
5 | import com.github.mikephil.charting.data.Entry;
6 |
7 | /**
8 | * Created by Philipp Jahoda on 21/10/15.
9 | */
10 | public interface ILineScatterCandleRadarDataSet extends IBarLineScatterCandleBubbleDataSet {
11 |
12 | /**
13 | * Returns true if vertical highlight indicator lines are enabled (drawn)
14 | * @return
15 | */
16 | boolean isVerticalHighlightIndicatorEnabled();
17 |
18 | /**
19 | * Returns true if vertical highlight indicator lines are enabled (drawn)
20 | * @return
21 | */
22 | boolean isHorizontalHighlightIndicatorEnabled();
23 |
24 | /**
25 | * Returns the line-width in which highlight lines are to be drawn.
26 | * @return
27 | */
28 | @Override
29 | float getHighlightLineWidth();
30 |
31 | /**
32 | * Returns the DashPathEffect that is used for highlighting.
33 | * @return
34 | */
35 | DashPathEffect getDashPathEffectHighlight();
36 | }
37 |
--------------------------------------------------------------------------------
/MPChartLib/src/test/java/com/github/mikephil/charting/test/ApproximatorTest.java:
--------------------------------------------------------------------------------
1 | package com.github.mikephil.charting.test;
2 |
3 | import com.github.mikephil.charting.data.Entry;
4 | import com.github.mikephil.charting.data.filter.Approximator;
5 |
6 | import org.junit.Test;
7 |
8 | import java.util.ArrayList;
9 | import java.util.List;
10 |
11 | import static junit.framework.Assert.assertEquals;
12 |
13 | /**
14 | * Created by philipp on 07/06/16.
15 | */
16 | public class ApproximatorTest {
17 |
18 | @Test
19 | public void testApproximation() {
20 |
21 | float[] points = new float[]{
22 | 10, 20,
23 | 20, 30,
24 | 25, 25,
25 | 30, 28,
26 | 31, 31,
27 | 33, 33,
28 | 40, 40,
29 | 44, 40,
30 | 48, 23,
31 | 50, 20,
32 | 55, 20,
33 | 60, 25};
34 |
35 | assertEquals(24, points.length);
36 |
37 | Approximator a = new Approximator();
38 |
39 | float[] reduced = a.reduceWithDouglasPeucker(points, 2);
40 |
41 | assertEquals(18, reduced.length);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_colored_lines.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
17 |
22 |
27 |
28 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/stockChart/model/bean/EXPMAEntity.java:
--------------------------------------------------------------------------------
1 | package com.github.mikephil.charting.stockChart.model.bean;
2 |
3 | import com.github.mikephil.charting.stockChart.model.KLineDataModel;
4 |
5 | import java.util.ArrayList;
6 |
7 | /**
8 | * Created by loro on 2017/3/8.
9 | */
10 |
11 | public class EXPMAEntity {
12 |
13 | private ArrayList EXPMAs;
14 |
15 | public EXPMAEntity(ArrayList kLineBeens, int n) {
16 | EXPMAs = new ArrayList<>();
17 |
18 | float ema = 0.0f;
19 | float t = n + 1;
20 | float yz = 2 / t;
21 | if (kLineBeens != null && kLineBeens.size() > 0) {
22 |
23 | for (int i = 0; i < kLineBeens.size(); i++) {
24 | if (i == 0) {
25 | ema = (float) kLineBeens.get(i).getClose();
26 | } else {
27 | ema = (float) ((yz * kLineBeens.get(i).getClose()) + ((1 - yz) * ema));
28 | // ema = (kLineBeens.get(i).close - ema) * (2 / (n + 1)) + ema;
29 | }
30 | EXPMAs.add(ema);
31 | }
32 | }
33 | }
34 |
35 | public ArrayList getEXPMAs() {
36 | return EXPMAs;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 | #E9403C
8 | #30A52F
9 | #696969
10 |
11 | #5198FA
12 | #E9967A
13 | #8d4bbb
14 | #804000
15 |
16 |
17 | #ffffff
18 | #406ebc
19 | #FFFFFF
20 | #e8e8e8
21 | #e8e8e8
22 | #A7ADBC
23 | #333333
24 | #7F9976
25 | #5198FA
26 | #E7B448
27 | #aa424242
28 | #D0F1FF
29 |
30 |
31 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
20 |
21 |
24 |
25 |
26 |
29 |
30 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/scatter/CrossShapeRenderer.java:
--------------------------------------------------------------------------------
1 | package com.github.mikephil.charting.renderer.scatter;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Paint;
5 |
6 | import com.github.mikephil.charting.interfaces.datasets.IScatterDataSet;
7 | import com.github.mikephil.charting.utils.Utils;
8 | import com.github.mikephil.charting.utils.ViewPortHandler;
9 |
10 | /**
11 | * Created by wajdic on 15/06/2016.
12 | * Created at Time 09:08
13 | */
14 | public class CrossShapeRenderer implements IShapeRenderer {
15 |
16 |
17 | @Override
18 | public void renderShape(Canvas c, IScatterDataSet dataSet, ViewPortHandler viewPortHandler,
19 | float posX, float posY, Paint renderPaint) {
20 |
21 | final float shapeHalf = dataSet.getScatterShapeSize() / 2f;
22 |
23 | renderPaint.setStyle(Paint.Style.STROKE);
24 | renderPaint.setStrokeWidth(Utils.convertDpToPixel(1f));
25 |
26 | c.drawLine(
27 | posX - shapeHalf,
28 | posY,
29 | posX + shapeHalf,
30 | posY,
31 | renderPaint);
32 | c.drawLine(
33 | posX,
34 | posY - shapeHalf,
35 | posX,
36 | posY + shapeHalf,
37 | renderPaint);
38 |
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/app/src/main/java/com/android/stockapp/ui/base/BaseApp.java:
--------------------------------------------------------------------------------
1 | package com.android.stockapp.ui.base;
2 |
3 | import android.app.Application;
4 | import android.os.Handler;
5 | import android.os.Looper;
6 |
7 | /**
8 | * Description:应用程序(基类)
9 | */
10 | public class BaseApp extends Application {
11 |
12 | public static BaseApp mContext = null; //获取到主线程的上下文
13 | public static Handler mAppHandler = null; //获取到主线程的handler
14 | public static Looper mAppLooper = null; //获取到主线程的looper
15 | public static Thread mMainThead = null; //获取到主线程
16 | public static int mMainTheadId; //获取到主线程的id
17 |
18 | @Override
19 | public void onCreate() {
20 | super.onCreate();
21 | mContext = this;
22 | mAppHandler = new Handler();
23 | mAppLooper = getMainLooper();
24 | mMainThead = Thread.currentThread();
25 | mMainTheadId = android.os.Process.myTid();//主線程id
26 | }
27 |
28 | public static BaseApp getApp() {
29 | return mContext;
30 | }
31 |
32 | public static Handler getAppHandler() {
33 | return mAppHandler;
34 | }
35 |
36 | public static Looper getAppLooper() {
37 | return mAppLooper;
38 | }
39 |
40 | public static Thread getMainThread() {
41 | return mMainThead;
42 | }
43 |
44 | public static int getMainThreadId() {
45 | return mMainTheadId;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/charts/CandleStickChart.java:
--------------------------------------------------------------------------------
1 |
2 | package com.github.mikephil.charting.charts;
3 |
4 | import android.content.Context;
5 | import android.util.AttributeSet;
6 |
7 | import com.github.mikephil.charting.data.CandleData;
8 | import com.github.mikephil.charting.interfaces.dataprovider.CandleDataProvider;
9 | import com.github.mikephil.charting.renderer.CandleStickChartRenderer;
10 |
11 | /**
12 | * Financial chart type that draws candle-sticks (OHCL chart).
13 | *
14 | * @author Philipp Jahoda
15 | */
16 | public class CandleStickChart extends BarLineChartBase implements CandleDataProvider {
17 |
18 | public CandleStickChart(Context context) {
19 | super(context);
20 | }
21 |
22 | public CandleStickChart(Context context, AttributeSet attrs) {
23 | super(context, attrs);
24 | }
25 |
26 | public CandleStickChart(Context context, AttributeSet attrs, int defStyle) {
27 | super(context, attrs, defStyle);
28 | }
29 |
30 | @Override
31 | protected void init() {
32 | super.init();
33 |
34 | mRenderer = new CandleStickChartRenderer(this, mAnimator, mViewPortHandler);
35 |
36 | getXAxis().setSpaceMin(0.5f);
37 | getXAxis().setSpaceMax(0.5f);
38 | }
39 |
40 | @Override
41 | public CandleData getCandleData() {
42 | return mData;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/formatter/IValueFormatter.java:
--------------------------------------------------------------------------------
1 | package com.github.mikephil.charting.formatter;
2 |
3 | import com.github.mikephil.charting.data.Entry;
4 | import com.github.mikephil.charting.utils.ViewPortHandler;
5 |
6 | /**
7 | * Interface to format all values before they are drawn as labels.
8 | *
9 | * @author Philipp Jahoda
10 | * @deprecated Extend {@link ValueFormatter} instead
11 | */
12 | @Deprecated
13 | public interface IValueFormatter
14 | {
15 |
16 | /**
17 | * Called when a value (from labels inside the chart) is formatted
18 | * before being drawn. For performance reasons, avoid excessive calculations
19 | * and memory allocations inside this method.
20 | *
21 | * @param value the value to be formatted
22 | * @param entry the entry the value belongs to - in e.g. BarChart, this is of class BarEntry
23 | * @param dataSetIndex the index of the DataSet the entry in focus belongs to
24 | * @param viewPortHandler provides information about the current chart state (scale, translation, ...)
25 | * @return the formatted label ready for being drawn
26 | *
27 | * @deprecated Extend {@link ValueFormatter} and override an appropriate method
28 | */
29 | @Deprecated
30 | String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler);
31 | }
32 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/scatter/ChevronDownShapeRenderer.java:
--------------------------------------------------------------------------------
1 | package com.github.mikephil.charting.renderer.scatter;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Paint;
5 |
6 | import com.github.mikephil.charting.interfaces.datasets.IScatterDataSet;
7 | import com.github.mikephil.charting.utils.Utils;
8 | import com.github.mikephil.charting.utils.ViewPortHandler;
9 |
10 | /**
11 | * Created by wajdic on 15/06/2016.
12 | * Created at Time 09:08
13 | */
14 | public class ChevronDownShapeRenderer implements IShapeRenderer {
15 |
16 |
17 | @Override
18 | public void renderShape(Canvas c, IScatterDataSet dataSet, ViewPortHandler viewPortHandler,
19 | float posX, float posY, Paint renderPaint) {
20 |
21 | final float shapeHalf = dataSet.getScatterShapeSize() / 2f;
22 |
23 | renderPaint.setStyle(Paint.Style.STROKE);
24 | renderPaint.setStrokeWidth(Utils.convertDpToPixel(1f));
25 |
26 | c.drawLine(
27 | posX,
28 | posY + (2 * shapeHalf),
29 | posX + (2 * shapeHalf),
30 | posY,
31 | renderPaint);
32 |
33 | c.drawLine(
34 | posX,
35 | posY + (2 * shapeHalf),
36 | posX - (2 * shapeHalf),
37 | posY,
38 | renderPaint);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/scatter/ChevronUpShapeRenderer.java:
--------------------------------------------------------------------------------
1 | package com.github.mikephil.charting.renderer.scatter;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Paint;
5 |
6 | import com.github.mikephil.charting.interfaces.datasets.IScatterDataSet;
7 | import com.github.mikephil.charting.utils.Utils;
8 | import com.github.mikephil.charting.utils.ViewPortHandler;
9 |
10 | /**
11 | * Created by wajdic on 15/06/2016.
12 | * Created at Time 09:08
13 | */
14 | public class ChevronUpShapeRenderer implements IShapeRenderer {
15 |
16 |
17 | @Override
18 | public void renderShape(Canvas c, IScatterDataSet dataSet, ViewPortHandler viewPortHandler,
19 | float posX, float posY, Paint renderPaint) {
20 |
21 | final float shapeHalf = dataSet.getScatterShapeSize() / 2f;
22 |
23 | renderPaint.setStyle(Paint.Style.STROKE);
24 | renderPaint.setStrokeWidth(Utils.convertDpToPixel(1f));
25 |
26 | c.drawLine(
27 | posX,
28 | posY - (2 * shapeHalf),
29 | posX + (2 * shapeHalf),
30 | posY,
31 | renderPaint);
32 |
33 | c.drawLine(
34 | posX,
35 | posY - (2 * shapeHalf),
36 | posX - (2 * shapeHalf),
37 | posY,
38 | renderPaint);
39 |
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/scatter/XShapeRenderer.java:
--------------------------------------------------------------------------------
1 | package com.github.mikephil.charting.renderer.scatter;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Paint;
5 |
6 | import com.github.mikephil.charting.interfaces.datasets.IScatterDataSet;
7 | import com.github.mikephil.charting.utils.Utils;
8 | import com.github.mikephil.charting.utils.ViewPortHandler;
9 |
10 | /**
11 | * Created by wajdic on 15/06/2016.
12 | * Created at Time 09:08
13 | */
14 | public class XShapeRenderer implements IShapeRenderer {
15 |
16 |
17 | @Override
18 | public void renderShape(Canvas c, IScatterDataSet dataSet, ViewPortHandler viewPortHandler,
19 | float posX, float posY, Paint renderPaint) {
20 |
21 | final float shapeHalf = dataSet.getScatterShapeSize() / 2f;
22 |
23 | renderPaint.setStyle(Paint.Style.STROKE);
24 | renderPaint.setStrokeWidth(Utils.convertDpToPixel(1f));
25 |
26 | c.drawLine(
27 | posX - shapeHalf,
28 | posY - shapeHalf,
29 | posX + shapeHalf,
30 | posY + shapeHalf,
31 | renderPaint);
32 | c.drawLine(
33 | posX + shapeHalf,
34 | posY - shapeHalf,
35 | posX - shapeHalf,
36 | posY + shapeHalf,
37 | renderPaint);
38 |
39 | }
40 |
41 | }
--------------------------------------------------------------------------------
/app/src/main/res/menu/bubble.xml:
--------------------------------------------------------------------------------
1 |
2 |
46 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/scatter.xml:
--------------------------------------------------------------------------------
1 |
2 |
46 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/stockChart/model/bean/SMAEntity.java:
--------------------------------------------------------------------------------
1 | package com.github.mikephil.charting.stockChart.model.bean;
2 |
3 |
4 | import com.github.mikephil.charting.stockChart.model.KLineDataModel;
5 |
6 | import java.util.ArrayList;
7 |
8 | import static java.lang.Float.NaN;
9 |
10 | /**
11 | * Created by Administrator on 2018/3/19.
12 | */
13 |
14 | public class SMAEntity {
15 | private ArrayList SMAs;
16 |
17 | public SMAEntity(ArrayList kLineBeen, int n) {
18 | this(kLineBeen, n, NaN);
19 | }
20 |
21 | public SMAEntity(ArrayList kLineBeen, int n, float defult) {
22 | SMAs = new ArrayList<>();
23 |
24 | float sma = 0.0f;
25 | int index = n - 1;
26 | if (kLineBeen != null && kLineBeen.size() > 0) {
27 | for (int i = 0; i < kLineBeen.size(); i++) {
28 | if (i >= index) {
29 | sma = getSMA(sma, (float) kLineBeen.get(i).getClose(), n, 1);
30 | } else {
31 | sma = (float) kLineBeen.get(i).getClose();
32 | }
33 | SMAs.add(sma);
34 | }
35 | }
36 | }
37 |
38 | public float getSMA(float perSMA, float close, int n, int m) {
39 | return close * m / n + perSMA * (n - m) / n;
40 | }
41 |
42 | public ArrayList getSMAs() {
43 | return SMAs;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_linechart_time.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
11 |
12 |
22 |
23 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/utils/MPPointD.java:
--------------------------------------------------------------------------------
1 |
2 | package com.github.mikephil.charting.utils;
3 |
4 | import java.util.List;
5 |
6 | /**
7 | * Point encapsulating two double values.
8 | *
9 | * @author Philipp Jahoda
10 | */
11 | public class MPPointD extends ObjectPool.Poolable {
12 |
13 | private static ObjectPool pool;
14 |
15 | static {
16 | pool = ObjectPool.create(64, new MPPointD(0, 0));
17 | pool.setReplenishPercentage(0.5f);
18 | }
19 |
20 | public static MPPointD getInstance(double x, double y) {
21 | MPPointD result = pool.get();
22 | result.x = x;
23 | result.y = y;
24 | return result;
25 | }
26 |
27 | public static void recycleInstance(MPPointD instance) {
28 | pool.recycle(instance);
29 | }
30 |
31 | public static void recycleInstances(List instances) {
32 | pool.recycle(instances);
33 | }
34 |
35 | public double x;
36 | public double y;
37 |
38 | @Override
39 | protected ObjectPool.Poolable instantiate() {
40 | return new MPPointD(0, 0);
41 | }
42 |
43 | private MPPointD(double x, double y) {
44 | this.x = x;
45 | this.y = y;
46 | }
47 |
48 | /**
49 | * returns a string representation of the object
50 | */
51 | @Override
52 | public String toString() {
53 | return "MPPointD, x: " + x + ", y: " + y;
54 | }
55 | }
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_scrollview.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
11 |
16 |
17 |
18 |
19 |
22 |
23 |
27 |
28 |
29 |
30 |
33 |
34 |
39 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/charts/BubbleChart.java:
--------------------------------------------------------------------------------
1 |
2 | package com.github.mikephil.charting.charts;
3 |
4 | import android.content.Context;
5 | import android.util.AttributeSet;
6 |
7 | import com.github.mikephil.charting.data.BubbleData;
8 | import com.github.mikephil.charting.interfaces.dataprovider.BubbleDataProvider;
9 | import com.github.mikephil.charting.renderer.BubbleChartRenderer;
10 |
11 | /**
12 | * The BubbleChart. Draws bubbles. Bubble chart implementation: Copyright 2015
13 | * Pierre-Marc Airoldi Licensed under Apache License 2.0. In the BubbleChart, it
14 | * is the area of the bubble, not the radius or diameter of the bubble that
15 | * conveys the data.
16 | *
17 | * @author Philipp Jahoda
18 | */
19 | public class BubbleChart extends BarLineChartBase implements BubbleDataProvider {
20 |
21 | public BubbleChart(Context context) {
22 | super(context);
23 | }
24 |
25 | public BubbleChart(Context context, AttributeSet attrs) {
26 | super(context, attrs);
27 | }
28 |
29 | public BubbleChart(Context context, AttributeSet attrs, int defStyle) {
30 | super(context, attrs, defStyle);
31 | }
32 |
33 | @Override
34 | protected void init() {
35 | super.init();
36 |
37 | mRenderer = new BubbleChartRenderer(this, mAnimator, mViewPortHandler);
38 | }
39 |
40 | @Override
41 | public BubbleData getBubbleData() {
42 | return mData;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/formatter/DefaultFillFormatter.java:
--------------------------------------------------------------------------------
1 | package com.github.mikephil.charting.formatter;
2 |
3 |
4 | import com.github.mikephil.charting.data.LineData;
5 | import com.github.mikephil.charting.interfaces.dataprovider.LineDataProvider;
6 | import com.github.mikephil.charting.interfaces.datasets.ILineDataSet;
7 |
8 | /**
9 | * Default formatter that calculates the position of the filled line.
10 | *
11 | * @author Philipp Jahoda
12 | */
13 | public class DefaultFillFormatter implements IFillFormatter {
14 |
15 | @Override
16 | public float getFillLinePosition(ILineDataSet dataSet, LineDataProvider dataProvider) {
17 |
18 | float fillMin = 0f;
19 | float chartMaxY = dataProvider.getYChartMax();
20 | float chartMinY = dataProvider.getYChartMin();
21 |
22 | LineData data = dataProvider.getLineData();
23 |
24 | if (dataSet.getYMax() > 0 && dataSet.getYMin() < 0) {
25 | fillMin = 0f;
26 | } else {
27 |
28 | float max, min;
29 |
30 | if (data.getYMax() > 0) {
31 | max = 0f;
32 | } else {
33 | max = chartMaxY;
34 | }
35 | if (data.getYMin() < 0) {
36 | min = 0f;
37 | } else {
38 | min = chartMinY;
39 | }
40 |
41 | fillMin = dataSet.getYMin() >= 0 ? min : max;
42 | }
43 |
44 | return fillMin;
45 | }
46 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/android/stockapp/ui/main/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.android.stockapp.ui.main;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.view.View;
6 |
7 | import androidx.appcompat.app.AppCompatActivity;
8 |
9 | import com.android.stockapp.R;
10 | import com.android.stockapp.application.MyApplication;
11 | import com.android.stockapp.ui.market.activity.StockDetailActivity;
12 | import com.android.stockapp.ui.mpchartexample.notimportant.MPMainActivity;
13 |
14 | import butterknife.ButterKnife;
15 | import butterknife.OnClick;
16 |
17 | public class MainActivity extends AppCompatActivity {
18 |
19 | @Override
20 | protected void onCreate(Bundle savedInstanceState) {
21 | super.onCreate(savedInstanceState);
22 | setContentView(R.layout.activity_main);
23 | ButterKnife.bind(this);
24 | }
25 |
26 | @Override
27 | protected void onPostResume() {
28 | super.onPostResume();
29 | MyApplication.getApplication().initDayNight();
30 | }
31 |
32 | @OnClick({R.id.btn_test, R.id.btn_mp})
33 | public void onViewClicked(View view) {
34 | switch (view.getId()) {
35 | case R.id.btn_test:
36 | startActivity(new Intent(MainActivity.this, StockDetailActivity.class));
37 | break;
38 | case R.id.btn_mp:
39 | startActivity(new Intent(MainActivity.this, MPMainActivity.class));
40 | break;
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/stockChart/markerView/BarBottomMarkerView.java:
--------------------------------------------------------------------------------
1 | package com.github.mikephil.charting.stockChart.markerView;
2 |
3 | import android.content.Context;
4 | import android.widget.TextView;
5 |
6 | import com.github.mikephil.charting.R;
7 | import com.github.mikephil.charting.components.MarkerView;
8 | import com.github.mikephil.charting.data.Entry;
9 | import com.github.mikephil.charting.highlight.Highlight;
10 | import com.github.mikephil.charting.utils.MPPointF;
11 |
12 | /**
13 | * Created by Administrator on 2016/9/12.
14 | */
15 | public class BarBottomMarkerView extends MarkerView {
16 |
17 | private TextView markerTv;
18 | private String date;
19 |
20 | /**
21 | * Constructor. Sets up the MarkerView with a custom layout resource.
22 | *
23 | * @param context
24 | * @param layoutResource the layout resource to use for the MarkerView
25 | */
26 | public BarBottomMarkerView(Context context, int layoutResource) {
27 | super(context, layoutResource);
28 | markerTv = (TextView) findViewById(R.id.marker_tv);
29 | markerTv.setTextSize(10);
30 | }
31 |
32 | public void setData(String date) {
33 | this.date = date;
34 | }
35 |
36 | @Override
37 | public void refreshContent(Entry e, Highlight highlight) {
38 | markerTv.setText(date);
39 | }
40 |
41 | @Override
42 | public MPPointF getOffset() {
43 | return new MPPointF(-(getWidth() / 2), -getHeight());
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/formatter/DefaultAxisValueFormatter.java:
--------------------------------------------------------------------------------
1 | package com.github.mikephil.charting.formatter;
2 |
3 | import java.text.DecimalFormat;
4 |
5 | /**
6 | * Created by philipp on 02/06/16.
7 | */
8 | public class DefaultAxisValueFormatter extends ValueFormatter
9 | {
10 |
11 | /**
12 | * decimalformat for formatting
13 | */
14 | protected DecimalFormat mFormat;
15 |
16 | /**
17 | * the number of decimal digits this formatter uses
18 | */
19 | protected int digits;
20 |
21 | /**
22 | * Constructor that specifies to how many digits the value should be
23 | * formatted.
24 | *
25 | * @param digits
26 | */
27 | public DefaultAxisValueFormatter(int digits) {
28 | this.digits = digits;
29 |
30 | StringBuffer b = new StringBuffer();
31 | for (int i = 0; i < digits; i++) {
32 | if (i == 0) {
33 | b.append(".");
34 | }
35 | b.append("0");
36 | }
37 |
38 | mFormat = new DecimalFormat("###,###,###,##0" + b.toString());
39 | }
40 |
41 | @Override
42 | public String getFormattedValue(float value) {
43 | // avoid memory allocations here (for performance)
44 | return mFormat.format(value);
45 | }
46 |
47 | /**
48 | * Returns the number of decimal digits this formatter uses or -1, if unspecified.
49 | *
50 | * @return
51 | */
52 | public int getDecimalDigits() {
53 | return digits;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/app/src/main/java/com/android/stockapp/ui/mpchartexample/custom/MyCustomXAxisValueFormatter.java:
--------------------------------------------------------------------------------
1 | package com.android.stockapp.ui.mpchartexample.custom;
2 |
3 | import com.github.mikephil.charting.formatter.ValueFormatter;
4 | import com.github.mikephil.charting.utils.ViewPortHandler;
5 |
6 | import java.text.DecimalFormat;
7 |
8 | /**
9 | * Created by Philipp Jahoda on 14/09/15.
10 | *
11 | * @deprecated The {@link MyAxisValueFormatter} does exactly the same thing and is more functional.
12 | */
13 | @Deprecated
14 | public class MyCustomXAxisValueFormatter extends ValueFormatter
15 | {
16 |
17 | private final DecimalFormat mFormat;
18 | private final ViewPortHandler mViewPortHandler;
19 |
20 | public MyCustomXAxisValueFormatter(ViewPortHandler viewPortHandler) {
21 | mViewPortHandler = viewPortHandler;
22 | // maybe do something here or provide parameters in constructor
23 | mFormat = new DecimalFormat("###,###,###,##0.0");
24 | }
25 |
26 | @Override
27 | public String getFormattedValue(float value) {
28 |
29 | //Log.i("TRANS", "x: " + viewPortHandler.getTransX() + ", y: " + viewPortHandler.getTransY());
30 |
31 | // e.g. adjust the x-axis values depending on scale / zoom level
32 | final float xScale = mViewPortHandler.getScaleX();
33 | if (xScale > 5)
34 | return "4";
35 | else if (xScale > 3)
36 | return "3";
37 | else if (xScale > 1)
38 | return "2";
39 | else
40 | return mFormat.format(value);
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_barchart_sinus.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
11 |
12 |
24 |
25 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/utils/TransformerHorizontalBarChart.java:
--------------------------------------------------------------------------------
1 |
2 | package com.github.mikephil.charting.utils;
3 |
4 | /**
5 | * Transformer class for the HorizontalBarChart.
6 | *
7 | * @author Philipp Jahoda
8 | */
9 | public class TransformerHorizontalBarChart extends Transformer {
10 |
11 | public TransformerHorizontalBarChart(ViewPortHandler viewPortHandler) {
12 | super(viewPortHandler);
13 | }
14 |
15 | /**
16 | * Prepares the matrix that contains all offsets.
17 | *
18 | * @param inverted
19 | */
20 | @Override
21 | public void prepareMatrixOffset(boolean inverted) {
22 |
23 | mMatrixOffset.reset();
24 |
25 | // offset.postTranslate(mOffsetLeft, getHeight() - mOffsetBottom);
26 |
27 | if (!inverted) {
28 | mMatrixOffset.postTranslate(mViewPortHandler.offsetLeft(),
29 | mViewPortHandler.getChartHeight() - mViewPortHandler.offsetBottom());
30 | } else {
31 | mMatrixOffset
32 | .setTranslate(
33 | -(mViewPortHandler.getChartWidth() - mViewPortHandler.offsetRight()),
34 | mViewPortHandler.getChartHeight() - mViewPortHandler.offsetBottom());
35 | mMatrixOffset.postScale(-1.0f, 1.0f);
36 | }
37 |
38 | // mMatrixOffset.set(offset);
39 |
40 | // mMatrixOffset.reset();
41 | //
42 | // mMatrixOffset.postTranslate(mOffsetLeft, getHeight() -
43 | // mOffsetBottom);
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_performance_linechart.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
11 |
12 |
24 |
25 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-android-extensions'
4 | apply plugin: 'kotlin-kapt'
5 |
6 | android {
7 | compileSdkVersion 28
8 | defaultConfig {
9 | applicationId "com.android.stockapp"
10 | minSdkVersion 15
11 | targetSdkVersion 28
12 | versionCode 1
13 | versionName "3.2.0"
14 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
15 | }
16 | buildTypes {
17 | release {
18 | minifyEnabled false
19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
20 | }
21 | }
22 | compileOptions {
23 | sourceCompatibility JavaVersion.VERSION_1_8
24 | targetCompatibility JavaVersion.VERSION_1_8
25 | }
26 | }
27 |
28 | dependencies {
29 | implementation fileTree(include: ['*.jar'], dir: 'libs')
30 | implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
31 | implementation 'androidx.appcompat:appcompat:1.0.2'
32 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
33 | testImplementation 'junit:junit:4.12'
34 | androidTestImplementation 'androidx.test:runner:1.1.1'
35 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
36 | implementation 'com.jakewharton:butterknife:10.0.0'
37 | kapt 'com.jakewharton:butterknife-compiler:10.0.0'
38 | implementation project(':MPChartLib')
39 | implementation 'com.google.android.material:material:1.0.0'
40 | }
41 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/bar.xml:
--------------------------------------------------------------------------------
1 |
2 |
50 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/candle.xml:
--------------------------------------------------------------------------------
1 |
2 |
50 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/jobs/ViewPortJob.java:
--------------------------------------------------------------------------------
1 |
2 | package com.github.mikephil.charting.jobs;
3 |
4 | import android.view.View;
5 |
6 | import com.github.mikephil.charting.utils.ObjectPool;
7 | import com.github.mikephil.charting.utils.Transformer;
8 | import com.github.mikephil.charting.utils.ViewPortHandler;
9 |
10 | /**
11 | * Runnable that is used for viewport modifications since they cannot be
12 | * executed at any time. This can be used to delay the execution of viewport
13 | * modifications until the onSizeChanged(...) method of the chart-view is called.
14 | * This is especially important if viewport modifying methods are called on the chart
15 | * directly after initialization.
16 | *
17 | * @author Philipp Jahoda
18 | */
19 | public abstract class ViewPortJob extends ObjectPool.Poolable implements Runnable {
20 |
21 | protected float[] pts = new float[2];
22 |
23 | protected ViewPortHandler mViewPortHandler;
24 | protected float xValue = 0f;
25 | protected float yValue = 0f;
26 | protected Transformer mTrans;
27 | protected View view;
28 |
29 | public ViewPortJob(ViewPortHandler viewPortHandler, float xValue, float yValue,
30 | Transformer trans, View v) {
31 |
32 | this.mViewPortHandler = viewPortHandler;
33 | this.xValue = xValue;
34 | this.yValue = yValue;
35 | this.mTrans = trans;
36 | this.view = v;
37 |
38 | }
39 |
40 | public float getXValue() {
41 | return xValue;
42 | }
43 |
44 | public float getYValue() {
45 | return yValue;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/stockChart/markerView/TimeRightMarkerView.java:
--------------------------------------------------------------------------------
1 | package com.github.mikephil.charting.stockChart.markerView;
2 |
3 | import android.content.Context;
4 | import android.widget.TextView;
5 |
6 | import com.github.mikephil.charting.R;
7 | import com.github.mikephil.charting.components.MarkerView;
8 | import com.github.mikephil.charting.data.Entry;
9 | import com.github.mikephil.charting.highlight.Highlight;
10 | import com.github.mikephil.charting.utils.MPPointF;
11 |
12 |
13 | import java.text.DecimalFormat;
14 |
15 | public class TimeRightMarkerView extends MarkerView {
16 | /**
17 | * Constructor. Sets up the MarkerView with a custom layout resource.
18 | *
19 | * @param context
20 | * @param layoutResource the layout resource to use for the MarkerView
21 | */
22 | private TextView markerTv;
23 | private float num;
24 | private DecimalFormat mFormat;
25 |
26 | public TimeRightMarkerView(Context context, int layoutResource) {
27 | super(context, layoutResource);
28 | mFormat = new DecimalFormat("#0.00");
29 | markerTv = (TextView) findViewById(R.id.marker_tv);
30 | markerTv.setTextSize(10);
31 |
32 | }
33 |
34 | public void setData(float num) {
35 | this.num = num;
36 | }
37 |
38 | @Override
39 | public void refreshContent(Entry e, Highlight highlight) {
40 | markerTv.setText(mFormat.format(num * 100) + "%");
41 | }
42 |
43 | @Override
44 | public MPPointF getOffset() {
45 | return new MPPointF(-(getWidth() / 2), -getHeight());
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/res/layout/view_time.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
11 |
12 |
17 |
18 |
23 |
24 |
25 |
30 |
31 |
36 |
37 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/stockChart/event/BaseEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014-2020,点证科技 Tech. Co., Ltd.
3 | * Author: Tony Dylan
4 | * Date: 2014-12-5
5 | * Description: 基于EventBus封装的Event基类,所有其他自定义Event全部继承此类。
6 | * Others:
7 | */
8 | package com.github.mikephil.charting.stockChart.event;
9 |
10 | public class BaseEvent {
11 | /**
12 | * 发送event的方法,用以区分事件
13 | */
14 | public int method;
15 |
16 | /**
17 | * 网络请求时code为网路请求的Response code,非网络请求时为本地定义的code
18 | */
19 | public int code;
20 |
21 | /**
22 | * 调用者class name,可用于接收者对不同对象调用者做区别对待。
23 | */
24 | public String caller = "unset";
25 |
26 | /**
27 | * 请求的参数
28 | */
29 | public Object param = null;
30 |
31 | /**
32 | * 用于提示的消息
33 | */
34 | public String msg;
35 |
36 | /**
37 | * 发送事件携带的对象内容
38 | */
39 | public Object obj;
40 |
41 | /**
42 | * 发送事件携带的对象内容,当event要传输两个对象时就需要用到此参数
43 | */
44 | public Object extraObj;
45 |
46 | /**
47 | * 发送事件携带的对象内容,当event要传输三个对象时就需要用到此参数
48 | */
49 | public Object thirdObj;
50 |
51 | /**
52 | * 只带一个对象的Event构造方法
53 | */
54 | public BaseEvent(int method) {
55 | this.method = method;
56 | }
57 |
58 | public BaseEvent(BaseEvent event) {
59 | this.method = event.method;
60 | this.code = event.code;
61 | this.obj = event.obj;
62 | this.extraObj = event.extraObj;
63 | this.thirdObj = event.thirdObj;
64 | this.msg = event.msg;
65 | this.caller = event.caller;
66 | this.param = event.param;
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/stockChart/markerView/LeftMarkerView.java:
--------------------------------------------------------------------------------
1 | package com.github.mikephil.charting.stockChart.markerView;
2 |
3 | import android.content.Context;
4 | import android.widget.TextView;
5 |
6 | import com.github.mikephil.charting.R;
7 | import com.github.mikephil.charting.components.MarkerView;
8 | import com.github.mikephil.charting.data.Entry;
9 | import com.github.mikephil.charting.highlight.Highlight;
10 | import com.github.mikephil.charting.utils.MPPointF;
11 | import com.github.mikephil.charting.utils.NumberUtils;
12 |
13 | import java.text.DecimalFormat;
14 |
15 | public class LeftMarkerView extends MarkerView {
16 | /**
17 | * Constructor. Sets up the MarkerView with a custom layout resource.
18 | *
19 | * @param context
20 | * @param layoutResource the layout resource to use for the MarkerView
21 | */
22 | private TextView markerTv;
23 | private float num;
24 | private int precision;
25 |
26 | public LeftMarkerView(Context context, int layoutResource, int precision) {
27 | super(context, layoutResource);
28 | this.precision = precision;
29 | markerTv = (TextView) findViewById(R.id.marker_tv);
30 | markerTv.setTextSize(10);
31 | }
32 |
33 | public void setData(float num) {
34 | this.num = num;
35 | }
36 |
37 | @Override
38 | public void refreshContent(Entry e, Highlight highlight) {
39 | markerTv.setText(NumberUtils.keepPrecisionR(num, precision));
40 | }
41 |
42 | @Override
43 | public MPPointF getOffset() {
44 | return new MPPointF(-(getWidth() / 2), -getHeight());
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/data/RadarData.java:
--------------------------------------------------------------------------------
1 |
2 | package com.github.mikephil.charting.data;
3 |
4 | import com.github.mikephil.charting.highlight.Highlight;
5 | import com.github.mikephil.charting.interfaces.datasets.IRadarDataSet;
6 |
7 | import java.util.ArrayList;
8 | import java.util.Arrays;
9 | import java.util.List;
10 |
11 | /**
12 | * Data container for the RadarChart.
13 | *
14 | * @author Philipp Jahoda
15 | */
16 | public class RadarData extends ChartData {
17 |
18 | private List mLabels;
19 |
20 | public RadarData() {
21 | super();
22 | }
23 |
24 | public RadarData(List dataSets) {
25 | super(dataSets);
26 | }
27 |
28 | public RadarData(IRadarDataSet... dataSets) {
29 | super(dataSets);
30 | }
31 |
32 | /**
33 | * Sets the labels that should be drawn around the RadarChart at the end of each web line.
34 | *
35 | * @param labels
36 | */
37 | public void setLabels(List labels) {
38 | this.mLabels = labels;
39 | }
40 |
41 | /**
42 | * Sets the labels that should be drawn around the RadarChart at the end of each web line.
43 | *
44 | * @param labels
45 | */
46 | public void setLabels(String... labels) {
47 | this.mLabels = Arrays.asList(labels);
48 | }
49 |
50 | public List getLabels() {
51 | return mLabels;
52 | }
53 |
54 | @Override
55 | public Entry getEntryForHighlight(Highlight highlight) {
56 | return getDataSetByIndex(highlight.getDataSetIndex()).getEntryForIndex((int) highlight.getX());
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/charts/LineChart.java:
--------------------------------------------------------------------------------
1 |
2 | package com.github.mikephil.charting.charts;
3 |
4 | import android.content.Context;
5 | import android.util.AttributeSet;
6 |
7 | import com.github.mikephil.charting.data.LineData;
8 | import com.github.mikephil.charting.interfaces.dataprovider.LineDataProvider;
9 | import com.github.mikephil.charting.renderer.LineChartRenderer;
10 |
11 | /**
12 | * Chart that draws lines, surfaces, circles, ...
13 | *
14 | * @author Philipp Jahoda
15 | */
16 | public class LineChart extends BarLineChartBase implements LineDataProvider {
17 |
18 | public LineChart(Context context) {
19 | super(context);
20 | }
21 |
22 | public LineChart(Context context, AttributeSet attrs) {
23 | super(context, attrs);
24 | }
25 |
26 | public LineChart(Context context, AttributeSet attrs, int defStyle) {
27 | super(context, attrs, defStyle);
28 | }
29 |
30 | @Override
31 | protected void init() {
32 | super.init();
33 |
34 | initRenderer();
35 | }
36 |
37 | protected void initRenderer() {
38 | mRenderer = new LineChartRenderer(this, mAnimator, mViewPortHandler);
39 | }
40 |
41 | @Override
42 | public LineData getLineData() {
43 | return mData;
44 | }
45 |
46 | @Override
47 | protected void onDetachedFromWindow() {
48 | // releases the bitmap in the renderer to avoid oom error
49 | if (mRenderer != null && mRenderer instanceof LineChartRenderer) {
50 | ((LineChartRenderer) mRenderer).releaseBitmap();
51 | }
52 | super.onDetachedFromWindow();
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/stockChart/markerView/KRightMarkerView.java:
--------------------------------------------------------------------------------
1 | package com.github.mikephil.charting.stockChart.markerView;
2 |
3 | import android.content.Context;
4 | import android.widget.TextView;
5 |
6 | import com.github.mikephil.charting.R;
7 | import com.github.mikephil.charting.components.MarkerView;
8 | import com.github.mikephil.charting.data.Entry;
9 | import com.github.mikephil.charting.highlight.Highlight;
10 | import com.github.mikephil.charting.utils.MPPointF;
11 | import com.github.mikephil.charting.utils.NumberUtils;
12 |
13 |
14 | import java.text.DecimalFormat;
15 |
16 | public class KRightMarkerView extends MarkerView {
17 | /**
18 | * Constructor. Sets up the MarkerView with a custom layout resource.
19 | *
20 | * @param context
21 | * @param layoutResource the layout resource to use for the MarkerView
22 | */
23 | private TextView markerTv;
24 | private float num;
25 | private int precision;
26 |
27 | public KRightMarkerView(Context context, int layoutResource,int precision) {
28 | super(context, layoutResource);
29 | this.precision = precision;
30 | markerTv = (TextView) findViewById(R.id.marker_tv);
31 | markerTv.setTextSize(10);
32 |
33 | }
34 |
35 | public void setData(float num) {
36 | this.num = num;
37 | }
38 |
39 | @Override
40 | public void refreshContent(Entry e, Highlight highlight) {
41 | markerTv.setText(NumberUtils.keepPrecisionR(num,precision));
42 | }
43 |
44 | @Override
45 | public MPPointF getOffset() {
46 | return new MPPointF(-(getWidth() / 2), -getHeight());
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_stock_detail.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
17 |
18 |
19 |
24 |
25 |
30 |
39 |
--------------------------------------------------------------------------------
/app/src/main/java/com/android/stockapp/ui/mpchartexample/custom/RadarMarkerView.java:
--------------------------------------------------------------------------------
1 |
2 | package com.android.stockapp.ui.mpchartexample.custom;
3 |
4 | import android.annotation.SuppressLint;
5 | import android.content.Context;
6 | import android.graphics.Typeface;
7 | import android.widget.TextView;
8 |
9 | import com.android.stockapp.R;
10 | import com.github.mikephil.charting.components.MarkerView;
11 | import com.github.mikephil.charting.data.Entry;
12 | import com.github.mikephil.charting.highlight.Highlight;
13 | import com.github.mikephil.charting.utils.MPPointF;
14 |
15 | import java.text.DecimalFormat;
16 |
17 | /**
18 | * Custom implementation of the MarkerView.
19 | *
20 | * @author Philipp Jahoda
21 | */
22 | @SuppressLint("ViewConstructor")
23 | public class RadarMarkerView extends MarkerView {
24 |
25 | private final TextView tvContent;
26 | private final DecimalFormat format = new DecimalFormat("##0");
27 |
28 | public RadarMarkerView(Context context, int layoutResource) {
29 | super(context, layoutResource);
30 |
31 | tvContent = findViewById(R.id.tvContent);
32 | tvContent.setTypeface(Typeface.createFromAsset(context.getAssets(), "OpenSans-Light.ttf"));
33 | }
34 |
35 | // runs every time the MarkerView is redrawn, can be used to update the
36 | // content (user-interface)
37 | @Override
38 | public void refreshContent(Entry e, Highlight highlight) {
39 | tvContent.setText(String.format("%s %%", format.format(e.getY())));
40 |
41 | super.refreshContent(e, highlight);
42 | }
43 |
44 | @Override
45 | public MPPointF getOffset() {
46 | return new MPPointF(-(getWidth() / 2), -getHeight() - 10);
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/app/src/main/assets/n.txt:
--------------------------------------------------------------------------------
1 | 0.0#0
2 | 0.05#1
3 | 0.1#2
4 | 0.15#3
5 | 0.2#4
6 | 0.25#5
7 | 0.3#6
8 | 0.35000002#7
9 | 0.40000004#8
10 | 0.45000005#9
11 | 0.50000006#10
12 | 0.5500001#11
13 | 0.6000001#12
14 | 0.6500001#13
15 | 0.7000001#14
16 | 0.7500001#15
17 | 0.80000013#16
18 | 0.85000014#17
19 | 0.90000015#18
20 | 0.95000017#19
21 | 1.0000001#20
22 | 1.0500001#21
23 | 1.1#22
24 | 1.15#23
25 | 1.1999999#24
26 | 1.2499999#25
27 | 1.2999998#26
28 | 1.3499998#27
29 | 1.3999997#28
30 | 1.4499997#29
31 | 1.4999996#30
32 | 1.5499996#31
33 | 1.5999995#32
34 | 1.6499995#33
35 | 1.6999995#34
36 | 1.7499994#35
37 | 1.7999994#36
38 | 1.8499993#37
39 | 1.8999993#38
40 | 1.9499992#39
41 | 1.9999992#40
42 | 2.0499992#41
43 | 2.0999992#42
44 | 2.1499991#43
45 | 2.199999#44
46 | 2.249999#45
47 | 2.299999#46
48 | 2.349999#47
49 | 2.399999#48
50 | 2.4499989#49
51 | 2.4999988#50
52 | 2.5499988#51
53 | 2.5999987#52
54 | 2.6499987#53
55 | 2.6999986#54
56 | 2.7499986#55
57 | 2.7999985#56
58 | 2.8499985#57
59 | 2.8999984#58
60 | 2.9499984#59
61 | 2.9999983#60
62 | 3.0499983#61
63 | 3.0999982#62
64 | 3.1499982#63
65 | 3.1999981#64
66 | 3.249998#65
67 | 3.299998#66
68 | 3.349998#67
69 | 3.399998#68
70 | 3.449998#69
71 | 3.4999979#70
72 | 3.5499978#71
73 | 3.5999978#72
74 | 3.6499977#73
75 | 3.6999977#74
76 | 3.7499976#75
77 | 3.7999976#76
78 | 3.8499975#77
79 | 3.8999975#78
80 | 3.9499974#79
81 | 3.9999974#80
82 | 4.0499973#81
83 | 4.0999975#82
84 | 4.1499977#83
85 | 4.199998#84
86 | 4.249998#85
87 | 4.2999983#86
88 | 4.3499985#87
89 | 4.3999987#88
90 | 4.449999#89
91 | 4.499999#90
92 | 4.549999#91
93 | 4.5999994#92
94 | 4.6499996#93
95 | 4.7#94
96 | 4.75#95
97 | 4.8#96
98 | 4.8500004#97
99 | 4.9000006#98
100 | 4.950001#99
--------------------------------------------------------------------------------
/app/src/main/java/com/android/stockapp/common/adapter/SimpleFragmentPagerAdapter.java:
--------------------------------------------------------------------------------
1 | package com.android.stockapp.common.adapter;
2 |
3 | import androidx.fragment.app.Fragment;
4 | import androidx.fragment.app.FragmentManager;
5 | import androidx.fragment.app.FragmentStatePagerAdapter;
6 |
7 | import java.util.Arrays;
8 | import java.util.List;
9 |
10 | /**
11 | * 装载Fragment的通用适配器
12 | */
13 | public class SimpleFragmentPagerAdapter extends FragmentStatePagerAdapter {
14 | private List mFragments;
15 | private List mTitles;
16 |
17 | public SimpleFragmentPagerAdapter(FragmentManager fm, Fragment[] fragments) {
18 | super(fm);
19 | mFragments = Arrays.asList(fragments);
20 | }
21 |
22 | public SimpleFragmentPagerAdapter(FragmentManager fm, List fragments) {
23 | super(fm);
24 | mFragments = fragments;
25 | }
26 |
27 | public SimpleFragmentPagerAdapter(FragmentManager fm, Fragment[] fragments, String[] titles) {
28 | this(fm, fragments);
29 | mTitles = Arrays.asList(titles);
30 | }
31 |
32 | public SimpleFragmentPagerAdapter(FragmentManager fm, List fragments, List titles) {
33 | this(fm, fragments);
34 | mTitles = titles;
35 | }
36 |
37 | @Override
38 | public Fragment getItem(int position) {
39 | return mFragments.get(position);
40 | }
41 |
42 | @Override
43 | public int getCount() {
44 | return mFragments.size();
45 | }
46 |
47 | @Override
48 | public CharSequence getPageTitle(int position) {
49 | if (mTitles != null && mTitles.size() > 0) {
50 | return mTitles.get(position);
51 | }
52 | return super.getPageTitle(position);
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/interfaces/datasets/ILineRadarDataSet.java:
--------------------------------------------------------------------------------
1 | package com.github.mikephil.charting.interfaces.datasets;
2 |
3 | import android.graphics.drawable.Drawable;
4 |
5 | import com.github.mikephil.charting.data.Entry;
6 |
7 | /**
8 | * Created by Philipp Jahoda on 21/10/15.
9 | */
10 | public interface ILineRadarDataSet extends ILineScatterCandleRadarDataSet {
11 |
12 | /**
13 | * Returns the color that is used for filling the line surface area.
14 | *
15 | * @return
16 | */
17 | int getFillColor();
18 |
19 | /**
20 | * Returns the drawable used for filling the area below the line.
21 | *
22 | * @return
23 | */
24 | Drawable getFillDrawable();
25 |
26 | /**
27 | * Returns the alpha value that is used for filling the line surface,
28 | * default: 85
29 | *
30 | * @return
31 | */
32 | int getFillAlpha();
33 |
34 | /**
35 | * Returns the stroke-width of the drawn line
36 | *
37 | * @return
38 | */
39 | float getLineWidth();
40 |
41 | /**
42 | * Returns true if filled drawing is enabled, false if not
43 | *
44 | * @return
45 | */
46 | boolean isDrawFilledEnabled();
47 |
48 | /**
49 | * Set to true if the DataSet should be drawn filled (surface), and not just
50 | * as a line, disabling this will give great performance boost. Please note that this method
51 | * uses the canvas.clipPath(...) method for drawing the filled area.
52 | * For devices with API level < 18 (Android 4.3), hardware acceleration of the chart should
53 | * be turned off. Default: false
54 | *
55 | * @param enabled
56 | */
57 | void setDrawFilled(boolean enabled);
58 | }
59 |
--------------------------------------------------------------------------------
/app/src/main/java/com/android/stockapp/ui/mpchartexample/custom/MyMarkerView.java:
--------------------------------------------------------------------------------
1 |
2 | package com.android.stockapp.ui.mpchartexample.custom;
3 |
4 | import android.annotation.SuppressLint;
5 | import android.content.Context;
6 | import android.widget.TextView;
7 |
8 | import com.android.stockapp.R;
9 | import com.github.mikephil.charting.components.MarkerView;
10 | import com.github.mikephil.charting.data.CandleEntry;
11 | import com.github.mikephil.charting.data.Entry;
12 | import com.github.mikephil.charting.highlight.Highlight;
13 | import com.github.mikephil.charting.utils.MPPointF;
14 | import com.github.mikephil.charting.utils.Utils;
15 |
16 | /**
17 | * Custom implementation of the MarkerView.
18 | *
19 | * @author Philipp Jahoda
20 | */
21 | @SuppressLint("ViewConstructor")
22 | public class MyMarkerView extends MarkerView {
23 |
24 | private final TextView tvContent;
25 |
26 | public MyMarkerView(Context context, int layoutResource) {
27 | super(context, layoutResource);
28 |
29 | tvContent = findViewById(R.id.tvContent);
30 | }
31 |
32 | // runs every time the MarkerView is redrawn, can be used to update the
33 | // content (user-interface)
34 | @Override
35 | public void refreshContent(Entry e, Highlight highlight) {
36 |
37 | if (e instanceof CandleEntry) {
38 |
39 | CandleEntry ce = (CandleEntry) e;
40 |
41 | tvContent.setText(Utils.formatNumber(ce.getHigh(), 0, true));
42 | } else {
43 |
44 | tvContent.setText(Utils.formatNumber(e.getY(), 0, true));
45 | }
46 |
47 | super.refreshContent(e, highlight);
48 | }
49 |
50 | @Override
51 | public MPPointF getOffset() {
52 | return new MPPointF(-(getWidth() / 2), -getHeight());
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/jobs/MoveViewJob.java:
--------------------------------------------------------------------------------
1 |
2 | package com.github.mikephil.charting.jobs;
3 |
4 | import android.view.View;
5 |
6 | import com.github.mikephil.charting.utils.ObjectPool;
7 | import com.github.mikephil.charting.utils.Transformer;
8 | import com.github.mikephil.charting.utils.ViewPortHandler;
9 |
10 | /**
11 | * Created by Philipp Jahoda on 19/02/16.
12 | */
13 | public class MoveViewJob extends ViewPortJob {
14 |
15 | private static ObjectPool pool;
16 |
17 | static {
18 | pool = ObjectPool.create(2, new MoveViewJob(null, 0, 0, null, null));
19 | pool.setReplenishPercentage(0.5f);
20 | }
21 |
22 | public static MoveViewJob getInstance(ViewPortHandler viewPortHandler, float xValue, float yValue, Transformer trans, View v) {
23 | MoveViewJob result = pool.get();
24 | result.mViewPortHandler = viewPortHandler;
25 | result.xValue = xValue;
26 | result.yValue = yValue;
27 | result.mTrans = trans;
28 | result.view = v;
29 | return result;
30 | }
31 |
32 | public static void recycleInstance(MoveViewJob instance) {
33 | pool.recycle(instance);
34 | }
35 |
36 | public MoveViewJob(ViewPortHandler viewPortHandler, float xValue, float yValue, Transformer trans, View v) {
37 | super(viewPortHandler, xValue, yValue, trans, v);
38 | }
39 |
40 | @Override
41 | public void run() {
42 |
43 | pts[0] = xValue;
44 | pts[1] = yValue;
45 |
46 | mTrans.pointValuesToPixel(pts);
47 | mViewPortHandler.centerViewPort(pts, view);
48 |
49 | this.recycleInstance(this);
50 | }
51 |
52 | @Override
53 | protected ObjectPool.Poolable instantiate() {
54 | return new MoveViewJob(mViewPortHandler, xValue, yValue, mTrans, view);
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/app/src/main/java/com/android/stockapp/ui/market/activity/StockDetailLandActivity.java:
--------------------------------------------------------------------------------
1 | package com.android.stockapp.ui.market.activity;
2 |
3 | import android.os.Bundle;
4 | import com.google.android.material.tabs.TabLayout;
5 | import androidx.fragment.app.Fragment;
6 | import androidx.appcompat.app.AppCompatActivity;
7 |
8 | import com.android.stockapp.R;
9 | import com.android.stockapp.common.adapter.SimpleFragmentPagerAdapter;
10 | import com.android.stockapp.common.viewpager.NoTouchScrollViewpager;
11 | import com.android.stockapp.ui.market.fragment.ChartFiveDayFragment;
12 | import com.android.stockapp.ui.market.fragment.ChartKLineFragment;
13 | import com.android.stockapp.ui.market.fragment.ChartOneDayFragment;
14 |
15 | import butterknife.BindView;
16 | import butterknife.ButterKnife;
17 |
18 | /**
19 | * 股票详情页-横屏
20 | */
21 | public class StockDetailLandActivity extends AppCompatActivity {
22 |
23 | @BindView(R.id.tab)
24 | TabLayout tabLayout;
25 | @BindView(R.id.view_pager)
26 | NoTouchScrollViewpager viewPager;
27 |
28 | @Override
29 | protected void onCreate(Bundle savedInstanceState) {
30 | super.onCreate(savedInstanceState);
31 | setContentView(R.layout.activity_stock_detail_land);
32 | ButterKnife.bind(this);
33 |
34 | Fragment[] fragments = {ChartOneDayFragment.newInstance(true), ChartFiveDayFragment.newInstance(true),
35 | ChartKLineFragment.newInstance(1,true), ChartKLineFragment.newInstance(7,true),
36 | ChartKLineFragment.newInstance(30,true)};
37 | String[] titles = {"分时", "五日", "日K", "周K", "月K"};
38 | viewPager.setOffscreenPageLimit(fragments.length);
39 | viewPager.setAdapter(new SimpleFragmentPagerAdapter(getSupportFragmentManager(), fragments, titles));
40 | tabLayout.setupWithViewPager(viewPager);
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/app/src/main/java/com/android/stockapp/ui/mpchartexample/custom/XYMarkerView.java:
--------------------------------------------------------------------------------
1 | package com.android.stockapp.ui.mpchartexample.custom;
2 |
3 | import android.annotation.SuppressLint;
4 | import android.content.Context;
5 | import android.widget.TextView;
6 |
7 | import com.android.stockapp.R;
8 | import com.github.mikephil.charting.components.MarkerView;
9 | import com.github.mikephil.charting.data.Entry;
10 | import com.github.mikephil.charting.formatter.ValueFormatter;
11 | import com.github.mikephil.charting.highlight.Highlight;
12 | import com.github.mikephil.charting.utils.MPPointF;
13 |
14 | import java.text.DecimalFormat;
15 |
16 | /**
17 | * Custom implementation of the MarkerView.
18 | *
19 | * @author Philipp Jahoda
20 | */
21 | @SuppressLint("ViewConstructor")
22 | public class XYMarkerView extends MarkerView {
23 |
24 | private final TextView tvContent;
25 | private final ValueFormatter xAxisValueFormatter;
26 |
27 | private final DecimalFormat format;
28 |
29 | public XYMarkerView(Context context, ValueFormatter xAxisValueFormatter) {
30 | super(context, R.layout.custom_marker_view);
31 |
32 | this.xAxisValueFormatter = xAxisValueFormatter;
33 | tvContent = findViewById(R.id.tvContent);
34 | format = new DecimalFormat("###.0");
35 | }
36 |
37 | // runs every time the MarkerView is redrawn, can be used to update the
38 | // content (user-interface)
39 | @Override
40 | public void refreshContent(Entry e, Highlight highlight) {
41 |
42 | tvContent.setText(String.format("x: %s, y: %s", xAxisValueFormatter.getFormattedValue(e.getX()), format.format(e.getY())));
43 |
44 | super.refreshContent(e, highlight);
45 | }
46 |
47 | @Override
48 | public MPPointF getOffset() {
49 | return new MPPointF(-(getWidth() / 2), -getHeight());
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/data/BarLineScatterCandleBubbleDataSet.java:
--------------------------------------------------------------------------------
1 |
2 | package com.github.mikephil.charting.data;
3 |
4 | import android.graphics.Color;
5 |
6 | import com.github.mikephil.charting.interfaces.datasets.IBarLineScatterCandleBubbleDataSet;
7 | import com.github.mikephil.charting.utils.Utils;
8 |
9 | import java.util.List;
10 |
11 | /**
12 | * Baseclass of all DataSets for Bar-, Line-, Scatter- and CandleStickChart.
13 | *
14 | * @author Philipp Jahoda
15 | */
16 | public abstract class BarLineScatterCandleBubbleDataSet extends DataSet implements IBarLineScatterCandleBubbleDataSet {
17 |
18 | /**
19 | * default highlight color
20 | */
21 | protected int mHighLightColor = Color.rgb(255, 187, 115);
22 | /**
23 | * the width of the highlight indicator lines
24 | */
25 | protected float mHighlightLineWidth = 0.5f;
26 |
27 | public BarLineScatterCandleBubbleDataSet(List yVals, String label) {
28 | super(yVals, label);
29 | }
30 |
31 | /**
32 | * Sets the color that is used for drawing the highlight indicators. Dont
33 | * forget to resolve the color using getResources().getColor(...) or
34 | * Color.rgb(...).
35 | *
36 | * @param color
37 | */
38 | public void setHighLightColor(int color) {
39 | mHighLightColor = color;
40 | }
41 |
42 | @Override
43 | public int getHighLightColor() {
44 | return mHighLightColor;
45 | }
46 |
47 | /**
48 | * Sets the width of the highlight line in dp.
49 | *
50 | * @param width
51 | */
52 | public void setHighlightLineWidth(float width) {
53 | mHighlightLineWidth = width;
54 | }
55 |
56 | @Override
57 | public float getHighlightLineWidth() {
58 | return mHighlightLineWidth;
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/formatter/IndexAxisValueFormatter.java:
--------------------------------------------------------------------------------
1 | package com.github.mikephil.charting.formatter;
2 |
3 | import java.util.Collection;
4 |
5 | /**
6 | * This formatter is used for passing an array of x-axis labels, on whole x steps.
7 | */
8 | public class IndexAxisValueFormatter extends ValueFormatter
9 | {
10 | private String[] mValues = new String[] {};
11 | private int mValueCount = 0;
12 |
13 | /**
14 | * An empty constructor.
15 | * Use `setValues` to set the axis labels.
16 | */
17 | public IndexAxisValueFormatter() {
18 | }
19 |
20 | /**
21 | * Constructor that specifies axis labels.
22 | *
23 | * @param values The values string array
24 | */
25 | public IndexAxisValueFormatter(String[] values) {
26 | if (values != null) {
27 | setValues(values);
28 | }
29 | }
30 |
31 | /**
32 | * Constructor that specifies axis labels.
33 | *
34 | * @param values The values string array
35 | */
36 | public IndexAxisValueFormatter(Collection values) {
37 | if (values != null) {
38 | setValues(values.toArray(new String[values.size()]));
39 | }
40 | }
41 |
42 | @Override
43 | public String getFormattedValue(float value) {
44 | int index = Math.round(value);
45 |
46 | if (index < 0 || index >= mValueCount || index != (int) value) {
47 | return "";
48 | }
49 |
50 | return mValues[index];
51 | }
52 |
53 | public String[] getValues() {
54 | return mValues;
55 | }
56 |
57 | public void setValues(String[] values) {
58 | if (values == null) {
59 | values = new String[]{};
60 | }
61 |
62 | this.mValues = values;
63 | this.mValueCount = values.length;
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/formatter/PercentFormatter.java:
--------------------------------------------------------------------------------
1 | package com.github.mikephil.charting.formatter;
2 |
3 | import com.github.mikephil.charting.charts.PieChart;
4 | import com.github.mikephil.charting.data.PieEntry;
5 |
6 | import java.text.DecimalFormat;
7 |
8 | /**
9 | * This IValueFormatter is just for convenience and simply puts a "%" sign after
10 | * each value. (Recommended for PieChart)
11 | *
12 | * @author Philipp Jahoda
13 | */
14 | public class PercentFormatter extends ValueFormatter
15 | {
16 |
17 | public DecimalFormat mFormat;
18 | private PieChart pieChart;
19 | private boolean percentSignSeparated;
20 |
21 | public PercentFormatter() {
22 | mFormat = new DecimalFormat("###,###,##0.0");
23 | percentSignSeparated = true;
24 | }
25 |
26 | // Can be used to remove percent signs if the chart isn't in percent mode
27 | public PercentFormatter(PieChart pieChart) {
28 | this();
29 | this.pieChart = pieChart;
30 | }
31 |
32 | // Can be used to remove percent signs if the chart isn't in percent mode
33 | public PercentFormatter(PieChart pieChart, boolean percentSignSeparated) {
34 | this(pieChart);
35 | this.percentSignSeparated = percentSignSeparated;
36 | }
37 |
38 | @Override
39 | public String getFormattedValue(float value) {
40 | return mFormat.format(value) + (percentSignSeparated ? " %" : "%");
41 | }
42 |
43 | @Override
44 | public String getPieLabel(float value, PieEntry pieEntry) {
45 | if (pieChart != null && pieChart.isUsePercentValuesEnabled()) {
46 | // Converted to percent
47 | return getFormattedValue(value);
48 | } else {
49 | // raw value, skip percent sign
50 | return mFormat.format(value);
51 | }
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/interfaces/dataprovider/ChartInterface.java:
--------------------------------------------------------------------------------
1 | package com.github.mikephil.charting.interfaces.dataprovider;
2 |
3 | import android.graphics.RectF;
4 |
5 | import com.github.mikephil.charting.data.ChartData;
6 | import com.github.mikephil.charting.formatter.ValueFormatter;
7 | import com.github.mikephil.charting.utils.MPPointF;
8 |
9 | /**
10 | * Interface that provides everything there is to know about the dimensions,
11 | * bounds, and range of the chart.
12 | *
13 | * @author Philipp Jahoda
14 | */
15 | public interface ChartInterface {
16 |
17 | /**
18 | * Returns the minimum x value of the chart, regardless of zoom or translation.
19 | *
20 | * @return
21 | */
22 | float getXChartMin();
23 |
24 | /**
25 | * Returns the maximum x value of the chart, regardless of zoom or translation.
26 | *
27 | * @return
28 | */
29 | float getXChartMax();
30 |
31 | float getXRange();
32 |
33 | /**
34 | * Returns the minimum y value of the chart, regardless of zoom or translation.
35 | *
36 | * @return
37 | */
38 | float getYChartMin();
39 |
40 | /**
41 | * Returns the maximum y value of the chart, regardless of zoom or translation.
42 | *
43 | * @return
44 | */
45 | float getYChartMax();
46 |
47 | /**
48 | * Returns the maximum distance in scren dp a touch can be away from an entry to cause it to get highlighted.
49 | *
50 | * @return
51 | */
52 | float getMaxHighlightDistance();
53 |
54 | int getWidth();
55 |
56 | int getHeight();
57 |
58 | MPPointF getCenterOfView();
59 |
60 | MPPointF getCenterOffsets();
61 |
62 | RectF getContentRect();
63 |
64 | ValueFormatter getDefaultValueFormatter();
65 |
66 | ChartData getData();
67 |
68 | int getMaxVisibleCount();
69 | }
70 |
--------------------------------------------------------------------------------
/app/src/main/java/com/android/stockapp/ui/mpchartexample/fragments/ComplexityFragment.java:
--------------------------------------------------------------------------------
1 | package com.android.stockapp.ui.mpchartexample.fragments;
2 |
3 | import android.graphics.Typeface;
4 | import android.os.Bundle;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 |
9 | import androidx.annotation.NonNull;
10 | import androidx.fragment.app.Fragment;
11 |
12 | import com.android.stockapp.R;
13 | import com.github.mikephil.charting.charts.LineChart;
14 | import com.github.mikephil.charting.components.Legend;
15 | import com.github.mikephil.charting.components.XAxis;
16 | import com.github.mikephil.charting.components.YAxis;
17 |
18 |
19 | public class ComplexityFragment extends SimpleFragment {
20 |
21 | @NonNull
22 | public static Fragment newInstance() {
23 | return new ComplexityFragment();
24 | }
25 |
26 | @SuppressWarnings("FieldCanBeLocal")
27 | private LineChart chart;
28 |
29 | @Override
30 | public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
31 | View v = inflater.inflate(R.layout.frag_simple_line, container, false);
32 |
33 | chart = v.findViewById(R.id.lineChart1);
34 |
35 | chart.getDescription().setEnabled(false);
36 |
37 | chart.setDrawGridBackground(false);
38 |
39 | chart.setData(getComplexity());
40 | chart.animateX(3000);
41 |
42 | Typeface tf = Typeface.createFromAsset(context.getAssets(), "OpenSans-Light.ttf");
43 |
44 | Legend l = chart.getLegend();
45 | l.setTypeface(tf);
46 |
47 | YAxis leftAxis = chart.getAxisLeft();
48 | leftAxis.setTypeface(tf);
49 |
50 | chart.getAxisRight().setEnabled(false);
51 |
52 | XAxis xAxis = chart.getXAxis();
53 | xAxis.setEnabled(false);
54 |
55 | return v;
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/formatter/DefaultValueFormatter.java:
--------------------------------------------------------------------------------
1 | package com.github.mikephil.charting.formatter;
2 |
3 | import java.text.DecimalFormat;
4 |
5 | /**
6 | * Default formatter used for formatting values inside the chart. Uses a DecimalFormat with
7 | * pre-calculated number of digits (depending on max and min value).
8 | *
9 | * @author Philipp Jahoda
10 | */
11 | public class DefaultValueFormatter extends ValueFormatter
12 | {
13 |
14 | /**
15 | * DecimalFormat for formatting
16 | */
17 | protected DecimalFormat mFormat;
18 |
19 | protected int mDecimalDigits;
20 |
21 | /**
22 | * Constructor that specifies to how many digits the value should be
23 | * formatted.
24 | *
25 | * @param digits
26 | */
27 | public DefaultValueFormatter(int digits) {
28 | setup(digits);
29 | }
30 |
31 | /**
32 | * Sets up the formatter with a given number of decimal digits.
33 | *
34 | * @param digits
35 | */
36 | public void setup(int digits) {
37 |
38 | this.mDecimalDigits = digits;
39 |
40 | StringBuffer b = new StringBuffer();
41 | for (int i = 0; i < digits; i++) {
42 | if (i == 0) {
43 | b.append(".");
44 | }
45 | b.append("0");
46 | }
47 |
48 | mFormat = new DecimalFormat("###,###,###,##0" + b.toString());
49 | }
50 |
51 | @Override
52 | public String getFormattedValue(float value) {
53 |
54 | // put more logic here ...
55 | // avoid memory allocations here (for performance reasons)
56 |
57 | return mFormat.format(value);
58 | }
59 |
60 | /**
61 | * Returns the number of decimal digits this formatter uses.
62 | *
63 | * @return
64 | */
65 | public int getDecimalDigits() {
66 | return mDecimalDigits;
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/pie.xml:
--------------------------------------------------------------------------------
1 |
2 |
62 |
--------------------------------------------------------------------------------
/app/src/main/java/com/android/stockapp/ui/mpchartexample/fragments/SineCosineFragment.java:
--------------------------------------------------------------------------------
1 | package com.android.stockapp.ui.mpchartexample.fragments;
2 |
3 | import android.graphics.Typeface;
4 | import android.os.Bundle;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 |
9 | import androidx.annotation.NonNull;
10 | import androidx.fragment.app.Fragment;
11 |
12 | import com.android.stockapp.R;
13 | import com.github.mikephil.charting.charts.LineChart;
14 | import com.github.mikephil.charting.components.Legend;
15 | import com.github.mikephil.charting.components.XAxis;
16 | import com.github.mikephil.charting.components.YAxis;
17 |
18 |
19 | public class SineCosineFragment extends SimpleFragment {
20 |
21 | @NonNull
22 | public static Fragment newInstance() {
23 | return new SineCosineFragment();
24 | }
25 |
26 | @SuppressWarnings("FieldCanBeLocal")
27 | private LineChart chart;
28 |
29 | @Override
30 | public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
31 | View v = inflater.inflate(R.layout.frag_simple_line, container, false);
32 |
33 | chart = v.findViewById(R.id.lineChart1);
34 |
35 | chart.getDescription().setEnabled(false);
36 |
37 | chart.setDrawGridBackground(false);
38 |
39 | chart.setData(generateLineData());
40 | chart.animateX(3000);
41 |
42 | Typeface tf = Typeface.createFromAsset(context.getAssets(), "OpenSans-Light.ttf");
43 |
44 | Legend l = chart.getLegend();
45 | l.setTypeface(tf);
46 |
47 | YAxis leftAxis = chart.getAxisLeft();
48 | leftAxis.setTypeface(tf);
49 | leftAxis.setAxisMaximum(1.2f);
50 | leftAxis.setAxisMinimum(-1.2f);
51 |
52 | chart.getAxisRight().setEnabled(false);
53 |
54 | XAxis xAxis = chart.getXAxis();
55 | xAxis.setEnabled(false);
56 |
57 | return v;
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/radar.xml:
--------------------------------------------------------------------------------
1 |
2 |
63 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/formatter/VolFormatter.java:
--------------------------------------------------------------------------------
1 | package com.github.mikephil.charting.formatter;
2 |
3 |
4 | import android.content.Context;
5 |
6 | import com.github.mikephil.charting.R;
7 | import com.github.mikephil.charting.components.AxisBase;
8 |
9 | import java.text.DecimalFormat;
10 |
11 | /**
12 | * 坐标label格式化
13 | */
14 | public class VolFormatter extends ValueFormatter {
15 |
16 | private int unit;
17 | private DecimalFormat mFormat;
18 | private String u;
19 | private String assetId;
20 | private Context context;
21 |
22 | public VolFormatter(Context context,String assetId){
23 | this.context = context;
24 | this.assetId = assetId;
25 | }
26 | @Override
27 | public String getAxisLabel(float value, AxisBase axis) {
28 | int e = (int) Math.floor(Math.log10(value));
29 | if (e >= 8) {
30 | unit = 8;
31 | } else if (e >= 4) {
32 | unit = 4;
33 | } else {
34 | unit = 1;
35 | }
36 |
37 | if (e == 1) {
38 | mFormat = new DecimalFormat("#0");
39 | } else {
40 | mFormat = new DecimalFormat("#0.00");
41 | }
42 | value = value / (int) Math.pow(10, unit);
43 | if (value == 0) {
44 | int e2 = (int) Math.floor(Math.log10(axis.getAxisMaximum()));
45 | if (e2 >= 8) {
46 | u = assetId.endsWith(".HK")?context.getResources().getString(R.string.billions_gu):context.getResources().getString(R.string.billions_shou);
47 | } else if (e2 >= 4) {
48 | u = assetId.endsWith(".HK")?context.getResources().getString(R.string.millions_gu):context.getResources().getString(R.string.millions_shou);
49 | } else {
50 | u = assetId.endsWith(".HK")?context.getResources().getString(R.string.gu):context.getResources().getString(R.string.shou);
51 | }
52 | return u;
53 | }
54 | return mFormat.format(value);
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/app/src/main/java/com/android/stockapp/ui/mpchartexample/custom/StackedBarsMarkerView.java:
--------------------------------------------------------------------------------
1 |
2 | package com.android.stockapp.ui.mpchartexample.custom;
3 |
4 | import android.annotation.SuppressLint;
5 | import android.content.Context;
6 | import android.widget.TextView;
7 |
8 | import com.android.stockapp.R;
9 | import com.github.mikephil.charting.components.MarkerView;
10 | import com.github.mikephil.charting.data.BarEntry;
11 | import com.github.mikephil.charting.data.Entry;
12 | import com.github.mikephil.charting.highlight.Highlight;
13 | import com.github.mikephil.charting.utils.MPPointF;
14 | import com.github.mikephil.charting.utils.Utils;
15 |
16 | /**
17 | * Custom implementation of the MarkerView.
18 | *
19 | * @author Philipp Jahoda
20 | */
21 | @SuppressWarnings("unused")
22 | @SuppressLint("ViewConstructor")
23 | public class StackedBarsMarkerView extends MarkerView {
24 |
25 | private TextView tvContent;
26 |
27 | public StackedBarsMarkerView(Context context, int layoutResource) {
28 | super(context, layoutResource);
29 |
30 | tvContent = findViewById(R.id.tvContent);
31 | }
32 |
33 | // runs every time the MarkerView is redrawn, can be used to update the
34 | // content (user-interface)
35 | @Override
36 | public void refreshContent(Entry e, Highlight highlight) {
37 |
38 | if (e instanceof BarEntry) {
39 |
40 | BarEntry be = (BarEntry) e;
41 |
42 | if(be.getYVals() != null) {
43 |
44 | // draw the stack value
45 | tvContent.setText(Utils.formatNumber(be.getYVals()[highlight.getStackIndex()], 0, true));
46 | } else {
47 | tvContent.setText(Utils.formatNumber(be.getY(), 0, true));
48 | }
49 | } else {
50 |
51 | tvContent.setText(Utils.formatNumber(e.getY(), 0, true));
52 | }
53 |
54 | super.refreshContent(e, highlight);
55 | }
56 |
57 | @Override
58 | public MPPointF getOffset() {
59 | return new MPPointF(-(getWidth() / 2), -getHeight());
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/interfaces/datasets/ICandleDataSet.java:
--------------------------------------------------------------------------------
1 | package com.github.mikephil.charting.interfaces.datasets;
2 |
3 | import android.graphics.Paint;
4 |
5 | import com.github.mikephil.charting.data.CandleEntry;
6 |
7 | /**
8 | * Created by philipp on 21/10/15.
9 | */
10 | public interface ICandleDataSet extends ILineScatterCandleRadarDataSet {
11 |
12 | /**
13 | * Returns the space that is left out on the left and right side of each
14 | * candle.
15 | *
16 | * @return
17 | */
18 | float getBarSpace();
19 |
20 | /**
21 | * Returns whether the candle bars should show?
22 | * When false, only "ticks" will show
23 | *
24 | * - default: true
25 | *
26 | * @return
27 | */
28 | boolean getShowCandleBar();
29 |
30 | /**
31 | * Returns the width of the candle-shadow-line in pixels.
32 | *
33 | * @return
34 | */
35 | float getShadowWidth();
36 |
37 | /**
38 | * Returns shadow color for all entries
39 | *
40 | * @return
41 | */
42 | int getShadowColor();
43 |
44 | /**
45 | * Returns the neutral color (for open == close)
46 | *
47 | * @return
48 | */
49 | int getNeutralColor();
50 |
51 | /**
52 | * Returns the increasing color (for open < close).
53 | *
54 | * @return
55 | */
56 | int getIncreasingColor();
57 |
58 | /**
59 | * Returns the decreasing color (for open > close).
60 | *
61 | * @return
62 | */
63 | int getDecreasingColor();
64 |
65 | /**
66 | * Returns paint style when open < close
67 | *
68 | * @return
69 | */
70 | Paint.Style getIncreasingPaintStyle();
71 |
72 | /**
73 | * Returns paint style when open > close
74 | *
75 | * @return
76 | */
77 | Paint.Style getDecreasingPaintStyle();
78 |
79 | /**
80 | * Is the shadow color same as the candle color?
81 | *
82 | * @return
83 | */
84 | boolean getShadowColorSameAsCandle();
85 | }
86 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/data/BubbleDataSet.java:
--------------------------------------------------------------------------------
1 |
2 | package com.github.mikephil.charting.data;
3 |
4 | import com.github.mikephil.charting.interfaces.datasets.IBubbleDataSet;
5 | import com.github.mikephil.charting.utils.Utils;
6 |
7 | import java.util.ArrayList;
8 | import java.util.List;
9 |
10 | public class BubbleDataSet extends BarLineScatterCandleBubbleDataSet implements IBubbleDataSet {
11 |
12 | protected float mMaxSize;
13 | protected boolean mNormalizeSize = true;
14 |
15 | private float mHighlightCircleWidth = 2.5f;
16 |
17 | public BubbleDataSet(List yVals, String label) {
18 | super(yVals, label);
19 | }
20 |
21 | @Override
22 | public void setHighlightCircleWidth(float width) {
23 | mHighlightCircleWidth = Utils.convertDpToPixel(width);
24 | }
25 |
26 | @Override
27 | public float getHighlightCircleWidth() {
28 | return mHighlightCircleWidth;
29 | }
30 |
31 | @Override
32 | protected void calcMinMax(BubbleEntry e) {
33 | super.calcMinMax(e);
34 |
35 | final float size = e.getSize();
36 |
37 | if (size > mMaxSize) {
38 | mMaxSize = size;
39 | }
40 | }
41 |
42 | @Override
43 | public DataSet copy() {
44 |
45 | List yVals = new ArrayList();
46 |
47 | for (int i = 0; i < mValues.size(); i++) {
48 | yVals.add(mValues.get(i).copy());
49 | }
50 |
51 | BubbleDataSet copied = new BubbleDataSet(yVals, getLabel());
52 | copied.mColors = mColors;
53 | copied.mHighLightColor = mHighLightColor;
54 |
55 | return copied;
56 | }
57 |
58 | @Override
59 | public float getMaxSize() {
60 | return mMaxSize;
61 | }
62 |
63 | @Override
64 | public boolean isNormalizeSizeEnabled() {
65 | return mNormalizeSize;
66 | }
67 |
68 | public void setNormalizeSizeEnabled(boolean normalizeSize) {
69 | mNormalizeSize = normalizeSize;
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/highlight/PieRadarHighlighter.java:
--------------------------------------------------------------------------------
1 | package com.github.mikephil.charting.highlight;
2 |
3 | import com.github.mikephil.charting.charts.PieChart;
4 | import com.github.mikephil.charting.charts.PieRadarChartBase;
5 |
6 | import java.util.ArrayList;
7 | import java.util.List;
8 |
9 | /**
10 | * Created by philipp on 12/06/16.
11 | */
12 | public abstract class PieRadarHighlighter implements IHighlighter {
13 |
14 | protected T mChart;
15 |
16 | /**
17 | * buffer for storing previously highlighted values
18 | */
19 | protected List mHighlightBuffer = new ArrayList();
20 |
21 | public PieRadarHighlighter(T chart) {
22 | this.mChart = chart;
23 | }
24 |
25 | @Override
26 | public Highlight getHighlight(float x, float y) {
27 |
28 | float touchDistanceToCenter = mChart.distanceToCenter(x, y);
29 |
30 | // check if a slice was touched
31 | if (touchDistanceToCenter > mChart.getRadius()) {
32 |
33 | // if no slice was touched, highlight nothing
34 | return null;
35 |
36 | } else {
37 |
38 | float angle = mChart.getAngleForPoint(x, y);
39 |
40 | if (mChart instanceof PieChart) {
41 | angle /= mChart.getAnimator().getPhaseY();
42 | }
43 |
44 | int index = mChart.getIndexForAngle(angle);
45 |
46 | // check if the index could be found
47 | if (index < 0 || index >= mChart.getData().getMaxEntryCountSet().getEntryCount()) {
48 | return null;
49 |
50 | } else {
51 | return getClosestHighlight(index, x, y);
52 | }
53 | }
54 | }
55 |
56 | /**
57 | * Returns the closest Highlight object of the given objects based on the touch position inside the chart.
58 | *
59 | * @param index
60 | * @param x
61 | * @param y
62 | * @return
63 | */
64 | protected abstract Highlight getClosestHighlight(int index, float x, float y);
65 | }
66 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/line.xml:
--------------------------------------------------------------------------------
1 |
2 |
66 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/components/IMarker.java:
--------------------------------------------------------------------------------
1 | package com.github.mikephil.charting.components;
2 |
3 | import android.graphics.Canvas;
4 |
5 | import com.github.mikephil.charting.data.Entry;
6 | import com.github.mikephil.charting.highlight.Highlight;
7 | import com.github.mikephil.charting.utils.MPPointF;
8 |
9 | public interface IMarker {
10 |
11 | /**
12 | * @return The desired (general) offset you wish the IMarker to have on the x- and y-axis.
13 | * By returning x: -(width / 2) you will center the IMarker horizontally.
14 | * By returning y: -(height / 2) you will center the IMarker vertically.
15 | */
16 | MPPointF getOffset();
17 |
18 | /**
19 | * @param posX This is the X position at which the marker wants to be drawn.
20 | * You can adjust the offset conditionally based on this argument.
21 | * @param posY This is the X position at which the marker wants to be drawn.
22 | * You can adjust the offset conditionally based on this argument.
23 | * @return The offset for drawing at the specific `point`. This allows conditional adjusting of the Marker position.
24 | * If you have no adjustments to make, return getOffset().
25 | */
26 | MPPointF getOffsetForDrawingAtPoint(float posX, float posY);
27 |
28 | /**
29 | * This method enables a specified custom IMarker to update it's content every time the IMarker is redrawn.
30 | *
31 | * @param e The Entry the IMarker belongs to. This can also be any subclass of Entry, like BarEntry or
32 | * CandleEntry, simply cast it at runtime.
33 | * @param highlight The highlight object contains information about the highlighted value such as it's dataset-index, the
34 | * selected range or stack-index (only stacked bar entries).
35 | */
36 | void refreshContent(Entry e, Highlight highlight);
37 |
38 | /**
39 | * Draws the IMarker on the given position on the screen with the given Canvas object.
40 | *
41 | * @param canvas
42 | * @param posX
43 | * @param posY
44 | */
45 | void draw(Canvas canvas, float posX, float posY);
46 | }
47 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/stockChart/model/bean/KMAEntity.java:
--------------------------------------------------------------------------------
1 | package com.github.mikephil.charting.stockChart.model.bean;
2 |
3 |
4 | import com.github.mikephil.charting.stockChart.model.KLineDataModel;
5 |
6 | import java.util.ArrayList;
7 |
8 | import static java.lang.Float.NaN;
9 |
10 | /**
11 | * Created by loro on 2017/3/7.
12 | */
13 |
14 | public class KMAEntity {
15 | private ArrayList MAs;
16 |
17 | /**
18 | * 得到已N日为单位的均值
19 | *
20 | * @param kLineBeen
21 | * @param n 几日均值
22 | */
23 | public KMAEntity(ArrayList kLineBeen, int n) {
24 | this(kLineBeen, n, NaN);
25 | }
26 |
27 | /**
28 | * 得到已N日为单位的均值
29 | *
30 | * @param kLineBeen
31 | * @param n 几日均值
32 | * @param defult 不足N日时的默认值
33 | */
34 | public KMAEntity(ArrayList kLineBeen, int n, float defult) {
35 | MAs = new ArrayList();
36 | float ma = 0.0f;
37 | int index = n - 1;
38 | if (kLineBeen != null && kLineBeen.size() > 0) {
39 | for (int i = 0; i < kLineBeen.size(); i++) {
40 | if (i >= index) {
41 | ma = getSum(i - index, i, kLineBeen) / n;
42 | } else {
43 | ma = defult;
44 | }
45 | MAs.add(ma);
46 | }
47 | }
48 | }
49 |
50 | private static float getSum(Integer a, Integer b, ArrayList datas) {
51 | float sum = 0;
52 | for (int i = a; i <= b; i++) {
53 | sum += datas.get(i).getClose();
54 | }
55 | return sum;
56 | }
57 |
58 | public static float getLastMA(ArrayList datas, int n) {
59 | if (null != datas && datas.size() > 0) {
60 | int count = datas.size() - 1;
61 | int index = n - 1;
62 | if (datas.size() >= n) {
63 | return getSum(count - index, count, datas) / n;
64 | }
65 | return NaN;
66 | }
67 | return NaN;
68 | }
69 |
70 | public ArrayList getMAs() {
71 | return MAs;
72 | }
73 |
74 | }
75 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/utils/FSize.java:
--------------------------------------------------------------------------------
1 |
2 | package com.github.mikephil.charting.utils;
3 |
4 | import java.util.List;
5 |
6 | /**
7 | * Class for describing width and height dimensions in some arbitrary
8 | * unit. Replacement for the android.Util.SizeF which is available only on API >= 21.
9 | */
10 | public final class FSize extends ObjectPool.Poolable{
11 |
12 | // TODO : Encapsulate width & height
13 |
14 | public float width;
15 | public float height;
16 |
17 | private static ObjectPool pool;
18 |
19 | static {
20 | pool = ObjectPool.create(256, new FSize(0,0));
21 | pool.setReplenishPercentage(0.5f);
22 | }
23 |
24 |
25 | @Override
26 | protected ObjectPool.Poolable instantiate(){
27 | return new FSize(0,0);
28 | }
29 |
30 | public static FSize getInstance(final float width, final float height){
31 | FSize result = pool.get();
32 | result.width = width;
33 | result.height = height;
34 | return result;
35 | }
36 |
37 | public static void recycleInstance(FSize instance){
38 | pool.recycle(instance);
39 | }
40 |
41 | public static void recycleInstances(List instances){
42 | pool.recycle(instances);
43 | }
44 |
45 | public FSize() {
46 | }
47 |
48 | public FSize(final float width, final float height) {
49 | this.width = width;
50 | this.height = height;
51 | }
52 |
53 | @Override
54 | public boolean equals(final Object obj) {
55 | if (obj == null) {
56 | return false;
57 | }
58 | if (this == obj) {
59 | return true;
60 | }
61 | if (obj instanceof FSize) {
62 | final FSize other = (FSize) obj;
63 | return width == other.width && height == other.height;
64 | }
65 | return false;
66 | }
67 |
68 | @Override
69 | public String toString() {
70 | return width + "x" + height;
71 | }
72 |
73 | /**
74 | * {@inheritDoc}
75 | */
76 | @Override
77 | public int hashCode() {
78 | return Float.floatToIntBits(width) ^ Float.floatToIntBits(height);
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/stockChart/model/bean/CCIEntity.java:
--------------------------------------------------------------------------------
1 | package com.github.mikephil.charting.stockChart.model.bean;
2 |
3 |
4 | import com.github.mikephil.charting.stockChart.model.KLineDataModel;
5 |
6 | import java.util.ArrayList;
7 | import java.util.List;
8 |
9 | import static java.lang.Float.NaN;
10 |
11 | /**
12 | * Created by Administrator on 2018/3/14.
13 | */
14 |
15 | public class CCIEntity {
16 | private ArrayList CCIs;
17 |
18 | public CCIEntity(ArrayList kLineBeen, int n) {
19 | this(kLineBeen, n, NaN);
20 | }
21 |
22 | public CCIEntity(List kLineBeen, int n, float defult) {
23 | CCIs = new ArrayList<>();
24 |
25 | float cci = 0.0f;
26 | float typ = 0.0f;
27 | float ma = 0.0f;
28 | float avedev = 0.0f;
29 | if (kLineBeen != null && kLineBeen.size() > 0) {
30 | {
31 | for (int i = 0; i < kLineBeen.size(); i++) {
32 | int index = n - 1;
33 | typ = (float) ((kLineBeen.get(i).getHigh() + kLineBeen.get(i).getLow() + kLineBeen.get(i).getClose()) / 3);
34 | if (i >= index) {
35 | ma = getSum(i - index, i, kLineBeen) / n;
36 | avedev = getSMA(avedev, (float) Math.abs(kLineBeen.get(i).getClose() - ma), n);
37 | } else {
38 | ma = defult;
39 | avedev = (float) Math.abs(kLineBeen.get(i).getClose());
40 | }
41 | cci = (float) ((typ - ma) / (0.015 * avedev));
42 | CCIs.add(cci);
43 | }
44 | }
45 | }
46 | }
47 |
48 | private static float getSum(Integer a, Integer b, List datas) {
49 | float sum = 0;
50 | for (int i = a; i <= b; i++) {
51 | sum += datas.get(i).getClose();
52 | }
53 | return sum;
54 | }
55 |
56 | private static float getSMA(float perSAM, float price, int n) {
57 | return perSAM * (n - 1) / n + price * 1 / n;
58 | }
59 |
60 | public ArrayList getCCIs() {
61 | return CCIs;
62 | }
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/app/src/main/java/com/android/stockapp/ui/base/BaseFragment.java:
--------------------------------------------------------------------------------
1 | package com.android.stockapp.ui.base;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.os.Bundle;
7 | import androidx.fragment.app.Fragment;
8 | import android.view.LayoutInflater;
9 | import android.view.View;
10 | import android.view.ViewGroup;
11 | import android.widget.Toast;
12 |
13 | import butterknife.ButterKnife;
14 |
15 | public abstract class BaseFragment extends Fragment {
16 | public Activity mAct;
17 | private View view;
18 |
19 | @Override
20 | public void onAttach(Activity activity) {
21 | super.onAttach(activity);
22 | mAct = activity;
23 | }
24 |
25 | @Override
26 | public void onCreate(Bundle savedInstanceState) {
27 | super.onCreate(savedInstanceState);
28 | }
29 |
30 | @Override
31 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
32 | Bundle savedInstanceState) {
33 | view = inflater.inflate(setLayoutId(), container, false);
34 | ButterKnife.bind(this,view);
35 | initBase(view);
36 | return view;
37 | }
38 |
39 | @Override
40 | public void onDestroyView() {
41 | super.onDestroyView();
42 | }
43 |
44 | protected abstract int setLayoutId();
45 |
46 | protected abstract void initBase(View view);
47 |
48 | @Override
49 | public void onAttach(Context context) {
50 | super.onAttach(context);
51 | }
52 |
53 | @Override
54 | public void onDetach() {
55 | super.onDetach();
56 | }
57 |
58 | protected void startToActivity(Class> cls){
59 | Intent intent = new Intent(mAct, cls);
60 | mAct.startActivity(intent);
61 | }
62 |
63 | Toast toast;
64 | public void showToast(String string) {
65 | if(toast == null){
66 | toast = Toast.makeText(mAct, string, Toast.LENGTH_SHORT);
67 | }else{
68 | toast.setText(string);
69 | }
70 | toast.show();
71 | }
72 |
73 | @Override
74 | public void onDestroy() {
75 | if(toast != null){
76 | toast.cancel();
77 | }
78 | super.onDestroy();
79 | }
80 |
81 | }
82 |
--------------------------------------------------------------------------------
/MPChartLib/src/main/java/com/github/mikephil/charting/interfaces/datasets/IPieDataSet.java:
--------------------------------------------------------------------------------
1 | package com.github.mikephil.charting.interfaces.datasets;
2 |
3 | import com.github.mikephil.charting.data.PieDataSet;
4 | import com.github.mikephil.charting.data.PieEntry;
5 |
6 | /**
7 | * Created by Philipp Jahoda on 03/11/15.
8 | */
9 | public interface IPieDataSet extends IDataSet {
10 |
11 | /**
12 | * Returns the space that is set to be between the piechart-slices of this
13 | * DataSet, in pixels.
14 | *
15 | * @return
16 | */
17 | float getSliceSpace();
18 |
19 | /**
20 | * When enabled, slice spacing will be 0.0 when the smallest value is going to be
21 | * smaller than the slice spacing itself.
22 | *
23 | * @return
24 | */
25 | boolean isAutomaticallyDisableSliceSpacingEnabled();
26 |
27 | /**
28 | * Returns the distance a highlighted piechart slice is "shifted" away from
29 | * the chart-center in dp.
30 | *
31 | * @return
32 | */
33 | float getSelectionShift();
34 |
35 | PieDataSet.ValuePosition getXValuePosition();
36 | PieDataSet.ValuePosition getYValuePosition();
37 |
38 | /**
39 | * When valuePosition is OutsideSlice, use slice colors as line color if true
40 | * */
41 | boolean isUsingSliceColorAsValueLineColor();
42 |
43 | /**
44 | * When valuePosition is OutsideSlice, indicates line color
45 | * */
46 | int getValueLineColor();
47 |
48 | /**
49 | * When valuePosition is OutsideSlice, indicates line width
50 | * */
51 | float getValueLineWidth();
52 |
53 | /**
54 | * When valuePosition is OutsideSlice, indicates offset as percentage out of the slice size
55 | */
56 | float getValueLinePart1OffsetPercentage();
57 |
58 | /**
59 | * When valuePosition is OutsideSlice, indicates length of first half of the line
60 | */
61 | float getValueLinePart1Length();
62 |
63 | /**
64 | * When valuePosition is OutsideSlice, indicates length of second half of the line
65 | */
66 | float getValueLinePart2Length();
67 |
68 | /**
69 | * When valuePosition is OutsideSlice, this allows variable line length
70 | */
71 | boolean isValueLineVariableLength();
72 |
73 | }
74 |
75 |
--------------------------------------------------------------------------------