的
@@ -0,0 +1 @@
|
||||
/build
|
||||
@@ -0,0 +1,42 @@
|
||||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlin-kapt'
|
||||
|
||||
android {
|
||||
setLibDefaultConfig(android)
|
||||
defaultConfig {
|
||||
dataBinding {
|
||||
enabled true
|
||||
}
|
||||
applicationId "cn.jingzhuan.lib.chart2.demo"
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
lintOptions {
|
||||
abortOnError false
|
||||
}
|
||||
namespace 'cn.jingzhuan.lib.chart2.demo'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||
implementation 'androidx.appcompat:appcompat:1.6.1'
|
||||
implementation 'androidx.recyclerview:recyclerview:1.3.1'
|
||||
implementation 'com.google.android.material:material:1.10.0'
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
||||
implementation 'com.airbnb.android:epoxy:5.1.3'
|
||||
implementation 'com.airbnb.android:epoxy-databinding:5.1.3'
|
||||
// Add the annotation processor if you are using Epoxy's annotations (recommended)
|
||||
kapt 'com.airbnb.android:epoxy-processor:5.1.3'
|
||||
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$ver.kotlinVersion"
|
||||
|
||||
implementation project(':chart')
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in /Users/Donglua/Library/Android/sdk/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the proguardFiles
|
||||
# directive in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the lineDataSet number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the lineDataSet number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
||||
|
||||
<application
|
||||
android:name=".App"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity
|
||||
android:name=".RangeDemoActivity"
|
||||
android:exported="false">
|
||||
<meta-data
|
||||
android:name="android.app.lib_name"
|
||||
android:value="" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".chart3.Chart3Activity"
|
||||
android:exported="false">
|
||||
<meta-data
|
||||
android:name="android.app.lib_name"
|
||||
android:value="" />
|
||||
</activity>
|
||||
<activity android:name=".MainActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -0,0 +1,15 @@
|
||||
package cn.jingzhuan.lib.chart2.demo;
|
||||
|
||||
import android.app.Application;
|
||||
|
||||
//import androidx.multidex.MultiDexApplication;
|
||||
|
||||
/**
|
||||
* Application
|
||||
* Created by donglua on 12/27/17.
|
||||
*/
|
||||
|
||||
public class App extends Application {
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package cn.jingzhuan.lib.chart2.demo;
|
||||
|
||||
import androidx.databinding.ViewDataBinding;
|
||||
import android.graphics.Color;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import cn.jingzhuan.lib.chart.data.BarDataSet;
|
||||
import cn.jingzhuan.lib.chart.data.BarValue;
|
||||
import cn.jingzhuan.lib.chart2.demo.databinding.LayoutBarChartClickableItemBinding;
|
||||
import com.airbnb.epoxy.DataBindingEpoxyModel;
|
||||
import com.airbnb.epoxy.EpoxyModelClass;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by donglua on 11/20/17.
|
||||
*/
|
||||
|
||||
@EpoxyModelClass(layout = R.layout.layout_bar_chart_clickable_item)
|
||||
public abstract class BarChartClickableModel extends DataBindingEpoxyModel {
|
||||
|
||||
private BarDataSet barDataSet;
|
||||
private List<BarValue> barValueList = new ArrayList<>();
|
||||
private List<String> labels = Arrays.asList("data1", "data2", "data3", "data4", "data5", "data6");
|
||||
|
||||
public BarChartClickableModel() {
|
||||
|
||||
barValueList.add(new BarValue(11));
|
||||
barValueList.add(new BarValue(4));
|
||||
barValueList.add(new BarValue(6));
|
||||
barValueList.add(new BarValue(13));
|
||||
barValueList.add(new BarValue(8));
|
||||
barValueList.add(new BarValue(9));
|
||||
|
||||
barDataSet = new BarDataSet(barValueList);
|
||||
barDataSet.setMaxValueOffsetPercent(0.2f);
|
||||
barDataSet.setDrawValueEnable(true);
|
||||
barDataSet.setValueTextSize(24);
|
||||
barDataSet.setAutoBarWidth(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View buildView(final ViewGroup parent) {
|
||||
View rootView = super.buildView(parent);
|
||||
|
||||
LayoutBarChartClickableItemBinding barBinding = (LayoutBarChartClickableItemBinding) rootView.getTag();
|
||||
|
||||
barBinding.barChart.setDataSet(barDataSet);
|
||||
barBinding.barChart.getAxisRight().setLabelTextColor(Color.BLACK);
|
||||
barBinding.barChart.getAxisBottom().setLabels(labels);
|
||||
barBinding.barChart.getAxisBottom().setLabelTextColor(Color.BLACK);
|
||||
|
||||
return rootView;
|
||||
}
|
||||
|
||||
@Override protected void setDataBindingVariables(ViewDataBinding binding) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package cn.jingzhuan.lib.chart2.demo
|
||||
|
||||
import androidx.databinding.ViewDataBinding
|
||||
import android.graphics.Color
|
||||
import android.graphics.Paint
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import cn.jingzhuan.lib.chart.data.BarDataSet
|
||||
import cn.jingzhuan.lib.chart.data.BarValue
|
||||
import cn.jingzhuan.lib.chart2.demo.databinding.LayoutBarChartBinding
|
||||
import com.airbnb.epoxy.DataBindingEpoxyModel
|
||||
import com.airbnb.epoxy.EpoxyModelClass
|
||||
import java.util.ArrayList
|
||||
|
||||
/**
|
||||
* Created by Donglua on 17/8/2.
|
||||
*/
|
||||
@EpoxyModelClass(layout = R.layout.layout_bar_chart)
|
||||
abstract class BarChartModel : DataBindingEpoxyModel() {
|
||||
|
||||
private val barDataSet: BarDataSet
|
||||
|
||||
init {
|
||||
|
||||
val barValueList = ArrayList<BarValue>()
|
||||
|
||||
barValueList.add(BarValue(11f))
|
||||
barValueList.add(BarValue(10f))
|
||||
barValueList.add(BarValue(11f))
|
||||
barValueList.add(BarValue(13f))
|
||||
barValueList.add(BarValue(11f))
|
||||
barValueList.add(BarValue(12f).apply { color = Color.RED })
|
||||
barValueList.add(BarValue(12f).apply { color = Color.RED })
|
||||
barValueList.add(BarValue(13f).apply { setGradientColors(Color.WHITE, Color.BLACK) })
|
||||
barValueList.add(BarValue(15f).apply { setGradientColors(Color.WHITE, Color.BLACK) })
|
||||
barValueList.add(BarValue(13f).apply {
|
||||
color = Color.RED
|
||||
paintStyle = Paint.Style.STROKE
|
||||
})
|
||||
barValueList.add(BarValue(15f).apply {
|
||||
color = Color.GREEN
|
||||
paintStyle = Paint.Style.STROKE
|
||||
})
|
||||
|
||||
barDataSet = BarDataSet(barValueList)
|
||||
barDataSet.isAutoBarWidth = true
|
||||
barDataSet.strokeThickness = 3f
|
||||
}
|
||||
|
||||
override fun buildView(parent: ViewGroup): View {
|
||||
val rootView = super.buildView(parent)
|
||||
|
||||
val barBinding = rootView.tag as LayoutBarChartBinding
|
||||
|
||||
barBinding.barChart.setDataSet(barDataSet)
|
||||
barBinding.barChart.axisRight.labelTextColor = Color.BLACK
|
||||
|
||||
return rootView
|
||||
}
|
||||
|
||||
override fun setDataBindingVariables(binding: ViewDataBinding) {
|
||||
binding as LayoutBarChartBinding
|
||||
|
||||
binding.barChart.animateY(500)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
package cn.jingzhuan.lib.chart2.demo;
|
||||
|
||||
import androidx.databinding.ViewDataBinding;
|
||||
import android.graphics.Color;
|
||||
import androidx.annotation.NonNull;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import cn.jingzhuan.lib.chart.data.CandlestickDataSet;
|
||||
import cn.jingzhuan.lib.chart.data.CandlestickValue;
|
||||
import cn.jingzhuan.lib.chart.component.Highlight;
|
||||
import cn.jingzhuan.lib.chart.data.ScatterTextDataSet;
|
||||
import cn.jingzhuan.lib.chart.data.ScatterTextValue;
|
||||
import cn.jingzhuan.lib.chart2.demo.databinding.LayoutCombineChartBinding;
|
||||
import cn.jingzhuan.lib.chart.event.HighlightStatusChangeListener;
|
||||
import com.airbnb.epoxy.DataBindingEpoxyModel;
|
||||
import com.airbnb.epoxy.EpoxyAttribute;
|
||||
import com.airbnb.epoxy.EpoxyModelClass;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.jingzhuan.lib.chart.component.AxisY.*;
|
||||
import static com.airbnb.epoxy.EpoxyAttribute.Option.DoNotHash;
|
||||
|
||||
/**
|
||||
* Created by donglua on 8/29/17.
|
||||
*/
|
||||
@EpoxyModelClass(layout = R.layout.layout_combine_chart)
|
||||
public abstract class CandlestickChartModel extends DataBindingEpoxyModel {
|
||||
|
||||
List<CandlestickValue> candlestickValues = new ArrayList<>();
|
||||
List<ScatterTextValue> scatterTextValues = new ArrayList<>();
|
||||
@EpoxyAttribute(DoNotHash) HighlightStatusChangeListener highlightStatusChangeListener;
|
||||
|
||||
public CandlestickChartModel() {
|
||||
|
||||
candlestickValues.add(new CandlestickValue(3145.27f, 3117.44f, 3123.88f, 3134.57f));
|
||||
candlestickValues.add(new CandlestickValue(3152.94f, 3131.41f, 3132.91f, 3140.85f));
|
||||
candlestickValues.add(new CandlestickValue(3155.00f, 3097.33f, 3131.35f, 3152.18f));
|
||||
candlestickValues.add(new CandlestickValue(3154.72f, 3136.58f, 3144.02f, 3154.65f));
|
||||
candlestickValues.add(new CandlestickValue(3154.78f, 3136.54f, 3147.22f, 3143.70f));
|
||||
candlestickValues.add(new CandlestickValue(3148.29f, 3123.75f, 3138.31f, 3135.35f));
|
||||
candlestickValues.add(new CandlestickValue(3143.82f, 3111.38f, 3127.11f, 3127.37f));
|
||||
candlestickValues.add(new CandlestickValue(3117.61f, 3092.09f, 3114.77f, 3103.04f));
|
||||
candlestickValues.add(new CandlestickValue(3093.44f, 3067.68f, 3090.07f, 3078.61f));
|
||||
candlestickValues.add(new CandlestickValue(3084.20f, 3056.56f, 3064.85f, 3080.53f));
|
||||
candlestickValues.add(new CandlestickValue(3090.82f, 3051.59f, 3078.16f, 3052.78f));
|
||||
candlestickValues.add(new CandlestickValue(3063.56f, 3016.53f, 3036.79f, 3061.50f));
|
||||
candlestickValues.add(new CandlestickValue(3090.48f, 3051.87f, 3054.11f, 3083.51f));
|
||||
candlestickValues.add(new CandlestickValue(3098.91f, 3085.93f, 3085.93f, 3090.22f));
|
||||
candlestickValues.add(new CandlestickValue(3113.51f, 3060.53f, 3082.87f, 3112.95f));
|
||||
candlestickValues.add(new CandlestickValue(3119.58f, 3101.30f, 3107.80f, 3104.43f));
|
||||
candlestickValues.add(new CandlestickValue(3103.43f, 3077.95f, 3082.33f, 3090.13f));
|
||||
candlestickValues.add(new CandlestickValue(3095.47f, 3081.28f, 3086.70f, 3090.62f));
|
||||
candlestickValues.add(new CandlestickValue(3103.93f, 3063.14f, 3087.16f, 3075.67f));
|
||||
candlestickValues.add(new CandlestickValue(3084.23f, 3050.84f, 3069.38f, 3061.94f));
|
||||
candlestickValues.add(new CandlestickValue(3064.81f, 3022.30f, 3047.57f, 3064.08f));
|
||||
candlestickValues.add(new CandlestickValue(3114.65f, 3052.83f, 3055.34f, 3107.83f));
|
||||
candlestickValues.add(new CandlestickValue(3120.65f, 3100.38f, 3101.29f, 3110.06f));
|
||||
candlestickValues.add(new CandlestickValue(3143.28f, 3111.56f, 3125.33f, 3117.17f));
|
||||
candlestickValues.add(new CandlestickValue(3113.52f, 3097.67f, 3108.41f, 3102.62f));
|
||||
candlestickValues.add(new CandlestickValue(3110.38f, 3081.84f, 3094.22f, 3105.54f));
|
||||
candlestickValues.add(new CandlestickValue(3105.50f, 3084.83f, 3102.11f, 3091.65f));
|
||||
candlestickValues.add(new CandlestickValue(3102.86f, 3078.79f, 3084.54f, 3102.12f));
|
||||
candlestickValues.add(new CandlestickValue(3140.77f, 3098.94f, 3101.76f, 3140.32f));
|
||||
candlestickValues.add(new CandlestickValue(3153.26f, 3132.82f, 3136.46f, 3150.33f));
|
||||
candlestickValues.add(new CandlestickValue(3165.91f, 3146.10f, 3147.45f, 3158.39f));
|
||||
candlestickValues.add(new CandlestickValue(3164.94f, 3135.31f, 3149.53f, 3139.87f));
|
||||
candlestickValues.add(new CandlestickValue(3155.98f, 3131.04f, 3134.01f, 3153.73f));
|
||||
candlestickValues.add(new CandlestickValue(3149.16f, 3125.35f, 3146.75f, 3130.66f));
|
||||
candlestickValues.add(new CandlestickValue(3137.59f, 3117.08f, 3125.59f, 3132.48f));
|
||||
candlestickValues.add(new CandlestickValue(3134.25f, 3117.85f, 3126.37f, 3123.16f));
|
||||
candlestickValues.add(new CandlestickValue(3146.77f, 3121.77f, 3122.15f, 3144.37f));
|
||||
candlestickValues.add(new CandlestickValue(3150.45f, 3134.61f, 3148.02f, 3140.01f));
|
||||
candlestickValues.add(new CandlestickValue(3157.03f, 3132.62f, 3148.98f, 3156.20f));
|
||||
candlestickValues.add(new CandlestickValue(3186.97f, 3146.63f, 3152.23f, 3147.44f));
|
||||
candlestickValues.add(new CandlestickValue(3158.05f, 3118.09f, 3138.43f, 3157.87f));
|
||||
candlestickValues.add(new CandlestickValue(3187.88f, 3156.97f, 3157.00f, 3185.43f));
|
||||
candlestickValues.add(new CandlestickValue(3193.45f, 3172.45f, 3183.41f, 3191.19f));
|
||||
candlestickValues.add(new CandlestickValue(3193.43f, 3170.78f, 3183.63f, 3173.20f));
|
||||
candlestickValues.add(new CandlestickValue(3188.77f, 3174.28f, 3174.97f, 3188.06f));
|
||||
candlestickValues.add(new CandlestickValue(3193.23f, 3171.57f, 3176.94f, 3192.42f));
|
||||
candlestickValues.add(new CandlestickValue(3196.29f, 3177.02f, 3192.00f, 3195.90f));
|
||||
candlestickValues.add(new CandlestickValue(3193.06f, 3174.31f, 3192.88f, 3182.80f));
|
||||
candlestickValues.add(new CandlestickValue(3207.31f, 3174.70f, 3179.21f, 3207.12f));
|
||||
candlestickValues.add(new CandlestickValue(3215.94f, 3188.77f, 3203.86f, 3212.43f));
|
||||
candlestickValues.add(new CandlestickValue(3219.52f, 3195.29f, 3203.82f, 3217.95f));
|
||||
candlestickValues.add(new CandlestickValue(3223.34f, 3203.20f, 3208.45f, 3212.62f));
|
||||
candlestickValues.add(new CandlestickValue(3226.90f, 3199.21f, 3201.52f, 3203.04f));
|
||||
candlestickValues.add(new CandlestickValue(3215.19f, 3177.92f, 3201.92f, 3197.54f));
|
||||
candlestickValues.add(new CandlestickValue(3219.27f, 3190.34f, 3192.36f, 3218.15f));
|
||||
candlestickValues.add(new CandlestickValue(3222.97f, 3204.85f, 3212.03f, 3222.41f));
|
||||
candlestickValues.add(new CandlestickValue(3230.35f, 3139.50f, 3219.79f, 3176.45f));
|
||||
candlestickValues.add(new CandlestickValue(3187.66f, 3150.12f, 3159.72f, 3187.57f));
|
||||
candlestickValues.add(new CandlestickValue(3232.93f, 3179.72f, 3181.39f, 3230.97f));
|
||||
candlestickValues.add(new CandlestickValue(3246.23f, 3225.42f, 3227.51f, 3244.86f));
|
||||
candlestickValues.add(new CandlestickValue(3247.70f, 3231.95f, 3236.59f, 3237.97f));
|
||||
candlestickValues.add(new CandlestickValue(3261.10f, 3230.07f, 3230.89f, 3250.60f));
|
||||
candlestickValues.add(new CandlestickValue(3261.64f, 3233.13f, 3249.13f, 3243.68f));
|
||||
candlestickValues.add(new CandlestickValue(3264.85f, 3228.04f, 3244.45f, 3247.66f));
|
||||
candlestickValues.add(new CandlestickValue(3251.92f, 3220.63f, 3243.76f, 3249.78f));
|
||||
candlestickValues.add(new CandlestickValue(3256.37f, 3232.95f, 3240.16f, 3253.23f));
|
||||
candlestickValues.add(new CandlestickValue(3276.94f, 3251.18f, 3252.75f, 3273.03f));
|
||||
candlestickValues.add(new CandlestickValue(3292.63f, 3273.50f, 3274.37f, 3292.63f));
|
||||
candlestickValues.add(new CandlestickValue(3305.42f, 3282.04f, 3288.52f, 3285.06f));
|
||||
candlestickValues.add(new CandlestickValue(3293.37f, 3262.15f, 3279.98f, 3272.92f));
|
||||
candlestickValues.add(new CandlestickValue(3287.18f, 3261.31f, 3269.32f, 3262.08f));
|
||||
candlestickValues.add(new CandlestickValue(3280.10f, 3243.71f, 3257.66f, 3279.45f));
|
||||
candlestickValues.add(new CandlestickValue(3285.47f, 3269.65f, 3277.18f, 3281.87f));
|
||||
candlestickValues.add(new CandlestickValue(3277.93f, 3263.85f, 3277.81f, 3275.57f));
|
||||
candlestickValues.add(new CandlestickValue(3282.52f, 3236.17f, 3269.72f, 3261.75f));
|
||||
candlestickValues.add(new CandlestickValue(3245.12f, 3200.75f, 3237.91f, 3208.54f));
|
||||
candlestickValues.add(new CandlestickValue(3240.05f, 3206.04f, 3206.04f, 3237.36f));
|
||||
candlestickValues.add(new CandlestickValue(3263.59f, 3235.10f, 3235.22f, 3251.26f));
|
||||
candlestickValues.add(new CandlestickValue(3248.78f, 3228.87f, 3247.85f, 3246.44f));
|
||||
candlestickValues.add(new CandlestickValue(3269.13f, 3251.45f, 3253.85f, 3268.42f));
|
||||
candlestickValues.add(new CandlestickValue(3275.08f, 3248.08f, 3253.23f, 3268.71f));
|
||||
candlestickValues.add(new CandlestickValue(3287.52f, 3270.47f, 3274.58f, 3286.90f));
|
||||
candlestickValues.add(new CandlestickValue(3293.47f, 3274.93f, 3287.61f, 3290.22f));
|
||||
candlestickValues.add(new CandlestickValue(3299.45f, 3274.43f, 3283.80f, 3287.69f));
|
||||
candlestickValues.add(new CandlestickValue(3297.98f, 3266.36f, 3287.95f, 3271.51f));
|
||||
candlestickValues.add(new CandlestickValue(3331.90f, 3271.45f, 3271.45f, 3331.52f));
|
||||
candlestickValues.add(new CandlestickValue(3375.03f, 3336.12f, 3336.12f, 3362.64f));
|
||||
candlestickValues.add(new CandlestickValue(3374.59f, 3354.45f, 3362.06f, 3365.22f));
|
||||
candlestickValues.add(new CandlestickValue(3376.64f, 3357.08f, 3361.82f, 3363.62f));
|
||||
candlestickValues.add(new CandlestickValue(3367.36f, 3341.14f, 3361.45f, 3349.57f));
|
||||
|
||||
|
||||
scatterTextValues.add(new ScatterTextValue(false,Float.NaN,0));
|
||||
scatterTextValues.add(new ScatterTextValue(false,Float.NaN,0));
|
||||
scatterTextValues.add(new ScatterTextValue(false,Float.NaN,0));
|
||||
scatterTextValues.add(new ScatterTextValue(false,Float.NaN,0));
|
||||
scatterTextValues.add(new ScatterTextValue(false,Float.NaN,0));
|
||||
scatterTextValues.add(new ScatterTextValue(false,Float.NaN,0));
|
||||
scatterTextValues.add(new ScatterTextValue(false,Float.NaN,0));
|
||||
scatterTextValues.add(new ScatterTextValue(false,Float.NaN,0));
|
||||
scatterTextValues.add(new ScatterTextValue(false,Float.NaN,0));
|
||||
scatterTextValues.add(new ScatterTextValue(true,3093.44f, 3067.68f));
|
||||
scatterTextValues.add(new ScatterTextValue(false,3084.20f, 3056.56f));
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override public View buildView(@NonNull ViewGroup parent) {
|
||||
View rootView = super.buildView(parent);
|
||||
|
||||
final LayoutCombineChartBinding b = (LayoutCombineChartBinding) rootView.getTag();
|
||||
|
||||
CandlestickDataSet dataSet = new CandlestickDataSet(candlestickValues);
|
||||
dataSet.setHighlightedVerticalEnable(true);
|
||||
dataSet.setHighlightedHorizontalEnable(true);
|
||||
|
||||
ScatterTextDataSet textDataSet = new ScatterTextDataSet(scatterTextValues);
|
||||
textDataSet.setText("加自选");
|
||||
textDataSet.setLineColor(Color.RED);
|
||||
textDataSet.setTextBgColor(Color.BLACK);
|
||||
textDataSet.setTextSize(24);
|
||||
|
||||
|
||||
b.combineChart.getAxisLeft().setAxisPosition(LEFT_OUTSIDE);
|
||||
b.combineChart.getAxisRight().setAxisPosition(RIGHT_INSIDE);
|
||||
b.combineChart.setMaxVisibleEntryCount(70);
|
||||
b.combineChart.setMinVisibleEntryCount(10);
|
||||
b.combineChart.setHighlightColor(Color.BLACK);
|
||||
//b.combineChart.setOnHighlightStatusChangeListener(highlightStatusChangeListener);
|
||||
//b.combineChart.setDataSet(new CandlestickDataSetArrowDecorator(dataSet));
|
||||
b.combineChart.addDataSet(dataSet);
|
||||
b.combineChart.addDataSet(textDataSet);
|
||||
|
||||
b.combineChart.setScaleGestureEnable(true);
|
||||
b.combineChart.setScaleXEnable(true);
|
||||
b.combineChart.setDraggingToMoveEnable(false);
|
||||
b.combineChart.setDoubleTapToZoom(true);
|
||||
b.combineChart.setHighlightDisable(false);
|
||||
b.combineChart.setDraggingToMoveEnable(true);
|
||||
b.combineChart.setOnHighlightStatusChangeListener(new HighlightStatusChangeListener() {
|
||||
@Override public void onHighlightShow(Highlight[] highlights) {
|
||||
b.combineChart.setDraggingToMoveEnable(false);
|
||||
}
|
||||
|
||||
@Override public void onHighlightHide() {
|
||||
b.combineChart.setDraggingToMoveEnable(true);
|
||||
}
|
||||
});
|
||||
b.combineChart.setOnClickListener(new View.OnClickListener() {
|
||||
@Override public void onClick(View v) {
|
||||
//b.combineChart.setHighlightDisable(false);
|
||||
//b.combineChart.setDraggingToMoveEnable(b.combineChart.isHighlightDisable());
|
||||
}
|
||||
});
|
||||
return rootView;
|
||||
}
|
||||
|
||||
@Override protected void setDataBindingVariables(ViewDataBinding binding) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
package cn.jingzhuan.lib.chart2.demo;
|
||||
|
||||
import androidx.databinding.ViewDataBinding;
|
||||
import android.graphics.Color;
|
||||
import androidx.annotation.NonNull;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.airbnb.epoxy.DataBindingEpoxyModel;
|
||||
import com.airbnb.epoxy.EpoxyAttribute;
|
||||
import com.airbnb.epoxy.EpoxyModelClass;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import cn.jingzhuan.lib.chart.component.Highlight;
|
||||
import cn.jingzhuan.lib.chart.data.CandlestickDataSet;
|
||||
import cn.jingzhuan.lib.chart.data.CandlestickValue;
|
||||
import cn.jingzhuan.lib.chart.event.HighlightStatusChangeListener;
|
||||
import cn.jingzhuan.lib.chart2.demo.databinding.LayoutCombineChartBinding;
|
||||
|
||||
import static cn.jingzhuan.lib.chart.component.AxisY.LEFT_OUTSIDE;
|
||||
import static cn.jingzhuan.lib.chart.component.AxisY.RIGHT_INSIDE;
|
||||
import static com.airbnb.epoxy.EpoxyAttribute.Option.DoNotHash;
|
||||
|
||||
/**
|
||||
* Created by donglua on 8/29/17.
|
||||
*/
|
||||
@EpoxyModelClass(layout = R.layout.layout_combine_chart)
|
||||
public abstract class CandlestickGapChartModel extends DataBindingEpoxyModel {
|
||||
|
||||
List<CandlestickValue> candlestickValues = new ArrayList<>();
|
||||
@EpoxyAttribute(DoNotHash) HighlightStatusChangeListener highlightStatusChangeListener;
|
||||
|
||||
public CandlestickGapChartModel() {
|
||||
candlestickValues.add(new CandlestickValue(21.91f, 21.4f, 21.58f, 21.9f));
|
||||
candlestickValues.add(new CandlestickValue(23.3f, 21.98f, 22.0f, 23.1f));
|
||||
candlestickValues.add(new CandlestickValue(23.92f, 23.1f, 23.1f, 23.6f));
|
||||
candlestickValues.add(new CandlestickValue(23.9f, 22.95f, 23.58f, 22.95f));
|
||||
candlestickValues.add(new CandlestickValue(23.27f, 22.56f, 23.2f, 22.98f));
|
||||
candlestickValues.add(new CandlestickValue(23.22f, 22.63f, 22.91f, 22.94f));
|
||||
candlestickValues.add(new CandlestickValue(23.42f, 22.78f, 23.08f, 23.1f));
|
||||
candlestickValues.add(new CandlestickValue(24.38f, 23.23f, 23.4f, 24.01f));
|
||||
candlestickValues.add(new CandlestickValue(24.47f, 23.86f, 24.03f, 24.11f));
|
||||
candlestickValues.add(new CandlestickValue(24.6f, 23.85f, 24.47f, 24.04f));
|
||||
candlestickValues.add(new CandlestickValue(24.39f, 23.62f, 23.75f, 23.8f));
|
||||
candlestickValues.add(new CandlestickValue(24.19f, 23.68f, 23.97f, 23.94f));
|
||||
candlestickValues.add(new CandlestickValue(24.08f, 23.56f, 23.91f, 23.58f));
|
||||
candlestickValues.add(new CandlestickValue(23.99f, 23.32f, 23.44f, 23.95f));
|
||||
candlestickValues.add(new CandlestickValue(24.22f, 23.81f, 23.96f, 24.16f));
|
||||
candlestickValues.add(new CandlestickValue(24.47f, 23.87f, 24.25f, 24.02f));
|
||||
candlestickValues.add(new CandlestickValue(24.14f, 23.68f, 24.06f, 23.68f));
|
||||
candlestickValues.add(new CandlestickValue(23.87f, 23.53f, 23.7f, 23.55f));
|
||||
candlestickValues.add(new CandlestickValue(24.2f, 23.4f, 23.59f, 24.17f));
|
||||
candlestickValues.add(new CandlestickValue(24.53f, 23.97f, 24.03f, 24.04f));
|
||||
candlestickValues.add(new CandlestickValue(24.76f, 23.65f, 23.94f, 24.73f));
|
||||
candlestickValues.add(new CandlestickValue(24.63f, 23.0f, 24.42f, 23.32f));
|
||||
candlestickValues.add(new CandlestickValue(20.99f, 20.99f, 20.99f, 20.99f));
|
||||
candlestickValues.add(new CandlestickValue(20.7f, 19.25f, 19.26f, 20.23f));
|
||||
candlestickValues.add(new CandlestickValue(20.97f, 20.2f, 20.28f, 20.47f));
|
||||
candlestickValues.add(new CandlestickValue(20.97f, 20.15f, 20.4f, 20.84f));
|
||||
candlestickValues.add(new CandlestickValue(22.39f, 20.6f, 20.65f, 22.27f));
|
||||
candlestickValues.add(new CandlestickValue(23.77f, 22.4f, 22.5f, 23.17f));
|
||||
candlestickValues.add(new CandlestickValue(23.9f, 22.44f, 23.32f, 23.0f));
|
||||
candlestickValues.add(new CandlestickValue(25.1f, 23.2f, 23.28f, 24.7f));
|
||||
candlestickValues.add(new CandlestickValue(25.22f, 24.21f, 24.61f, 24.51f));
|
||||
candlestickValues.add(new CandlestickValue(25.66f, 24.4f, 24.69f, 25.27f));
|
||||
candlestickValues.add(new CandlestickValue(27.8f, 25.44f, 25.5f, 27.8f));
|
||||
candlestickValues.add(new CandlestickValue(30.58f, 28.77f, 29.02f, 30.58f));
|
||||
candlestickValues.add(new CandlestickValue(30.9f, 29.2f, 30.9f, 29.25f));
|
||||
candlestickValues.add(new CandlestickValue(30.56f, 28.66f, 29.31f, 30.2f));
|
||||
candlestickValues.add(new CandlestickValue(32.99f, 31.01f, 31.3f, 31.8f));
|
||||
candlestickValues.add(new CandlestickValue(34.18f, 31.41f, 32.6f, 33.4f));
|
||||
}
|
||||
|
||||
@Override public View buildView(@NonNull ViewGroup parent) {
|
||||
View rootView = super.buildView(parent);
|
||||
|
||||
final LayoutCombineChartBinding b = (LayoutCombineChartBinding) rootView.getTag();
|
||||
|
||||
CandlestickDataSet dataSet = new CandlestickDataSet(candlestickValues);
|
||||
dataSet.setHighlightedVerticalEnable(true);
|
||||
dataSet.setHighlightedHorizontalEnable(true);
|
||||
dataSet.setEnableGap(true);
|
||||
|
||||
b.combineChart.getAxisLeft().setAxisPosition(LEFT_OUTSIDE);
|
||||
b.combineChart.getAxisRight().setAxisPosition(RIGHT_INSIDE);
|
||||
b.combineChart.setMaxVisibleEntryCount(70);
|
||||
b.combineChart.setMinVisibleEntryCount(10);
|
||||
b.combineChart.setHighlightColor(Color.BLACK);
|
||||
//b.combineChart.setOnHighlightStatusChangeListener(highlightStatusChangeListener);
|
||||
//b.combineChart.setDataSet(new CandlestickDataSetArrowDecorator(dataSet));
|
||||
b.combineChart.setDataSet(dataSet);
|
||||
|
||||
b.combineChart.setScaleGestureEnable(true);
|
||||
b.combineChart.setScaleXEnable(true);
|
||||
b.combineChart.setDraggingToMoveEnable(false);
|
||||
b.combineChart.setDoubleTapToZoom(true);
|
||||
b.combineChart.setHighlightDisable(false);
|
||||
b.combineChart.setDraggingToMoveEnable(true);
|
||||
b.combineChart.setOnHighlightStatusChangeListener(new HighlightStatusChangeListener() {
|
||||
@Override public void onHighlightShow(Highlight[] highlights) {
|
||||
b.combineChart.setDraggingToMoveEnable(false);
|
||||
}
|
||||
|
||||
@Override public void onHighlightHide() {
|
||||
b.combineChart.setDraggingToMoveEnable(true);
|
||||
}
|
||||
});
|
||||
return rootView;
|
||||
}
|
||||
|
||||
@Override protected void setDataBindingVariables(ViewDataBinding binding) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
package cn.jingzhuan.lib.chart2.demo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import cn.jingzhuan.lib.chart.data.CandlestickValue;
|
||||
|
||||
public class ChartDataConfig {
|
||||
|
||||
public static List<CandlestickValue> getDefaultKlineList() {
|
||||
List<CandlestickValue> list = new ArrayList<>();
|
||||
list.add(new CandlestickValue(3145.27f, 3117.44f, 3123.88f, 3134.57f, 1692322131L - 86400 * 120));
|
||||
list.add(new CandlestickValue(3152.94f, 3131.41f, 3132.91f, 3140.85f, 1692322131L - 86400 * 119));
|
||||
list.add(new CandlestickValue(3155.00f, 3097.33f, 3131.35f, 3152.18f, 1692322131L - 86400 * 118));
|
||||
list.add(new CandlestickValue(3154.72f, 3136.58f, 3144.02f, 3154.65f, 1692322131L - 86400 * 117));
|
||||
list.add(new CandlestickValue(3154.78f, 3136.54f, 3147.22f, 3143.70f, 1692322131L - 86400 * 116));
|
||||
list.add(new CandlestickValue(3148.29f, 3123.75f, 3138.31f, 3135.35f, 1692322131L - 86400 * 115));
|
||||
list.add(new CandlestickValue(3143.82f, 3111.38f, 3127.11f, 3127.37f, 1692322131L - 86400 * 114));
|
||||
list.add(new CandlestickValue(3117.61f, 3092.09f, 3114.77f, 3103.04f, 1692322131L - 86400 * 113));
|
||||
list.add(new CandlestickValue(3093.44f, 3067.68f, 3090.07f, 3078.61f, 1692322131L - 86400 * 112));
|
||||
list.add(new CandlestickValue(3084.20f, 3056.56f, 3064.85f, 3080.53f, 1692322131L - 86400 * 111));
|
||||
|
||||
list.add(new CandlestickValue(3090.82f, 3051.59f, 3078.16f, 3052.78f, 1692322131L - 86400 * 110));
|
||||
list.add(new CandlestickValue(3063.56f, 3016.53f, 3036.79f, 3061.50f, 1692322131L - 86400 * 109));
|
||||
list.add(new CandlestickValue(3090.48f, 3051.87f, 3054.11f, 3083.51f, 1692322131L - 86400 * 108));
|
||||
list.add(new CandlestickValue(3098.91f, 3085.93f, 3085.93f, 3090.22f, 1692322131L - 86400 * 107));
|
||||
list.add(new CandlestickValue(3113.51f, 3060.53f, 3082.87f, 3112.95f, 1692322131L - 86400 * 106));
|
||||
list.add(new CandlestickValue(3119.58f, 3101.30f, 3107.80f, 3104.43f, 1692322131L - 86400 * 105));
|
||||
list.add(new CandlestickValue(3103.43f, 3077.95f, 3082.33f, 3090.13f, 1692322131L - 86400 * 104));
|
||||
list.add(new CandlestickValue(3095.47f, 3081.28f, 3086.70f, 3090.62f, 1692322131L - 86400 * 103));
|
||||
list.add(new CandlestickValue(3103.93f, 3063.14f, 3087.16f, 3075.67f, 1692322131L - 86400 * 102));
|
||||
list.add(new CandlestickValue(3084.23f, 3050.84f, 3069.38f, 3061.94f, 1692322131L - 86400 * 101));
|
||||
|
||||
list.add(new CandlestickValue(3064.81f, 3022.30f, 3047.57f, 3064.08f, 1692322131L - 86400 * 100));
|
||||
list.add(new CandlestickValue(3114.65f, 3052.83f, 3055.34f, 3107.83f, 1692322131L - 86400 * 99));
|
||||
list.add(new CandlestickValue(3120.65f, 3100.38f, 3101.29f, 3110.06f, 1692322131L - 86400 * 98));
|
||||
list.add(new CandlestickValue(3143.28f, 3111.56f, 3125.33f, 3117.17f, 1692322131L - 86400 * 97));
|
||||
list.add(new CandlestickValue(3113.52f, 3097.67f, 3108.41f, 3102.62f, 1692322131L - 86400 * 96));
|
||||
list.add(new CandlestickValue(3110.38f, 3081.84f, 3094.22f, 3105.54f, 1692322131L - 86400 * 95));
|
||||
list.add(new CandlestickValue(3105.50f, 3084.83f, 3102.11f, 3091.65f, 1692322131L - 86400 * 94));
|
||||
list.add(new CandlestickValue(3102.86f, 3078.79f, 3084.54f, 3102.12f, 1692322131L - 86400 * 93));
|
||||
list.add(new CandlestickValue(3140.77f, 3098.94f, 3101.76f, 3140.32f, 1692322131L - 86400 * 92));
|
||||
list.add(new CandlestickValue(3153.26f, 3132.82f, 3136.46f, 3150.33f, 1692322131L - 86400 * 91));
|
||||
|
||||
list.add(new CandlestickValue(3165.91f, 3146.10f, 3147.45f, 3158.39f, 1692322131L - 86400 * 90));
|
||||
list.add(new CandlestickValue(3164.94f, 3135.31f, 3149.53f, 3139.87f, 1692322131L - 86400 * 89));
|
||||
list.add(new CandlestickValue(3155.98f, 3131.04f, 3134.01f, 3153.73f, 1692322131L - 86400 * 88));
|
||||
list.add(new CandlestickValue(3149.16f, 3125.35f, 3146.75f, 3130.66f, 1692322131L - 86400 * 87));
|
||||
list.add(new CandlestickValue(3137.59f, 3117.08f, 3125.59f, 3132.48f, 1692322131L - 86400 * 86));
|
||||
list.add(new CandlestickValue(3134.25f, 3117.85f, 3126.37f, 3123.16f, 1692322131L - 86400 * 85));
|
||||
list.add(new CandlestickValue(3146.77f, 3121.77f, 3122.15f, 3144.37f, 1692322131L - 86400 * 84));
|
||||
list.add(new CandlestickValue(3150.45f, 3134.61f, 3148.02f, 3140.01f, 1692322131L - 86400 * 83));
|
||||
list.add(new CandlestickValue(3157.03f, 3132.62f, 3148.98f, 3156.20f, 1692322131L - 86400 * 82));
|
||||
list.add(new CandlestickValue(3186.97f, 3146.63f, 3152.23f, 3147.44f, 1692322131L - 86400 * 81));
|
||||
|
||||
list.add(new CandlestickValue(3158.05f, 3118.09f, 3138.43f, 3157.87f, 1692322131L - 86400 * 80));
|
||||
list.add(new CandlestickValue(3187.88f, 3156.97f, 3157.00f, 3185.43f, 1692322131L - 86400 * 79));
|
||||
list.add(new CandlestickValue(3193.45f, 3172.45f, 3183.41f, 3191.19f, 1692322131L - 86400 * 78));
|
||||
list.add(new CandlestickValue(3193.43f, 3170.78f, 3183.63f, 3173.20f, 1692322131L - 86400 * 77));
|
||||
list.add(new CandlestickValue(3188.77f, 3174.28f, 3174.97f, 3188.06f, 1692322131L - 86400 * 76));
|
||||
list.add(new CandlestickValue(3193.23f, 3171.57f, 3176.94f, 3192.42f, 1692322131L - 86400 * 75));
|
||||
list.add(new CandlestickValue(3196.29f, 3177.02f, 3192.00f, 3195.90f, 1692322131L - 86400 * 74));
|
||||
list.add(new CandlestickValue(3193.06f, 3174.31f, 3192.88f, 3182.80f, 1692322131L - 86400 * 73));
|
||||
list.add(new CandlestickValue(3207.31f, 3174.70f, 3179.21f, 3207.12f, 1692322131L - 86400 * 72));
|
||||
list.add(new CandlestickValue(3215.94f, 3188.77f, 3203.86f, 3212.43f, 1692322131L - 86400 * 71));
|
||||
|
||||
list.add(new CandlestickValue(3219.52f, 3195.29f, 3203.82f, 3217.95f, 1692322131L - 86400 * 70));
|
||||
list.add(new CandlestickValue(3223.34f, 3203.20f, 3208.45f, 3212.62f, 1692322131L - 86400 * 69));
|
||||
list.add(new CandlestickValue(3226.90f, 3199.21f, 3201.52f, 3203.04f, 1692322131L - 86400 * 68));
|
||||
list.add(new CandlestickValue(3215.19f, 3177.92f, 3201.92f, 3197.54f, 1692322131L - 86400 * 67));
|
||||
list.add(new CandlestickValue(3219.27f, 3190.34f, 3192.36f, 3218.15f, 1692322131L - 86400 * 66));
|
||||
list.add(new CandlestickValue(3222.97f, 3204.85f, 3212.03f, 3222.41f, 1692322131L - 86400 * 65));
|
||||
list.add(new CandlestickValue(3230.35f, 3139.50f, 3219.79f, 3176.45f, 1692322131L - 86400 * 64));
|
||||
list.add(new CandlestickValue(3187.66f, 3150.12f, 3159.72f, 3187.57f, 1692322131L - 86400 * 63));
|
||||
list.add(new CandlestickValue(3232.93f, 3179.72f, 3181.39f, 3230.97f, 1692322131L - 86400 * 62));
|
||||
list.add(new CandlestickValue(3246.23f, 3225.42f, 3227.51f, 3244.86f, 1692322131L - 86400 * 61));
|
||||
|
||||
list.add(new CandlestickValue(3247.70f, 3231.95f, 3236.59f, 3237.97f, 1692322131L - 86400 * 60));
|
||||
list.add(new CandlestickValue(3261.10f, 3230.07f, 3230.89f, 3250.60f, 1692322131L - 86400 * 59));
|
||||
list.add(new CandlestickValue(3261.64f, 3233.13f, 3249.13f, 3243.68f, 1692322131L - 86400 * 58));
|
||||
list.add(new CandlestickValue(3264.85f, 3228.04f, 3244.45f, 3247.66f, 1692322131L - 86400 * 57));
|
||||
list.add(new CandlestickValue(3251.92f, 3220.63f, 3243.76f, 3249.78f, 1692322131L - 86400 * 56));
|
||||
list.add(new CandlestickValue(3256.37f, 3232.95f, 3240.16f, 3253.23f, 1692322131L - 86400 * 55));
|
||||
list.add(new CandlestickValue(3276.94f, 3251.18f, 3252.75f, 3273.03f, 1692322131L - 86400 * 54));
|
||||
list.add(new CandlestickValue(3292.63f, 3273.50f, 3274.37f, 3292.63f, 1692322131L - 86400 * 53));
|
||||
list.add(new CandlestickValue(3305.42f, 3282.04f, 3288.52f, 3285.06f, 1692322131L - 86400 * 52));
|
||||
list.add(new CandlestickValue(3293.37f, 3262.15f, 3279.98f, 3272.92f, 1692322131L - 86400 * 51));
|
||||
|
||||
list.add(new CandlestickValue(3287.18f, 3261.31f, 3269.32f, 3262.08f, 1692322131L - 86400 * 50));
|
||||
list.add(new CandlestickValue(3280.10f, 3243.71f, 3257.66f, 3279.45f, 1692322131L - 86400 * 49));
|
||||
list.add(new CandlestickValue(3285.47f, 3269.65f, 3277.18f, 3281.87f, 1692322131L - 86400 * 48));
|
||||
list.add(new CandlestickValue(3277.93f, 3263.85f, 3277.81f, 3275.57f, 1692322131L - 86400 * 47));
|
||||
list.add(new CandlestickValue(3282.52f, 3236.17f, 3269.72f, 3261.75f, 1692322131L - 86400 * 46));
|
||||
list.add(new CandlestickValue(3245.12f, 3200.75f, 3237.91f, 3208.54f, 1692322131L - 86400 * 45));
|
||||
list.add(new CandlestickValue(3240.05f, 3206.04f, 3206.04f, 3237.36f, 1692322131L - 86400 * 44));
|
||||
list.add(new CandlestickValue(3263.59f, 3235.10f, 3235.22f, 3251.26f, 1692322131L - 86400 * 43));
|
||||
list.add(new CandlestickValue(3248.78f, 3228.87f, 3247.85f, 3246.44f, 1692322131L - 86400 * 42));
|
||||
list.add(new CandlestickValue(3269.13f, 3251.45f, 3253.85f, 3268.42f, 1692322131L - 86400 * 41));
|
||||
|
||||
list.add(new CandlestickValue(3275.08f, 3248.08f, 3253.23f, 3268.71f, 1692322131L - 86400 * 40));
|
||||
list.add(new CandlestickValue(3287.52f, 3270.47f, 3274.58f, 3286.90f, 1692322131L - 86400 * 39));
|
||||
list.add(new CandlestickValue(3293.47f, 3274.93f, 3287.61f, 3290.22f, 1692322131L - 86400 * 38));
|
||||
list.add(new CandlestickValue(3299.45f, 3274.43f, 3283.80f, 3287.69f, 1692322131L - 86400 * 37));
|
||||
list.add(new CandlestickValue(3297.98f, 3266.36f, 3287.95f, 3271.51f, 1692322131L - 86400 * 36));
|
||||
list.add(new CandlestickValue(3331.90f, 3271.45f, 3271.45f, 3331.52f, 1692322131L - 86400 * 35));
|
||||
list.add(new CandlestickValue(3375.03f, 3336.12f, 3336.12f, 3362.64f, 1692322131L - 86400 * 34));
|
||||
list.add(new CandlestickValue(3374.59f, 3354.45f, 3362.06f, 3365.22f, 1692322131L - 86400 * 33));
|
||||
list.add(new CandlestickValue(3376.64f, 3357.08f, 3361.82f, 3363.62f, 1692322131L - 86400 * 32));
|
||||
list.add(new CandlestickValue(3367.36f, 3341.14f, 3361.45f, 3349.57f, 1692322131L - 86400 * 31));
|
||||
|
||||
list.add(new CandlestickValue(3282.52f, 3236.17f, 3269.72f, 3261.75f, 1692322131L - 86400 * 30));
|
||||
list.add(new CandlestickValue(3245.12f, 3200.75f, 3237.91f, 3208.54f, 1692322131L - 86400 * 29));
|
||||
list.add(new CandlestickValue(3240.05f, 3206.04f, 3206.04f, 3237.36f, 1692322131L - 86400 * 28));
|
||||
list.add(new CandlestickValue(3263.59f, 3235.10f, 3235.22f, 3251.26f, 1692322131L - 86400 * 27));
|
||||
list.add(new CandlestickValue(3248.78f, 3228.87f, 3247.85f, 3246.44f, 1692322131L - 86400 * 26));
|
||||
list.add(new CandlestickValue(3269.13f, 3251.45f, 3253.85f, 3268.42f, 1692322131L - 86400 * 25));
|
||||
list.add(new CandlestickValue(3275.08f, 3248.08f, 3253.23f, 3268.71f, 1692322131L - 86400 * 24));
|
||||
list.add(new CandlestickValue(3287.52f, 3270.47f, 3274.58f, 3286.90f, 1692322131L - 86400 * 23));
|
||||
list.add(new CandlestickValue(3280.10f, 3243.71f, 3257.66f, 3279.45f, 1692322131L - 86400 * 22));
|
||||
list.add(new CandlestickValue(3285.47f, 3269.65f, 3277.18f, 3281.87f, 1692322131L - 86400 * 21));
|
||||
|
||||
list.add(new CandlestickValue(3277.93f, 3263.85f, 3277.81f, 3275.57f, 1692322131L - 86400 * 20));
|
||||
list.add(new CandlestickValue(3282.52f, 3236.17f, 3269.72f, 3261.75f, 1692322131L - 86400 * 19));
|
||||
list.add(new CandlestickValue(3245.12f, 3200.75f, 3237.91f, 3208.54f, 1692322131L - 86400 * 18));
|
||||
list.add(new CandlestickValue(3240.05f, 3206.04f, 3206.04f, 3237.36f, 1692322131L - 86400 * 17));
|
||||
list.add(new CandlestickValue(3263.59f, 3235.10f, 3235.22f, 3251.26f, 1692322131L - 86400 * 16));
|
||||
list.add(new CandlestickValue(3248.78f, 3228.87f, 3247.85f, 3246.44f, 1692322131L - 86400 * 15));
|
||||
list.add(new CandlestickValue(3269.13f, 3251.45f, 3253.85f, 3268.42f, 1692322131L - 86400 * 14));
|
||||
list.add(new CandlestickValue(3261.10f, 3230.07f, 3230.89f, 3250.60f, 1692322131L - 86400 * 13));
|
||||
list.add(new CandlestickValue(3261.64f, 3233.13f, 3249.13f, 3243.68f, 1692322131L - 86400 * 12));
|
||||
list.add(new CandlestickValue(3264.85f, 3228.04f, 3244.45f, 3247.66f, 1692322131L - 86400 * 11));
|
||||
|
||||
list.add(new CandlestickValue(3251.92f, 3220.63f, 3243.76f, 3249.78f, 1692322131L - 86400 * 10));
|
||||
list.add(new CandlestickValue(3256.37f, 3232.95f, 3240.16f, 3253.23f, 1692322131L - 86400 * 9));
|
||||
list.add(new CandlestickValue(3276.94f, 3251.18f, 3252.75f, 3273.03f, 1692322131L - 86400 * 8));
|
||||
list.add(new CandlestickValue(3292.63f, 3273.50f, 3274.37f, 3292.63f, 1692322131L - 86400 * 7));
|
||||
list.add(new CandlestickValue(3305.42f, 3282.04f, 3288.52f, 3285.06f, 1692322131L - 86400 * 6));
|
||||
list.add(new CandlestickValue(3293.37f, 3262.15f, 3279.98f, 3272.92f, 1692322131L - 86400 * 5));
|
||||
list.add(new CandlestickValue(3287.18f, 3261.31f, 3269.32f, 3262.08f, 1692322131L - 86400 * 4));
|
||||
list.add(new CandlestickValue(3280.10f, 3243.71f, 3257.66f, 3279.45f, 1692322131L - 86400 * 3));
|
||||
list.add(new CandlestickValue(3285.47f, 3269.65f, 3277.18f, 3281.87f, 1692322131L - 86400 * 2));
|
||||
list.add(new CandlestickValue(3280.10f, 3243.71f, 3257.66f, 3279.45f, 1692322131L - 86400));
|
||||
list.add(new CandlestickValue(3285.47f, 3269.65f, 3277.18f, 3281.87f, 1692322131L));
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package cn.jingzhuan.lib.chart2.demo;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.viewpager.widget.PagerAdapter;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import cn.jingzhuan.lib.chart.component.Highlight;
|
||||
import cn.jingzhuan.lib.chart.event.HighlightStatusChangeListener;
|
||||
import com.airbnb.epoxy.SimpleEpoxyAdapter;
|
||||
|
||||
/**
|
||||
* Created by donglua on 9/7/17.
|
||||
*/
|
||||
|
||||
public class ChartViewPagerAdapter extends PagerAdapter {
|
||||
|
||||
private RecyclerView view1;
|
||||
private RecyclerView view2;
|
||||
private RecyclerView view3;
|
||||
|
||||
private SimpleEpoxyAdapter epoxyAdapter1;
|
||||
private SimpleEpoxyAdapter epoxyAdapter2;
|
||||
private SimpleEpoxyAdapter epoxyAdapter3;
|
||||
|
||||
@SuppressLint("InflateParams")
|
||||
ChartViewPagerAdapter(Context context) {
|
||||
LayoutInflater layoutInflater = LayoutInflater.from(context);
|
||||
view1 = (RecyclerView) layoutInflater.inflate(R.layout.activity_main, null);
|
||||
view2 = (RecyclerView) layoutInflater.inflate(R.layout.activity_main, null);
|
||||
view3 = (RecyclerView) layoutInflater.inflate(R.layout.activity_main, null);
|
||||
|
||||
final HighlightStatusChangeListener highlightStatusListener = new HighlightStatusChangeListener() {
|
||||
@Override public void onHighlightShow(Highlight[] highlights) {
|
||||
view1.getParent().requestDisallowInterceptTouchEvent(true);
|
||||
}
|
||||
|
||||
@Override public void onHighlightHide() {
|
||||
view1.getParent().requestDisallowInterceptTouchEvent(false);
|
||||
}
|
||||
};
|
||||
|
||||
epoxyAdapter1 = new SimpleEpoxyAdapter();
|
||||
epoxyAdapter1.addModels(new MinuteChartModel_().id(0).highlightStatusChangeListener(highlightStatusListener));
|
||||
|
||||
epoxyAdapter2 = new SimpleEpoxyAdapter();
|
||||
epoxyAdapter2.addModels(new CandlestickChartModel_().id(1).highlightStatusChangeListener(highlightStatusListener));
|
||||
|
||||
epoxyAdapter3 = new SimpleEpoxyAdapter();
|
||||
epoxyAdapter3.addModels(new CombineChartModel_().id(3));
|
||||
|
||||
view1.setAdapter(epoxyAdapter1);
|
||||
view2.setAdapter(epoxyAdapter2);
|
||||
view3.setAdapter(epoxyAdapter3);
|
||||
}
|
||||
|
||||
@Override public int getCount() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@NonNull @Override
|
||||
public Object instantiateItem(ViewGroup container, int position) {
|
||||
View view = null;
|
||||
switch (position) {
|
||||
case 0:
|
||||
view = view1;
|
||||
break;
|
||||
case 1:
|
||||
view = view2;
|
||||
break;
|
||||
case 2:
|
||||
view = view3;
|
||||
break;
|
||||
}
|
||||
container.addView(view);
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override public boolean isViewFromObject(View view, Object object) {
|
||||
return view == object;
|
||||
}
|
||||
|
||||
@Override public void destroyItem(ViewGroup container, int position, Object object) {
|
||||
container.removeView((View) object);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
package cn.jingzhuan.lib.chart2.demo;
|
||||
|
||||
import androidx.databinding.ViewDataBinding;
|
||||
import android.graphics.Color;
|
||||
|
||||
import android.graphics.LinearGradient;
|
||||
import android.graphics.Shader;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import cn.jingzhuan.lib.chart.component.AxisX;
|
||||
import cn.jingzhuan.lib.chart.data.BarDataSet;
|
||||
import cn.jingzhuan.lib.chart.data.BarValue;
|
||||
import cn.jingzhuan.lib.chart.data.CandlestickDataSet;
|
||||
import cn.jingzhuan.lib.chart.data.CandlestickValue;
|
||||
import cn.jingzhuan.lib.chart.data.LineDataSet;
|
||||
import cn.jingzhuan.lib.chart.data.PointValue;
|
||||
import com.airbnb.epoxy.DataBindingEpoxyModel;
|
||||
import com.airbnb.epoxy.EpoxyModelClass;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import cn.jingzhuan.lib.chart.component.AxisY;
|
||||
import cn.jingzhuan.lib.chart.data.ScatterTextDataSet;
|
||||
import cn.jingzhuan.lib.chart.data.ScatterTextValue;
|
||||
import cn.jingzhuan.lib.chart2.demo.databinding.LayoutCombineChartBinding;
|
||||
|
||||
/**
|
||||
* Created by Donglua on 17/8/3.
|
||||
*/
|
||||
@EpoxyModelClass(layout = R.layout.layout_combine_chart)
|
||||
public abstract class CombineChartModel extends DataBindingEpoxyModel {
|
||||
|
||||
private CandlestickDataSet barDataSet;
|
||||
private LineDataSet line;
|
||||
List<ScatterTextValue> scatterTextValues = new ArrayList<>();
|
||||
List<CandlestickValue> candlestickValues = new ArrayList<>();
|
||||
List<PointValue> lineValues = new ArrayList<>();
|
||||
|
||||
public CombineChartModel() {
|
||||
|
||||
List<BarValue> barValueList = new ArrayList<>();
|
||||
|
||||
barValueList.add(new BarValue(1));
|
||||
barValueList.add(new BarValue(-2));
|
||||
barValueList.add(new BarValue(0));
|
||||
barValueList.add(new BarValue(3));
|
||||
barValueList.add(new BarValue(1));
|
||||
barValueList.add(new BarValue(2));
|
||||
barValueList.add(new BarValue(2));
|
||||
barValueList.add(new BarValue(3));
|
||||
barValueList.add(new BarValue(5));
|
||||
|
||||
candlestickValues.add(new CandlestickValue(3145.27f, 3117.44f, 3123.88f, 3134.57f));
|
||||
candlestickValues.add(new CandlestickValue(3152.94f, 3131.41f, 3132.91f, 3140.85f));
|
||||
candlestickValues.add(new CandlestickValue(3155.00f, 3097.33f, 3131.35f, 3152.18f));
|
||||
candlestickValues.add(new CandlestickValue(3154.72f, 3136.58f, 3144.02f, 3154.65f));
|
||||
candlestickValues.add(new CandlestickValue(3154.78f, 3136.54f, 3147.22f, 3143.70f));
|
||||
candlestickValues.add(new CandlestickValue(3148.29f, 3123.75f, 3138.31f, 3135.35f));
|
||||
candlestickValues.add(new CandlestickValue(3143.82f, 3111.38f, 3127.11f, 3127.37f));
|
||||
candlestickValues.add(new CandlestickValue(3117.61f, 3092.09f, 3114.77f, 3103.04f));
|
||||
candlestickValues.add(new CandlestickValue(3093.44f, 3067.68f, 3090.07f, 3078.61f));
|
||||
candlestickValues.add(new CandlestickValue(3152.94f, 3131.41f, 3132.91f, 3140.85f));
|
||||
|
||||
lineValues.add(new PointValue(3117.44f));
|
||||
lineValues.add(new PointValue(3131.41f));
|
||||
lineValues.add(new PointValue(3097.33f));
|
||||
lineValues.add(new PointValue(3136.58f));
|
||||
lineValues.add(new PointValue(3136.54f));
|
||||
lineValues.add(new PointValue(3123.75f));
|
||||
lineValues.add(new PointValue(3111.38f));
|
||||
lineValues.add(new PointValue(3092.09f));
|
||||
lineValues.add(new PointValue(3067.68f));
|
||||
lineValues.add(new PointValue(3131.41f));
|
||||
|
||||
barDataSet = new CandlestickDataSet(candlestickValues, AxisY.DEPENDENCY_BOTH);
|
||||
barDataSet.setAutoWidth(true);
|
||||
barDataSet.setColor(Color.DKGRAY);
|
||||
|
||||
scatterTextValues.add(new ScatterTextValue(false,Float.NaN,0));
|
||||
scatterTextValues.add(new ScatterTextValue(false,Float.NaN,0));
|
||||
scatterTextValues.add(new ScatterTextValue(false,Float.NaN,0));
|
||||
scatterTextValues.add(new ScatterTextValue(false,Float.NaN,0));
|
||||
scatterTextValues.add(new ScatterTextValue(false,Float.NaN,0));
|
||||
scatterTextValues.add(new ScatterTextValue(false,Float.NaN,0));
|
||||
scatterTextValues.add(new ScatterTextValue(false,Float.NaN,0));
|
||||
scatterTextValues.add(new ScatterTextValue(false,Float.NaN,0));
|
||||
scatterTextValues.add(new ScatterTextValue(true,3093.44f, 5));
|
||||
scatterTextValues.add(new ScatterTextValue(true,3152f, 3131.41f));
|
||||
|
||||
|
||||
final List<Float> floats = Arrays.asList(3134.55f, 3134.62f, 3134.34f, 3133.53f, 3133.37f,
|
||||
3132.10f, 3131.55f, 3132.10f, 3133.30f, 3133.39f, 3133.02f, 3133.32f, 3132.60f,
|
||||
3132.88f, 3132.46f, 3131.71f, 3132.14f, 3132.83f, 3132.40f, 3133.32f, 3134.26f,
|
||||
3135.62f, 3136.88f, 3138.13f, 3138.51f, 3138.17f, 3138.73f, 3138.40f, 3138.65f,
|
||||
3137.40f, 3137.05f, 3136.25f, 3136.70f, 3137.04f, 3136.28f, 3136.26f, 3135.62f,
|
||||
3135.91f, 3135.85f, 3135.80f, 3136.21f, 3136.12f, 3136.41f, 3136.54f, 3136.30f,
|
||||
3136.35f, 3135.62f, 3134.05f, 3133.15f, 3132.52f, 3132.28f, 3132.98f, 3133.08f,
|
||||
3132.93f, 3133.18f, 3133.12f, 3134.12f, 3133.87f, 3133.84f, 3134.03f, 3134.16f,
|
||||
3134.62f, 3135.23f, 3135.51f, 3135.59f, 3135.79f, 3136.02f, 3135.46f, 3135.90f,
|
||||
3135.09f, 3135.05f, 3134.57f, 3135.03f, 3134.52f, 3134.82f, 3134.57f, 3134.78f,
|
||||
3135.44f, 3135.13f, 3136.28f, 3136.62f, 3137.25f, 3137.16f, 3137.62f, 3138.21f,
|
||||
3138.07f, 3138.09f, 3138.47f, 3139.63f, 3139.70f, 3140.38f, 3140.87f, 3142.22f,
|
||||
3142.80f, 3143.58f, 3142.84f, 3143.13f, 3143.77f, 3143.77f, 3146.54f, 3145.62f,
|
||||
3144.90f, 3144.80f, 3144.78f, 3144.76f, 3144.40f, 3144.15f, 3144.60f, 3145.46f,
|
||||
3146.13f, 3145.82f, 3146.05f, 3144.65f, 3144.27f, 3144.29f, 3143.62f, 3143.67f,
|
||||
3143.56f, 3142.93f, 3142.19f, 3142.72f, 3142.29f, 3142.39f, 3141.31f, 3141.92f,
|
||||
3142.13f, 3141.65f, 3141.60f, 3140.42f, 3139.55f, 3139.94f, 3140.05f, 3139.12f,
|
||||
3139.35f, 3138.90f, 3139.02f, 3138.87f, 3138.83f, 3138.53f, 3139.31f, 3139.36f,
|
||||
3138.91f, 3139.06f, 3139.13f, 3139.52f, 3139.57f, 3138.82f, 3138.17f, 3138.5f,
|
||||
3137.95f, 3138.55f, 3137.82f, 3138.25f, 3137.59f, 3137.75f, 3137.96f, 3138.37f,
|
||||
3137.82f, 3138.22f, 3138.17f, 3137.31f, 3137.96f, 3137.22f, 3137.82f, 3137.19f,
|
||||
3137.78f, 3137.93f, 3138.65f, 3138.70f, 3140.12f, 3140.35f, 3140.28f, 3140.46f,
|
||||
3140.22f, 3140.06f, 3138.75f, 3139.31f, 3138.73f, 3137.54f, 3137.13f, 3136.23f,
|
||||
3136.20f, 3136.53f, 3135.56f, 3135.71f, 3135.68f, 3135.89f, 3136.31f, 3135.81f,
|
||||
3135.82f, 3135.5f, 3136.18f, 3138.01f, 3137.89f, 3138.09f, 3138.21f, 3138.52f,
|
||||
3138.70f, 3138.55f, 3138.02f, 3137.73f, 3137.36f, 3137.59f, 3137.45f, 3137.89f,
|
||||
3138.29f, 3138.63f, 3138.54f, 3139.09f, 3140.09f, 3140.89f, 3141.19f, 3141.57f,
|
||||
3141.92f, 3142.10f, 3142.44f, 3143.38f, 3143.96f, 3144.77f, 3144.37f, 3148.02f,
|
||||
3149.62f, 3149.79f, 3149.5f, 3148.58f, 3148.39f, 3148.43f, 3148.5f, 3148.12f,
|
||||
3146.07f, 3144.87f, 3145.0f, 3144.67f, 3142.95f, 3143.63f, 3143.5f, 3144.13f,
|
||||
3145.08f, 3145.06f, 3144.96f, 3143.86f);
|
||||
|
||||
List<PointValue> values = new ArrayList<>();
|
||||
for (Float value: floats) {
|
||||
values.add(new PointValue(value));
|
||||
}
|
||||
line = new LineDataSet(values, AxisY.DEPENDENCY_LEFT);
|
||||
line.setHighlightedVerticalEnable(true);
|
||||
}
|
||||
|
||||
@Override public View buildView(ViewGroup parent) {
|
||||
View rootView = super.buildView(parent);
|
||||
|
||||
LayoutCombineChartBinding chartBinding = (LayoutCombineChartBinding) rootView.getTag();
|
||||
|
||||
chartBinding.combineChart.enableHighlightDashPathEffect(new float[] {10, 10}, 10);
|
||||
chartBinding.combineChart.addDataSet(barDataSet);
|
||||
chartBinding.combineChart.addDataSet(line);
|
||||
|
||||
LineDataSet lineDataSet = new LineDataSet(lineValues);
|
||||
lineDataSet.setColor(Color.YELLOW);
|
||||
lineDataSet.setShader(new LinearGradient(0f, 0f, 0f, 0f, 0x20ffaa00, 0x20ffaa00, Shader.TileMode.MIRROR));
|
||||
chartBinding.combineChart.addDataSet(lineDataSet);
|
||||
|
||||
ScatterTextDataSet textDataSet = new ScatterTextDataSet(scatterTextValues);
|
||||
textDataSet.setText("加自选");
|
||||
textDataSet.setLineColor(Color.RED);
|
||||
textDataSet.setTextBgColor(Color.BLACK);
|
||||
textDataSet.setTextSize(40);
|
||||
|
||||
chartBinding.combineChart.setMinVisibleEntryCount(10);
|
||||
chartBinding.combineChart.addDataSet(textDataSet);
|
||||
|
||||
return rootView;
|
||||
}
|
||||
|
||||
@Override protected void setDataBindingVariables(ViewDataBinding binding) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package cn.jingzhuan.lib.chart2.demo;
|
||||
|
||||
import static com.airbnb.epoxy.EpoxyAttribute.Option.DoNotHash;
|
||||
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.databinding.ViewDataBinding;
|
||||
|
||||
import com.airbnb.epoxy.DataBindingEpoxyModel;
|
||||
import com.airbnb.epoxy.EpoxyAttribute;
|
||||
import com.airbnb.epoxy.EpoxyModelClass;
|
||||
import cn.jingzhuan.lib.chart2.demo.databinding.LayoutCommonButtonBinding;
|
||||
|
||||
|
||||
@EpoxyModelClass(layout = R.layout.layout_common_button)
|
||||
public abstract class CommonButtonModel extends DataBindingEpoxyModel {
|
||||
@EpoxyAttribute(DoNotHash)
|
||||
View.OnClickListener onClickListener = null;
|
||||
|
||||
@EpoxyAttribute
|
||||
String buttonText = "";
|
||||
|
||||
public CommonButtonModel() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public View buildView(@NonNull ViewGroup parent) {
|
||||
View rootView = super.buildView(parent);
|
||||
|
||||
final LayoutCommonButtonBinding binding = (LayoutCommonButtonBinding) rootView.getTag();
|
||||
|
||||
binding.btnText.setOnClickListener(v -> onClickListener.onClick(v));
|
||||
|
||||
binding.btnText.setText(buttonText);
|
||||
return rootView;
|
||||
}
|
||||
|
||||
@Override protected void setDataBindingVariables(ViewDataBinding binding) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package cn.jingzhuan.lib.chart2.demo;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.airbnb.epoxy.AutoModel;
|
||||
import com.airbnb.epoxy.EpoxyController;
|
||||
|
||||
import cn.jingzhuan.lib.chart2.demo.chart3.Chart3Activity;
|
||||
|
||||
/**
|
||||
* Created by Donglua on 17/7/26.
|
||||
*/
|
||||
|
||||
public class DemoAdapterController extends EpoxyController {
|
||||
|
||||
@AutoModel LineChartModel_ lineChartModel;
|
||||
@AutoModel MinuteChartModel_ minuteChartModel;
|
||||
@AutoModel BarChartModel_ barChartModel_;
|
||||
@AutoModel BarChartClickableModel_ barChartClickableModel_;
|
||||
@AutoModel CombineChartModel_ combineChartModel_;
|
||||
@AutoModel CandlestickChartModel_ candlestickChartModel_;
|
||||
@AutoModel ViewPagerModel_ viewPagerModel_;
|
||||
@AutoModel ScatterChartModel_ scatterChartModel_;
|
||||
@AutoModel ScatterChart2Model_ scatterChart2Model_;
|
||||
@AutoModel
|
||||
CommonButtonModel_ rangeChartModel_;
|
||||
|
||||
@AutoModel
|
||||
CommonButtonModel_ chart3Model_;
|
||||
|
||||
private final Context context;
|
||||
|
||||
public DemoAdapterController(Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void buildModels() {
|
||||
|
||||
rangeChartModel_.onClickListener(v ->
|
||||
v.getContext().startActivity(new Intent(v.getContext(), RangeDemoActivity.class))
|
||||
);
|
||||
rangeChartModel_.buttonText("区间统计");
|
||||
rangeChartModel_.addTo(this);
|
||||
|
||||
chart3Model_.onClickListener(v ->
|
||||
v.getContext().startActivity(new Intent(v.getContext(), Chart3Activity.class))
|
||||
);
|
||||
chart3Model_.buttonText("chart3");
|
||||
chart3Model_.addTo(this);
|
||||
|
||||
new LayoutDescTextBindingModel_().id("LineDataSet").text("LineDataSet Chart").addTo(this);
|
||||
lineChartModel.addTo(this);
|
||||
|
||||
new LayoutDescTextBindingModel_().id("Minute").text("Minute Chart").addTo(this);
|
||||
minuteChartModel.onClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Toast.makeText(v.getContext(), "Click", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}).addTo(this);
|
||||
|
||||
new LayoutDescTextBindingModel_().id("Bar").text("Bar Chart").addTo(this);
|
||||
barChartModel_.addTo(this);
|
||||
barChartClickableModel_.addTo(this);
|
||||
|
||||
new LayoutDescTextBindingModel_().id("Combine").text("Combine Chart").addTo(this);
|
||||
combineChartModel_.addTo(this);
|
||||
|
||||
new LayoutDescTextBindingModel_().id("Candlestick").text("Candlestick Chart").addTo(this);
|
||||
candlestickChartModel_.addTo(this);
|
||||
|
||||
new LayoutDescTextBindingModel_().id("View Pager").text("ViewPager").addTo(this);
|
||||
viewPagerModel_.pagerAdapter(new ChartViewPagerAdapter(context)).addTo(this);
|
||||
|
||||
new LayoutDescTextBindingModel_().id("Scatter Chart").text("Scatter Chart").addTo(this);
|
||||
scatterChartModel_.addTo(this);
|
||||
scatterChart2Model_.addTo(this);
|
||||
|
||||
new LayoutDescTextBindingModel_().id("CandlestickGap").text("缺口").addTo(this);
|
||||
new CandlestickGapChartModel_().id("CandlestickGapChartModel_").addTo(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package cn.jingzhuan.lib.chart2.demo;
|
||||
|
||||
import androidx.databinding.ViewDataBinding;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import android.graphics.Color;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import cn.jingzhuan.lib.chart.data.LineDataSet;
|
||||
import cn.jingzhuan.lib.chart.data.PointValue;
|
||||
import cn.jingzhuan.lib.chart.Viewport;;
|
||||
import com.airbnb.epoxy.DataBindingEpoxyModel;
|
||||
import com.airbnb.epoxy.EpoxyModelClass;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import cn.jingzhuan.lib.chart2.demo.databinding.LayoutLineChartBinding;
|
||||
|
||||
import static cn.jingzhuan.lib.chart.Viewport.*;
|
||||
|
||||
/**
|
||||
* Created by Donglua on 17/7/26.
|
||||
*/
|
||||
@EpoxyModelClass(layout = R.layout.layout_line_chart)
|
||||
public abstract class LineChartModel extends DataBindingEpoxyModel {
|
||||
|
||||
private LineDataSet line;
|
||||
private LineDataSet line2;
|
||||
|
||||
public LineChartModel() {
|
||||
|
||||
final List<Float> floats = Arrays.asList(3134.55f, 3134.62f, 3134.34f, 3133.53f, 3133.37f,
|
||||
3132.10f, 3131.55f, 3132.10f, 3133.30f, 3133.39f, 3133.02f, 3133.32f, 3132.60f,
|
||||
3132.88f, 3132.46f, 3131.71f, 3132.14f, 3132.83f, 3132.40f, 3133.32f, 3134.26f,
|
||||
3135.62f, 3136.88f, 3138.13f, 3138.51f, 3138.17f, 3138.73f, 3138.40f, 3138.65f,
|
||||
3137.40f, 3137.05f, 3136.25f, 3136.70f, 3137.04f, 3136.28f, 3136.26f, 3135.62f,
|
||||
3135.91f, 3135.85f, 3135.80f, 3136.21f, 3136.12f, 3136.41f, 3136.54f, 3136.30f,
|
||||
3136.35f, 3135.62f, 3134.05f, 3133.15f, 3132.52f, 3132.28f, 3132.98f, 3133.08f,
|
||||
3132.93f, 3133.18f, 3133.12f, 3134.12f, 3133.87f, 3133.84f, 3134.03f, 3134.16f,
|
||||
3134.62f, 3135.23f, 3135.51f, 3135.59f, 3135.79f, 3136.02f, 3135.46f, 3135.90f,
|
||||
3135.09f, 3135.05f, 3134.57f, 3135.03f, 3134.52f, 3134.82f, 3134.57f, 3134.78f,
|
||||
3135.44f, 3135.13f, 3136.28f, 3136.62f, 3137.25f, 3137.16f, 3137.62f, 3138.21f,
|
||||
3138.07f, 3138.09f, 3138.47f, 3139.63f, 3139.70f, 3140.38f, 3140.87f, 3142.22f,
|
||||
3142.80f, 3143.58f, 3142.84f, 3143.13f, 3143.77f, 3143.77f, 3146.54f, 3145.62f,
|
||||
3144.90f, 3144.80f, 3144.78f, 3144.76f, 3144.40f, 3144.15f, 3144.60f, 3145.46f,
|
||||
3146.13f, 3145.82f, 3146.05f, 3144.65f, 3144.27f, 3144.29f, 3143.62f, 3143.67f,
|
||||
3143.56f, 3142.93f, 3142.19f, 3142.72f, 3142.29f, 3142.39f, 3141.31f, 3141.92f,
|
||||
3142.13f, 3141.65f, 3141.60f, 3140.42f, 3139.55f, 3139.94f, 3140.05f, 3139.12f,
|
||||
3139.35f, 3138.90f, 3139.02f, 3138.87f, 3138.83f, 3138.53f, 3139.31f, 3139.36f,
|
||||
3138.91f, 3139.06f, 3139.13f, 3139.52f, 3139.57f, 3138.82f, 3138.17f, 3138.5f,
|
||||
3137.95f, 3138.55f, 3137.82f, 3138.25f, 3137.59f, 3137.75f, 3137.96f, 3138.37f,
|
||||
3137.82f, 3138.22f, 3138.17f, 3137.31f, 3137.96f, 3137.22f, 3137.82f, 3137.19f,
|
||||
3137.78f, 3137.93f, 3138.65f, 3138.70f, 3140.12f, 3140.35f, 3140.28f, 3140.46f,
|
||||
3140.22f, 3140.06f, 3138.75f, 3139.31f, 3138.73f, 3137.54f, 3137.13f, 3136.23f,
|
||||
3136.20f, 3136.53f, 3135.56f, 3135.71f, 3135.68f, 3135.89f, 3136.31f, 3135.81f,
|
||||
3135.82f, 3135.5f, 3136.18f, 3138.01f, 3137.89f, 3138.09f, 3138.21f, 3138.52f,
|
||||
3138.70f, 3138.55f, 3138.02f, 3137.73f, 3137.36f, 3137.59f, 3137.45f, 3137.89f,
|
||||
3138.29f, 3138.63f, 3138.54f, 3139.09f, 3140.09f, 3140.89f, 3141.19f, 3141.57f,
|
||||
3141.92f, 3142.10f, 3142.44f, 3143.38f, 3143.96f, 3144.77f, 3144.37f, 3148.02f,
|
||||
3149.62f, 3149.79f, 3149.5f, 3148.58f, 3148.39f, 3148.43f, 3148.5f, 3148.12f,
|
||||
3146.07f, 3144.87f, 3145.0f, 3144.67f, 3142.95f, 3143.63f, 3143.5f, 3144.13f,
|
||||
3145.08f, 3145.06f, 3144.96f, 3143.86f);
|
||||
|
||||
List<PointValue> values = new ArrayList<>();
|
||||
for (Float value: floats) {
|
||||
values.add(new PointValue(value));
|
||||
}
|
||||
|
||||
|
||||
line = new LineDataSet(values);
|
||||
// line.setOffsetPercent(0.1f);
|
||||
line.setLineThickness(3);
|
||||
line.setColor(Color.RED);
|
||||
line2 = new LineDataSet(values);
|
||||
line2.setHorizontalLine(true);
|
||||
line2.setTag("MA5");
|
||||
line2.setColor(Color.RED);
|
||||
}
|
||||
|
||||
@Override public View buildView(@NonNull ViewGroup parent) {
|
||||
View rootView = super.buildView(parent);
|
||||
|
||||
final LayoutLineChartBinding bd = (LayoutLineChartBinding) rootView.getTag();
|
||||
bd.lineChart.setCurrentViewport(new Viewport(0.5f, AXIS_Y_MIN, AXIS_X_MAX, AXIS_Y_MAX));
|
||||
bd.lineChart.setDoubleTapToZoom(true);
|
||||
bd.lineChart.addLine(line);
|
||||
bd.lineChart.addLine(line2);
|
||||
|
||||
|
||||
bd.btMoveLeft.setOnClickListener(new View.OnClickListener() {
|
||||
@Override public void onClick(View v) {
|
||||
bd.lineChart.moveLeft();
|
||||
}
|
||||
});
|
||||
bd.btMoveRight.setOnClickListener(new View.OnClickListener() {
|
||||
@Override public void onClick(View v) {
|
||||
bd.lineChart.moveRight();
|
||||
}
|
||||
});
|
||||
|
||||
return rootView;
|
||||
}
|
||||
|
||||
@Override protected void setDataBindingVariables(ViewDataBinding binding) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package cn.jingzhuan.lib.chart2.demo;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
DemoAdapterController controller = new DemoAdapterController(this);
|
||||
|
||||
RecyclerView recyclerView = findViewById(R.id.recyclerView);
|
||||
|
||||
recyclerView.setAdapter(controller.getAdapter());
|
||||
|
||||
controller.requestModelBuild();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
package cn.jingzhuan.lib.chart2.demo;
|
||||
|
||||
import androidx.databinding.ViewDataBinding;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.LinearGradient;
|
||||
import android.graphics.Shader;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import cn.jingzhuan.lib.chart.data.MinuteLine;
|
||||
import cn.jingzhuan.lib.chart.data.PointValue;
|
||||
import cn.jingzhuan.lib.chart.data.ValueFormatter;
|
||||
import cn.jingzhuan.lib.chart2.demo.databinding.LayoutMinuteChartBinding;
|
||||
import cn.jingzhuan.lib.chart.event.HighlightStatusChangeListener;
|
||||
import com.airbnb.epoxy.DataBindingEpoxyModel;
|
||||
import com.airbnb.epoxy.EpoxyAttribute;
|
||||
import com.airbnb.epoxy.EpoxyModelClass;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import static com.airbnb.epoxy.EpoxyAttribute.Option.DoNotHash;
|
||||
|
||||
/**
|
||||
* Created by Donglua on 17/7/26.
|
||||
*/
|
||||
|
||||
@EpoxyModelClass(layout = R.layout.layout_minute_chart)
|
||||
public abstract class MinuteChartModel extends DataBindingEpoxyModel {
|
||||
|
||||
private final MinuteLine line;
|
||||
private final float lastClose = 11.27f;
|
||||
|
||||
@EpoxyAttribute(DoNotHash) View.OnClickListener onClickListener;
|
||||
@EpoxyAttribute(DoNotHash) HighlightStatusChangeListener highlightStatusChangeListener;
|
||||
|
||||
public MinuteChartModel() {
|
||||
|
||||
final List<Float> floats =
|
||||
Arrays.asList(11.17449f, 11.15434f, 11.16595f, 11.18753f, 11.25440f, 11.27073f,
|
||||
11.27655f, 11.28625f, 11.28847f, 11.29051f, 11.29548f, 11.29861f, 11.31060f,
|
||||
11.3284f, 11.37816f, 11.55310f, 11.630815f, 11.67925f, 11.69136f, 11.70062f,
|
||||
11.71826f, 11.7231f, 11.72815f, 11.73347f, 11.73745f, 11.73951f, 11.74206f,
|
||||
11.74301f, 11.74439f, 11.748f, 11.75036f, 11.75095f, 11.75179f, 11.75248f,
|
||||
11.75364f, 11.75408f, 11.75480f, 11.75523f, 11.75574f, 11.75635f, 11.75658f,
|
||||
11.75653f, 11.75634f, 11.75630f, 11.75648f, 11.75646f, 11.75623f, 11.75595f,
|
||||
11.75535f, 11.75532f, 11.75566f, 11.75635f, 11.7568f, 11.75707f, 11.75712f,
|
||||
11.75716f, 11.75725f, 11.75740f, 11.75747f, 11.75758f, 11.75761f, 11.75753f,
|
||||
11.75761f, 11.75843f, 11.75917f, 11.75963f, 11.75987f, 11.76059f, 11.76152f,
|
||||
11.76369f, 11.76426f, 11.76446f, 11.76476f, 11.76524f, 11.76556f, 11.76582f,
|
||||
11.76620f, 11.76672f, 11.76706f, 11.76722f, 11.76734f, 11.76747f, 11.76757f,
|
||||
11.76773f, 11.76784f, 11.76798f, 11.768167f, 11.76890f, 11.77048f, 11.77456f,
|
||||
11.77975f, 11.78389f, 11.78564f, 11.78687f, 11.78745f, 11.78922f, 11.79016f,
|
||||
11.79115f, 11.7921f, 11.79493f, 11.79727f, 11.80075f, 11.80353f, 11.80501f,
|
||||
11.80609f, 11.80723f, 11.80804f, 11.808804f, 11.80939f, 11.80992f, 11.81042f,
|
||||
11.810842f, 11.81131f, 11.81160f, 11.81220f, 11.81263f, 11.81307f, 11.81345f,
|
||||
11.81370f, 11.81391f, 11.81391f, 11.81438f, 11.815f, 11.8159f, 11.81694f, 11.81789f,
|
||||
11.81858f, 11.81979f, 11.82164f, 11.83589f, 11.85183f, 11.86026f, 11.86534f,
|
||||
11.869019f, 11.8747f, 11.87665f, 11.87817f, 11.879498f, 11.88067f, 11.88169f,
|
||||
11.88243f, 11.88314f, 11.88457f, 11.88600f, 11.88785f, 11.89003f, 11.89152f,
|
||||
11.89222f, 11.89326f, 11.89778f, 11.89976f, 11.90208f, 11.90356f, 11.90446f,
|
||||
11.905189f, 11.90743f, 11.91124f, 11.91410f, 11.91525f, 11.91636f, 11.919332f,
|
||||
11.9204f, 11.93025f, 11.97543f, 11.98504f, 11.98811f, 11.9973f, 11.99822f,
|
||||
11.99884f, 11.99967f, 12.01106f, 12.01314f, 12.01556f, 12.01905f, 12.02244f,
|
||||
12.02431f, 12.02863f, 12.03055f, 12.03342f, 12.03391f, 12.03451f, 12.03473f,
|
||||
12.03511f, 12.03528f, 12.035439f, 12.03549f, 12.0356f, 12.03586f, 12.03604f,
|
||||
12.03629f, 12.03680f, 12.03695f, 12.03699f, 12.03723f, 12.03739f, 12.03746f,
|
||||
12.03752f, 12.037683f, 12.03771f, 12.03792f, 12.03796f, 12.03856f, 12.03860f,
|
||||
12.03868f, 12.038836f, 12.03899f, 12.03905f, 12.03908f, 12.03914f, 12.03921f,
|
||||
12.03924f, 12.03937f, 12.03948f, 12.03954f, 12.03958f, 12.03964f, 12.03966f,
|
||||
12.0397f, 12.03979f, 12.03985f, 12.03988f, 12.03995f, 12.04000f, 12.04021f,
|
||||
12.04030f, 12.04048f, 12.04051f, 12.040565f, 12.04060f, 12.04163f, 12.04201f,
|
||||
12.04210f, 12.04233f, 12.04259f, 12.04264f, 12.04272f, 12.04276f, 12.04279f,
|
||||
12.04279f, 12.04307f);
|
||||
|
||||
List<PointValue> values = new ArrayList<>();
|
||||
for (Float value: floats) {
|
||||
values.add(new PointValue(value));
|
||||
}
|
||||
|
||||
line = new MinuteLine(values);
|
||||
line.setHighlightedVerticalEnable(true);
|
||||
line.setHighlightedHorizontalEnable(true);
|
||||
line.setLastClose(lastClose);
|
||||
}
|
||||
|
||||
@Override public View buildView(ViewGroup parent) {
|
||||
View rootView = super.buildView(parent);
|
||||
|
||||
final LayoutMinuteChartBinding minuteBinding = (LayoutMinuteChartBinding) rootView.getTag();
|
||||
|
||||
minuteBinding.minuteChart.getAxisLeft().enableGridDashPathEffect(new float[] {10, 10}, 10);
|
||||
minuteBinding.minuteChart.getAxisTop().enableGridDashPathEffect(new float[] {10, 10}, 10);
|
||||
minuteBinding.minuteChart.getAxisTop().setGridLineEnable(true);
|
||||
|
||||
minuteBinding.minuteChart.getAxisRight().setLabelValueFormatter(new ValueFormatter() {
|
||||
@Override
|
||||
public String format(float value, int index) {
|
||||
return String.format(Locale.ENGLISH, "%.2f%%",
|
||||
(value - lastClose) / lastClose * 100);
|
||||
}
|
||||
});
|
||||
|
||||
minuteBinding.minuteChart.getAxisBottom().setGridCount(1);
|
||||
minuteBinding.minuteChart.getAxisTop().setGridCount(3);
|
||||
minuteBinding.minuteChart.getAxisRight().setGridCount(1);
|
||||
|
||||
minuteBinding.minuteChart.getAxisBottom().setLabelValueFormatter(new ValueFormatter() {
|
||||
@Override
|
||||
public String format(float value, int index) {
|
||||
if (index == 0) {
|
||||
return "9:30";
|
||||
}
|
||||
if (index == 1) {
|
||||
return "11:30/13:00";
|
||||
}
|
||||
if (index == 2) {
|
||||
return "15:00";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
});
|
||||
|
||||
minuteBinding.minuteChart.setOnHighlightStatusChangeListener(highlightStatusChangeListener);
|
||||
|
||||
minuteBinding.minuteChart.setHighlightColor(Color.BLACK);
|
||||
|
||||
minuteBinding.minuteChart.setScaleXEnable(false);
|
||||
|
||||
line.setShader(new LinearGradient(0, 0, 0, 0, 0x10000000, 0x10000000, Shader.TileMode.REPEAT));
|
||||
|
||||
minuteBinding.minuteChart.addLine(line);
|
||||
|
||||
minuteBinding.minuteChart.setOnClickListener(new View.OnClickListener() {
|
||||
@Override public void onClick(View v) {
|
||||
|
||||
minuteBinding.minuteChart.animateX(1000);
|
||||
|
||||
if (onClickListener != null) {
|
||||
onClickListener.onClick(v);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
minuteBinding.minuteChart.enableHighlightDashPathEffect(new float[] {10, 10}, 10);
|
||||
|
||||
return rootView;
|
||||
}
|
||||
|
||||
@Override protected void setDataBindingVariables(ViewDataBinding binding) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,424 @@
|
||||
package cn.jingzhuan.lib.chart2.demo
|
||||
|
||||
import android.graphics.Paint
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.appcompat.widget.AppCompatButton
|
||||
import cn.jingzhuan.lib.chart.Viewport
|
||||
import cn.jingzhuan.lib.chart.component.AxisY
|
||||
import cn.jingzhuan.lib.chart.component.Highlight
|
||||
import cn.jingzhuan.lib.chart.data.CandlestickDataSet
|
||||
import cn.jingzhuan.lib.chart.data.CandlestickValue
|
||||
import cn.jingzhuan.lib.chart.data.CombineData
|
||||
import cn.jingzhuan.lib.chart.data.ScatterTextDataSet
|
||||
import cn.jingzhuan.lib.chart.data.ScatterTextValue
|
||||
import cn.jingzhuan.lib.chart.event.HighlightStatusChangeListener
|
||||
import cn.jingzhuan.lib.chart.event.OnScaleListener
|
||||
import cn.jingzhuan.lib.chart.renderer.CandlestickDataSetArrowDecorator
|
||||
import cn.jingzhuan.lib.chart.utils.ForceAlign
|
||||
import cn.jingzhuan.lib.chart3.formatter.DateTimeFormatter
|
||||
import cn.jingzhuan.lib.chart3.formatter.DateTimeFormatter.formatTime
|
||||
import java.text.SimpleDateFormat
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
import kotlin.math.round
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
class RangeDemoActivity : AppCompatActivity() {
|
||||
|
||||
private var candlestickValues: MutableList<CandlestickValue> = ArrayList()
|
||||
|
||||
private lateinit var llRangeInfo: LinearLayout
|
||||
|
||||
private lateinit var tvCloseRange: TextView
|
||||
|
||||
private lateinit var tvInfo: TextView
|
||||
|
||||
private lateinit var tvOpen: TextView
|
||||
|
||||
private lateinit var tvNumber: TextView
|
||||
|
||||
private lateinit var combineChart: TestChartKLineView
|
||||
|
||||
private lateinit var btnRange: AppCompatButton
|
||||
|
||||
private lateinit var btnAddTag: AppCompatButton
|
||||
|
||||
private lateinit var btnScaleIn: AppCompatButton
|
||||
|
||||
private lateinit var btnScaleOut: AppCompatButton
|
||||
|
||||
private lateinit var btnHighlightAlways: AppCompatButton
|
||||
|
||||
private lateinit var btnMoveLeft: AppCompatButton
|
||||
|
||||
private lateinit var btnMoveRight: AppCompatButton
|
||||
|
||||
private lateinit var btnTouchPoint: AppCompatButton
|
||||
|
||||
private val lastClose = 3388.98f
|
||||
|
||||
private var leftTime = ""
|
||||
|
||||
private var rightTime = ""
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_range_demo)
|
||||
|
||||
initView()
|
||||
|
||||
initListener()
|
||||
|
||||
setChartData()
|
||||
|
||||
// val dataSet2 = CandlestickDataSet(candlestickValues)
|
||||
// dataSet.isHighlightedHorizontalEnable = true
|
||||
// dataSet.isHighlightedVerticalEnable = true
|
||||
// dataSet.color = 0xFFFD263F.toInt()
|
||||
// dataSet.increasingPaintStyle = Paint.Style.FILL_AND_STROKE
|
||||
// dataSet.strokeThickness = 2f
|
||||
// dataSet.decreasingColor = 0xFF00AA3B.toInt()
|
||||
// dataSet.increasingColor = 0xFFFD263F.toInt()
|
||||
// combineChart.addDataSet(dataSet2)
|
||||
|
||||
combineChart.onHighlightStatusChangeListener =
|
||||
object : HighlightStatusChangeListener {
|
||||
override fun onHighlightShow(highlights: Array<out Highlight>?) {
|
||||
llRangeInfo.visibility = View.VISIBLE
|
||||
if (!highlights.isNullOrEmpty()) {
|
||||
val data = candlestickValues[highlights[0].dataIndex]
|
||||
tvInfo.text = "开:${data.open} 高:${data.high} 收:${data.close} 低:${data.low}"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onHighlightHide() {
|
||||
llRangeInfo.visibility = View.INVISIBLE
|
||||
}
|
||||
}
|
||||
|
||||
combineChart.renderer.rangeRenderer.setOnRangeListener{ startX, endX, _ ->
|
||||
val startIndex = combineChart.renderer.rangeRenderer.getEntryIndexByCoordinate(startX, 0f)
|
||||
val endIndex = combineChart.renderer.rangeRenderer.getEntryIndexByCoordinate(endX, 0f)
|
||||
tvNumber.text = "周期数:${endIndex - startIndex}"
|
||||
updateCloseRangeButton(startX, endX)
|
||||
}
|
||||
}
|
||||
|
||||
private fun initView() {
|
||||
llRangeInfo = findViewById(R.id.ll_range_info)
|
||||
tvCloseRange = findViewById(R.id.tv_close_range)
|
||||
tvInfo = findViewById(R.id.tv_info)
|
||||
tvOpen = findViewById(R.id.tv_open)
|
||||
tvNumber = findViewById(R.id.tv_number)
|
||||
combineChart = findViewById(R.id.combine_chart)
|
||||
btnRange = findViewById(R.id.btn_range)
|
||||
btnAddTag = findViewById(R.id.btn_add_tag)
|
||||
btnScaleIn = findViewById(R.id.btn_scale_in)
|
||||
btnScaleOut = findViewById(R.id.btn_scale_out)
|
||||
btnHighlightAlways = findViewById(R.id.btn_highlight_always)
|
||||
btnMoveLeft = findViewById(R.id.btn_move_left)
|
||||
btnMoveRight = findViewById(R.id.btn_move_right)
|
||||
btnTouchPoint = findViewById(R.id.btn_touch_point)
|
||||
combineChart.scaleSensitivity = 1.1f
|
||||
|
||||
combineChart.axisRight.setLabelValueFormatter { value, index ->
|
||||
if (index == 1 || value.isNaN() || value >= Int.MAX_VALUE || value <= -Int.MAX_VALUE)
|
||||
return@setLabelValueFormatter ""
|
||||
val v = when (index) {
|
||||
0 -> combineChart.axisLeft.yMin
|
||||
2 -> combineChart.axisLeft.yMax
|
||||
else -> value
|
||||
}
|
||||
if (v.isNaN() || v >= Int.MAX_VALUE || v <= -Int.MAX_VALUE)
|
||||
return@setLabelValueFormatter ""
|
||||
return@setLabelValueFormatter if (lastClose > 0.0) {
|
||||
val result =
|
||||
(v - lastClose) / lastClose
|
||||
String.format("%.2f%%", result / 0.01)
|
||||
} else ""
|
||||
}
|
||||
combineChart.axisBottom.setLabelValueFormatter { _, index ->
|
||||
when (index) {
|
||||
0 -> leftTime
|
||||
4 -> rightTime
|
||||
else -> ""
|
||||
}
|
||||
}
|
||||
|
||||
combineChart.axisBottom.setValueIndexFormatter { index ->
|
||||
val time = candlestickValues.getOrNull(index)?.time
|
||||
if (time != null) {
|
||||
DateTimeFormatter.ofPattern("yyyy-MM-dd").formatTime(time * 1000L)
|
||||
} else ""
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun setLeftRightTime(
|
||||
viewport: Viewport,
|
||||
) {
|
||||
val candlestickDataSet = combineChart.candlestickDataSet
|
||||
if (candlestickDataSet != null && candlestickDataSet.firstOrNull() != null) {
|
||||
val values = candlestickDataSet.first().getVisiblePoints(viewport)
|
||||
if (values.isNotEmpty()) {
|
||||
leftTime = DateTimeFormatter.ofPattern("yyyy-MM-dd").formatTime(values.first().time * 1000L)
|
||||
rightTime = DateTimeFormatter.ofPattern("yyyy-MM-dd").formatTime(values.last().time * 1000L)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun initListener() {
|
||||
btnScaleIn.setOnClickListener {
|
||||
combineChart.zoomIn(ForceAlign.RIGHT)
|
||||
}
|
||||
|
||||
btnScaleOut.setOnClickListener {
|
||||
combineChart.zoomOut(ForceAlign.RIGHT)
|
||||
}
|
||||
|
||||
btnAddTag.setOnClickListener {
|
||||
val textDataSet = addTextData()
|
||||
textDataSet.drawIndex = 11000
|
||||
combineChart.addDataSet(textDataSet)
|
||||
combineChart.postInvalidate()
|
||||
}
|
||||
|
||||
btnRange.setOnClickListener {
|
||||
if (combineChart.rangeEnable) return@setOnClickListener
|
||||
combineChart.renderer.rangeRenderer.resetData()
|
||||
combineChart.cleanHighlight()
|
||||
combineChart.rangeEnable = true
|
||||
combineChart.isDraggingToMoveEnable = false
|
||||
combineChart.isHighlightDisable = true
|
||||
combineChart.postInvalidate()
|
||||
tvCloseRange.visibility = View.VISIBLE
|
||||
llRangeInfo.visibility = View.VISIBLE
|
||||
tvOpen.visibility = View.GONE
|
||||
tvNumber.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
btnHighlightAlways.setOnClickListener {
|
||||
combineChart.isHighlightVolatile = false
|
||||
}
|
||||
|
||||
btnMoveLeft.setOnClickListener {
|
||||
combineChart.stepMoveLeft()
|
||||
}
|
||||
|
||||
btnMoveRight.setOnClickListener {
|
||||
combineChart.stepMoveRight()
|
||||
}
|
||||
|
||||
btnTouchPoint.setOnClickListener {
|
||||
combineChart.isTouchPointEnable = !combineChart.isTouchPointEnable
|
||||
}
|
||||
|
||||
tvCloseRange.setOnClickListener {
|
||||
combineChart.rangeEnable = false
|
||||
combineChart.isDraggingToMoveEnable = true
|
||||
combineChart.isHighlightDisable = false
|
||||
combineChart.postInvalidate()
|
||||
llRangeInfo.visibility = View.INVISIBLE
|
||||
tvOpen.visibility = View.VISIBLE
|
||||
tvNumber.visibility = View.GONE
|
||||
tvCloseRange.visibility = View.GONE
|
||||
}
|
||||
|
||||
tvOpen.setOnClickListener {
|
||||
if (combineChart.rangeEnable) return@setOnClickListener
|
||||
combineChart.cleanHighlight()
|
||||
combineChart.rangeEnable = true
|
||||
combineChart.isDraggingToMoveEnable = false
|
||||
combineChart.isHighlightDisable = true
|
||||
combineChart.postInvalidate()
|
||||
llRangeInfo.visibility = View.VISIBLE
|
||||
tvCloseRange.visibility = View.VISIBLE
|
||||
tvOpen.visibility = View.GONE
|
||||
tvNumber.visibility = View.VISIBLE
|
||||
|
||||
}
|
||||
|
||||
combineChart.setOnScaleListener(object : OnScaleListener{
|
||||
override fun onScaleStart(viewport: Viewport) {
|
||||
|
||||
}
|
||||
|
||||
override fun onScale(viewport: Viewport) {
|
||||
}
|
||||
|
||||
override fun onScaleEnd(viewport: Viewport) {
|
||||
val from = round(candlestickValues.size * viewport.left)
|
||||
val to = round(candlestickValues.size * viewport.right)
|
||||
Log.d("Chart", "onScaleEnd->size=${to - from}")
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
combineChart.setOnLoadMoreKlineListener {
|
||||
loadMoreChartData()
|
||||
}
|
||||
|
||||
combineChart.addOnViewportChangeListener {viewPort ->
|
||||
setLeftRightTime(viewPort)
|
||||
if (!combineChart.isHighlightVolatile) {
|
||||
val renderer = combineChart.renderer
|
||||
val dataSet = combineChart.candlestickDataSet
|
||||
val chartWidth = combineChart.contentRect.width()
|
||||
val visibleSize = dataSet.firstOrNull()?.getVisibleRange(viewPort)?.roundToInt() ?: 0
|
||||
val highlight = combineChart.highlights?.firstOrNull()
|
||||
val highLightIndex = highlight?.dataIndex ?: -1
|
||||
val highLightX = getEntryCoordinateByIndex(highLightIndex, viewPort)
|
||||
val candleWidth = if (dataSet.firstOrNull()?.isAutoWidth == true) {
|
||||
(chartWidth / visibleSize).toFloat()
|
||||
} else {
|
||||
dataSet.firstOrNull()?.candleWidth
|
||||
} ?: 0f
|
||||
val halfCandleWidth = candleWidth.times(0.5f)
|
||||
|
||||
val leftBorder = 0f
|
||||
val rightBorder = chartWidth.toFloat() - halfCandleWidth
|
||||
val dataIndex = when {
|
||||
highLightX <= leftBorder -> {
|
||||
getEntryIndexByCoordinate(halfCandleWidth, viewPort)
|
||||
}
|
||||
highLightX >= rightBorder -> {
|
||||
getEntryIndexByCoordinate(rightBorder, viewPort)
|
||||
}
|
||||
else -> highLightIndex
|
||||
}
|
||||
|
||||
val x = max(halfCandleWidth, min(rightBorder, highLightX + halfCandleWidth))
|
||||
val y = highlight?.y ?: Float.NaN
|
||||
Log.d("JZChart", "OnViewportChangeListener visibleSize:$visibleSize, highLightIndex:$highLightIndex, highLightX:$highLightX, contentRect.width:${candleWidth}, x:$x, y:$y, dataIndex:$dataIndex")
|
||||
combineChart.highlightValue(Highlight(x, y, dataIndex))
|
||||
|
||||
}
|
||||
// Log.d("JZChart", "left= ${viewPort.left} +++ right= ${viewPort.right}")
|
||||
}
|
||||
}
|
||||
|
||||
private fun addTextData(): ScatterTextDataSet {
|
||||
val entries = java.util.ArrayList<ScatterTextValue>(candlestickValues.size)
|
||||
candlestickValues.forEachIndexed { index, value ->
|
||||
entries.add(ScatterTextValue(true, value.high,value.low))
|
||||
}
|
||||
val dataSet = ScatterTextDataSet(entries)
|
||||
|
||||
dataSet.axisDependency = AxisY.DEPENDENCY_BOTH
|
||||
dataSet.text = "加自选"
|
||||
dataSet.textColor = 0xffFD263F.toInt()
|
||||
dataSet.textBgColor = 0xB3FFFFFF.toInt()
|
||||
dataSet.lineColor = 0xffFD263F.toInt()
|
||||
dataSet.frameColor = 0xffFD263F.toInt()
|
||||
dataSet.textSize = 30
|
||||
|
||||
return dataSet
|
||||
}
|
||||
|
||||
private fun updateCloseRangeButton(startX: Float, endX: Float) {
|
||||
|
||||
val centerX = (startX + endX) * 0.5f
|
||||
|
||||
var transX = centerX - tvCloseRange.width * 0.5f
|
||||
|
||||
if (transX < combineChart.left) {
|
||||
transX = 0f
|
||||
} else if (transX > combineChart.width - tvCloseRange.width) {
|
||||
transX = combineChart.width.toFloat() - tvCloseRange.width
|
||||
}
|
||||
|
||||
tvCloseRange.translationX = transX
|
||||
}
|
||||
|
||||
private fun loadMoreChartData() {
|
||||
val lastSize = candlestickValues.size
|
||||
candlestickValues.addAll(ChartDataConfig.getDefaultKlineList())
|
||||
val newSize = candlestickValues.size
|
||||
reCalcViewportByLoadMore(lastSize, newSize)
|
||||
|
||||
val dataSet = CandlestickDataSet(candlestickValues)
|
||||
dataSet.isHighlightedHorizontalEnable = true
|
||||
dataSet.isHighlightedVerticalEnable = true
|
||||
dataSet.increasingPaintStyle = Paint.Style.STROKE
|
||||
dataSet.strokeThickness = 2f
|
||||
|
||||
val arrowDataSet = CandlestickDataSetArrowDecorator(dataSet).apply { offsetPercent = 0.05f }
|
||||
|
||||
val data = CombineData().apply {
|
||||
add(arrowDataSet)
|
||||
}
|
||||
|
||||
combineChart.setCombineData(data)
|
||||
|
||||
}
|
||||
|
||||
private fun reCalcViewportByLoadMore(originCount : Int, newCount: Int) {
|
||||
if (originCount != newCount) {
|
||||
val viewport = combineChart.currentViewport
|
||||
val from = viewport.left * originCount + (newCount - originCount);
|
||||
val to = viewport.right * originCount + (newCount - originCount);
|
||||
viewport.left = from / newCount
|
||||
viewport.right = to / newCount
|
||||
|
||||
if (!combineChart.isHighlightVolatile) {
|
||||
val highlight = combineChart.highlights?.firstOrNull()
|
||||
val x = highlight?.x ?: 0f
|
||||
val y = highlight?.y ?: 0f
|
||||
val dataIndex = getEntryIndexByCoordinate(x, viewport)
|
||||
Log.d("JZChart", "reCalcViewportByLoadMore $dataIndex, x=$x")
|
||||
combineChart.highlightValue(Highlight(x, y, dataIndex))
|
||||
}
|
||||
combineChart.setCurrentViewport(viewport)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getEntryIndexByCoordinate(x: Float, viewport: Viewport): Int {
|
||||
val contentRect = combineChart.contentRect
|
||||
val valueCount = candlestickValues.size
|
||||
var index: Int =
|
||||
(((x - contentRect.left) * viewport.width() / contentRect.width() + viewport.left) * valueCount.toFloat()).toInt()
|
||||
if (index >= valueCount) index = valueCount - 1
|
||||
if (index < 0) index = 0
|
||||
return index
|
||||
}
|
||||
|
||||
private fun getEntryCoordinateByIndex(index: Int, viewport: Viewport): Float {
|
||||
val contentRect = combineChart.contentRect
|
||||
val valueCount = candlestickValues.size
|
||||
var x: Float = contentRect.left + (index / valueCount.toFloat() - viewport.left) / viewport.width() * contentRect.width()
|
||||
if (x > contentRect.right) x = contentRect.right.toFloat()
|
||||
if (x < contentRect.left) x = contentRect.left.toFloat()
|
||||
return x
|
||||
}
|
||||
|
||||
private fun setChartData() {
|
||||
candlestickValues.clear();
|
||||
candlestickValues.addAll(ChartDataConfig.getDefaultKlineList())
|
||||
|
||||
val dataSet = CandlestickDataSet(candlestickValues)
|
||||
dataSet.isHighlightedHorizontalEnable = true
|
||||
dataSet.isHighlightedVerticalEnable = true
|
||||
dataSet.increasingPaintStyle = Paint.Style.STROKE
|
||||
dataSet.strokeThickness = 2f
|
||||
|
||||
val arrowDataSet = CandlestickDataSetArrowDecorator(dataSet).apply {
|
||||
offsetPercent = 0.05f
|
||||
textSize = 32
|
||||
textColor = 0xff3F51B5.toInt()
|
||||
}
|
||||
|
||||
val data = CombineData().apply {
|
||||
add(arrowDataSet)
|
||||
}
|
||||
combineChart.setCombineData(data)
|
||||
setLeftRightTime(combineChart.currentViewport)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package cn.jingzhuan.lib.chart2.demo;
|
||||
|
||||
import androidx.databinding.ViewDataBinding;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import androidx.appcompat.content.res.AppCompatResources;
|
||||
import cn.jingzhuan.lib.chart.data.ScatterDataSet;
|
||||
import cn.jingzhuan.lib.chart.data.ScatterTextValue;
|
||||
import cn.jingzhuan.lib.chart.data.ScatterValue;
|
||||
import cn.jingzhuan.lib.chart.renderer.TextValueRenderer;
|
||||
import cn.jingzhuan.lib.chart2.demo.databinding.LayoutScatterChartBinding;
|
||||
import com.airbnb.epoxy.DataBindingEpoxyModel;
|
||||
import com.airbnb.epoxy.EpoxyModelClass;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by donglua on 10/19/17.
|
||||
*/
|
||||
|
||||
@EpoxyModelClass(layout = R.layout.layout_scatter_chart)
|
||||
public abstract class ScatterChart2Model extends DataBindingEpoxyModel {
|
||||
|
||||
private ScatterDataSet scatterDataSet;
|
||||
|
||||
private final List<String> textList =
|
||||
Arrays.asList("data1", "data2", "data3", "data4", "data5", "data6");
|
||||
|
||||
public ScatterChart2Model() {
|
||||
|
||||
final List<ScatterValue> scatterValues = new ArrayList<>();
|
||||
|
||||
scatterValues.add(new ScatterValue(1f));
|
||||
scatterValues.add(new ScatterValue(2f));
|
||||
scatterValues.add(new ScatterValue(1f));
|
||||
scatterValues.add(new ScatterValue(2f));
|
||||
scatterValues.add(new ScatterValue(1f));
|
||||
scatterValues.add(new ScatterValue(2f));
|
||||
|
||||
scatterDataSet = new ScatterDataSet(scatterValues);
|
||||
scatterDataSet.setMinValueOffsetPercent(0.5f);
|
||||
scatterDataSet.setMaxValueOffsetPercent(0.5f);
|
||||
scatterDataSet.setAutoWidth(false);
|
||||
scatterDataSet.addTextValueRenderer(new TextValueRenderer() {
|
||||
@Override public void render(Canvas canvas, Paint textPaint, int index, float x, float y) {
|
||||
textPaint.setTextSize(24f);
|
||||
canvas.drawText(textList.get(index), x, y, textPaint);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override protected void setDataBindingVariables(ViewDataBinding binding) {
|
||||
|
||||
if (binding instanceof LayoutScatterChartBinding) {
|
||||
|
||||
Drawable drawable = AppCompatResources.getDrawable(binding.getRoot().getContext(),
|
||||
R.drawable.shape_circle);
|
||||
scatterDataSet.setShape(drawable);
|
||||
|
||||
LayoutScatterChartBinding bd = (LayoutScatterChartBinding) binding;
|
||||
|
||||
bd.combineChart.getAxisBottom().setGridCount(1);
|
||||
bd.combineChart.getAxisLeft().setGridCount(1);
|
||||
bd.combineChart.addDataSet(scatterDataSet);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package cn.jingzhuan.lib.chart2.demo;
|
||||
|
||||
import androidx.databinding.ViewDataBinding;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import androidx.appcompat.content.res.AppCompatResources;
|
||||
import cn.jingzhuan.lib.chart.data.ScatterDataSet;
|
||||
import cn.jingzhuan.lib.chart.data.ScatterValue;
|
||||
import cn.jingzhuan.lib.chart2.demo.databinding.LayoutCombineChartBinding;
|
||||
import com.airbnb.epoxy.DataBindingEpoxyModel;
|
||||
import com.airbnb.epoxy.EpoxyModelClass;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by donglua on 10/19/17.
|
||||
*/
|
||||
|
||||
@EpoxyModelClass(layout = R.layout.layout_combine_chart)
|
||||
public abstract class ScatterChartModel extends DataBindingEpoxyModel {
|
||||
|
||||
private ScatterDataSet scatterDataSet;
|
||||
|
||||
public ScatterChartModel() {
|
||||
|
||||
final List<ScatterValue> scatterValues = new ArrayList<>();
|
||||
|
||||
scatterValues.add(new ScatterValue(2));
|
||||
scatterValues.add(new ScatterValue(3));
|
||||
scatterValues.add(new ScatterValue(4));
|
||||
scatterValues.add(new ScatterValue(6));
|
||||
scatterValues.add(new ScatterValue(9));
|
||||
scatterValues.add(new ScatterValue(2));
|
||||
scatterValues.add(new ScatterValue(4));
|
||||
scatterValues.add(new ScatterValue(6));
|
||||
scatterValues.add(new ScatterValue(9));
|
||||
scatterValues.add(new ScatterValue(0));
|
||||
scatterValues.add(new ScatterValue(8));
|
||||
scatterValues.add(new ScatterValue(9));
|
||||
scatterValues.add(new ScatterValue(4));
|
||||
scatterValues.add(new ScatterValue(1));
|
||||
scatterValues.add(new ScatterValue(2));
|
||||
|
||||
scatterDataSet = new ScatterDataSet(scatterValues);
|
||||
scatterDataSet.setAutoWidth(true);
|
||||
}
|
||||
|
||||
@Override protected void setDataBindingVariables(ViewDataBinding binding) {
|
||||
|
||||
if (binding instanceof LayoutCombineChartBinding) {
|
||||
|
||||
Drawable drawable = AppCompatResources.getDrawable(binding.getRoot().getContext(), R.drawable.ic_example);
|
||||
scatterDataSet.setShape(drawable);
|
||||
|
||||
LayoutCombineChartBinding bd = (LayoutCombineChartBinding) binding;
|
||||
|
||||
bd.combineChart.addDataSet(scatterDataSet);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
package cn.jingzhuan.lib.chart2.demo
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Canvas
|
||||
import android.graphics.Color
|
||||
import android.graphics.Color.BLACK
|
||||
import android.graphics.Color.WHITE
|
||||
import android.util.AttributeSet
|
||||
import android.util.Log
|
||||
import androidx.core.content.ContextCompat
|
||||
import cn.jingzhuan.lib.chart.component.Highlight
|
||||
import cn.jingzhuan.lib.chart.data.AbstractDataSet
|
||||
import cn.jingzhuan.lib.chart.data.CandlestickDataSet
|
||||
import cn.jingzhuan.lib.chart2.renderer.CombineChartRenderer
|
||||
import cn.jingzhuan.lib.chart2.widget.CombineChart
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
|
||||
const val MIN_VISIBLE_ENTRY_COUNT = 10
|
||||
const val MAX_VISIBLE_ENTRY_COUNT = 100
|
||||
const val DEFAULT_VISIBLE_ENTRY_COUNT = 40
|
||||
|
||||
class TestChartKLineView(ctx: Context, attrs: AttributeSet?) : CombineChart(ctx, attrs) {
|
||||
private var viewportMin: Float = 0f
|
||||
private var viewportMax: Float = 0f
|
||||
|
||||
override fun initChart() {
|
||||
isEnableVerticalHighlight = true
|
||||
isEnableHorizontalHighlight = true
|
||||
isEnableHighlightLeftText = true
|
||||
isEnableHighlightRightText = true
|
||||
isEnableHighlightBottomText = true
|
||||
highlightTextBgHeight = 50
|
||||
highlightTextBgColor = BLACK
|
||||
highlightTextColor = WHITE
|
||||
highlightTextSize = 28f
|
||||
super.initChart()
|
||||
setRenderer(object : CombineChartRenderer(this) {
|
||||
init {
|
||||
highlightColor = BLACK
|
||||
}
|
||||
|
||||
override fun calcDataSetMinMax() {
|
||||
super.calcDataSetMinMax()
|
||||
viewportMin = chartData.leftMin
|
||||
viewportMax = chartData.leftMax
|
||||
}
|
||||
|
||||
override fun renderHighlighted(canvas: Canvas?, highlights: Array<out Highlight>) {
|
||||
super.renderHighlighted(
|
||||
canvas,
|
||||
highlights.map { it.y = it.touchY; it }.toTypedArray()
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
axisBottom.isLabelEnable = true
|
||||
axisBottom.labelHeight = 50
|
||||
axisBottom.labelTextSize = 28f
|
||||
axisBottom.labelTextColor = BLACK
|
||||
setIsMainChart(true)
|
||||
|
||||
isScaleGestureEnable = true
|
||||
isScaleXEnable = true
|
||||
|
||||
|
||||
axisTop.isGridLineEnable = true
|
||||
axisLeft.gridCount = 3
|
||||
axisLeft.isGridSlidIndex = 2
|
||||
axisTop.gridCount = 0
|
||||
axisRight.gridCount = 0
|
||||
axisBottom.gridCount = 3
|
||||
axisBottom.isGridSlidIndex = 2
|
||||
axisLeft.isLabelEnable = true
|
||||
axisLeft.setLabelValueFormatter { value, index ->
|
||||
if (index == 1 || index == 3) "" else String.format("%.2f", value)
|
||||
}
|
||||
axisLeft.enableGridDashPathEffect(floatArrayOf(10f, 10f), 8f)
|
||||
axisBottom.enableGridDashPathEffect(floatArrayOf(10f, 10f), 8f)
|
||||
|
||||
minVisibleEntryCount = MIN_VISIBLE_ENTRY_COUNT
|
||||
maxVisibleEntryCount = MAX_VISIBLE_ENTRY_COUNT
|
||||
defaultVisibleEntryCount = DEFAULT_VISIBLE_ENTRY_COUNT
|
||||
|
||||
}
|
||||
|
||||
override fun addDataSet(abstractDataSet: AbstractDataSet<*>?) {
|
||||
if (abstractDataSet is CandlestickDataSet) {
|
||||
if (abstractDataSet.neutralColor != Color.TRANSPARENT)
|
||||
abstractDataSet.neutralColor = Color.GRAY
|
||||
}
|
||||
super.addDataSet(abstractDataSet)
|
||||
}
|
||||
|
||||
override fun isCanZoomIn(): Boolean {
|
||||
return currentVisibleEntryCount >= MIN_VISIBLE_ENTRY_COUNT && super.isCanZoomIn()
|
||||
}
|
||||
|
||||
override fun isCanZoomOut(): Boolean {
|
||||
return currentVisibleEntryCount <= MAX_VISIBLE_ENTRY_COUNT && super.isCanZoomOut()
|
||||
}
|
||||
|
||||
override fun zoomIn(forceAlignX: Int) {
|
||||
if (currentVisibleEntryCount <= MIN_VISIBLE_ENTRY_COUNT) return
|
||||
super.zoomIn(forceAlignX)
|
||||
}
|
||||
|
||||
override fun zoomOut(forceAlignX: Int) {
|
||||
if (currentVisibleEntryCount >= MAX_VISIBLE_ENTRY_COUNT) return
|
||||
super.zoomOut(forceAlignX)
|
||||
}
|
||||
|
||||
fun stepMoveLeft() {
|
||||
val visibleSize = candlestickDataSet.firstOrNull()?.getVisibleRange(currentViewport)?.roundToInt() ?: 0
|
||||
val width = contentRect.width().toFloat()
|
||||
val percent = (width / visibleSize) / width
|
||||
moveLeft(percent)
|
||||
}
|
||||
|
||||
fun stepMoveRight() {
|
||||
val visibleSize = candlestickDataSet.firstOrNull()?.getVisibleRange(currentViewport)?.roundToInt() ?: 0
|
||||
val width = contentRect.width().toFloat()
|
||||
val percent = (width / visibleSize) / width
|
||||
moveRight(percent)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package cn.jingzhuan.lib.chart2.demo;
|
||||
|
||||
import androidx.databinding.ViewDataBinding;
|
||||
import androidx.viewpager.widget.PagerAdapter;
|
||||
import cn.jingzhuan.lib.chart2.demo.databinding.LayoutViewPagerBinding;
|
||||
import com.airbnb.epoxy.DataBindingEpoxyModel;
|
||||
import com.airbnb.epoxy.EpoxyAttribute;
|
||||
import com.airbnb.epoxy.EpoxyModelClass;
|
||||
|
||||
/**
|
||||
* Created by donglua on 9/7/17.
|
||||
*/
|
||||
@EpoxyModelClass(layout = R.layout.layout_view_pager)
|
||||
public abstract class ViewPagerModel extends DataBindingEpoxyModel {
|
||||
|
||||
@EpoxyAttribute PagerAdapter pagerAdapter;
|
||||
|
||||
@Override protected void setDataBindingVariables(ViewDataBinding binding) {
|
||||
|
||||
LayoutViewPagerBinding b = (LayoutViewPagerBinding) binding;
|
||||
|
||||
b.viewPager.setAdapter(pagerAdapter);
|
||||
|
||||
}
|
||||
|
||||
@Override public boolean shouldSaveViewState() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
package cn.jingzhuan.lib.chart2.demo.chart3
|
||||
|
||||
import cn.jingzhuan.lib.chart3.data.value.CandlestickValue
|
||||
import cn.jingzhuan.lib.chart3.data.value.LineValue
|
||||
|
||||
object DataConfig {
|
||||
|
||||
val callAuctionList = listOf(
|
||||
LineValue(3134.57f, 1692322131L - 86400 * 120),
|
||||
LineValue(3140.85f, 1692322131L - 86400 * 120 + 10),
|
||||
LineValue(3152.18f, 1692322131L - 86400 * 120 + 20),
|
||||
LineValue(3195.90f, 1692322131L - 86400 * 120 + 30),
|
||||
LineValue(3061.50f, 1692322131L - 86400 * 120 + 40),
|
||||
LineValue(3090.22f, 1692322131L - 86400 * 120 + 50),
|
||||
LineValue(3237.97f, 1692322131L - 86400 * 120 + 60),
|
||||
LineValue(3272.92f, 1692322131L - 86400 * 120 + 70),
|
||||
LineValue(3154.65f, 1692322131L - 86400 * 120 + 80),
|
||||
LineValue(3075.67f, 1692322131L - 86400 * 120 + 90),
|
||||
LineValue(3134.57f, 1692322131L - 86400 * 120 + 150),
|
||||
LineValue(3140.85f, 1692322131L - 86400 * 120 + 180),
|
||||
LineValue(3152.18f, 1692322131L - 86400 * 120 + 200),
|
||||
LineValue(3195.90f, 1692322131L - 86400 * 120 + 210),
|
||||
LineValue(3061.50f, 1692322131L - 86400 * 120 + 211),
|
||||
LineValue(3090.22f, 1692322131L - 86400 * 120 + 213),
|
||||
LineValue(3237.97f, 1692322131L - 86400 * 120 + 215),
|
||||
LineValue(3272.92f, 1692322131L - 86400 * 120 + 216),
|
||||
LineValue(3154.65f, 1692322131L - 86400 * 120 + 217),
|
||||
LineValue(3075.67f, 1692322131L - 86400 * 120 + 218),
|
||||
LineValue(3134.57f, 1692322131L - 86400 * 120 + 300),
|
||||
LineValue(3140.85f, 1692322131L - 86400 * 120 + 350),
|
||||
LineValue(3152.18f, 1692322131L - 86400 * 120 + 400),
|
||||
LineValue(3195.90f, 1692322131L - 86400 * 120 + 450),
|
||||
LineValue(3061.50f, 1692322131L - 86400 * 120 + 460),
|
||||
LineValue(3090.22f, 1692322131L - 86400 * 120 + 500),
|
||||
LineValue(3237.97f, 1692322131L - 86400 * 120 + 520),
|
||||
LineValue(3272.92f, 1692322131L - 86400 * 120 + 540),
|
||||
LineValue(3154.65f, 1692322131L - 86400 * 120 + 560),
|
||||
LineValue(3075.67f, 1692322131L - 86400 * 120 + 580),
|
||||
)
|
||||
val candlestickList = listOf(
|
||||
CandlestickValue(3145.27f, 3117.44f, 3123.88f, 3134.57f, 1692322131L - 86400 * 120),
|
||||
CandlestickValue(3152.94f, 3131.41f, 3132.91f, 3140.85f, 1692322131L - 86400 * 119),
|
||||
CandlestickValue(3155.00f, 3097.33f, 3131.35f, 3152.18f, 1692322131L - 86400 * 118),
|
||||
CandlestickValue(3154.72f, 3136.58f, 3144.02f, 3154.65f, 1692322131L - 86400 * 117),
|
||||
CandlestickValue(3154.78f, 3136.54f, 3147.22f, 3143.70f, 1692322131L - 86400 * 116),
|
||||
CandlestickValue(3148.29f, 3123.75f, 3138.31f, 3135.35f, 1692322131L - 86400 * 115),
|
||||
CandlestickValue(3143.82f, 3111.38f, 3127.11f, 3127.37f, 1692322131L - 86400 * 114),
|
||||
CandlestickValue(3117.61f, 3092.09f, 3114.77f, 3103.04f, 1692322131L - 86400 * 113),
|
||||
CandlestickValue(3093.44f, 3067.68f, 3090.07f, 3078.61f, 1692322131L - 86400 * 112),
|
||||
CandlestickValue(3084.20f, 3056.56f, 3064.85f, 3080.53f, 1692322131L - 86400 * 111),
|
||||
|
||||
CandlestickValue(3090.82f, 3051.59f, 3078.16f, 3052.78f, 1692322131L - 86400 * 110),
|
||||
CandlestickValue(3063.56f, 3016.53f, 3036.79f, 3061.50f, 1692322131L - 86400 * 109),
|
||||
CandlestickValue(3090.48f, 3051.87f, 3054.11f, 3083.51f, 1692322131L - 86400 * 108),
|
||||
CandlestickValue(3098.91f, 3085.93f, 3085.93f, 3090.22f, 1692322131L - 86400 * 107),
|
||||
CandlestickValue(3113.51f, 3060.53f, 3082.87f, 3112.95f, 1692322131L - 86400 * 106),
|
||||
CandlestickValue(3119.58f, 3101.30f, 3107.80f, 3104.43f, 1692322131L - 86400 * 105),
|
||||
CandlestickValue(3103.43f, 3077.95f, 3082.33f, 3090.13f, 1692322131L - 86400 * 104),
|
||||
CandlestickValue(3095.47f, 3081.28f, 3086.70f, 3090.62f, 1692322131L - 86400 * 103),
|
||||
CandlestickValue(3103.93f, 3063.14f, 3087.16f, 3075.67f, 1692322131L - 86400 * 102),
|
||||
CandlestickValue(3084.23f, 3050.84f, 3069.38f, 3061.94f, 1692322131L - 86400 * 101),
|
||||
|
||||
CandlestickValue(3010.81f, 3005.30f, 3006.57f, 3009.08f, 1692322131L - 86400 * 100),
|
||||
CandlestickValue(3114.65f, 3052.83f, 3055.34f, 3107.83f, 1692322131L - 86400 * 99),
|
||||
CandlestickValue(3120.65f, 3100.38f, 3101.29f, 3110.06f, 1692322131L - 86400 * 98),
|
||||
CandlestickValue(3143.28f, 3111.56f, 3125.33f, 3117.17f, 1692322131L - 86400 * 97),
|
||||
CandlestickValue(3113.52f, 3097.67f, 3108.41f, 3102.62f, 1692322131L - 86400 * 96),
|
||||
CandlestickValue(3110.38f, 3081.84f, 3094.22f, 3105.54f, 1692322131L - 86400 * 95),
|
||||
CandlestickValue(3105.50f, 3084.83f, 3102.11f, 3091.65f, 1692322131L - 86400 * 94),
|
||||
CandlestickValue(3102.86f, 3078.79f, 3084.54f, 3102.12f, 1692322131L - 86400 * 93),
|
||||
CandlestickValue(3140.77f, 3098.94f, 3101.76f, 3140.32f, 1692322131L - 86400 * 92),
|
||||
CandlestickValue(3153.26f, 3132.82f, 3136.46f, 3150.33f, 1692322131L - 86400 * 91),
|
||||
|
||||
CandlestickValue(3165.91f, 3146.10f, 3147.45f, 3158.39f, 1692322131L - 86400 * 90),
|
||||
CandlestickValue(3164.94f, 3135.31f, 3149.53f, 3139.87f, 1692322131L - 86400 * 89),
|
||||
CandlestickValue(3155.98f, 3131.04f, 3134.01f, 3153.73f, 1692322131L - 86400 * 88),
|
||||
CandlestickValue(3149.16f, 3125.35f, 3146.75f, 3130.66f, 1692322131L - 86400 * 87),
|
||||
CandlestickValue(3137.59f, 3117.08f, 3125.59f, 3132.48f, 1692322131L - 86400 * 86),
|
||||
CandlestickValue(3134.25f, 3117.85f, 3126.37f, 3123.16f, 1692322131L - 86400 * 85),
|
||||
CandlestickValue(3146.77f, 3121.77f, 3122.15f, 3144.37f, 1692322131L - 86400 * 84),
|
||||
CandlestickValue(3150.45f, 3134.61f, 3148.02f, 3140.01f, 1692322131L - 86400 * 83),
|
||||
CandlestickValue(3157.03f, 3132.62f, 3148.98f, 3156.20f, 1692322131L - 86400 * 82),
|
||||
CandlestickValue(3186.97f, 3146.63f, 3152.23f, 3147.44f, 1692322131L - 86400 * 81),
|
||||
|
||||
CandlestickValue(3158.05f, 3118.09f, 3138.43f, 3157.87f, 1692322131L - 86400 * 80),
|
||||
CandlestickValue(3187.88f, 3156.97f, 3157.00f, 3185.43f, 1692322131L - 86400 * 79),
|
||||
CandlestickValue(3193.45f, 3172.45f, 3183.41f, 3191.19f, 1692322131L - 86400 * 78),
|
||||
CandlestickValue(3193.43f, 3170.78f, 3183.63f, 3173.20f, 1692322131L - 86400 * 77),
|
||||
CandlestickValue(3188.77f, 3174.28f, 3174.97f, 3188.06f, 1692322131L - 86400 * 76),
|
||||
CandlestickValue(3193.23f, 3171.57f, 3176.94f, 3192.42f, 1692322131L - 86400 * 75),
|
||||
CandlestickValue(3196.29f, 3177.02f, 3192.00f, 3195.90f, 1692322131L - 86400 * 74),
|
||||
CandlestickValue(3193.06f, 3174.31f, 3192.88f, 3182.80f, 1692322131L - 86400 * 73),
|
||||
CandlestickValue(3207.31f, 3174.70f, 3179.21f, 3207.12f, 1692322131L - 86400 * 72),
|
||||
CandlestickValue(3215.94f, 3188.77f, 3203.86f, 3212.43f, 1692322131L - 86400 * 71),
|
||||
|
||||
CandlestickValue(3219.52f, 3195.29f, 3203.82f, 3217.95f, 1692322131L - 86400 * 70),
|
||||
CandlestickValue(3223.34f, 3203.20f, 3208.45f, 3212.62f, 1692322131L - 86400 * 69),
|
||||
CandlestickValue(3226.90f, 3199.21f, 3201.52f, 3203.04f, 1692322131L - 86400 * 68),
|
||||
CandlestickValue(3215.19f, 3177.92f, 3201.92f, 3197.54f, 1692322131L - 86400 * 67),
|
||||
CandlestickValue(3219.27f, 3190.34f, 3192.36f, 3218.15f, 1692322131L - 86400 * 66),
|
||||
CandlestickValue(3222.97f, 3204.85f, 3212.03f, 3222.41f, 1692322131L - 86400 * 65),
|
||||
CandlestickValue(3230.35f, 3139.50f, 3219.79f, 3176.45f, 1692322131L - 86400 * 64),
|
||||
CandlestickValue(3187.66f, 3150.12f, 3159.72f, 3187.57f, 1692322131L - 86400 * 63),
|
||||
CandlestickValue(3232.93f, 3179.72f, 3181.39f, 3230.97f, 1692322131L - 86400 * 62),
|
||||
CandlestickValue(3246.23f, 3225.42f, 3227.51f, 3244.86f, 1692322131L - 86400 * 61),
|
||||
|
||||
CandlestickValue(3247.70f, 3231.95f, 3236.59f, 3237.97f, 1692322131L - 86400 * 60),
|
||||
CandlestickValue(3261.10f, 3230.07f, 3230.89f, 3250.60f, 1692322131L - 86400 * 59),
|
||||
CandlestickValue(3261.64f, 3233.13f, 3249.13f, 3243.68f, 1692322131L - 86400 * 58),
|
||||
CandlestickValue(3264.85f, 3228.04f, 3244.45f, 3247.66f, 1692322131L - 86400 * 57),
|
||||
CandlestickValue(3251.92f, 3220.63f, 3243.76f, 3249.78f, 1692322131L - 86400 * 56),
|
||||
CandlestickValue(3256.37f, 3232.95f, 3240.16f, 3253.23f, 1692322131L - 86400 * 55),
|
||||
CandlestickValue(3276.94f, 3251.18f, 3252.75f, 3273.03f, 1692322131L - 86400 * 54),
|
||||
CandlestickValue(3292.63f, 3273.50f, 3274.37f, 3292.63f, 1692322131L - 86400 * 53),
|
||||
CandlestickValue(3305.42f, 3282.04f, 3288.52f, 3285.06f, 1692322131L - 86400 * 52),
|
||||
CandlestickValue(3293.37f, 3262.15f, 3279.98f, 3272.92f, 1692322131L - 86400 * 51),
|
||||
|
||||
CandlestickValue(3287.18f, 3261.31f, 3269.32f, 3262.08f, 1692322131L - 86400 * 50),
|
||||
CandlestickValue(3280.10f, 3243.71f, 3257.66f, 3279.45f, 1692322131L - 86400 * 49),
|
||||
CandlestickValue(3285.47f, 3269.65f, 3277.18f, 3281.87f, 1692322131L - 86400 * 48),
|
||||
CandlestickValue(3277.93f, 3263.85f, 3277.81f, 3275.57f, 1692322131L - 86400 * 47),
|
||||
CandlestickValue(3282.52f, 3236.17f, 3269.72f, 3261.75f, 1692322131L - 86400 * 46),
|
||||
CandlestickValue(3245.12f, 3200.75f, 3237.91f, 3208.54f, 1692322131L - 86400 * 45),
|
||||
CandlestickValue(3240.05f, 3206.04f, 3206.04f, 3237.36f, 1692322131L - 86400 * 44),
|
||||
CandlestickValue(3263.59f, 3235.10f, 3235.22f, 3251.26f, 1692322131L - 86400 * 43),
|
||||
CandlestickValue(3248.78f, 3228.87f, 3247.85f, 3246.44f, 1692322131L - 86400 * 42),
|
||||
CandlestickValue(3269.13f, 3251.45f, 3253.85f, 3268.42f, 1692322131L - 86400 * 41),
|
||||
|
||||
CandlestickValue(3275.08f, 3248.08f, 3253.23f, 3268.71f, 1692322131L - 86400 * 40),
|
||||
CandlestickValue(3287.52f, 3270.47f, 3274.58f, 3286.90f, 1692322131L - 86400 * 39),
|
||||
CandlestickValue(3293.47f, 3274.93f, 3287.61f, 3290.22f, 1692322131L - 86400 * 38),
|
||||
CandlestickValue(3299.45f, 3274.43f, 3283.80f, 3287.69f, 1692322131L - 86400 * 37),
|
||||
CandlestickValue(3297.98f, 3266.36f, 3287.95f, 3271.51f, 1692322131L - 86400 * 36),
|
||||
CandlestickValue(3331.90f, 3271.45f, 3271.45f, 3331.52f, 1692322131L - 86400 * 35),
|
||||
CandlestickValue(3375.03f, 3336.12f, 3336.12f, 3362.64f, 1692322131L - 86400 * 34),
|
||||
CandlestickValue(3374.59f, 3354.45f, 3362.06f, 3365.22f, 1692322131L - 86400 * 33),
|
||||
CandlestickValue(3376.64f, 3357.08f, 3361.82f, 3363.62f, 1692322131L - 86400 * 32),
|
||||
CandlestickValue(3367.36f, 3341.14f, 3361.45f, 3349.57f, 1692322131L - 86400 * 31),
|
||||
|
||||
CandlestickValue(3282.52f, 3236.17f, 3269.72f, 3261.75f, 1692322131L - 86400 * 30),
|
||||
CandlestickValue(3245.12f, 3200.75f, 3237.91f, 3208.54f, 1692322131L - 86400 * 29),
|
||||
CandlestickValue(3240.05f, 3206.04f, 3206.04f, 3237.36f, 1692322131L - 86400 * 28),
|
||||
CandlestickValue(3263.59f, 3235.10f, 3235.22f, 3251.26f, 1692322131L - 86400 * 27),
|
||||
CandlestickValue(3248.78f, 3228.87f, 3247.85f, 3246.44f, 1692322131L - 86400 * 26),
|
||||
CandlestickValue(3269.13f, 3251.45f, 3253.85f, 3268.42f, 1692322131L - 86400 * 25),
|
||||
CandlestickValue(3275.08f, 3248.08f, 3253.23f, 3268.71f, 1692322131L - 86400 * 24),
|
||||
CandlestickValue(3287.52f, 3270.47f, 3274.58f, 3286.90f, 1692322131L - 86400 * 23),
|
||||
CandlestickValue(3280.10f, 3243.71f, 3257.66f, 3279.45f, 1692322131L - 86400 * 22),
|
||||
CandlestickValue(3285.47f, 3269.65f, 3277.18f, 3281.87f, 1692322131L - 86400 * 21),
|
||||
|
||||
CandlestickValue(3277.93f, 3263.85f, 3277.81f, 3275.57f, 1692322131L - 86400 * 20),
|
||||
CandlestickValue(3282.52f, 3236.17f, 3269.72f, 3261.75f, 1692322131L - 86400 * 19),
|
||||
CandlestickValue(3245.12f, 3200.75f, 3237.91f, 3208.54f, 1692322131L - 86400 * 18),
|
||||
CandlestickValue(3240.05f, 3206.04f, 3206.04f, 3237.36f, 1692322131L - 86400 * 17),
|
||||
CandlestickValue(3263.59f, 3235.10f, 3235.22f, 3251.26f, 1692322131L - 86400 * 16),
|
||||
CandlestickValue(3248.78f, 3228.87f, 3247.85f, 3246.44f, 1692322131L - 86400 * 15),
|
||||
CandlestickValue(3269.13f, 3251.45f, 3253.85f, 3268.42f, 1692322131L - 86400 * 14),
|
||||
CandlestickValue(3261.10f, 3230.07f, 3230.89f, 3250.60f, 1692322131L - 86400 * 13),
|
||||
CandlestickValue(3261.64f, 3233.13f, 3249.13f, 3243.68f, 1692322131L - 86400 * 12),
|
||||
CandlestickValue(3264.85f, 3228.04f, 3244.45f, 3247.66f, 1692322131L - 86400 * 11),
|
||||
|
||||
CandlestickValue(3251.92f, 3220.63f, 3243.76f, 3249.78f, 1692322131L - 86400 * 10),
|
||||
CandlestickValue(3256.37f, 3232.95f, 3240.16f, 3253.23f, 1692322131L - 86400 * 9),
|
||||
CandlestickValue(3276.94f, 3251.18f, 3252.75f, 3273.03f, 1692322131L - 86400 * 8),
|
||||
CandlestickValue(3292.63f, 3273.50f, 3274.37f, 3292.63f, 1692322131L - 86400 * 7),
|
||||
CandlestickValue(3305.42f, 3282.04f, 3288.52f, 3285.06f, 1692322131L - 86400 * 6),
|
||||
CandlestickValue(3293.37f, 3262.15f, 3279.98f, 3272.92f, 1692322131L - 86400 * 5),
|
||||
CandlestickValue(3287.18f, 3261.31f, 3269.32f, 3262.08f, 1692322131L - 86400 * 4),
|
||||
CandlestickValue(3180.10f, 3160.71f, 3170.66f, 3177.45f, 1692322131L - 86400 * 3),
|
||||
CandlestickValue(3200.47f, 3188.65f, 3198.18f, 3191.87f, 1692322131L - 86400 * 2),
|
||||
CandlestickValue(3250.10f, 3210.71f, 3233.66f, 3248.45f, 1692322131L - 86400),
|
||||
CandlestickValue(3285.47f, 3269.65f, 3277.18f, 3281.87f, 1692322131L),
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package cn.jingzhuan.lib.chart2.demo.chart3.chart
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import cn.jingzhuan.lib.chart3.formatter.IValueFormatter
|
||||
import cn.jingzhuan.lib.chart3.widget.MinuteChartView
|
||||
|
||||
|
||||
class MainCallAuctionChartView(ctx: Context, attrs: AttributeSet?) : MinuteChartView(ctx, attrs) {
|
||||
|
||||
init {
|
||||
minVisibleEntryCount = 600
|
||||
maxVisibleEntryCount = 600
|
||||
|
||||
isEnableHighlightLeftText = false
|
||||
|
||||
axisLeft.apply {
|
||||
isLabelEnable = false
|
||||
gridCount = 3
|
||||
enableGridDashPathEffect(floatArrayOf(10f, 10f), 8f)
|
||||
}
|
||||
axisRight.apply {
|
||||
isLabelEnable = false
|
||||
gridCount = 1
|
||||
}
|
||||
|
||||
axisTop.apply {
|
||||
isLabelEnable = false
|
||||
isGridLineEnable = false
|
||||
}
|
||||
axisBottom.apply {
|
||||
isGridLineEnable = false
|
||||
gridCount = 1
|
||||
labelValueFormatter = object : IValueFormatter {
|
||||
override fun format(value: Float, index: Int): String {
|
||||
return when (index) {
|
||||
0 -> "09:15-25"
|
||||
else -> ""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package cn.jingzhuan.lib.chart2.demo.chart3.chart
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.BitmapFactory
|
||||
import android.util.AttributeSet
|
||||
import androidx.core.content.ContextCompat
|
||||
import cn.jingzhuan.lib.chart.R
|
||||
import cn.jingzhuan.lib.chart3.widget.KlineChartView
|
||||
|
||||
class MainKlineChartView(ctx: Context, attrs: AttributeSet?) : KlineChartView(ctx, attrs) {
|
||||
|
||||
override fun initChart() {
|
||||
super.initChart()
|
||||
highlightThickness = 4
|
||||
highlightColor = ContextCompat.getColor(
|
||||
context,
|
||||
android.R.color.holo_red_dark
|
||||
)
|
||||
highlightTextColor = ContextCompat.getColor(
|
||||
context,
|
||||
android.R.color.white
|
||||
)
|
||||
highlightTextSize = 28
|
||||
|
||||
setRangeTouchBitmap(BitmapFactory.decodeResource(context.resources, R.drawable.ico_red_dot), BitmapFactory.decodeResource(context.resources, R.drawable.ico_red_dot))
|
||||
setShowRangeLinen(true)
|
||||
setRangeHedgeWhole(true)
|
||||
setRangeMaxDiffEntry(5)
|
||||
|
||||
}
|
||||
init {
|
||||
currentVisibleEntryCount = 250
|
||||
decimalDigitsNumber = 3
|
||||
axisRight.gridCount = 0
|
||||
axisLeft.isGridSlidIndex = 2
|
||||
showScaleMin = true
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package cn.jingzhuan.lib.chart2.demo.chart3.chart
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import cn.jingzhuan.lib.chart3.widget.MinuteChartView
|
||||
|
||||
class MainMinuteChartView(ctx: Context, attrs: AttributeSet?) : MinuteChartView(ctx, attrs) {
|
||||
|
||||
init {
|
||||
maxVisibleEntryCount = 242
|
||||
minVisibleEntryCount = 242
|
||||
decimalDigitsNumber = 2
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package cn.jingzhuan.lib.chart2.demo.chart3.chart
|
||||
|
||||
import cn.jingzhuan.lib.chart3.Highlight
|
||||
|
||||
interface OnSubChartTouchListener {
|
||||
|
||||
fun touchHighlight(highlight: Highlight, x: Float, y: Float)
|
||||
|
||||
fun checkIfClickToSwitch()
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package cn.jingzhuan.lib.chart2.demo.chart3.chart
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import cn.jingzhuan.lib.chart3.Highlight
|
||||
import cn.jingzhuan.lib.chart3.event.OnTouchPointListener
|
||||
import cn.jingzhuan.lib.chart3.utils.ChartConstant.HIGHLIGHT_STATUS_FOREVER
|
||||
import cn.jingzhuan.lib.chart3.utils.ChartConstant.HIGHLIGHT_STATUS_INITIAL
|
||||
import cn.jingzhuan.lib.chart3.widget.KlineChartView
|
||||
import cn.jingzhuan.lib.chart3.widget.StaticChartView
|
||||
|
||||
class SubChartView(ctx: Context, attrs: AttributeSet?) : StaticChartView(ctx, attrs) {
|
||||
|
||||
private var mainChartView: KlineChartView? = null
|
||||
|
||||
private var subChartTouchListener : OnSubChartTouchListener? = null
|
||||
|
||||
init {
|
||||
currentVisibleEntryCount = 40
|
||||
decimalDigitsNumber = 2
|
||||
isEnableHighlightBottomText = false
|
||||
|
||||
axisLeft.labelValueFormatter = SubKlineLeftValueFormatter(decimalDigitsNumber)
|
||||
|
||||
val highlight = Highlight()
|
||||
addOnTouchPointListener(object : OnTouchPointListener {
|
||||
override fun touch(x: Float, y: Float) {
|
||||
val chartMain = mainChartView ?: return
|
||||
if (chartMain.isOpenRange) return
|
||||
// 如果历史分时已打开
|
||||
val mainHighlightState = chartMain.highlightState
|
||||
if (mainHighlightState == HIGHLIGHT_STATUS_FOREVER) {
|
||||
return
|
||||
}
|
||||
|
||||
// 如果此时正在长按 不往下处理
|
||||
if (isLongPress) {
|
||||
if (!chartMain.isHighlightEnable) return
|
||||
if (subChartTouchListener != null) {
|
||||
subChartTouchListener?.touchHighlight(highlight, x, y)
|
||||
}
|
||||
return
|
||||
}
|
||||
if (mainHighlightState != HIGHLIGHT_STATUS_INITIAL) {
|
||||
// 如果光标正在显示 清除
|
||||
chartMain.onHighlightClean()
|
||||
} else {
|
||||
// 光标未显示 判断是否可以切换指标
|
||||
if (subChartTouchListener != null) {
|
||||
subChartTouchListener?.checkIfClickToSwitch()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
fun addSubChartTouchListener(listener: OnSubChartTouchListener) {
|
||||
this.subChartTouchListener = listener
|
||||
}
|
||||
|
||||
fun relatedMainChart(chartView: KlineChartView) {
|
||||
this.mainChartView = chartView
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package cn.jingzhuan.lib.chart2.demo.chart3.chart
|
||||
|
||||
import cn.jingzhuan.lib.chart3.formatter.IValueFormatter
|
||||
import cn.jingzhuan.lib.chart3.utils.NumberUtils
|
||||
|
||||
class SubKlineLeftValueFormatter(private val decimalDigitsNumber: Int) : IValueFormatter {
|
||||
|
||||
override fun format(value: Float, index: Int): String {
|
||||
return if (index == 1 || value.isNaN() || value > Int.MAX_VALUE || value < Int.MIN_VALUE) ""
|
||||
else NumberUtils.keepPrecision("$value", decimalDigitsNumber)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
|
||||
|
||||
package cn.jingzhuan.lib.chart2.demo;
|
||||
|
||||
import com.airbnb.epoxy.EpoxyDataBindingLayouts;
|
||||
import com.airbnb.epoxy.PackageModelViewConfig;
|
||||
|
||||
@EpoxyDataBindingLayouts({
|
||||
R.layout.layout_desc_text,
|
||||
})
|
||||
@PackageModelViewConfig(
|
||||
rClass = R.class
|
||||
)
|
||||
interface EpoxyDataBindingConfig {
|
||||
}
|
||||
|
After Width: | Height: | Size: 767 B |
|
After Width: | Height: | Size: 495 B |
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
|
||||
<item android:state_checked="true">
|
||||
<layer-list>
|
||||
<item>
|
||||
<shape>
|
||||
<stroke android:width="1dp" android:color="#FD263F" />
|
||||
<solid android:color="#FD263F" />
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
||||
</item>
|
||||
|
||||
|
||||
<item android:state_checked="false">
|
||||
<layer-list>
|
||||
<item>
|
||||
<shape>
|
||||
<stroke android:width="1dp" android:color="#FD263F" />
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
||||
|
||||
</item>
|
||||
|
||||
|
||||
|
||||
</selector>
|
||||
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
|
||||
<item android:state_checked="true">
|
||||
<layer-list>
|
||||
<item>
|
||||
<shape>
|
||||
<corners android:bottomLeftRadius="2dp" android:topLeftRadius="2dp" />
|
||||
<solid android:color="#FD263F" />
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
||||
</item>
|
||||
|
||||
|
||||
<item android:state_checked="false">
|
||||
<layer-list>
|
||||
<item>
|
||||
<shape>
|
||||
<corners android:bottomLeftRadius="2dp" android:topLeftRadius="2dp" />
|
||||
<stroke android:width="1dp" android:color="#FD263F" />
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
||||
|
||||
</item>
|
||||
|
||||
</selector>
|
||||
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
|
||||
<item android:state_checked="true">
|
||||
<layer-list>
|
||||
<item>
|
||||
<shape>
|
||||
<corners android:bottomRightRadius="2dp" android:topRightRadius="2dp" />
|
||||
<stroke android:width="1dp" android:color="#FD263F" />
|
||||
<solid android:color="#FD263F" />
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
||||
</item>
|
||||
|
||||
|
||||
<item android:state_checked="false">
|
||||
<layer-list>
|
||||
<item>
|
||||
<shape>
|
||||
<corners android:bottomRightRadius="2dp" android:topRightRadius="2dp" />
|
||||
<stroke android:width="1dp" android:color="#FD263F" />
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
||||
|
||||
</item>
|
||||
|
||||
|
||||
|
||||
</selector>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<solid android:color="#FD263F" />
|
||||
<corners android:radius="2dp" />
|
||||
</shape>
|
||||
@@ -0,0 +1,113 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportHeight="108.0"
|
||||
android:viewportWidth="108.0">
|
||||
<path
|
||||
android:fillColor="#26A69A"
|
||||
android:pathData="M0,0h108v108h-108z"
|
||||
android:strokeColor="#66FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,0L19,108"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M9,0L9,108"
|
||||
android:strokeColor="#66FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,0L39,108"
|
||||
android:strokeColor="#66FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,0L29,108"
|
||||
android:strokeColor="#66FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,0L59,108"
|
||||
android:strokeColor="#66FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,0L49,108"
|
||||
android:strokeColor="#66FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,0L79,108"
|
||||
android:strokeColor="#66FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,0L69,108"
|
||||
android:strokeColor="#66FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M89,0L89,108"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M99,0L99,108"
|
||||
android:strokeColor="#66FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,89L108,89"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,99L108,99"
|
||||
android:strokeColor="#66FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,69L108,69"
|
||||
android:strokeColor="#66FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,79L108,79"
|
||||
android:strokeColor="#66FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,49L108,49"
|
||||
android:strokeColor="#66FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,59L108,59"
|
||||
android:strokeColor="#66FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,29L108,29"
|
||||
android:strokeColor="#66FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,39L108,39"
|
||||
android:strokeColor="#66FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,19L108,19"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,9L108,9"
|
||||
android:strokeColor="#66FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
</vector>
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval">
|
||||
|
||||
<solid android:color="@color/colorPrimary" />
|
||||
|
||||
<size android:width="64dp" android:height="64dp" />
|
||||
|
||||
</shape>
|
||||
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:color="#FD263F" android:state_pressed="true" />
|
||||
<item android:color="#FD263F" android:state_selected="true"/>
|
||||
<item android:color="#FD263F" android:state_checked="false"/>
|
||||
<item android:color="#FFFFFF" />
|
||||
|
||||
</selector>
|
||||
@@ -0,0 +1,541 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/top_option"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:paddingStart="10dp"
|
||||
android:paddingEnd="10dp"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<RadioGroup
|
||||
android:id="@+id/rg"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="32dp"
|
||||
android:layout_gravity="center"
|
||||
android:checkedButton="@id/rb_day"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rb_day"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/bg_rb_red_left"
|
||||
android:button="@null"
|
||||
android:gravity="center"
|
||||
android:text="日K"
|
||||
android:textColor="@drawable/text_rb_red"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rb_year"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/bg_rb_red_center"
|
||||
android:button="@null"
|
||||
android:gravity="center"
|
||||
android:text="年K"
|
||||
android:textColor="@drawable/text_rb_red"
|
||||
android:layout_marginStart="-1dp"
|
||||
android:layout_marginEnd="-1dp"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rb_minute"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/bg_rb_red_center"
|
||||
android:button="@null"
|
||||
android:gravity="center"
|
||||
android:text="分时"
|
||||
android:textColor="@drawable/text_rb_red"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rb_callAuction"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/bg_rb_red_right"
|
||||
android:button="@null"
|
||||
android:gravity="center"
|
||||
android:text="集合竞价"
|
||||
android:textColor="@drawable/text_rb_red"
|
||||
android:layout_marginStart="-1dp"
|
||||
android:textSize="14sp" />
|
||||
</RadioGroup>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_info"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="25dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/top_option">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_info"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:textColor="@android:color/holo_orange_dark"
|
||||
tools:text="开:3888.00 高:3888.00 低:3888.00 收:3888.00"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<cn.jingzhuan.lib.chart3.widget.KlineTimeRangeView
|
||||
android:id="@+id/time_range_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="20dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
app:textColor="#A1ABBB"
|
||||
app:textSize="12sp"
|
||||
app:textBackgroundColor="#FD263F"
|
||||
app:textBackgroundRadius="2dp"
|
||||
app:lineColor="#ffe5e5e5"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/top_option" />
|
||||
|
||||
<cn.jingzhuan.lib.chart2.demo.chart3.chart.MainKlineChartView
|
||||
android:id="@+id/kline_main"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="200dp"
|
||||
android:layout_marginTop="2dp"
|
||||
app:axisColor="#ffe5e5e5"
|
||||
app:axisThickness="0.5dp"
|
||||
app:backgroundColor="#F7F7F7"
|
||||
app:gridColor="#ffe5e5e5"
|
||||
app:labelTextColor="#A1ABBB"
|
||||
app:labelTextSize="11dp"
|
||||
app:bottomLabelHeight="18dp"
|
||||
app:showWaterMark="true"
|
||||
app:showMaxMinValue="true"
|
||||
app:maxMinValueTextSize="11dp"
|
||||
app:maxMinValueTextColor="#A1ABBB"
|
||||
app:lastPriceLineColor="#950BFF"
|
||||
app:layout_constraintLeft_toLeftOf="@+id/ll_info"
|
||||
app:layout_constraintRight_toRightOf="@+id/ll_info"
|
||||
app:layout_constraintTop_toBottomOf="@+id/ll_info"/>
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_kline_op"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:layout_marginBottom="25dp"
|
||||
app:layout_constraintLeft_toLeftOf="@+id/kline_main"
|
||||
app:layout_constraintBottom_toBottomOf="@id/kline_main">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_zoom_in"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="10dp"
|
||||
android:text="放大"
|
||||
android:textSize="12sp"
|
||||
android:textColor="@android:color/holo_blue_dark"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_zoom_out"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="10dp"
|
||||
android:text="缩小"
|
||||
android:textSize="12sp"
|
||||
android:textColor="@color/colorAccent"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_range"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="10dp"
|
||||
android:text="区间统计"
|
||||
android:textSize="12sp"
|
||||
android:textColor="@color/colorPrimary"/>
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_full"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="10dp"
|
||||
android:text="全屏"
|
||||
android:textSize="12sp"
|
||||
android:textColor="@color/colorPrimary"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_price_line"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="10dp"
|
||||
android:text="现价线"
|
||||
android:textSize="12sp"
|
||||
android:textColor="@color/colorPrimary"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<cn.jingzhuan.lib.chart2.demo.chart3.chart.MainMinuteChartView
|
||||
android:id="@+id/minute_main"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="200dp"
|
||||
android:layout_marginTop="10dp"
|
||||
app:axisColor="#ffe5e5e5"
|
||||
app:axisThickness="0.5dp"
|
||||
app:gridColor="#ffe5e5e5"
|
||||
app:labelTextColor="#A1ABBB"
|
||||
app:labelTextSize="11dp"
|
||||
app:bottomLabelHeight="18dp"
|
||||
app:layout_constraintLeft_toLeftOf="@+id/ll_info"
|
||||
app:layout_constraintRight_toRightOf="@+id/ll_info"
|
||||
app:layout_constraintTop_toBottomOf="@+id/ll_info"
|
||||
android:visibility="gone" />
|
||||
|
||||
<cn.jingzhuan.lib.chart2.demo.chart3.chart.MainCallAuctionChartView
|
||||
android:id="@+id/call_auction_main"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="200dp"
|
||||
android:layout_marginTop="10dp"
|
||||
app:axisColor="#ffe5e5e5"
|
||||
app:axisThickness="0.5dp"
|
||||
app:gridColor="#ffe5e5e5"
|
||||
app:labelTextColor="#A1ABBB"
|
||||
app:labelTextSize="11dp"
|
||||
app:bottomLabelHeight="18dp"
|
||||
app:layout_constraintLeft_toLeftOf="@+id/ll_info"
|
||||
app:layout_constraintRight_toRightOf="@+id/ll_info"
|
||||
app:layout_constraintTop_toBottomOf="@+id/ll_info"
|
||||
android:visibility="gone" />
|
||||
|
||||
|
||||
<cn.jingzhuan.lib.chart2.demo.chart3.chart.SubChartView
|
||||
android:id="@+id/kline_sub1"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="100dp"
|
||||
android:layout_marginTop="5dp"
|
||||
app:axisColor="#ffe5e5e5"
|
||||
app:axisThickness="0.5dp"
|
||||
app:gridColor="#ffe5e5e5"
|
||||
app:labelTextColor="#A1ABBB"
|
||||
app:labelTextSize="11dp"
|
||||
app:layout_constraintLeft_toLeftOf="@+id/kline_main"
|
||||
app:layout_constraintRight_toRightOf="@+id/kline_main"
|
||||
app:layout_constraintTop_toBottomOf="@+id/kline_main"/>
|
||||
|
||||
<cn.jingzhuan.lib.chart2.demo.chart3.chart.SubChartView
|
||||
android:id="@+id/kline_sub2"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="100dp"
|
||||
android:layout_marginTop="5dp"
|
||||
app:axisColor="#ffe5e5e5"
|
||||
app:axisThickness="0.5dp"
|
||||
app:gridColor="#ffe5e5e5"
|
||||
app:labelTextColor="#A1ABBB"
|
||||
app:labelTextSize="11dp"
|
||||
app:layout_constraintLeft_toLeftOf="@+id/kline_main"
|
||||
app:layout_constraintRight_toRightOf="@+id/kline_main"
|
||||
app:layout_constraintTop_toBottomOf="@+id/kline_sub1"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_history"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="350dp"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
android:background="@android:color/holo_blue_dark"
|
||||
android:visibility="gone">
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_draw_line"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="10dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:text="画线"
|
||||
android:textSize="12sp"
|
||||
android:textColor="@color/colorPrimary"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/top_option"/>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/ll_draw_line_tool"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="350dp"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
android:background="@android:color/darker_gray"
|
||||
android:visibility="gone">
|
||||
<TextView
|
||||
android:id="@+id/tv_draw_segment"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="10dp"
|
||||
android:text="画线段"
|
||||
android:textSize="12sp"
|
||||
android:textColor="@android:color/white"
|
||||
android:background="@color/colorPrimary"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginStart="10dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_draw_straight"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="10dp"
|
||||
android:text="画直线"
|
||||
android:textSize="12sp"
|
||||
android:textColor="@android:color/white"
|
||||
android:background="@color/colorPrimary"
|
||||
app:layout_constraintLeft_toRightOf="@+id/tv_draw_segment"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginStart="10dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_draw_end_anchor"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="10dp"
|
||||
android:text="画箭头线段"
|
||||
android:textSize="12sp"
|
||||
android:textColor="@android:color/white"
|
||||
android:background="@color/colorPrimary"
|
||||
app:layout_constraintLeft_toRightOf="@+id/tv_draw_straight"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginStart="10dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_draw_rect"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="10dp"
|
||||
android:text="画矩形"
|
||||
android:textSize="12sp"
|
||||
android:textColor="@android:color/white"
|
||||
android:background="@color/colorPrimary"
|
||||
app:layout_constraintLeft_toRightOf="@+id/tv_draw_end_anchor"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginStart="10dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_draw_hjfg"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="10dp"
|
||||
android:text="画黄金分割"
|
||||
android:textSize="12sp"
|
||||
android:textColor="@android:color/white"
|
||||
android:background="@color/colorPrimary"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tv_draw_segment"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginStart="10dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_draw_fbnc"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="10dp"
|
||||
android:text="画斐波那挈线"
|
||||
android:textSize="12sp"
|
||||
android:textColor="@android:color/white"
|
||||
android:background="@color/colorPrimary"
|
||||
app:layout_constraintLeft_toRightOf="@+id/tv_draw_hjfg"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tv_draw_segment"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginStart="10dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_draw_horizon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="10dp"
|
||||
android:text="画水平线"
|
||||
android:textSize="12sp"
|
||||
android:textColor="@android:color/white"
|
||||
android:background="@color/colorPrimary"
|
||||
app:layout_constraintLeft_toRightOf="@+id/tv_draw_fbnc"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tv_draw_segment"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginStart="10dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_draw_vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="10dp"
|
||||
android:text="画垂直线"
|
||||
android:textSize="12sp"
|
||||
android:textColor="@android:color/white"
|
||||
android:background="@color/colorPrimary"
|
||||
app:layout_constraintLeft_toRightOf="@+id/tv_draw_horizon"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tv_draw_segment"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginStart="10dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_draw_ray"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="10dp"
|
||||
android:text="画射线"
|
||||
android:textSize="12sp"
|
||||
android:textColor="@android:color/white"
|
||||
android:background="@color/colorPrimary"
|
||||
app:layout_constraintLeft_toRightOf="@+id/tv_draw_vertical"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tv_draw_segment"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginStart="10dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_draw_price_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="10dp"
|
||||
android:text="价格标注"
|
||||
android:textSize="12sp"
|
||||
android:textColor="@android:color/white"
|
||||
android:background="@color/colorPrimary"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tv_draw_hjfg"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginStart="10dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_draw_font"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="10dp"
|
||||
android:text="文字标注"
|
||||
android:textSize="12sp"
|
||||
android:textColor="@android:color/white"
|
||||
android:background="@color/colorPrimary"
|
||||
app:layout_constraintLeft_toRightOf="@+id/tv_draw_price_label"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tv_draw_hjfg"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginStart="10dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_draw_parallel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="10dp"
|
||||
android:text="画平行线"
|
||||
android:textSize="12sp"
|
||||
android:textColor="@android:color/white"
|
||||
android:background="@color/colorPrimary"
|
||||
app:layout_constraintLeft_toRightOf="@+id/tv_draw_rect"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginStart="10dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_adsorb"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="10dp"
|
||||
android:text="吸附"
|
||||
android:textSize="12sp"
|
||||
android:textColor="@android:color/holo_green_dark"
|
||||
app:layout_constraintLeft_toLeftOf="@+id/tv_delete"
|
||||
app:layout_constraintRight_toRightOf="@+id/tv_delete"
|
||||
app:layout_constraintBottom_toTopOf="@+id/tv_revoke"
|
||||
android:layout_marginBottom="20dp"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_revoke"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="10dp"
|
||||
android:text="撤销"
|
||||
android:textSize="12sp"
|
||||
android:textColor="@android:color/white"
|
||||
android:background="@color/colorPrimary"
|
||||
app:layout_constraintLeft_toLeftOf="@+id/tv_delete"
|
||||
app:layout_constraintRight_toRightOf="@+id/tv_delete"
|
||||
app:layout_constraintBottom_toTopOf="@+id/tv_delete"
|
||||
android:layout_marginBottom="20dp"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_delete"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="10dp"
|
||||
android:text="删除"
|
||||
android:textSize="12sp"
|
||||
android:textColor="@android:color/white"
|
||||
android:background="@color/colorPrimary"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:layout_marginEnd="10dp"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_step"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
tools:text="请点击放置起点 0/2"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="14sp"
|
||||
android:paddingStart="12dp"
|
||||
android:paddingEnd="12dp"
|
||||
android:paddingTop="5dp"
|
||||
android:paddingBottom="5dp"
|
||||
android:layout_marginTop="60dp"
|
||||
android:background="#181818"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:visibility="gone"
|
||||
/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_cap"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="80dp"
|
||||
android:padding="1dp"
|
||||
android:background="@drawable/bg_rb_red_center"
|
||||
android:scaleType="fitCenter"
|
||||
android:visibility="gone"/>
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/recyclerView"
|
||||
android:paddingLeft="12dp"
|
||||
android:paddingRight="12dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
tools:context="cn.jingzhuan.lib.chart2.demo.MainActivity" />
|
||||
@@ -0,0 +1,148 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
tools:context=".RangeDemoActivity">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatButton
|
||||
android:id="@+id/btn_range"
|
||||
android:text="区间统计"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatButton
|
||||
android:id="@+id/btn_add_tag"
|
||||
android:text="添加文本标记"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatButton
|
||||
android:id="@+id/btn_scale_in"
|
||||
android:text="放大"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatButton
|
||||
android:id="@+id/btn_scale_out"
|
||||
android:text="缩小"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatButton
|
||||
android:id="@+id/btn_highlight_always"
|
||||
android:text="光标常驻"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
<androidx.appcompat.widget.AppCompatButton
|
||||
android:id="@+id/btn_move_left"
|
||||
android:text="左移"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatButton
|
||||
android:id="@+id/btn_move_right"
|
||||
android:text="右移"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatButton
|
||||
android:id="@+id/btn_touch_point"
|
||||
android:text="touchPoint"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="30dp"
|
||||
android:paddingStart="10dp"
|
||||
android:paddingEnd="10dp">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_range_info"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:paddingStart="10dp"
|
||||
android:paddingEnd="10dp"
|
||||
android:orientation="horizontal"
|
||||
android:visibility="invisible">
|
||||
<TextView
|
||||
android:id="@+id/tv_info"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="开:-- 高:-- 收:-- 低--"
|
||||
android:textColor="@color/colorAccent"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_open"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="区间统计"
|
||||
android:textColor="@android:color/black"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_number"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="周期数:--"
|
||||
android:textColor="@android:color/black"
|
||||
android:visibility="gone"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<cn.jingzhuan.lib.chart2.demo.TestChartKLineView
|
||||
android:id="@+id/combine_chart"
|
||||
android:layout_height="200dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_marginTop="10dp"
|
||||
app:backgroundColor="#F7F7F7"
|
||||
app:axisColor="#ffe5e5e5"
|
||||
app:axisThickness="0.5dp"
|
||||
app:gridColor="#ffe5e5e5"
|
||||
app:labelTextColor="#A1ABBB"
|
||||
app:labelTextSize="11dp"
|
||||
app:layout_constraintTop_toBottomOf="@+id/ll_range_info"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_close_range"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="关闭"
|
||||
android:background="@drawable/bg_red_close_range"
|
||||
android:textSize="11dp"
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingRight="8dp"
|
||||
android:visibility="gone"
|
||||
android:textColor="@android:color/white"
|
||||
app:layout_constraintLeft_toLeftOf="@id/combine_chart"
|
||||
app:layout_constraintBottom_toBottomOf="@id/combine_chart"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout>
|
||||
|
||||
<cn.jingzhuan.lib.chart2.widget.BarChart
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:id="@+id/barChart"
|
||||
android:layout_height="200dp" />
|
||||
|
||||
</layout>
|
||||
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="200dp"
|
||||
>
|
||||
|
||||
<cn.jingzhuan.lib.chart2.widget.BarChart
|
||||
android:id="@+id/barChart"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</layout>
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
>
|
||||
|
||||
<cn.jingzhuan.lib.chart2.widget.CombineChart
|
||||
android:id="@+id/combine_chart"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="400dp" />
|
||||
|
||||
</layout>
|
||||
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatButton
|
||||
android:id="@+id/btn_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
tools:text="区间统计" />
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</layout>
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
>
|
||||
<data>
|
||||
<variable name="text" type="String" />
|
||||
</data>
|
||||
|
||||
<TextView
|
||||
android:padding="12dp"
|
||||
android:text="@{text}"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</layout>
|
||||
@@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
tools:ignore="HardcodedText"
|
||||
>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
>
|
||||
<cn.jingzhuan.lib.chart2.widget.LineChart
|
||||
app:labelSeparation="4dp"
|
||||
android:id="@+id/lineChart"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="200dp" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
>
|
||||
|
||||
<Button
|
||||
style="?android:attr/buttonBarButtonStyle"
|
||||
android:id="@+id/bt_move_left"
|
||||
android:text="move left"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
<Button
|
||||
style="?android:attr/buttonBarButtonStyle"
|
||||
android:id="@+id/bt_move_right"
|
||||
android:text="move right"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
</layout>
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
>
|
||||
|
||||
<cn.jingzhuan.lib.chart2.widget.LineChart
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:id="@+id/minute_chart"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="200dp" />
|
||||
|
||||
</layout>
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<layout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
>
|
||||
|
||||
<cn.jingzhuan.lib.chart2.widget.CombineChart
|
||||
android:id="@+id/combine_chart"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="160dp" />
|
||||
|
||||
</layout>
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
>
|
||||
<androidx.viewpager.widget.ViewPager
|
||||
android:id="@+id/view_pager"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="240dp" />
|
||||
|
||||
</layout>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background" />
|
||||
<foreground android:drawable="@mipmap/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background" />
|
||||
<foreground android:drawable="@mipmap/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
||||
|
After Width: | Height: | Size: 3.3 KiB |
|
After Width: | Height: | Size: 5.0 KiB |
|
After Width: | Height: | Size: 5.0 KiB |
|
After Width: | Height: | Size: 2.3 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 4.5 KiB |
|
After Width: | Height: | Size: 6.8 KiB |
|
After Width: | Height: | Size: 7.2 KiB |
|
After Width: | Height: | Size: 6.8 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 9.2 KiB |
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 16 KiB |
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="colorPrimary">#3F51B5</color>
|
||||
<color name="colorPrimaryDark">#303F9F</color>
|
||||
<color name="colorAccent">#FF4081</color>
|
||||
</resources>
|
||||
@@ -0,0 +1,3 @@
|
||||
<resources>
|
||||
<string name="app_name">JingZhuanChart</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,11 @@
|
||||
<resources>
|
||||
|
||||
<!-- Base application theme. -->
|
||||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
@@ -0,0 +1,17 @@
|
||||
package cn.jingzhuan.lib.chart.demo;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
public class ExampleUnitTest {
|
||||
@Test
|
||||
public void addition_isCorrect() throws Exception {
|
||||
assertEquals(4, 2 + 2);
|
||||
}
|
||||
}
|
||||