的
@@ -0,0 +1 @@
|
||||
/build
|
||||
@@ -0,0 +1,41 @@
|
||||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlin-kapt'
|
||||
|
||||
android {
|
||||
setLibDefaultConfig(android)
|
||||
defaultConfig {
|
||||
dataBinding {
|
||||
enabled true
|
||||
}
|
||||
applicationId "cn.jingzhuan.lib.chart.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.chart.demo'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||
implementation 'androidx.appcompat:appcompat:1.0.0'
|
||||
implementation 'androidx.recyclerview:recyclerview:1.0.0'
|
||||
testImplementation 'junit:junit:4.12'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||
implementation 'com.airbnb.android:epoxy:4.6.2'
|
||||
implementation 'com.airbnb.android:epoxy-databinding:4.6.2'
|
||||
// Add the annotation processor if you are using Epoxy's annotations (recommended)
|
||||
kapt 'com.airbnb.android:epoxy-processor:4.6.2'
|
||||
|
||||
implementation rootProject.ext.dependencies["kotlinStdlibJdk8"]
|
||||
|
||||
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,24 @@
|
||||
<?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="cn.jingzhuan.lib.chart.demo.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=".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,13 @@
|
||||
package cn.jingzhuan.lib.chart.demo;
|
||||
|
||||
import android.app.Application;
|
||||
|
||||
/**
|
||||
* Application
|
||||
* Created by donglua on 12/27/17.
|
||||
*/
|
||||
|
||||
public class App extends Application {
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package cn.jingzhuan.lib.chart.demo;
|
||||
|
||||
import androidx.databinding.ViewDataBinding;
|
||||
import android.graphics.Color;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Toast;
|
||||
import cn.jingzhuan.lib.chart.base.Chart;
|
||||
import cn.jingzhuan.lib.chart.data.BarDataSet;
|
||||
import cn.jingzhuan.lib.chart.data.BarValue;
|
||||
import cn.jingzhuan.lib.chart.demo.databinding.LayoutBarChartClickableItemBinding;
|
||||
import cn.jingzhuan.lib.chart.event.OnEntryClickListener;
|
||||
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);
|
||||
|
||||
barBinding.barChart.setOnEntryClickListener(new OnEntryClickListener() {
|
||||
@Override public void onEntryClick(Chart chart, int position) {
|
||||
Toast.makeText(parent.getContext(),
|
||||
"value = " + barValueList.get(position).getValues()[0],
|
||||
Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
return rootView;
|
||||
}
|
||||
|
||||
@Override protected void setDataBindingVariables(ViewDataBinding binding) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package cn.jingzhuan.lib.chart.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.chart.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))
|
||||
barValueList.add(BarValue(12f))
|
||||
barValueList.add(BarValue(13f).apply { setGradientColors(Color.WHITE, Color.BLACK) })
|
||||
barValueList.add(BarValue(15f).apply { setGradientColors(Color.WHITE, Color.BLACK) })
|
||||
|
||||
barDataSet = BarDataSet(barValueList)
|
||||
barDataSet.isAutoBarWidth = true
|
||||
}
|
||||
|
||||
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,166 @@
|
||||
package cn.jingzhuan.lib.chart.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.base.Chart;
|
||||
import cn.jingzhuan.lib.chart.data.CandlestickDataSet;
|
||||
import cn.jingzhuan.lib.chart.data.CandlestickValue;
|
||||
import cn.jingzhuan.lib.chart.demo.databinding.LayoutBarChartBinding;
|
||||
import cn.jingzhuan.lib.chart.demo.databinding.LayoutCombineChartBinding;
|
||||
import cn.jingzhuan.lib.chart.event.HighlightStatusChangeListener;
|
||||
import cn.jingzhuan.lib.chart.event.OnEntryClickListener;
|
||||
|
||||
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<>();
|
||||
@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));
|
||||
}
|
||||
|
||||
@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);
|
||||
|
||||
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.setOnClickListener(new View.OnClickListener() {
|
||||
@Override public void onClick(View v) {
|
||||
b.combineChart.setDraggingToMoveEnable(b.combineChart.isHighlightDisable());
|
||||
}
|
||||
});
|
||||
b.combineChart.setOnEntryClickListener(new OnEntryClickListener() {
|
||||
@Override public void onEntryClick(Chart chart, int position) {
|
||||
b.combineChart.setHighlightDisable(!b.combineChart.isHighlightDisable());
|
||||
b.combineChart.setDraggingToMoveEnable(b.combineChart.isHighlightDisable());
|
||||
}
|
||||
});
|
||||
return rootView;
|
||||
}
|
||||
|
||||
@Override protected void setDataBindingVariables(ViewDataBinding binding) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package cn.jingzhuan.lib.chart.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,104 @@
|
||||
package cn.jingzhuan.lib.chart.demo;
|
||||
|
||||
import androidx.databinding.ViewDataBinding;
|
||||
import android.graphics.Color;
|
||||
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
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.BarDataSet;
|
||||
import cn.jingzhuan.lib.chart.data.BarValue;
|
||||
import cn.jingzhuan.lib.chart.data.LineDataSet;
|
||||
import cn.jingzhuan.lib.chart.data.PointValue;
|
||||
import cn.jingzhuan.lib.chart.demo.databinding.LayoutCombineChartBinding;
|
||||
|
||||
/**
|
||||
* Created by Donglua on 17/8/3.
|
||||
*/
|
||||
@EpoxyModelClass(layout = R.layout.layout_combine_chart)
|
||||
public abstract class CombineChartModel extends DataBindingEpoxyModel {
|
||||
|
||||
private BarDataSet barDataSet;
|
||||
private LineDataSet line;
|
||||
|
||||
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));
|
||||
|
||||
barDataSet = new BarDataSet(barValueList, AxisY.DEPENDENCY_RIGHT);
|
||||
barDataSet.setAutoBarWidth(true);
|
||||
barDataSet.setColor(Color.DKGRAY);
|
||||
|
||||
|
||||
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);
|
||||
|
||||
return rootView;
|
||||
}
|
||||
|
||||
@Override protected void setDataBindingVariables(ViewDataBinding binding) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package cn.jingzhuan.lib.chart.demo;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.LayoutDirection;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.airbnb.epoxy.AutoModel;
|
||||
import com.airbnb.epoxy.EpoxyController;
|
||||
|
||||
/**
|
||||
* 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_;
|
||||
|
||||
private Context context;
|
||||
|
||||
public DemoAdapterController(Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void buildModels() {
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package cn.jingzhuan.lib.chart.demo;
|
||||
|
||||
import androidx.databinding.ViewDataBinding;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
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.chart.data.LineDataSet;
|
||||
import cn.jingzhuan.lib.chart.data.PointValue;
|
||||
import cn.jingzhuan.lib.chart.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;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@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.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.chart.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,150 @@
|
||||
package cn.jingzhuan.lib.chart.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.chart.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);
|
||||
|
||||
onClickListener.onClick(v);
|
||||
}
|
||||
});
|
||||
|
||||
minuteBinding.minuteChart.enableHighlightDashPathEffect(new float[] {10, 10}, 10);
|
||||
|
||||
return rootView;
|
||||
}
|
||||
|
||||
@Override protected void setDataBindingVariables(ViewDataBinding binding) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package cn.jingzhuan.lib.chart.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 android.widget.Toast;
|
||||
import cn.jingzhuan.lib.chart.base.Chart;
|
||||
import cn.jingzhuan.lib.chart.data.ScatterDataSet;
|
||||
import cn.jingzhuan.lib.chart.data.ScatterValue;
|
||||
import cn.jingzhuan.lib.chart.demo.databinding.LayoutScatterChartBinding;
|
||||
import cn.jingzhuan.lib.chart.event.OnEntryClickListener;
|
||||
import cn.jingzhuan.lib.chart.renderer.TextValueRenderer;
|
||||
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);
|
||||
|
||||
bd.combineChart.setOnEntryClickListener(new OnEntryClickListener() {
|
||||
@Override public void onEntryClick(Chart chart, int position) {
|
||||
if (position >= 0) {
|
||||
Toast.makeText(chart.getContext(), textList.get(position), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package cn.jingzhuan.lib.chart.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.chart.demo.databinding.LayoutBarChartBinding;
|
||||
import cn.jingzhuan.lib.chart.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,29 @@
|
||||
package cn.jingzhuan.lib.chart.demo;
|
||||
|
||||
import androidx.databinding.ViewDataBinding;
|
||||
import androidx.viewpager.widget.PagerAdapter;
|
||||
import cn.jingzhuan.lib.chart.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,13 @@
|
||||
|
||||
package cn.jingzhuan.lib.chart.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,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,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.chart.demo.MainActivity" />
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout>
|
||||
|
||||
<cn.jingzhuan.lib.chart.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.chart.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.chart.widget.CombineChart
|
||||
android:id="@+id/combine_chart"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="200dp" />
|
||||
|
||||
</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.chart.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,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
>
|
||||
|
||||
<cn.jingzhuan.lib.chart.widget.LineChart
|
||||
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.chart.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);
|
||||
}
|
||||
}
|
||||