|
@@ -1,8 +1,120 @@
|
|
|
package cn.muchinfo.rma.view.base.chart
|
|
package cn.muchinfo.rma.view.base.chart
|
|
|
|
|
|
|
|
|
|
+import android.content.res.Configuration
|
|
|
|
|
+import android.graphics.Color
|
|
|
|
|
+import android.os.Bundle
|
|
|
|
|
+import android.util.TypedValue
|
|
|
|
|
+import android.view.LayoutInflater
|
|
|
|
|
+import android.view.View
|
|
|
|
|
+import android.view.ViewGroup
|
|
|
|
|
+import cn.muchinfo.rma.R
|
|
|
|
|
+import cn.muchinfo.rma.global.data.chart.ChartTSData
|
|
|
import cn.muchinfo.rma.view.base.BaseFragment
|
|
import cn.muchinfo.rma.view.base.BaseFragment
|
|
|
|
|
+import com.desfate.chart.LineChart
|
|
|
|
|
|
|
|
class TimeChartFragment : BaseFragment<TimeChartViewModel>(){
|
|
class TimeChartFragment : BaseFragment<TimeChartViewModel>(){
|
|
|
|
|
|
|
|
|
|
+ private var mView: View? = null
|
|
|
|
|
+ private var lineChart: LineChart? = null
|
|
|
|
|
+
|
|
|
|
|
+ private var frontSize: Int = 20
|
|
|
|
|
+ private var chartColor : Boolean = true
|
|
|
|
|
+
|
|
|
|
|
+ override fun onCreateView(
|
|
|
|
|
+ inflater: LayoutInflater,
|
|
|
|
|
+ container: ViewGroup?,
|
|
|
|
|
+ savedInstanceState: Bundle?
|
|
|
|
|
+ ): View? {
|
|
|
|
|
+ mView = inflater.inflate(R.layout.fragment_time_chart, container, false)
|
|
|
|
|
+ lineChart = mView?.findViewById<LineChart>(R.id.mtp_otc_time_chart)
|
|
|
|
|
+ return super.onCreateView(inflater, container, savedInstanceState)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
|
|
+ super.onCreate(savedInstanceState)
|
|
|
|
|
+
|
|
|
|
|
+ lineChart?.axisXColor = Color.LTGRAY
|
|
|
|
|
+ lineChart?.axisYColor = Color.LTGRAY
|
|
|
|
|
+ lineChart?.borderColor = Color.LTGRAY
|
|
|
|
|
+ lineChart?.longitudeFontSize = frontSize
|
|
|
|
|
+ lineChart?.latitudeFontSize = frontSize
|
|
|
|
|
+ lineChart?.longitudeColor = Color.GRAY
|
|
|
|
|
+ lineChart?.longitudeFontColor = Color.GRAY
|
|
|
|
|
+ lineChart?.latitudeNum = 4
|
|
|
|
|
+ // 最大经线数
|
|
|
|
|
+ lineChart?.longitudeNum = 1
|
|
|
|
|
+ lineChart?.startIndex = 1
|
|
|
|
|
+ lineChart?.latitudeColor = Color.GRAY
|
|
|
|
|
+ lineChart?.latitudeFontColor = Color.GRAY
|
|
|
|
|
+ var typedValue = TypedValue()
|
|
|
|
|
+
|
|
|
|
|
+ if(chartColor){
|
|
|
|
|
+ lineChart?.backgroundColor = activity?.resources?.getColor(R.color.black)!!
|
|
|
|
|
+ }else {
|
|
|
|
|
+ lineChart?.backgroundColor = activity?.resources?.getColor(R.color.white)!!
|
|
|
|
|
+ }
|
|
|
|
|
+ // 设置屏幕最多显示多少条数据,如果多余这个数字将要滑动才能看见
|
|
|
|
|
+ lineChart?.maxPointNum = 1440
|
|
|
|
|
+ lineChart?.isDisplayAxisXTitle = true
|
|
|
|
|
+ lineChart?.isDisplayAxisYTitle = true
|
|
|
|
|
+ lineChart?.isDisplayLatitude = true
|
|
|
|
|
+ lineChart?.isDisplayLongitude = true
|
|
|
|
|
+ lineChart?.isDisplayCrossXOnTouch = true
|
|
|
|
|
+ lineChart?.isDisplayCrossYOnTouch = true
|
|
|
|
|
+// lineChart?.addNotify()
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ fun draw(){
|
|
|
|
|
+
|
|
|
|
|
+ // 设置分时图数据
|
|
|
|
|
+ // 设置分时图数据
|
|
|
|
|
+// setTimeData(lineChart, dataContainer)
|
|
|
|
|
+// if (isReset) {
|
|
|
|
|
+// lineChart?.notifyAxisMarginLeft = GridChart.DEFAULT_AXIS_MARGIN_LEFT
|
|
|
|
|
+// lineChart?.startIndex = -1
|
|
|
|
|
+// }
|
|
|
|
|
+// // 绘制
|
|
|
|
|
+// // 绘制
|
|
|
|
|
+// lineChart?.invalidate()
|
|
|
|
|
+//
|
|
|
|
|
+// val minuts: LineEntity = lineChart.lineData[0]
|
|
|
|
|
+// val avg10: LineEntity = lineChart.lineData[1]
|
|
|
|
|
+// if (minuts.getLineData() == null || avg10.getLineData() == null) {
|
|
|
|
|
+// return
|
|
|
|
|
+// }
|
|
|
|
|
+// val m1: Double = minuts.getLineData().get(dataContainer.mSize - 1)
|
|
|
|
|
+// val dAVG10: Double = avg10.getLineData().get(dataContainer.mSize - 1)
|
|
|
|
|
+// // 设置标题显示
|
|
|
|
|
+// // 设置标题显示
|
|
|
|
|
+// OTCChartControl.getInstance(activity).setTimeText(titleText, m1, dAVG10)
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ fun setTimeData(data : ChartTSData){
|
|
|
|
|
+// lineChart?.setMaxValue(data.historyDatas?.last().getSettlementPrice())
|
|
|
|
|
+// lineChart?.setMinValue(data.historyDatas?.first().getSettlementPrice())
|
|
|
|
|
+// lineChart?.initAxisY(
|
|
|
|
|
+// preClose + "",
|
|
|
|
|
+// lastPrice,
|
|
|
|
|
+// OTCChartControl.getInstance(activity).getDecimalPlace().toString() + ""
|
|
|
|
|
+// )
|
|
|
|
|
+// // 这句就是设置数据
|
|
|
|
|
+// // 这句就是设置数据
|
|
|
|
|
+// lineChart?.setLineData(lines)
|
|
|
|
|
+// // 不知道为啥 实际显示的数据总比这里设置的size小2个,所以这里强行补2
|
|
|
|
|
+// // 不知道为啥 实际显示的数据总比这里设置的size小2个,所以这里强行补2
|
|
|
|
|
+// if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
|
|
|
|
+// lineChart?.setDatasNum(OTCChartControl.getInstance(activity).get().mSize + 2)
|
|
|
|
|
+// } else {
|
|
|
|
|
+// // 如果是竖屏,又没啥问题
|
|
|
|
|
+// lineChart?.setDatasNum(OTCChartControl.getInstance(activity).get().mSize)
|
|
|
|
|
+// }
|
|
|
|
|
+// // +
|
|
|
|
|
+// // dataContainer.mSize
|
|
|
|
|
+// // +
|
|
|
|
|
+// // dataContainer.mSize
|
|
|
|
|
+// lineChart?.setDecimalNum(OTCChartControl.getInstance(activity).getDecimalPlace())
|
|
|
|
|
+// lineChart?.setMaxPointNum(1440)
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
}
|
|
}
|