├── .gitignore ├── README.MD ├── build.gradle ├── build.gradle2.png ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── mobile ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── db │ │ └── williamchartdemo │ │ ├── SandboxAnimationTest.java │ │ ├── SandboxAxisTest.java │ │ ├── SandboxBarTest.java │ │ ├── SandboxGridTest.java │ │ ├── SandboxLineTest.java │ │ └── SandboxStackTest.java │ └── main │ ├── AndroidManifest.xml │ ├── assets │ ├── OpenSans-Regular.ttf │ ├── OpenSans-Semibold.ttf │ ├── Ponsi-Regular.otf │ └── Roboto-Regular.ttf │ ├── java │ └── com │ │ └── db │ │ └── williamchartdemo │ │ ├── CardController.java │ │ ├── ChartsFragment.java │ │ ├── MainActivity.java │ │ ├── SandboxFragment.java │ │ ├── barchart │ │ ├── BarCardOne.java │ │ ├── BarCardThree.java │ │ └── BarCardTwo.java │ │ ├── linechart │ │ ├── LineCardOne.java │ │ ├── LineCardThree.java │ │ └── LineCardTwo.java │ │ └── stackedchart │ │ ├── StackedCardOne.java │ │ ├── StackedCardThree.java │ │ └── StackedCardTwo.java │ └── res │ ├── drawable-hdpi │ └── ic_launcher.png │ ├── drawable-mdpi │ └── ic_launcher.png │ ├── drawable-xhdpi │ └── ic_launcher.png │ ├── drawable-xxhdpi │ └── ic_launcher.png │ ├── drawable │ ├── alpha_high_btn.xml │ ├── alpha_low_btn.xml │ ├── alpha_medium_btn.xml │ ├── anim_start_btn.xml │ ├── axis_x_btn.xml │ ├── axis_y_btn.xml │ ├── bar_btn.xml │ ├── bar_corner1_bck.xml │ ├── bar_corner3_bck.xml │ ├── bar_corner4_bck.xml │ ├── brush_btn.xml │ ├── code_btn.xml │ ├── color_bck.xml │ ├── color_btn.xml │ ├── gradient_line_bck.xml │ ├── grid_full_bck.xml │ ├── grid_hor_bck.xml │ ├── grid_ver_bck.xml │ ├── ic_alpha_high_off.xml │ ├── ic_alpha_high_on.xml │ ├── ic_alpha_low_off.xml │ ├── ic_alpha_low_on.xml │ ├── ic_alpha_medium_off.xml │ ├── ic_alpha_medium_on.xml │ ├── ic_anim_start_off.xml │ ├── ic_anim_start_on.xml │ ├── ic_bar_off.xml │ ├── ic_bar_on.xml │ ├── ic_brush_off.xml │ ├── ic_brush_on.xml │ ├── ic_code.xml │ ├── ic_face.xml │ ├── ic_grade.xml │ ├── ic_line_off.xml │ ├── ic_line_on.xml │ ├── ic_play.xml │ ├── ic_play_grey_toolbar.xml │ ├── ic_play_toolbar.xml │ ├── ic_refresh.xml │ ├── ic_refresh_grey.xml │ ├── ic_smooth_off.xml │ ├── ic_smooth_on.xml │ ├── ic_stack_off.xml │ ├── ic_stack_on.xml │ ├── line_btn.xml │ ├── line_dashed2_bck.xml │ ├── line_dashed_bck.xml │ ├── line_solid_bck.xml │ ├── order_equal_bck.xml │ ├── order_first_bck.xml │ ├── order_last_bck.xml │ ├── order_middle_bck.xml │ ├── play_btn.xml │ ├── point_size2_bck.xml │ ├── point_size3_bck.xml │ ├── point_size4_bck.xml │ ├── rect_round_corners_bck.xml │ ├── round_bck.xml │ ├── round_bck_2.xml │ ├── smooth_btn.xml │ ├── stack_btn.xml │ ├── stacked_one_point1_bck.xml │ ├── stacked_one_point2_bck.xml │ ├── stacked_one_point3_bck.xml │ ├── standard_btn.xml │ ├── thickness_size1_bck.xml │ ├── thickness_size2_bck.xml │ └── thickness_size3_bck.xml │ ├── layout │ ├── card_toolbar.xml │ ├── card_toolbar_grey.xml │ ├── charts.xml │ ├── color_picker.xml │ ├── linechart_three_tooltip.xml │ ├── main.xml │ ├── sandbox.xml │ ├── sandbox_animation.xml │ ├── sandbox_axis.xml │ ├── sandbox_bar.xml │ ├── sandbox_chart.xml │ ├── sandbox_grid.xml │ ├── sandbox_line.xml │ ├── sandbox_play.xml │ ├── spinner_item.xml │ └── square_tooltip.xml │ ├── menu │ └── menu.xml │ └── values │ ├── colors.xml │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml ├── screenshot.gif ├── settings.gradle ├── simpledemp ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── db │ │ └── williamchart │ │ └── simpledemp │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── db │ │ │ └── williamchart │ │ │ └── simpledemp │ │ │ └── MainActivity.java │ └── res │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── db │ └── williamchart │ └── simpledemp │ └── ExampleUnitTest.java ├── wearable ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── db │ │ └── williamchartwear │ │ ├── BarFragment.java │ │ ├── ChartGridPagerAdapter.java │ │ ├── LineFragment.java │ │ ├── MainActivity.java │ │ └── StackedFragment.java │ └── res │ ├── drawable-hdpi │ └── ic_launcher.png │ ├── drawable-mdpi │ └── ic_launcher.png │ ├── drawable-xhdpi │ └── ic_launcher.png │ ├── drawable-xxhdpi │ └── ic_launcher.png │ ├── layout │ ├── activity_main.xml │ ├── fragment_bar.xml │ ├── fragment_line.xml │ └── fragment_stacked.xml │ ├── mipmap-hdpi │ └── ic_launcher.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ └── ic_launcher.png │ ├── mipmap-xxhdpi │ └── ic_launcher.png │ └── values │ └── strings.xml └── williamchart ├── build.gradle ├── gradle.properties ├── proguard-rules.pro └── src ├── main ├── AndroidManifest.xml ├── java │ └── com │ │ └── db │ │ └── chart │ │ ├── Tools.java │ │ ├── animation │ │ ├── Animation.java │ │ ├── ChartAnimationListener.java │ │ └── style │ │ │ ├── BaseStyleAnimation.java │ │ │ └── DashAnimation.java │ │ ├── listener │ │ ├── OnEntryClickListener.java │ │ └── OnTooltipEventListener.java │ │ ├── model │ │ ├── Bar.java │ │ ├── BarSet.java │ │ ├── ChartEntry.java │ │ ├── ChartSet.java │ │ ├── LineSet.java │ │ └── Point.java │ │ ├── renderer │ │ ├── AxisRenderer.java │ │ ├── XRenderer.java │ │ └── YRenderer.java │ │ ├── tooltip │ │ └── Tooltip.java │ │ └── view │ │ ├── BarChartView.java │ │ ├── BaseBarChartView.java │ │ ├── BaseStackBarChartView.java │ │ ├── ChartView.java │ │ ├── HorizontalBarChartView.java │ │ ├── HorizontalStackBarChartView.java │ │ ├── LineChartView.java │ │ └── StackBarChartView.java └── res │ └── values │ ├── attrs.xml │ └── dimens.xml └── test └── java └── com └── db └── chart ├── model ├── BarSetTest.java └── LineSetTest.java ├── renderer ├── AxisRendererTest.java ├── XRendererTest.java └── YRendererTest.java └── view └── ChartViewTest.java /.gitignore: -------------------------------------------------------------------------------- 1 | /local.properties 2 | /.idea/workspace.xml 3 | .DS_Store 4 | 5 | 6 | # Generated by http://gitignore.io 7 | 8 | ### Eclipse ### 9 | *.pydevproject 10 | .project 11 | .metadata 12 | bin/** 13 | tmp/** 14 | tmp/**/* 15 | *.tmp 16 | *.bak 17 | *.swp 18 | *~.nib 19 | local.properties 20 | .classpath 21 | .settings/ 22 | .loadpath 23 | 24 | # External tool builders 25 | .externalToolBuilders/ 26 | 27 | # Locally stored "Eclipse launch configurations" 28 | *.launch 29 | 30 | # CDT-specific 31 | .cproject 32 | 33 | # PDT-specific 34 | .buildpath 35 | 36 | ### IntelliJ ### 37 | *.iml 38 | *.ipr 39 | *.iws 40 | .idea/ 41 | 42 | ### Android ### 43 | # built application files 44 | *.apk 45 | *.ap_ 46 | 47 | # files for the dex VM 48 | *.dex 49 | 50 | # Java class files 51 | *.class 52 | 53 | # generated files 54 | bin/ 55 | gen/ 56 | 57 | # Proguard folder generated by Eclipse 58 | proguard/ 59 | 60 | # Proguard folder generated by Intellij 61 | proguard_logs/ 62 | 63 | adt-bundle-windows-x86_64/ 64 | 65 | ### Windows ### 66 | # Windows image file caches 67 | Thumbs.db 68 | ehthumbs.db 69 | 70 | # Folder config file 71 | Desktop.ini 72 | 73 | # Recycle Bin used on file shares 74 | $RECYCLE.BIN/ 75 | 76 | ### Linux ### 77 | .* 78 | !.gitignore 79 | *~ 80 | # Generated by http://gitignore.io 81 | 82 | ### Gradle ### 83 | # Exclude Folder List # 84 | .gradle/ 85 | build/ 86 | .gradletasknamecache 87 | 88 | javadoc/ 89 | 90 | ### Keystore file ### 91 | *.keystore 92 | 93 | ### Google Play API file ### 94 | *.p12 -------------------------------------------------------------------------------- /README.MD: -------------------------------------------------------------------------------- 1 | # WilliamChart项目使用 2 | 3 | 开源地址:[https://github.com/open-android/WilliamChart](https://github.com/open-android/WilliamChart "https://github.com/open-android/WilliamChart") 4 | 5 | # 运行效果 6 | 7 | ![](screenshot.gif) 8 | 9 | * 爱生活,爱学习,更爱做代码的搬运工,分类查找更方便请下载黑马助手app 10 | 11 | 12 | ![黑马助手.png](http://upload-images.jianshu.io/upload_images/4037105-f777f1214328dcc4.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 13 | 14 | ## 使用步骤 15 | 16 | ### 1. 在project的build.gradle添加如下代码(如下图) 17 | 18 | allprojects { 19 | repositories { 20 | maven { url "https://jitpack.io" } 21 | } 22 | } 23 | 24 | ![](build.gradle2.png) 25 | 26 | ### 2. 在Module的build.gradle添加依赖 27 | 28 | compile 'com.github.open-android:WilliamChart:v2.4.0' 29 | 30 | 31 | ### 3.布局文件使用 32 | 33 | 40 | 41 | ### 4.Activity初始化 42 | 43 | mChart = (LineChartView) findViewById(R.id.chart); 44 | 45 | LineSet dataset = new LineSet(mLabels, mValues[0]); 46 | //...省略部分代码,请参考mobile中事例 47 | mChart.addData(dataset);//设置数据 48 | 49 | 50 | mChart.show();//显示 51 | 52 | * 详细的使用方法在DEMO里面都演示啦,如果你觉得这个库还不错,请赏我一颗star吧~~~ 53 | 54 | * 欢迎关注微信公众号 55 | 56 | ![](http://upload-images.jianshu.io/upload_images/4037105-8f737b5104dd0b5d.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | jcenter() 4 | } 5 | dependencies { 6 | classpath 'com.android.tools.build:gradle:2.2.2' 7 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.1' 8 | classpath 'com.github.triplet.gradle:play-publisher:1.1.5' 9 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' 10 | } 11 | } 12 | 13 | allprojects { 14 | repositories { 15 | jcenter() 16 | } 17 | } 18 | 19 | task clean(type: Delete) { 20 | delete rootProject.buildDir 21 | } -------------------------------------------------------------------------------- /build.gradle2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/WilliamChart/b277e0d6ee82711862c667953deb1b9551fb266b/build.gradle2.png -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2014 SBG Apps 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | ANDROID_BUILD_MIN_SDK_VERSION=15 18 | ANDROID_BUILD_TARGET_SDK_VERSION=24 19 | ANDROID_BUILD_SDK_VERSION=24 20 | ANDROID_BUILD_TOOLS_VERSION=25.0.1 21 | 22 | BINTRAY_REPO = 'maven' 23 | BINTRAY_NAME = 'com.diogobernardino:williamchart' 24 | 25 | LIB_NAME = 'WilliamChart' 26 | LIB_ARTIFACT = 'williamchart' 27 | LIB_DESCRIPTION = 'Flexible charting library with nice motion effects.' 28 | WEBSITE = 'https://github.com/diogobernardino/WilliamChart' 29 | GIT_URL = 'https://github.com/diogobernardino/WilliamChart.git' 30 | 31 | DEV_ID = 'diogobernardino' 32 | DEV_NAME = 'Diogo Bernardino' 33 | DEV_MAIL = 'mail@diogobernardino.com' 34 | 35 | LICENSE_NAME = 'The Apache Software License, Version 2.0' 36 | LICENSE_URL = 'http://www.apache.org/licenses/LICENSE-2.0.txt' 37 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/WilliamChart/b277e0d6ee82711862c667953deb1b9551fb266b/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sat Jan 24 09:32:26 CET 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip 7 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /mobile/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'com.github.triplet.play' 3 | 4 | Properties properties = new Properties() 5 | properties.load(project.rootProject.file('local.properties').newDataInputStream()) 6 | 7 | android { 8 | compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION) 9 | buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION 10 | 11 | defaultConfig { 12 | minSdkVersion Integer.parseInt(project.ANDROID_BUILD_MIN_SDK_VERSION) 13 | targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION) 14 | versionName "2.4.0" 15 | versionCode 16 16 | applicationId "com.db.williamchartdemo" 17 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 18 | } 19 | signingConfigs { 20 | release { 21 | storeFile file("williamchart-release.keystore") 22 | storePassword properties.getProperty("apk.store_password") 23 | keyAlias "william" 24 | keyPassword properties.getProperty("apk.key_password") 25 | } 26 | } 27 | buildTypes { 28 | release { 29 | minifyEnabled false 30 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 31 | signingConfig signingConfigs.release 32 | } 33 | } 34 | } 35 | 36 | dependencies { 37 | compile project(':williamchart') 38 | compile 'com.android.support:appcompat-v7:25.1.0' 39 | compile 'com.android.support:design:25.1.0' 40 | compile 'com.android.support:cardview-v7:25.1.0' 41 | compile 'com.larswerkman:HoloColorPicker:1.5' 42 | androidTestCompile 'com.android.support:support-annotations:25.1.0' 43 | androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2' 44 | androidTestCompile 'com.android.support.test:runner:0.5' 45 | } 46 | 47 | play { 48 | serviceAccountEmail = '1034055180604-compute@developer.gserviceaccount.com' 49 | pk12File = file('williamchart.p12') 50 | track = 'alpha' 51 | } -------------------------------------------------------------------------------- /mobile/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/diogobernardino/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /mobile/src/androidTest/java/com/db/williamchartdemo/SandboxAnimationTest.java: -------------------------------------------------------------------------------- 1 | package com.db.williamchartdemo; 2 | 3 | import android.os.SystemClock; 4 | import android.support.test.filters.LargeTest; 5 | import android.support.test.rule.ActivityTestRule; 6 | import android.support.test.runner.AndroidJUnit4; 7 | 8 | import org.junit.Before; 9 | import org.junit.Rule; 10 | import org.junit.Test; 11 | import org.junit.runner.RunWith; 12 | 13 | import static android.support.test.espresso.Espresso.onData; 14 | import static android.support.test.espresso.Espresso.onView; 15 | import static android.support.test.espresso.action.ViewActions.click; 16 | import static android.support.test.espresso.action.ViewActions.swipeLeft; 17 | import static android.support.test.espresso.matcher.ViewMatchers.withId; 18 | import static org.hamcrest.Matchers.allOf; 19 | import static org.hamcrest.Matchers.instanceOf; 20 | import static org.hamcrest.Matchers.is; 21 | 22 | 23 | @RunWith(AndroidJUnit4.class) 24 | @LargeTest 25 | public class SandboxAnimationTest { 26 | 27 | @Rule 28 | public ActivityTestRule mActivityRule = new ActivityTestRule(MainActivity.class); 29 | 30 | private int mCurrTab; 31 | 32 | 33 | @Before 34 | public void setUp() { 35 | 36 | mCurrTab = 0; 37 | onView(withId(R.id.spinner)).perform(click()); 38 | onData(allOf(is(instanceOf(String.class)), is("sandbox"))).perform(click()); 39 | } 40 | 41 | 42 | @Test 43 | public void elasticEasingAnimation() { 44 | 45 | swipeLeftTo(4); 46 | onView(withId(R.id.sandbox_anim_easing_type)).perform(click()); 47 | onData(allOf(is(instanceOf(String.class)), is("Bounce"))).perform(click()); 48 | swipeLeftTo(5); 49 | onView(withId(R.id.sandbox_play_play)).perform(click()); 50 | } 51 | 52 | 53 | @Test 54 | public void durationAnimation() { 55 | 56 | swipeLeftTo(4); 57 | onView(withId(R.id.sandbox_anim_duration)).perform(click()); 58 | onData(allOf(is(instanceOf(String.class)), is("1500ms"))).perform(click()); 59 | swipeLeftTo(5); 60 | onView(withId(R.id.sandbox_play_play)).perform(click()); 61 | } 62 | 63 | 64 | @Test 65 | public void alphaAnimation() { 66 | 67 | swipeLeftTo(4); 68 | onView(withId(R.id.sandbox_anim_alpha)).perform(click()); 69 | swipeLeftTo(5); 70 | onView(withId(R.id.sandbox_play_play)).perform(click()); 71 | } 72 | 73 | 74 | @Test 75 | public void orderFirstAnimation() { 76 | 77 | swipeLeftTo(4); 78 | onView(withId(R.id.sandbox_anim_orderf)).perform(click()); 79 | swipeLeftTo(5); 80 | onView(withId(R.id.sandbox_play_play)).perform(click()); 81 | } 82 | 83 | 84 | @Test 85 | public void orderLastAnimation() { 86 | 87 | swipeLeftTo(4); 88 | onView(withId(R.id.sandbox_anim_orderl)).perform(click()); 89 | swipeLeftTo(5); 90 | onView(withId(R.id.sandbox_play_play)).perform(click()); 91 | } 92 | 93 | 94 | @Test 95 | public void orderCenterAnimation() { 96 | 97 | swipeLeftTo(4); 98 | onView(withId(R.id.sandbox_anim_orderm)).perform(click()); 99 | swipeLeftTo(5); 100 | onView(withId(R.id.sandbox_play_play)).perform(click()); 101 | } 102 | 103 | 104 | @Test 105 | public void enterTopLeftAnimation() { 106 | 107 | swipeLeftTo(4); 108 | onView(withId(R.id.sandbox_anim_entertl)).perform(click()); 109 | swipeLeftTo(5); 110 | onView(withId(R.id.sandbox_play_play)).perform(click()); 111 | } 112 | 113 | 114 | private void swipeLeftTo(int goal) { 115 | 116 | for (int i = mCurrTab; i < goal; i++) { 117 | onView(withId(R.id.pager)).perform(swipeLeft()); 118 | SystemClock.sleep(300); 119 | } 120 | mCurrTab = goal; 121 | SystemClock.sleep(300); 122 | } 123 | } -------------------------------------------------------------------------------- /mobile/src/androidTest/java/com/db/williamchartdemo/SandboxAxisTest.java: -------------------------------------------------------------------------------- 1 | package com.db.williamchartdemo; 2 | 3 | import android.os.SystemClock; 4 | import android.support.test.filters.LargeTest; 5 | import android.support.test.rule.ActivityTestRule; 6 | import android.support.test.runner.AndroidJUnit4; 7 | 8 | import org.junit.Before; 9 | import org.junit.Rule; 10 | import org.junit.Test; 11 | import org.junit.runner.RunWith; 12 | 13 | import static android.support.test.espresso.Espresso.onData; 14 | import static android.support.test.espresso.Espresso.onView; 15 | import static android.support.test.espresso.action.ViewActions.click; 16 | import static android.support.test.espresso.action.ViewActions.replaceText; 17 | import static android.support.test.espresso.action.ViewActions.swipeLeft; 18 | import static android.support.test.espresso.matcher.ViewMatchers.withId; 19 | import static org.hamcrest.Matchers.allOf; 20 | import static org.hamcrest.Matchers.instanceOf; 21 | import static org.hamcrest.Matchers.is; 22 | 23 | 24 | @RunWith(AndroidJUnit4.class) 25 | @LargeTest 26 | public class SandboxAxisTest { 27 | 28 | @Rule 29 | public ActivityTestRule mActivityRule = new ActivityTestRule(MainActivity.class); 30 | 31 | private int mCurrTab; 32 | 33 | 34 | @Before 35 | public void setUp() { 36 | 37 | mCurrTab = 0; 38 | onView(withId(R.id.spinner)).perform(click()); 39 | onData(allOf(is(instanceOf(String.class)), is("sandbox"))).perform(click()); 40 | } 41 | 42 | 43 | @Test 44 | public void noYLabels() { 45 | 46 | swipeLeftTo(1); 47 | onView(withId(R.id.sandbox_axis_y_outside)).perform(click()); 48 | swipeLeftTo(5); 49 | onView(withId(R.id.sandbox_play_play)).perform(click()); 50 | } 51 | 52 | 53 | @Test 54 | public void insideYLabels() { 55 | 56 | swipeLeftTo(1); 57 | onView(withId(R.id.sandbox_axis_y_inside)).perform(click()); 58 | swipeLeftTo(5); 59 | onView(withId(R.id.sandbox_play_play)).perform(click()); 60 | } 61 | 62 | 63 | @Test 64 | public void noYAxis() { 65 | 66 | swipeLeftTo(1); 67 | onView(withId(R.id.sandbox_axis_y)).perform(click()); 68 | swipeLeftTo(5); 69 | onView(withId(R.id.sandbox_play_play)).perform(click()); 70 | } 71 | 72 | 73 | @Test 74 | public void noYAxisNoYLabels() { 75 | 76 | swipeLeftTo(1); 77 | onView(withId(R.id.sandbox_axis_y)).perform(click()); 78 | onView(withId(R.id.sandbox_axis_y_outside)).perform(click()); 79 | swipeLeftTo(5); 80 | onView(withId(R.id.sandbox_play_play)).perform(click()); 81 | } 82 | 83 | 84 | @Test 85 | public void noXLabels() { 86 | 87 | swipeLeftTo(1); 88 | onView(withId(R.id.sandbox_axis_x_outside)).perform(click()); 89 | swipeLeftTo(5); 90 | onView(withId(R.id.sandbox_play_play)).perform(click()); 91 | } 92 | 93 | 94 | @Test 95 | public void insideXLabels() { 96 | 97 | swipeLeftTo(1); 98 | onView(withId(R.id.sandbox_axis_x_inside)).perform(click()); 99 | swipeLeftTo(5); 100 | onView(withId(R.id.sandbox_play_play)).perform(click()); 101 | } 102 | 103 | 104 | @Test 105 | public void noXAxis() { 106 | 107 | swipeLeftTo(1); 108 | onView(withId(R.id.sandbox_axis_x)).perform(click()); 109 | swipeLeftTo(5); 110 | onView(withId(R.id.sandbox_play_play)).perform(click()); 111 | } 112 | 113 | 114 | @Test 115 | public void noXAxisNoXLabels() { 116 | 117 | swipeLeftTo(1); 118 | onView(withId(R.id.sandbox_axis_x)).perform(click()); 119 | onView(withId(R.id.sandbox_axis_x_outside)).perform(click()); 120 | swipeLeftTo(5); 121 | onView(withId(R.id.sandbox_play_play)).perform(click()); 122 | } 123 | 124 | 125 | @Test 126 | public void labelsWithMetric() { 127 | 128 | swipeLeftTo(1); 129 | onView(withId(R.id.sandbox_axis_label_format_value)).perform(replaceText("metric")); 130 | swipeLeftTo(5); 131 | onView(withId(R.id.sandbox_play_play)).perform(click()); 132 | } 133 | 134 | 135 | private void swipeLeftTo(int goal) { 136 | 137 | for (int i = mCurrTab; i < goal; i++) { 138 | onView(withId(R.id.pager)).perform(swipeLeft()); 139 | SystemClock.sleep(300); 140 | } 141 | mCurrTab = goal; 142 | SystemClock.sleep(300); 143 | } 144 | } -------------------------------------------------------------------------------- /mobile/src/androidTest/java/com/db/williamchartdemo/SandboxBarTest.java: -------------------------------------------------------------------------------- 1 | package com.db.williamchartdemo; 2 | 3 | import android.os.SystemClock; 4 | import android.support.test.filters.LargeTest; 5 | import android.support.test.rule.ActivityTestRule; 6 | import android.support.test.runner.AndroidJUnit4; 7 | 8 | import org.junit.Before; 9 | import org.junit.Rule; 10 | import org.junit.Test; 11 | import org.junit.runner.RunWith; 12 | 13 | import static android.support.test.espresso.Espresso.onData; 14 | import static android.support.test.espresso.Espresso.onView; 15 | import static android.support.test.espresso.action.ViewActions.click; 16 | import static android.support.test.espresso.action.ViewActions.swipeLeft; 17 | import static android.support.test.espresso.matcher.ViewMatchers.withId; 18 | import static org.hamcrest.Matchers.allOf; 19 | import static org.hamcrest.Matchers.instanceOf; 20 | import static org.hamcrest.Matchers.is; 21 | 22 | 23 | @RunWith(AndroidJUnit4.class) 24 | @LargeTest 25 | public class SandboxBarTest { 26 | 27 | @Rule 28 | public ActivityTestRule mActivityRule = new ActivityTestRule(MainActivity.class); 29 | 30 | private int mCurrTab; 31 | 32 | 33 | @Before 34 | public void setUp() { 35 | 36 | mCurrTab = 0; 37 | onView(withId(R.id.spinner)).perform(click()); 38 | onData(allOf(is(instanceOf(String.class)), is("sandbox"))).perform(click()); 39 | onView(withId(R.id.sandbox_chart_bar)).perform(click()); 40 | } 41 | 42 | 43 | @Test 44 | public void defaultBarChart() { 45 | 46 | swipeLeftTo(5); 47 | onView(withId(R.id.sandbox_play_play)).perform(click()); 48 | } 49 | 50 | 51 | @Test 52 | public void roundCornersBar() { 53 | 54 | swipeLeftTo(3); 55 | onView(withId(R.id.sandbox_bar_corner3)).perform(click()); 56 | swipeLeftTo(5); 57 | onView(withId(R.id.sandbox_play_play)).perform(click()); 58 | } 59 | 60 | 61 | @Test 62 | public void spacingBar() { 63 | 64 | swipeLeftTo(3); 65 | onView(withId(R.id.sandbox_bar_spacing4)).perform(click()); 66 | swipeLeftTo(5); 67 | onView(withId(R.id.sandbox_play_play)).perform(click()); 68 | } 69 | 70 | 71 | @Test 72 | public void backgroundBar() { 73 | 74 | swipeLeftTo(3); 75 | onView(withId(R.id.sandbox_bar_background)).perform(click()); 76 | swipeLeftTo(5); 77 | onView(withId(R.id.sandbox_play_play)).perform(click()); 78 | } 79 | 80 | 81 | private void swipeLeftTo(int goal) { 82 | 83 | for (int i = mCurrTab; i < goal; i++) { 84 | onView(withId(R.id.pager)).perform(swipeLeft()); 85 | SystemClock.sleep(300); 86 | } 87 | mCurrTab = goal; 88 | SystemClock.sleep(300); 89 | } 90 | } -------------------------------------------------------------------------------- /mobile/src/androidTest/java/com/db/williamchartdemo/SandboxGridTest.java: -------------------------------------------------------------------------------- 1 | package com.db.williamchartdemo; 2 | 3 | import android.os.SystemClock; 4 | import android.support.test.filters.LargeTest; 5 | import android.support.test.rule.ActivityTestRule; 6 | import android.support.test.runner.AndroidJUnit4; 7 | 8 | import org.junit.Before; 9 | import org.junit.Rule; 10 | import org.junit.Test; 11 | import org.junit.runner.RunWith; 12 | 13 | import static android.support.test.espresso.Espresso.onData; 14 | import static android.support.test.espresso.Espresso.onView; 15 | import static android.support.test.espresso.action.ViewActions.click; 16 | import static android.support.test.espresso.action.ViewActions.swipeLeft; 17 | import static android.support.test.espresso.matcher.ViewMatchers.withId; 18 | import static org.hamcrest.Matchers.allOf; 19 | import static org.hamcrest.Matchers.instanceOf; 20 | import static org.hamcrest.Matchers.is; 21 | 22 | 23 | @RunWith(AndroidJUnit4.class) 24 | @LargeTest 25 | public class SandboxGridTest { 26 | 27 | @Rule 28 | public ActivityTestRule mActivityRule = new ActivityTestRule(MainActivity.class); 29 | 30 | private int mCurrTab; 31 | 32 | 33 | @Before 34 | public void setUp() { 35 | 36 | mCurrTab = 0; 37 | onView(withId(R.id.spinner)).perform(click()); 38 | onData(allOf(is(instanceOf(String.class)), is("sandbox"))).perform(click()); 39 | } 40 | 41 | 42 | @Test 43 | public void horizontalGrid() { 44 | 45 | swipeLeftTo(2); 46 | onView(withId(R.id.sandbox_grid_hor)).perform(click()); 47 | swipeLeftTo(5); 48 | onView(withId(R.id.sandbox_play_play)).perform(click()); 49 | } 50 | 51 | 52 | @Test 53 | public void verticalGrid() { 54 | 55 | swipeLeftTo(2); 56 | onView(withId(R.id.sandbox_grid_ver)).perform(click()); 57 | swipeLeftTo(5); 58 | onView(withId(R.id.sandbox_play_play)).perform(click()); 59 | } 60 | 61 | 62 | @Test 63 | public void fullGrid() { 64 | 65 | swipeLeftTo(2); 66 | onView(withId(R.id.sandbox_grid_full)).perform(click()); 67 | swipeLeftTo(5); 68 | onView(withId(R.id.sandbox_play_play)).perform(click()); 69 | } 70 | 71 | 72 | @Test 73 | public void dashedGrid() { 74 | 75 | swipeLeftTo(2); 76 | onView(withId(R.id.sandbox_grid_full)).perform(click()); 77 | onView(withId(R.id.sandbox_grid_dashed2)).perform(click()); 78 | swipeLeftTo(5); 79 | onView(withId(R.id.sandbox_play_play)).perform(click()); 80 | } 81 | 82 | 83 | @Test 84 | public void thicknessGrid() { 85 | 86 | swipeLeftTo(2); 87 | onView(withId(R.id.sandbox_grid_full)).perform(click()); 88 | onView(withId(R.id.sandbox_grid_thickness2)).perform(click()); 89 | swipeLeftTo(5); 90 | onView(withId(R.id.sandbox_play_play)).perform(click()); 91 | } 92 | 93 | 94 | private void swipeLeftTo(int goal) { 95 | 96 | for (int i = mCurrTab; i < goal; i++) { 97 | onView(withId(R.id.pager)).perform(swipeLeft()); 98 | SystemClock.sleep(300); 99 | } 100 | mCurrTab = goal; 101 | SystemClock.sleep(300); 102 | } 103 | } -------------------------------------------------------------------------------- /mobile/src/androidTest/java/com/db/williamchartdemo/SandboxLineTest.java: -------------------------------------------------------------------------------- 1 | package com.db.williamchartdemo; 2 | 3 | import android.os.SystemClock; 4 | import android.support.test.filters.LargeTest; 5 | import android.support.test.rule.ActivityTestRule; 6 | import android.support.test.runner.AndroidJUnit4; 7 | 8 | import org.junit.Before; 9 | import org.junit.Rule; 10 | import org.junit.Test; 11 | import org.junit.runner.RunWith; 12 | 13 | import static android.support.test.espresso.Espresso.onData; 14 | import static android.support.test.espresso.Espresso.onView; 15 | import static android.support.test.espresso.action.ViewActions.click; 16 | import static android.support.test.espresso.action.ViewActions.swipeLeft; 17 | import static android.support.test.espresso.matcher.ViewMatchers.withId; 18 | import static org.hamcrest.Matchers.allOf; 19 | import static org.hamcrest.Matchers.instanceOf; 20 | import static org.hamcrest.Matchers.is; 21 | 22 | 23 | @RunWith(AndroidJUnit4.class) 24 | @LargeTest 25 | public class SandboxLineTest { 26 | 27 | @Rule 28 | public ActivityTestRule mActivityRule = new ActivityTestRule(MainActivity.class); 29 | 30 | private int mCurrTab; 31 | 32 | 33 | @Before 34 | public void setUp() { 35 | 36 | mCurrTab = 0; 37 | onView(withId(R.id.spinner)).perform(click()); 38 | onData(allOf(is(instanceOf(String.class)), is("sandbox"))).perform(click()); 39 | } 40 | 41 | 42 | @Test 43 | public void defaultLineChart() { 44 | 45 | swipeLeftTo(5); 46 | onView(withId(R.id.sandbox_play_play)).perform(click()); 47 | } 48 | 49 | 50 | @Test 51 | public void smoothLine() { 52 | 53 | swipeLeftTo(3); 54 | onView(withId(R.id.sandbox_line_smooth)).perform(click()); 55 | swipeLeftTo(5); 56 | onView(withId(R.id.sandbox_play_play)).perform(click()); 57 | } 58 | 59 | 60 | @Test 61 | public void dashedLine() { 62 | 63 | swipeLeftTo(3); 64 | onView(withId(R.id.sandbox_line_dashed)).perform(click()); 65 | swipeLeftTo(5); 66 | onView(withId(R.id.sandbox_play_play)).perform(click()); 67 | } 68 | 69 | 70 | @Test 71 | public void thicknessLine() { 72 | 73 | swipeLeftTo(3); 74 | onView(withId(R.id.sandbox_line_thickness2)).perform(click()); 75 | swipeLeftTo(5); 76 | onView(withId(R.id.sandbox_play_play)).perform(click()); 77 | } 78 | 79 | 80 | @Test 81 | public void pointsLine() { 82 | 83 | swipeLeftTo(3); 84 | onView(withId(R.id.sandbox_point_size2)).perform(click()); 85 | swipeLeftTo(5); 86 | onView(withId(R.id.sandbox_play_play)).perform(click()); 87 | } 88 | 89 | 90 | private void swipeLeftTo(int goal) { 91 | 92 | for (int i = mCurrTab; i < goal; i++) { 93 | onView(withId(R.id.pager)).perform(swipeLeft()); 94 | SystemClock.sleep(300); 95 | } 96 | mCurrTab = goal; 97 | SystemClock.sleep(300); 98 | } 99 | } -------------------------------------------------------------------------------- /mobile/src/androidTest/java/com/db/williamchartdemo/SandboxStackTest.java: -------------------------------------------------------------------------------- 1 | package com.db.williamchartdemo; 2 | 3 | import android.os.SystemClock; 4 | import android.support.test.filters.LargeTest; 5 | import android.support.test.rule.ActivityTestRule; 6 | import android.support.test.runner.AndroidJUnit4; 7 | 8 | import org.junit.Before; 9 | import org.junit.Rule; 10 | import org.junit.Test; 11 | import org.junit.runner.RunWith; 12 | 13 | import static android.support.test.espresso.Espresso.onData; 14 | import static android.support.test.espresso.Espresso.onView; 15 | import static android.support.test.espresso.action.ViewActions.click; 16 | import static android.support.test.espresso.action.ViewActions.swipeLeft; 17 | import static android.support.test.espresso.matcher.ViewMatchers.withId; 18 | import static org.hamcrest.Matchers.allOf; 19 | import static org.hamcrest.Matchers.instanceOf; 20 | import static org.hamcrest.Matchers.is; 21 | 22 | 23 | @RunWith(AndroidJUnit4.class) 24 | @LargeTest 25 | public class SandboxStackTest { 26 | 27 | @Rule 28 | public ActivityTestRule mActivityRule = new ActivityTestRule(MainActivity.class); 29 | 30 | private int mCurrTab; 31 | 32 | 33 | @Before 34 | public void setUp() { 35 | 36 | mCurrTab = 0; 37 | onView(withId(R.id.spinner)).perform(click()); 38 | onData(allOf(is(instanceOf(String.class)), is("sandbox"))).perform(click()); 39 | onView(withId(R.id.sandbox_chart_stacked)).perform(click()); 40 | } 41 | 42 | 43 | @Test 44 | public void defaultStackChart() { 45 | 46 | swipeLeftTo(5); 47 | onView(withId(R.id.sandbox_play_play)).perform(click()); 48 | } 49 | 50 | 51 | @Test 52 | public void roundCornersBar() { 53 | 54 | swipeLeftTo(3); 55 | onView(withId(R.id.sandbox_bar_corner3)).perform(click()); 56 | swipeLeftTo(5); 57 | onView(withId(R.id.sandbox_play_play)).perform(click()); 58 | } 59 | 60 | 61 | @Test 62 | public void spacingBar() { 63 | 64 | swipeLeftTo(3); 65 | onView(withId(R.id.sandbox_bar_spacing4)).perform(click()); 66 | swipeLeftTo(5); 67 | onView(withId(R.id.sandbox_play_play)).perform(click()); 68 | } 69 | 70 | 71 | @Test 72 | public void backgroundBar() { 73 | 74 | swipeLeftTo(3); 75 | onView(withId(R.id.sandbox_bar_background)).perform(click()); 76 | swipeLeftTo(5); 77 | onView(withId(R.id.sandbox_play_play)).perform(click()); 78 | } 79 | 80 | 81 | private void swipeLeftTo(int goal) { 82 | 83 | for (int i = mCurrTab; i < goal; i++) { 84 | onView(withId(R.id.pager)).perform(swipeLeft()); 85 | SystemClock.sleep(300); 86 | } 87 | mCurrTab = goal; 88 | SystemClock.sleep(300); 89 | } 90 | } -------------------------------------------------------------------------------- /mobile/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /mobile/src/main/assets/OpenSans-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/WilliamChart/b277e0d6ee82711862c667953deb1b9551fb266b/mobile/src/main/assets/OpenSans-Regular.ttf -------------------------------------------------------------------------------- /mobile/src/main/assets/OpenSans-Semibold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/WilliamChart/b277e0d6ee82711862c667953deb1b9551fb266b/mobile/src/main/assets/OpenSans-Semibold.ttf -------------------------------------------------------------------------------- /mobile/src/main/assets/Ponsi-Regular.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/WilliamChart/b277e0d6ee82711862c667953deb1b9551fb266b/mobile/src/main/assets/Ponsi-Regular.otf -------------------------------------------------------------------------------- /mobile/src/main/assets/Roboto-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/WilliamChart/b277e0d6ee82711862c667953deb1b9551fb266b/mobile/src/main/assets/Roboto-Regular.ttf -------------------------------------------------------------------------------- /mobile/src/main/java/com/db/williamchartdemo/CardController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Diogo Bernardino 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.db.williamchartdemo; 18 | 19 | import android.os.Handler; 20 | import android.support.v7.widget.CardView; 21 | import android.view.View; 22 | import android.widget.ImageButton; 23 | import android.widget.RelativeLayout; 24 | 25 | 26 | public class CardController { 27 | 28 | 29 | private final ImageButton mPlayBtn; 30 | 31 | private final ImageButton mUpdateBtn; 32 | 33 | private final Runnable unlockAction = new Runnable() { 34 | @Override 35 | public void run() { 36 | 37 | new Handler().postDelayed(new Runnable() { 38 | public void run() { 39 | 40 | unlock(); 41 | } 42 | }, 500); 43 | } 44 | }; 45 | 46 | protected boolean firstStage; 47 | 48 | private final Runnable showAction = new Runnable() { 49 | @Override 50 | public void run() { 51 | 52 | new Handler().postDelayed(new Runnable() { 53 | public void run() { 54 | 55 | show(unlockAction); 56 | } 57 | }, 500); 58 | } 59 | }; 60 | 61 | 62 | protected CardController(CardView card) { 63 | 64 | super(); 65 | 66 | RelativeLayout toolbar = (RelativeLayout) card.findViewById(R.id.chart_toolbar); 67 | mPlayBtn = (ImageButton) toolbar.findViewById(R.id.play); 68 | mUpdateBtn = (ImageButton) toolbar.findViewById(R.id.update); 69 | 70 | mPlayBtn.setOnClickListener(new View.OnClickListener() { 71 | 72 | @Override 73 | public void onClick(View v) { 74 | 75 | dismiss(showAction); 76 | } 77 | }); 78 | 79 | mUpdateBtn.setOnClickListener(new View.OnClickListener() { 80 | 81 | @Override 82 | public void onClick(View v) { 83 | 84 | update(); 85 | } 86 | }); 87 | } 88 | 89 | 90 | public void init() { 91 | 92 | show(unlockAction); 93 | } 94 | 95 | 96 | protected void show(Runnable action) { 97 | 98 | lock(); 99 | firstStage = false; 100 | } 101 | 102 | 103 | protected void update() { 104 | 105 | lock(); 106 | firstStage = !firstStage; 107 | } 108 | 109 | 110 | protected void dismiss(Runnable action) { 111 | 112 | lock(); 113 | } 114 | 115 | 116 | private void lock() { 117 | 118 | mPlayBtn.setEnabled(false); 119 | mUpdateBtn.setEnabled(false); 120 | } 121 | 122 | 123 | private void unlock() { 124 | 125 | mPlayBtn.setEnabled(true); 126 | mUpdateBtn.setEnabled(true); 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /mobile/src/main/java/com/db/williamchartdemo/ChartsFragment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Diogo Bernardino 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.db.williamchartdemo; 18 | 19 | import android.graphics.Typeface; 20 | import android.os.Bundle; 21 | import android.support.v4.app.Fragment; 22 | import android.support.v7.app.AppCompatActivity; 23 | import android.support.v7.widget.CardView; 24 | import android.support.v7.widget.Toolbar; 25 | import android.view.LayoutInflater; 26 | import android.view.View; 27 | import android.view.ViewGroup; 28 | import android.widget.TextView; 29 | 30 | import com.db.williamchartdemo.barchart.BarCardOne; 31 | import com.db.williamchartdemo.barchart.BarCardThree; 32 | import com.db.williamchartdemo.barchart.BarCardTwo; 33 | import com.db.williamchartdemo.linechart.LineCardOne; 34 | import com.db.williamchartdemo.linechart.LineCardThree; 35 | import com.db.williamchartdemo.linechart.LineCardTwo; 36 | import com.db.williamchartdemo.stackedchart.StackedCardOne; 37 | import com.db.williamchartdemo.stackedchart.StackedCardThree; 38 | import com.db.williamchartdemo.stackedchart.StackedCardTwo; 39 | 40 | 41 | public class ChartsFragment extends Fragment { 42 | 43 | 44 | @Override 45 | public void onCreate(Bundle savedInstanceState) { 46 | 47 | super.onCreate(savedInstanceState); 48 | setHasOptionsMenu(true); 49 | } 50 | 51 | 52 | @Override 53 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 54 | Bundle savedInstanceState) { 55 | 56 | View layout = inflater.inflate(R.layout.charts, container, false); 57 | 58 | ((AppCompatActivity) getActivity()).setSupportActionBar( 59 | (Toolbar) layout.findViewById(R.id.toolbar)); 60 | ((TextView) layout.findViewById(R.id.title)).setTypeface( 61 | Typeface.createFromAsset(getContext().getAssets(), "Ponsi-Regular.otf")); 62 | 63 | (new LineCardOne((CardView) layout.findViewById(R.id.card1), getContext())).init(); 64 | (new LineCardThree((CardView) layout.findViewById(R.id.card2), getContext())).init(); 65 | (new BarCardOne((CardView) layout.findViewById(R.id.card3), getContext())).init(); 66 | (new StackedCardThree((CardView) layout.findViewById(R.id.card4), getContext())).init(); 67 | (new StackedCardOne((CardView) layout.findViewById(R.id.card5))).init(); 68 | (new BarCardThree((CardView) layout.findViewById(R.id.card6), getContext())).init(); 69 | (new BarCardTwo((CardView) layout.findViewById(R.id.card7), getContext())).init(); 70 | (new StackedCardTwo((CardView) layout.findViewById(R.id.card8))).init(); 71 | (new LineCardTwo((CardView) layout.findViewById(R.id.card9))).init(); 72 | 73 | return layout; 74 | } 75 | 76 | 77 | } 78 | -------------------------------------------------------------------------------- /mobile/src/main/java/com/db/williamchartdemo/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.db.williamchartdemo; 2 | 3 | import android.content.ActivityNotFoundException; 4 | import android.content.Intent; 5 | import android.net.Uri; 6 | import android.os.Bundle; 7 | import android.support.v4.view.MenuItemCompat; 8 | import android.support.v7.app.AppCompatActivity; 9 | import android.view.Menu; 10 | import android.view.MenuItem; 11 | import android.view.View; 12 | import android.widget.AdapterView; 13 | import android.widget.ArrayAdapter; 14 | import android.widget.Spinner; 15 | 16 | 17 | public class MainActivity extends AppCompatActivity implements AdapterView.OnItemSelectedListener { 18 | 19 | 20 | private android.support.v4.app.Fragment mCurrFragment; 21 | 22 | private int currSpinnerSelection = 0; 23 | 24 | private ArrayAdapter mAdapter; 25 | 26 | 27 | @Override 28 | protected void onCreate(Bundle savedInstanceState) { 29 | 30 | super.onCreate(savedInstanceState); 31 | setContentView(R.layout.main); 32 | 33 | mAdapter = ArrayAdapter.createFromResource(this, R.array.spinner_options, 34 | android.R.layout.simple_spinner_item); 35 | mAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); 36 | 37 | switch (currSpinnerSelection){ 38 | case 0: mCurrFragment = new ChartsFragment(); break; 39 | case 1: mCurrFragment = new SandboxFragment(); break; 40 | } 41 | 42 | getSupportFragmentManager().beginTransaction().add(R.id.container, mCurrFragment).commit(); 43 | } 44 | 45 | 46 | @Override 47 | public boolean onCreateOptionsMenu(Menu menu) { 48 | 49 | getMenuInflater().inflate(R.menu.menu, menu); 50 | MenuItem item = menu.findItem(R.id.spinner); 51 | 52 | Spinner spinner = (Spinner) MenuItemCompat.getActionView(item); 53 | spinner.setAdapter(mAdapter); 54 | spinner.setSelection(currSpinnerSelection); 55 | spinner.setOnItemSelectedListener(this); 56 | 57 | return super.onCreateOptionsMenu(menu); 58 | } 59 | 60 | 61 | @Override 62 | public boolean onOptionsItemSelected(MenuItem item) { 63 | 64 | switch (item.getItemId()) { 65 | case R.id.github: 66 | startActivity(new Intent("android.intent.action.VIEW", 67 | Uri.parse("https://github.com/diogobernardino/WilliamChart"))); 68 | return true; 69 | case R.id.play: 70 | try { 71 | startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse( 72 | "market://details?id=" + this.getApplicationContext().getPackageName()))); 73 | } catch (ActivityNotFoundException e) { 74 | startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse( 75 | "http://play.google.com/store/apps/details?id=" + 76 | "https://play.google.com/store/apps/details?id=com.db.williamchartdemo"))); 77 | } 78 | return true; 79 | default: 80 | return super.onOptionsItemSelected(item); 81 | } 82 | } 83 | 84 | 85 | public void onMenuClick(View view) { 86 | 87 | ((SandboxFragment) mCurrFragment).onMenuClick(view); 88 | } 89 | 90 | 91 | public void onPlay(View view) { 92 | 93 | ((SandboxFragment) mCurrFragment).onPlay(view); 94 | } 95 | 96 | 97 | @Override 98 | public void onItemSelected(AdapterView parent, View view, int position, long id) { 99 | 100 | if (position != currSpinnerSelection) { 101 | switch (position) { 102 | case 0: 103 | mCurrFragment = new ChartsFragment(); 104 | break; 105 | case 1: 106 | mCurrFragment = new SandboxFragment(); 107 | break; 108 | default: 109 | break; 110 | } 111 | getSupportFragmentManager().beginTransaction() 112 | .replace(R.id.container, mCurrFragment) 113 | .commit(); 114 | currSpinnerSelection = position; 115 | } 116 | } 117 | 118 | 119 | @Override 120 | public void onNothingSelected(AdapterView parent) {} 121 | 122 | } 123 | -------------------------------------------------------------------------------- /mobile/src/main/java/com/db/williamchartdemo/barchart/BarCardOne.java: -------------------------------------------------------------------------------- 1 | package com.db.williamchartdemo.barchart; 2 | 3 | import android.animation.PropertyValuesHolder; 4 | import android.content.Context; 5 | import android.graphics.Color; 6 | import android.os.Build; 7 | import android.support.v7.widget.CardView; 8 | import android.view.View; 9 | 10 | import com.db.chart.Tools; 11 | import com.db.chart.animation.Animation; 12 | import com.db.chart.model.BarSet; 13 | import com.db.chart.renderer.XRenderer; 14 | import com.db.chart.renderer.YRenderer; 15 | import com.db.chart.tooltip.Tooltip; 16 | import com.db.chart.view.BarChartView; 17 | import com.db.williamchartdemo.CardController; 18 | import com.db.williamchartdemo.R; 19 | 20 | 21 | public class BarCardOne extends CardController { 22 | 23 | 24 | private final Context mContext; 25 | 26 | private final BarChartView mChart; 27 | 28 | private final String[] mLabels = {"A", "B", "C", "D"}; 29 | 30 | private final float[][] mValues = {{6.5f, 8.5f, 2.5f, 10f}, {7.5f, 3.5f, 5.5f, 4f}}; 31 | 32 | 33 | public BarCardOne(CardView card, Context context) { 34 | 35 | super(card); 36 | 37 | mChart = (BarChartView) card.findViewById(R.id.chart3); 38 | mContext = context; 39 | } 40 | 41 | 42 | @Override 43 | public void show(Runnable action) { 44 | 45 | super.show(action); 46 | 47 | // Data 48 | BarSet barSet = new BarSet(mLabels, mValues[0]); 49 | barSet.setColor(Color.parseColor("#fc2a53")); 50 | mChart.addData(barSet); 51 | 52 | mChart.setBarSpacing(Tools.fromDpToPx(20)); 53 | mChart.setRoundCorners(Tools.fromDpToPx(2)); 54 | mChart.setBarBackgroundColor(Color.parseColor("#592932")); 55 | 56 | // Chart 57 | mChart.setXAxis(false) 58 | .setYAxis(false) 59 | .setXLabels(XRenderer.LabelPosition.OUTSIDE) 60 | .setYLabels(YRenderer.LabelPosition.NONE) 61 | .setLabelsColor(Color.parseColor("#86705c")) 62 | .setAxisColor(Color.parseColor("#86705c")); 63 | 64 | int[] order = {1, 0, 2, 3}; 65 | final Runnable auxAction = action; 66 | Runnable chartOneAction = new Runnable() { 67 | @Override 68 | public void run() { 69 | 70 | auxAction.run(); 71 | showTooltip(); 72 | } 73 | }; 74 | mChart.show(new Animation().setOverlap(.7f, order).setEndAction(chartOneAction)); 75 | } 76 | 77 | 78 | @Override 79 | public void update() { 80 | 81 | super.update(); 82 | 83 | mChart.dismissAllTooltips(); 84 | if (firstStage) mChart.updateValues(0, mValues[1]); 85 | else mChart.updateValues(0, mValues[0]); 86 | mChart.notifyDataUpdate(); 87 | } 88 | 89 | 90 | @Override 91 | public void dismiss(Runnable action) { 92 | 93 | super.dismiss(action); 94 | 95 | mChart.dismissAllTooltips(); 96 | int[] order = {0, 2, 1, 3}; 97 | mChart.dismiss(new Animation().setOverlap(.7f, order).setEndAction(action)); 98 | } 99 | 100 | 101 | private void showTooltip() { 102 | 103 | // Tooltip 104 | Tooltip tip = new Tooltip(mContext, R.layout.square_tooltip); 105 | 106 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { 107 | 108 | tip.setEnterAnimation(PropertyValuesHolder.ofFloat(View.ALPHA, 1), 109 | PropertyValuesHolder.ofFloat(View.SCALE_X, 1f), 110 | PropertyValuesHolder.ofFloat(View.SCALE_Y, 1f)).setDuration(200); 111 | 112 | tip.setExitAnimation(PropertyValuesHolder.ofFloat(View.ALPHA, 0), 113 | PropertyValuesHolder.ofFloat(View.SCALE_X, 0f), 114 | PropertyValuesHolder.ofFloat(View.SCALE_Y, 0f)).setDuration(200); 115 | } 116 | tip.setVerticalAlignment(Tooltip.Alignment.BOTTOM_TOP); 117 | tip.setDimensions((int) Tools.fromDpToPx(25), (int) Tools.fromDpToPx(25)); 118 | tip.setMargins(0, 0, 0, (int) Tools.fromDpToPx(10)); 119 | tip.prepare(mChart.getEntriesArea(0).get(2), 0); 120 | 121 | mChart.showTooltip(tip, true); 122 | } 123 | 124 | } 125 | -------------------------------------------------------------------------------- /mobile/src/main/java/com/db/williamchartdemo/barchart/BarCardThree.java: -------------------------------------------------------------------------------- 1 | package com.db.williamchartdemo.barchart; 2 | 3 | import android.animation.PropertyValuesHolder; 4 | import android.content.Context; 5 | import android.graphics.Color; 6 | import android.os.Build; 7 | import android.support.v7.widget.CardView; 8 | import android.view.View; 9 | import android.view.animation.AccelerateDecelerateInterpolator; 10 | 11 | import com.db.chart.Tools; 12 | import com.db.chart.animation.Animation; 13 | import com.db.chart.model.BarSet; 14 | import com.db.chart.renderer.AxisRenderer; 15 | import com.db.chart.tooltip.Tooltip; 16 | import com.db.chart.view.BarChartView; 17 | import com.db.williamchartdemo.CardController; 18 | import com.db.williamchartdemo.R; 19 | 20 | 21 | public class BarCardThree extends CardController { 22 | 23 | 24 | private final Context mContext; 25 | 26 | 27 | private final BarChartView mChart; 28 | 29 | private final String[] mLabels = 30 | {"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", 31 | "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""}; 32 | 33 | private final float[][] mValues = 34 | {{2.5f, 3.7f, 4f, 8f, 4.5f, 4f, 5f, 7f, 10f, 14f, 12f, 6f, 7f, 8f, 9f, 8f, 9f, 8f, 7f, 35 | 6f, 5f, 4f, 3f, 4f, 5f, 6f, 7f, 8f, 9f, 11f, 12f, 14, 13f, 10f, 9f, 8f, 7f, 5f, 36 | 4f, 6f}, 37 | {3.5f, 4.7f, 5f, 9f, 5.5f, 5f, 6f, 8f, 11f, 13f, 11f, 7f, 6f, 7f, 10f, 11f, 12f, 38 | 9f, 8f, 7f, 6f, 5f, 4f, 3f, 6f, 7f, 8f, 9f, 10f, 12f, 13f, 11, 13f, 10f, 39 | 8f, 7f, 5f, 4f, 3f, 7f}}; 40 | 41 | 42 | public BarCardThree(CardView card, Context context) { 43 | 44 | super(card); 45 | 46 | mContext = context; 47 | mChart = (BarChartView) card.findViewById(R.id.chart6); 48 | } 49 | 50 | 51 | @Override 52 | public void show(Runnable action) { 53 | 54 | super.show(action); 55 | 56 | Tooltip tip = new Tooltip(mContext); 57 | tip.setBackgroundColor(Color.parseColor("#CC7B1F")); 58 | 59 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { 60 | PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat(View.ALPHA, 1); 61 | tip.setEnterAnimation(alpha).setDuration(150); 62 | 63 | alpha = PropertyValuesHolder.ofFloat(View.ALPHA, 0); 64 | tip.setExitAnimation(alpha).setDuration(150); 65 | } 66 | 67 | mChart.setTooltips(tip); 68 | 69 | BarSet dataset = new BarSet(mLabels, mValues[0]); 70 | dataset.setColor(Color.parseColor("#eb993b")); 71 | mChart.addData(dataset); 72 | 73 | mChart.setBarSpacing(Tools.fromDpToPx(1.5f)); 74 | 75 | mChart.setXLabels(AxisRenderer.LabelPosition.NONE) 76 | .setYLabels(AxisRenderer.LabelPosition.NONE) 77 | .setXAxis(false) 78 | .setYAxis(false); 79 | 80 | Animation anim = new Animation().setEasing(new AccelerateDecelerateInterpolator()).setEndAction(action); 81 | 82 | mChart.show(anim); 83 | } 84 | 85 | 86 | @Override 87 | public void update() { 88 | 89 | super.update(); 90 | 91 | mChart.dismissAllTooltips(); 92 | if (firstStage) mChart.updateValues(0, mValues[1]); 93 | else mChart.updateValues(0, mValues[0]); 94 | mChart.notifyDataUpdate(); 95 | } 96 | 97 | 98 | @Override 99 | public void dismiss(Runnable action) { 100 | 101 | super.dismiss(action); 102 | 103 | mChart.dismissAllTooltips(); 104 | mChart.dismiss(new Animation().setEasing(new AccelerateDecelerateInterpolator()).setEndAction(action)); 105 | } 106 | 107 | } 108 | -------------------------------------------------------------------------------- /mobile/src/main/java/com/db/williamchartdemo/linechart/LineCardOne.java: -------------------------------------------------------------------------------- 1 | package com.db.williamchartdemo.linechart; 2 | 3 | import android.animation.PropertyValuesHolder; 4 | import android.content.Context; 5 | import android.graphics.Color; 6 | import android.graphics.Typeface; 7 | import android.os.Build; 8 | import android.support.v7.widget.CardView; 9 | import android.view.View; 10 | import android.view.animation.BounceInterpolator; 11 | import android.widget.TextView; 12 | 13 | import com.db.chart.Tools; 14 | import com.db.chart.animation.Animation; 15 | import com.db.chart.model.LineSet; 16 | import com.db.chart.renderer.AxisRenderer; 17 | import com.db.chart.tooltip.Tooltip; 18 | import com.db.chart.view.LineChartView; 19 | import com.db.williamchartdemo.CardController; 20 | import com.db.williamchartdemo.R; 21 | 22 | 23 | public class LineCardOne extends CardController { 24 | 25 | 26 | private final LineChartView mChart; 27 | 28 | 29 | private final Context mContext; 30 | 31 | 32 | private final String[] mLabels = {"Jan", "Fev", "Mar", "Apr", "Jun", "May", "Jul", "Aug", "Sep"}; 33 | 34 | private final float[][] mValues = {{3.5f, 4.7f, 4.3f, 8f, 6.5f, 9.9f, 7f, 8.3f, 7.0f}, 35 | {4.5f, 2.5f, 2.5f, 9f, 4.5f, 9.5f, 5f, 8.3f, 1.8f}}; 36 | 37 | private Tooltip mTip; 38 | 39 | private Runnable mBaseAction; 40 | 41 | 42 | public LineCardOne(CardView card, Context context) { 43 | 44 | super(card); 45 | 46 | mContext = context; 47 | mChart = (LineChartView) card.findViewById(R.id.chart1); 48 | } 49 | 50 | 51 | @Override 52 | public void show(Runnable action) { 53 | 54 | super.show(action); 55 | 56 | // Tooltip 57 | mTip = new Tooltip(mContext, R.layout.linechart_three_tooltip, R.id.value); 58 | 59 | ((TextView) mTip.findViewById(R.id.value)).setTypeface( 60 | Typeface.createFromAsset(mContext.getAssets(), "OpenSans-Semibold.ttf")); 61 | 62 | mTip.setVerticalAlignment(Tooltip.Alignment.BOTTOM_TOP); 63 | mTip.setDimensions((int) Tools.fromDpToPx(58), (int) Tools.fromDpToPx(25)); 64 | 65 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { 66 | 67 | mTip.setEnterAnimation(PropertyValuesHolder.ofFloat(View.ALPHA, 1), 68 | PropertyValuesHolder.ofFloat(View.SCALE_Y, 1f), 69 | PropertyValuesHolder.ofFloat(View.SCALE_X, 1f)).setDuration(200); 70 | 71 | mTip.setExitAnimation(PropertyValuesHolder.ofFloat(View.ALPHA, 0), 72 | PropertyValuesHolder.ofFloat(View.SCALE_Y, 0f), 73 | PropertyValuesHolder.ofFloat(View.SCALE_X, 0f)).setDuration(200); 74 | 75 | mTip.setPivotX(Tools.fromDpToPx(65) / 2); 76 | mTip.setPivotY(Tools.fromDpToPx(25)); 77 | } 78 | 79 | mChart.setTooltips(mTip); 80 | 81 | // Data 82 | LineSet dataset = new LineSet(mLabels, mValues[0]); 83 | dataset.setColor(Color.parseColor("#758cbb")) 84 | .setFill(Color.parseColor("#2d374c")) 85 | .setDotsColor(Color.parseColor("#758cbb")) 86 | .setThickness(4) 87 | .setDashed(new float[] {10f, 10f}) 88 | .beginAt(5); 89 | mChart.addData(dataset); 90 | 91 | dataset = new LineSet(mLabels, mValues[0]); 92 | dataset.setColor(Color.parseColor("#b3b5bb")) 93 | .setFill(Color.parseColor("#2d374c")) 94 | .setDotsColor(Color.parseColor("#ffc755")) 95 | .setThickness(4) 96 | .endAt(6); 97 | mChart.addData(dataset); 98 | 99 | // Chart 100 | mChart.setBorderSpacing(Tools.fromDpToPx(15)) 101 | .setAxisBorderValues(0, 20) 102 | .setYLabels(AxisRenderer.LabelPosition.NONE) 103 | .setLabelsColor(Color.parseColor("#6a84c3")) 104 | .setXAxis(false) 105 | .setYAxis(false); 106 | 107 | mBaseAction = action; 108 | Runnable chartAction = new Runnable() { 109 | @Override 110 | public void run() { 111 | 112 | mBaseAction.run(); 113 | mTip.prepare(mChart.getEntriesArea(0).get(3), mValues[0][3]); 114 | mChart.showTooltip(mTip, true); 115 | } 116 | }; 117 | 118 | Animation anim = new Animation().setEasing(new BounceInterpolator()).setEndAction(chartAction); 119 | 120 | mChart.show(anim); 121 | } 122 | 123 | 124 | @Override 125 | public void update() { 126 | 127 | super.update(); 128 | 129 | mChart.dismissAllTooltips(); 130 | if (firstStage) { 131 | mChart.updateValues(0, mValues[1]); 132 | mChart.updateValues(1, mValues[1]); 133 | } else { 134 | mChart.updateValues(0, mValues[0]); 135 | mChart.updateValues(1, mValues[0]); 136 | } 137 | mChart.getChartAnimation().setEndAction(mBaseAction); 138 | mChart.notifyDataUpdate(); 139 | } 140 | 141 | 142 | @Override 143 | public void dismiss(Runnable action) { 144 | 145 | super.dismiss(action); 146 | 147 | mChart.dismissAllTooltips(); 148 | mChart.dismiss(new Animation().setEasing(new BounceInterpolator()).setEndAction(action)); 149 | } 150 | 151 | } 152 | -------------------------------------------------------------------------------- /mobile/src/main/java/com/db/williamchartdemo/linechart/LineCardThree.java: -------------------------------------------------------------------------------- 1 | package com.db.williamchartdemo.linechart; 2 | 3 | import android.content.Context; 4 | import android.graphics.Color; 5 | import android.support.v7.widget.CardView; 6 | 7 | import com.db.chart.Tools; 8 | import com.db.chart.animation.Animation; 9 | import com.db.chart.model.LineSet; 10 | import com.db.chart.renderer.AxisRenderer; 11 | import com.db.chart.view.LineChartView; 12 | import com.db.williamchartdemo.CardController; 13 | import com.db.williamchartdemo.R; 14 | 15 | 16 | public class LineCardThree extends CardController { 17 | 18 | 19 | private final LineChartView mChart; 20 | 21 | private final String[] mLabels = {"", "", "", "", "", "", "", "", ""}; 22 | 23 | private final float[][] mValues = {{0f, 2f, 1.4f, 4.f, 3.5f, 4.3f, 2f, 4f, 6.f}, 24 | {1.5f, 2.5f, 1.5f, 5f, 4f, 5f, 4.3f, 2.1f, 1.4f}}; 25 | 26 | 27 | public LineCardThree(CardView card, Context context) { 28 | 29 | super(card); 30 | 31 | mChart = (LineChartView) card.findViewById(R.id.chart2); 32 | } 33 | 34 | 35 | @Override 36 | public void show(Runnable action) { 37 | 38 | super.show(action); 39 | 40 | LineSet dataset = new LineSet(mLabels, mValues[0]); 41 | dataset.setColor(Color.parseColor("#53c1bd")) 42 | .setFill(Color.parseColor("#3d6c73")) 43 | .setGradientFill(new int[] {Color.parseColor("#364d5a"), Color.parseColor("#3f7178")}, 44 | null); 45 | mChart.addData(dataset); 46 | 47 | mChart.setBorderSpacing(1) 48 | .setXLabels(AxisRenderer.LabelPosition.NONE) 49 | .setYLabels(AxisRenderer.LabelPosition.NONE) 50 | .setXAxis(false) 51 | .setYAxis(false) 52 | .setBorderSpacing(Tools.fromDpToPx(5)); 53 | 54 | Animation anim = new Animation().setEndAction(action); 55 | 56 | mChart.show(anim); 57 | } 58 | 59 | 60 | @Override 61 | public void update() { 62 | 63 | super.update(); 64 | 65 | mChart.dismissAllTooltips(); 66 | if (firstStage) { 67 | mChart.updateValues(0, mValues[1]); 68 | } else { 69 | mChart.updateValues(0, mValues[0]); 70 | } 71 | mChart.notifyDataUpdate(); 72 | } 73 | 74 | 75 | @Override 76 | public void dismiss(Runnable action) { 77 | 78 | super.dismiss(action); 79 | 80 | mChart.dismissAllTooltips(); 81 | mChart.dismiss(new Animation().setEndAction(action)); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /mobile/src/main/java/com/db/williamchartdemo/linechart/LineCardTwo.java: -------------------------------------------------------------------------------- 1 | package com.db.williamchartdemo.linechart; 2 | 3 | import android.graphics.Color; 4 | import android.graphics.DashPathEffect; 5 | import android.graphics.Paint; 6 | import android.support.v7.widget.CardView; 7 | 8 | import com.db.chart.Tools; 9 | import com.db.chart.animation.Animation; 10 | import com.db.chart.model.LineSet; 11 | import com.db.chart.model.Point; 12 | import com.db.chart.renderer.AxisRenderer; 13 | import com.db.chart.view.ChartView; 14 | import com.db.chart.view.LineChartView; 15 | import com.db.williamchartdemo.CardController; 16 | import com.db.williamchartdemo.R; 17 | 18 | 19 | public class LineCardTwo extends CardController { 20 | 21 | 22 | private final LineChartView mChart; 23 | 24 | private final String[] mLabels = 25 | {"", "", "", "", "START", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", 26 | "", "", "", "", "", "", "", "", "", "", "", "", "", "", "FINISH", "", "", "", 27 | ""}; 28 | 29 | private final float[][] mValues = 30 | {{35f, 37f, 47f, 49f, 43f, 46f, 80f, 83f, 65f, 68f, 28f, 55f, 58f, 50f, 53f, 53f, 57f, 31 | 48f, 50f, 53f, 54f, 25f, 27f, 35f, 37f, 35f, 80f, 82f, 55f, 59f, 85f, 82f, 60f, 32 | 55f, 63f, 65f, 58f, 60f, 63f, 60f}, 33 | {85f, 85f, 85f, 85f, 85f, 85f, 85f, 85f, 85f, 85f, 85f, 85f, 85f, 85f, 85f, 85f, 34 | 85f, 85f, 85f, 85f, 85f, 85f, 85f, 85f, 85f, 85f, 85f, 85f, 85f, 85f, 35 | 85f, 85f, 85f, 85f, 85f, 85f, 85f, 85f, 85f, 85f}}; 36 | 37 | 38 | public LineCardTwo(CardView card) { 39 | 40 | super(card); 41 | 42 | mChart = (LineChartView) card.findViewById(R.id.chart9); 43 | } 44 | 45 | 46 | @Override 47 | public void show(Runnable action) { 48 | 49 | super.show(action); 50 | 51 | LineSet dataset = new LineSet(mLabels, mValues[0]); 52 | dataset.setColor(Color.parseColor("#004f7f")) 53 | .setThickness(Tools.fromDpToPx(3)) 54 | .setSmooth(true) 55 | .beginAt(4) 56 | .endAt(36); 57 | for (int i = 0; i < mLabels.length; i += 5) { 58 | Point point = (Point) dataset.getEntry(i); 59 | point.setColor(Color.parseColor("#ffffff")); 60 | point.setStrokeColor(Color.parseColor("#0290c3")); 61 | if (i == 30 || i == 10) point.setRadius(Tools.fromDpToPx(6)); 62 | } 63 | mChart.addData(dataset); 64 | 65 | Paint thresPaint = new Paint(); 66 | thresPaint.setColor(Color.parseColor("#0079ae")); 67 | thresPaint.setStyle(Paint.Style.STROKE); 68 | thresPaint.setAntiAlias(true); 69 | thresPaint.setStrokeWidth(Tools.fromDpToPx(.75f)); 70 | thresPaint.setPathEffect(new DashPathEffect(new float[] {10, 10}, 0)); 71 | 72 | Paint gridPaint = new Paint(); 73 | gridPaint.setColor(Color.parseColor("#ffffff")); 74 | gridPaint.setStyle(Paint.Style.STROKE); 75 | gridPaint.setAntiAlias(true); 76 | gridPaint.setStrokeWidth(Tools.fromDpToPx(.75f)); 77 | 78 | mChart.setBorderSpacing(Tools.fromDpToPx(0)) 79 | .setXLabels(AxisRenderer.LabelPosition.OUTSIDE) 80 | .setLabelsColor(Color.parseColor("#304a00")) 81 | .setYLabels(AxisRenderer.LabelPosition.NONE) 82 | .setXAxis(false) 83 | .setYAxis(false) 84 | .setGrid(0, 7, gridPaint) 85 | .setValueThreshold(80f, 80f, thresPaint) 86 | .setAxisBorderValues(0, 110); 87 | 88 | Animation anim = new Animation().setStartPoint(0, .5f).setEndAction(action); 89 | 90 | mChart.show(anim); 91 | } 92 | 93 | 94 | @Override 95 | public void update() { 96 | 97 | super.update(); 98 | 99 | if (firstStage) { 100 | mChart.updateValues(0, mValues[1]); 101 | } else { 102 | mChart.updateValues(0, mValues[0]); 103 | } 104 | mChart.notifyDataUpdate(); 105 | } 106 | 107 | 108 | @Override 109 | public void dismiss(Runnable action) { 110 | 111 | super.dismiss(action); 112 | 113 | mChart.dismiss(new Animation().setStartPoint(1, .5f).setEndAction(action)); 114 | } 115 | 116 | } 117 | -------------------------------------------------------------------------------- /mobile/src/main/java/com/db/williamchartdemo/stackedchart/StackedCardThree.java: -------------------------------------------------------------------------------- 1 | package com.db.williamchartdemo.stackedchart; 2 | 3 | import android.content.Context; 4 | import android.graphics.Color; 5 | import android.graphics.Typeface; 6 | import android.support.v7.widget.CardView; 7 | import android.view.animation.AccelerateInterpolator; 8 | import android.view.animation.DecelerateInterpolator; 9 | import android.widget.TextView; 10 | 11 | import com.db.chart.Tools; 12 | import com.db.chart.animation.Animation; 13 | import com.db.chart.model.BarSet; 14 | import com.db.chart.renderer.AxisRenderer; 15 | import com.db.chart.view.HorizontalStackBarChartView; 16 | import com.db.williamchartdemo.CardController; 17 | import com.db.williamchartdemo.R; 18 | 19 | 20 | public class StackedCardThree extends CardController { 21 | 22 | 23 | private final HorizontalStackBarChartView mChart; 24 | 25 | private final String[] mLabels = {"", "", "", ""}; 26 | 27 | private final float[][] mValues = 28 | {{30f, 60f, 50f, 80f}, {-70f, -40f, -50f, -20f}, {50f, 70f, 10f, 30f}, 29 | {-40f, -70f, -60f, -50f}}; 30 | 31 | 32 | public StackedCardThree(CardView card, Context context) { 33 | 34 | super(card); 35 | 36 | mChart = (HorizontalStackBarChartView) card.findViewById(R.id.chart4); 37 | ((TextView) card.findViewById(R.id.electric_text)).setTypeface( 38 | Typeface.createFromAsset(context.getAssets(), "Ponsi-Regular.otf")); 39 | ((TextView) card.findViewById(R.id.fuel_text)).setTypeface( 40 | Typeface.createFromAsset(context.getAssets(), "Ponsi-Regular.otf")); 41 | } 42 | 43 | 44 | @Override 45 | public void show(Runnable action) { 46 | 47 | super.show(action); 48 | 49 | BarSet dataset = new BarSet(mLabels, mValues[0]); 50 | dataset.setColor(Color.parseColor("#687E8E")); 51 | mChart.addData(dataset); 52 | 53 | dataset = new BarSet(mLabels, mValues[1]); 54 | dataset.setColor(Color.parseColor("#FF5C8E67")); 55 | mChart.addData(dataset); 56 | 57 | mChart.setRoundCorners(Tools.fromDpToPx(5)); 58 | mChart.setBarSpacing(Tools.fromDpToPx(5)); 59 | 60 | mChart.setBorderSpacing(Tools.fromDpToPx(5)) 61 | .setYLabels(AxisRenderer.LabelPosition.NONE) 62 | .setXLabels(AxisRenderer.LabelPosition.NONE) 63 | .setXAxis(false) 64 | .setYAxis(false) 65 | .setAxisBorderValues(-80, 80, 10); 66 | 67 | Animation anim = new Animation().setEasing(new DecelerateInterpolator()).setEndAction(action); 68 | 69 | mChart.show(anim); 70 | } 71 | 72 | 73 | @Override 74 | public void update() { 75 | 76 | super.update(); 77 | 78 | if (firstStage) { 79 | mChart.updateValues(0, mValues[2]); 80 | mChart.updateValues(1, mValues[3]); 81 | } else { 82 | mChart.updateValues(0, mValues[0]); 83 | mChart.updateValues(1, mValues[1]); 84 | } 85 | mChart.notifyDataUpdate(); 86 | } 87 | 88 | 89 | @Override 90 | public void dismiss(Runnable action) { 91 | 92 | super.dismiss(action); 93 | 94 | mChart.dismiss(mChart.getChartAnimation().setEasing(new AccelerateInterpolator()).setEndAction(action)); 95 | } 96 | 97 | } 98 | -------------------------------------------------------------------------------- /mobile/src/main/java/com/db/williamchartdemo/stackedchart/StackedCardTwo.java: -------------------------------------------------------------------------------- 1 | package com.db.williamchartdemo.stackedchart; 2 | 3 | import android.graphics.Color; 4 | import android.graphics.Paint; 5 | import android.support.v7.widget.CardView; 6 | import android.view.animation.AccelerateDecelerateInterpolator; 7 | import android.view.animation.AccelerateInterpolator; 8 | 9 | import com.db.chart.Tools; 10 | import com.db.chart.animation.Animation; 11 | import com.db.chart.model.BarSet; 12 | import com.db.chart.view.ChartView; 13 | import com.db.chart.view.HorizontalStackBarChartView; 14 | import com.db.williamchartdemo.CardController; 15 | import com.db.williamchartdemo.R; 16 | 17 | import java.text.DecimalFormat; 18 | 19 | 20 | public class StackedCardTwo extends CardController { 21 | 22 | 23 | private final HorizontalStackBarChartView mChart; 24 | 25 | private final String[] mLabels = {"0-20", "20-40", "40-60", "60-80", "80-100", "100+"}; 26 | 27 | private final float[][] mValues = 28 | {{1.8f, 2f, 2.4f, 2.2f, 3.3f, 3.45f}, {-1.8f, -2.1f, -2.55f, -2.40f, -3.40f, -3.5f}, 29 | {1.8f, 2.1f, 2.55f, 2.40f, 3.40f, 3.5f}, 30 | {-1.8f, -2f, -2.4f, -2.2f, -3.3f, -3.45f}}; 31 | 32 | 33 | public StackedCardTwo(CardView card) { 34 | 35 | super(card); 36 | 37 | mChart = (HorizontalStackBarChartView) card.findViewById(R.id.chart8); 38 | } 39 | 40 | 41 | @Override 42 | public void show(Runnable action) { 43 | 44 | super.show(action); 45 | 46 | BarSet barSet = new BarSet(mLabels, mValues[0]); 47 | barSet.setColor(Color.parseColor("#90ee7e")); 48 | mChart.addData(barSet); 49 | 50 | barSet = new BarSet(mLabels, mValues[1]); 51 | barSet.setColor(Color.parseColor("#2b908f")); 52 | mChart.addData(barSet); 53 | 54 | Paint gridPaint = new Paint(); 55 | gridPaint.setColor(Color.parseColor("#e7e7e7")); 56 | gridPaint.setStyle(Paint.Style.STROKE); 57 | gridPaint.setAntiAlias(true); 58 | gridPaint.setStrokeWidth(Tools.fromDpToPx(.7f)); 59 | 60 | mChart.setBarSpacing(Tools.fromDpToPx(10)); 61 | 62 | mChart.setBorderSpacing(0) 63 | .setStep(1) 64 | .setGrid(0, 10, gridPaint) 65 | .setXAxis(false) 66 | .setYAxis(false) 67 | .setLabelsFormat(new DecimalFormat("##'M'")) 68 | .show(new Animation().setDuration(2500) 69 | .setEasing(new AccelerateInterpolator()) 70 | .setEndAction(action)); 71 | } 72 | 73 | 74 | @Override 75 | public void update() { 76 | 77 | super.update(); 78 | 79 | if (firstStage) { 80 | mChart.updateValues(0, mValues[2]); 81 | mChart.updateValues(1, mValues[3]); 82 | } else { 83 | mChart.updateValues(0, mValues[0]); 84 | mChart.updateValues(1, mValues[1]); 85 | } 86 | mChart.notifyDataUpdate(); 87 | } 88 | 89 | 90 | @Override 91 | public void dismiss(Runnable action) { 92 | 93 | super.dismiss(action); 94 | 95 | mChart.dismiss( 96 | new Animation().setDuration(2500).setEasing(new AccelerateInterpolator()).setEndAction(action)); 97 | } 98 | 99 | } 100 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/WilliamChart/b277e0d6ee82711862c667953deb1b9551fb266b/mobile/src/main/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /mobile/src/main/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/WilliamChart/b277e0d6ee82711862c667953deb1b9551fb266b/mobile/src/main/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /mobile/src/main/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/WilliamChart/b277e0d6ee82711862c667953deb1b9551fb266b/mobile/src/main/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /mobile/src/main/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/WilliamChart/b277e0d6ee82711862c667953deb1b9551fb266b/mobile/src/main/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/alpha_high_btn.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 7 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/alpha_low_btn.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 7 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/alpha_medium_btn.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 7 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/anim_start_btn.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 7 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/axis_x_btn.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/axis_y_btn.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/bar_btn.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 7 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/bar_corner1_bck.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/bar_corner3_bck.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/bar_corner4_bck.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/brush_btn.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 7 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/code_btn.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/color_bck.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/color_btn.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 7 | 8 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/gradient_line_bck.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 9 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/grid_hor_bck.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/grid_ver_bck.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/ic_alpha_high_off.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/ic_alpha_high_on.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/ic_alpha_low_off.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/ic_alpha_low_on.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/ic_alpha_medium_off.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/ic_alpha_medium_on.xml: -------------------------------------------------------------------------------- 1 | 6 | 8 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/ic_anim_start_off.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/ic_anim_start_on.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/ic_bar_off.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/ic_bar_on.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/ic_brush_off.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/ic_brush_on.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/ic_code.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/ic_face.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/ic_grade.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/ic_line_off.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/ic_line_on.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/ic_play.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/ic_play_grey_toolbar.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/ic_play_toolbar.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/ic_refresh.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/ic_refresh_grey.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/ic_smooth_off.xml: -------------------------------------------------------------------------------- 1 | 6 | 8 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/ic_smooth_on.xml: -------------------------------------------------------------------------------- 1 | 6 | 8 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/ic_stack_off.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/ic_stack_on.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/line_btn.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 7 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/line_dashed2_bck.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/line_dashed_bck.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/line_solid_bck.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/order_equal_bck.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/order_first_bck.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/order_last_bck.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/order_middle_bck.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/play_btn.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/point_size2_bck.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/point_size3_bck.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/point_size4_bck.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/rect_round_corners_bck.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/round_bck.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/round_bck_2.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/smooth_btn.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 7 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/stack_btn.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 7 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/stacked_one_point1_bck.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/stacked_one_point2_bck.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/stacked_one_point3_bck.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/standard_btn.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 7 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/thickness_size1_bck.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/thickness_size2_bck.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /mobile/src/main/res/drawable/thickness_size3_bck.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /mobile/src/main/res/layout/card_toolbar.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 15 | 23 | -------------------------------------------------------------------------------- /mobile/src/main/res/layout/card_toolbar_grey.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 15 | 23 | -------------------------------------------------------------------------------- /mobile/src/main/res/layout/color_picker.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 10 | 11 | 15 | 16 | -------------------------------------------------------------------------------- /mobile/src/main/res/layout/linechart_three_tooltip.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 18 | 19 | 26 | -------------------------------------------------------------------------------- /mobile/src/main/res/layout/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | -------------------------------------------------------------------------------- /mobile/src/main/res/layout/sandbox.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 16 | 17 | 22 | 29 | 30 | 31 | 39 | 40 | 41 | 42 | 51 | 52 | -------------------------------------------------------------------------------- /mobile/src/main/res/layout/sandbox_chart.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 11 | 12 | 20 | 21 | 22 | 27 | 28 | 38 | 39 | 50 | 51 | 52 | 53 | 58 | 59 | 70 | 71 | 83 | 84 | 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /mobile/src/main/res/layout/sandbox_play.xml: -------------------------------------------------------------------------------- 1 | 10 | 11 | 19 | 20 | 26 | 27 | 34 | 35 | 41 | 42 | 48 | 49 | 55 | 56 | 57 | 58 | 63 | 73 | 86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /mobile/src/main/res/layout/spinner_item.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /mobile/src/main/res/layout/square_tooltip.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /mobile/src/main/res/menu/menu.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 10 | 13 | 16 | 17 | -------------------------------------------------------------------------------- /mobile/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | #607D8B 5 | #455A64 6 | #CFD8DC 7 | #009688 8 | #212121 9 | #727272 10 | #FFFFFF 11 | #B6B6B6 12 | 13 | #009688 14 | #CFD8DC 15 | 16 | #ff363436 17 | 18 | 19 | -------------------------------------------------------------------------------- /mobile/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8dp 5 | 8dp 6 | 7 | 40dp 8 | 30dp 9 | 10 | 7dp 11 | 17dp 12 | 17dp 13 | 14 | 0dp 15 | 16 | 13dp 17 | 20dp 18 | 27dp 19 | 35dp 20 | 21 | 100dp 22 | 23 | 50sp 24 | 25 | 15dp 26 | 27 | 40dp 28 | 29 | 1dp 30 | .5dp 31 | 0dp 32 | 33 | -------------------------------------------------------------------------------- /mobile/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | williamchart 4 | 5 | Github 6 | Google Play 7 | 8 | 9 | Decelerate 10 | Accelerate 11 | Bounce 12 | 13 | 14 | 15 | 500ms 16 | 1500ms 17 | 3000ms 18 | 19 | 20 | 21 | STATE 1 22 | STATE 2 23 | STATE 3 24 | 25 | 26 | electric 27 | fuel 28 | 29 | 30 | X 31 | Y 32 | metric 33 | 34 | 35 | showroom 36 | sandbox 37 | 38 | 39 | AVERAGE TIME 40 | Commuters 41 | 00:15:39 42 | 43 | -------------------------------------------------------------------------------- /mobile/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 12 | 13 | 16 | 17 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /simpledemp/src/test/java/com/db/williamchart/simpledemp/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.db.williamchart.simpledemp; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /wearable/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /wearable/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | 4 | android { 5 | compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION) 6 | buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION 7 | 8 | defaultConfig { 9 | applicationId "com.db.williamchartdemo" 10 | minSdkVersion 20 11 | targetSdkVersion 25 12 | versionCode 1 13 | versionName "1.0" 14 | } 15 | buildTypes { 16 | release { 17 | minifyEnabled false 18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 19 | } 20 | } 21 | } 22 | 23 | dependencies { 24 | compile project(':williamchart') 25 | compile 'com.google.android.support:wearable:2.0.0-alpha2' 26 | compile 'com.google.android.gms:play-services-wearable:10.0.1' 27 | } 28 | -------------------------------------------------------------------------------- /wearable/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in C:\Android\sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /wearable/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 13 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /wearable/src/main/java/com/db/williamchartwear/BarFragment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.db.williamchartwear; 18 | 19 | import android.app.Fragment; 20 | import android.graphics.Color; 21 | import android.os.Bundle; 22 | import android.view.LayoutInflater; 23 | import android.view.View; 24 | import android.view.ViewGroup; 25 | import android.view.animation.AnticipateInterpolator; 26 | import android.view.animation.BounceInterpolator; 27 | 28 | import com.db.chart.Tools; 29 | import com.db.chart.animation.Animation; 30 | import com.db.chart.model.BarSet; 31 | import com.db.chart.renderer.AxisRenderer; 32 | import com.db.chart.view.BarChartView; 33 | 34 | 35 | public class BarFragment extends Fragment implements View.OnClickListener { 36 | 37 | private final String[] mLabels = 38 | {"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", 39 | "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""}; 40 | 41 | private final float[][] mValues = 42 | {{3.5f, 4.7f, 5f, 9f, 5.5f, 5f, 6f, 8f, 11f, 13f, 11f, 7f, 6f, 7f, 10f, 11f, 12f, 9f, 8f, 43 | 7f, 6f, 5f, 4f, 3f, 6f, 7f, 8f, 9f, 10f, 12f, 13f, 11, 13f, 10f, 8f, 7f, 5f, 4f, 44 | 3f, 7f}, 45 | {2.5f, 3.7f, 4f, 8f, 4.5f, 4f, 5f, 7f, 10f, 14f, 12f, 6f, 7f, 8f, 9f, 8f, 9f, 8f, 46 | 7f, 6f, 5f, 4f, 3f, 4f, 5f, 6f, 7f, 8f, 9f, 11f, 12f, 14, 13f, 10f, 9f, 47 | 8f, 7f, 5f, 4f, 6f}}; 48 | 49 | private BarChartView mChart; 50 | 51 | private boolean mFirstStage; 52 | 53 | 54 | @Override 55 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 56 | Bundle savedInstanceState) { 57 | 58 | View layout = inflater.inflate(R.layout.fragment_bar, container, false); 59 | mChart = (BarChartView) layout.findViewById(R.id.chart); 60 | mFirstStage = true; 61 | 62 | layout.setOnClickListener(this); 63 | mChart.setOnClickListener(this); 64 | 65 | BarSet dataset = new BarSet(mLabels, mValues[0]); 66 | dataset.setColor(Color.parseColor("#eb993b")); 67 | mChart.addData(dataset); 68 | 69 | mChart.setBarSpacing(Tools.fromDpToPx(3)); 70 | 71 | mChart.setXLabels(AxisRenderer.LabelPosition.NONE) 72 | .setYLabels(AxisRenderer.LabelPosition.NONE) 73 | .setXAxis(false) 74 | .setYAxis(false); 75 | mChart.show(new Animation().setEasing(new BounceInterpolator())); 76 | 77 | return layout; 78 | } 79 | 80 | 81 | @Override 82 | public void onClick(View view) { 83 | 84 | if (mFirstStage) mChart.updateValues(0, mValues[1]); 85 | else mChart.updateValues(0, mValues[0]); 86 | 87 | mFirstStage = !mFirstStage; 88 | mChart.notifyDataUpdate(); 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /wearable/src/main/java/com/db/williamchartwear/ChartGridPagerAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.db.williamchartwear; 18 | 19 | import android.app.Fragment; 20 | import android.app.FragmentManager; 21 | import android.content.Context; 22 | import android.support.wearable.view.FragmentGridPagerAdapter; 23 | 24 | 25 | public class ChartGridPagerAdapter extends FragmentGridPagerAdapter { 26 | 27 | public ChartGridPagerAdapter(Context ctx, FragmentManager fm) { 28 | 29 | super(fm); 30 | } 31 | 32 | 33 | @Override 34 | public Fragment getFragment(int row, int col) { 35 | 36 | switch (row) { 37 | case 0: 38 | return new LineFragment(); 39 | case 1: 40 | return new BarFragment(); 41 | case 2: 42 | return new StackedFragment(); 43 | default: 44 | return new LineFragment(); 45 | } 46 | } 47 | 48 | 49 | @Override 50 | public int getRowCount() { 51 | 52 | return 3; 53 | } 54 | 55 | 56 | @Override 57 | public int getColumnCount(int i) { 58 | 59 | return 1; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /wearable/src/main/java/com/db/williamchartwear/LineFragment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.db.williamchartwear; 18 | 19 | import android.app.Fragment; 20 | import android.graphics.Color; 21 | import android.graphics.DashPathEffect; 22 | import android.graphics.Paint; 23 | import android.os.Bundle; 24 | import android.view.LayoutInflater; 25 | import android.view.View; 26 | import android.view.ViewGroup; 27 | 28 | import com.db.chart.Tools; 29 | import com.db.chart.animation.Animation; 30 | import com.db.chart.model.LineSet; 31 | import com.db.chart.model.Point; 32 | import com.db.chart.renderer.AxisRenderer; 33 | import com.db.chart.view.ChartView; 34 | import com.db.chart.view.LineChartView; 35 | 36 | 37 | public class LineFragment extends Fragment implements View.OnClickListener { 38 | 39 | private final String[] mLabels = 40 | {"", "", "", "", "START", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", 41 | "", "", "", "", "", "", "", "", "", "", "", "", "", "", "FINISH", "", "", "", 42 | ""}; 43 | 44 | private final float[][] mValues = 45 | {{35f, 37f, 47f, 49f, 43f, 46f, 80f, 83f, 65f, 68f, 28f, 55f, 58f, 50f, 53f, 53f, 57f, 46 | 48f, 50f, 53f, 54f, 25f, 27f, 35f, 37f, 35f, 80f, 82f, 55f, 59f, 85f, 82f, 60f, 47 | 55f, 63f, 65f, 58f, 60f, 63f, 60f}, 48 | {85f, 85f, 85f, 85f, 85f, 85f, 85f, 85f, 85f, 85f, 85f, 85f, 85f, 85f, 85f, 85f, 49 | 85f, 85f, 85f, 85f, 85f, 85f, 85f, 85f, 85f, 85f, 85f, 85f, 85f, 85f, 50 | 85f, 85f, 85f, 85f, 85f, 85f, 85f, 85f, 85f, 85f}}; 51 | 52 | private LineChartView mChart; 53 | 54 | private boolean mFirstStage; 55 | 56 | 57 | @Override 58 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 59 | Bundle savedInstanceState) { 60 | 61 | View layout = inflater.inflate(R.layout.fragment_line, container, false); 62 | mChart = (LineChartView) layout.findViewById(R.id.chart); 63 | mFirstStage = true; 64 | 65 | layout.setOnClickListener(this); 66 | mChart.setOnClickListener(this); 67 | 68 | LineSet dataset = new LineSet(mLabels, mValues[0]); 69 | dataset.setColor(Color.parseColor("#004f7f")) 70 | .setThickness(Tools.fromDpToPx(3)) 71 | .setSmooth(true) 72 | .beginAt(4) 73 | .endAt(36); 74 | for (int i = 0; i < mLabels.length; i += 5) { 75 | Point point = (Point) dataset.getEntry(i); 76 | point.setColor(Color.parseColor("#ffffff")); 77 | point.setStrokeColor(Color.parseColor("#0290c3")); 78 | if (i == 30 || i == 10) point.setRadius(Tools.fromDpToPx(6)); 79 | } 80 | mChart.addData(dataset); 81 | 82 | Paint thresPaint = new Paint(); 83 | thresPaint.setColor(Color.parseColor("#0079ae")); 84 | thresPaint.setStyle(Paint.Style.STROKE); 85 | thresPaint.setAntiAlias(true); 86 | thresPaint.setStrokeWidth(Tools.fromDpToPx(.75f)); 87 | thresPaint.setPathEffect(new DashPathEffect(new float[] {10, 10}, 0)); 88 | 89 | Paint gridPaint = new Paint(); 90 | gridPaint.setColor(Color.parseColor("#ffffff")); 91 | gridPaint.setStyle(Paint.Style.STROKE); 92 | gridPaint.setAntiAlias(true); 93 | gridPaint.setStrokeWidth(Tools.fromDpToPx(.75f)); 94 | 95 | mChart.setBorderSpacing(Tools.fromDpToPx(0)) 96 | .setXLabels(AxisRenderer.LabelPosition.OUTSIDE) 97 | .setLabelsColor(Color.parseColor("#304a00")) 98 | .setYLabels(AxisRenderer.LabelPosition.NONE) 99 | .setXAxis(false) 100 | .setYAxis(false) 101 | .setGrid(ChartView.GridType.VERTICAL, 1, 7, gridPaint) 102 | .setValueThreshold(80f, 80f, thresPaint) 103 | .setAxisBorderValues(0, 110); 104 | 105 | mChart.show(new Animation().setStartPoint(0, .5f)); 106 | 107 | return layout; 108 | } 109 | 110 | 111 | @Override 112 | public void onClick(View view) { 113 | 114 | if (mFirstStage) mChart.updateValues(0, mValues[1]); 115 | else mChart.updateValues(0, mValues[0]); 116 | 117 | mFirstStage = !mFirstStage; 118 | mChart.notifyDataUpdate(); 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /wearable/src/main/java/com/db/williamchartwear/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.db.williamchartwear; 2 | 3 | import android.app.Activity; 4 | import android.os.Bundle; 5 | import android.support.wearable.view.GridViewPager; 6 | 7 | 8 | public class MainActivity extends Activity { 9 | 10 | @Override 11 | protected void onCreate(Bundle savedInstanceState) { 12 | 13 | super.onCreate(savedInstanceState); 14 | setContentView(R.layout.activity_main); 15 | 16 | final GridViewPager pager = (GridViewPager) findViewById(R.id.pager); 17 | pager.setAdapter(new ChartGridPagerAdapter(this, getFragmentManager())); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /wearable/src/main/java/com/db/williamchartwear/StackedFragment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.db.williamchartwear; 18 | 19 | import android.app.Fragment; 20 | import android.graphics.Color; 21 | import android.graphics.DashPathEffect; 22 | import android.graphics.Paint; 23 | import android.os.Bundle; 24 | import android.view.LayoutInflater; 25 | import android.view.View; 26 | import android.view.ViewGroup; 27 | 28 | import com.db.chart.Tools; 29 | import com.db.chart.animation.Animation; 30 | import com.db.chart.model.BarSet; 31 | import com.db.chart.renderer.AxisRenderer; 32 | import com.db.chart.view.StackBarChartView; 33 | 34 | 35 | public class StackedFragment extends Fragment implements View.OnClickListener { 36 | 37 | private final String[] mLabels = {"JAN", "FEV", "MAR", "ABR", "MAI", "JUN", "JUL"}; 38 | 39 | private final float[][] mValuesOne = 40 | {{30f, 40f, 25f, 25f, 40f, 25f, 25f}, {30f, 30f, 25f, 40f, 25f, 30f, 40f}, 41 | {30f, 30f, 25f, 25f, 25f, 25f, 25f}}; 42 | 43 | private StackBarChartView mChart; 44 | 45 | private boolean mFirstStage; 46 | 47 | 48 | @Override 49 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 50 | Bundle savedInstanceState) { 51 | 52 | View layout = inflater.inflate(R.layout.fragment_stacked, container, false); 53 | mChart = (StackBarChartView) layout.findViewById(R.id.chart); 54 | mFirstStage = true; 55 | 56 | layout.setOnClickListener(this); 57 | mChart.setOnClickListener(this); 58 | 59 | Paint thresPaint = new Paint(); 60 | thresPaint.setColor(Color.parseColor("#dad8d6")); 61 | thresPaint.setPathEffect(new DashPathEffect(new float[] {10, 20}, 0)); 62 | thresPaint.setStyle(Paint.Style.STROKE); 63 | thresPaint.setAntiAlias(true); 64 | thresPaint.setStrokeWidth(Tools.fromDpToPx(.75f)); 65 | 66 | BarSet stackBarSet = new BarSet(mLabels, mValuesOne[0]); 67 | stackBarSet.setColor(Color.parseColor("#a1d949")); 68 | mChart.addData(stackBarSet); 69 | 70 | stackBarSet = new BarSet(mLabels, mValuesOne[1]); 71 | stackBarSet.setColor(Color.parseColor("#ffcc6a")); 72 | mChart.addData(stackBarSet); 73 | 74 | stackBarSet = new BarSet(mLabels, mValuesOne[2]); 75 | stackBarSet.setColor(Color.parseColor("#ff7a57")); 76 | mChart.addData(stackBarSet); 77 | 78 | mChart.setBarSpacing(Tools.fromDpToPx(15)); 79 | mChart.setRoundCorners(Tools.fromDpToPx(1)); 80 | 81 | mChart.setXAxis(false) 82 | .setXLabels(AxisRenderer.LabelPosition.OUTSIDE) 83 | .setYAxis(false) 84 | .setYLabels(AxisRenderer.LabelPosition.NONE) 85 | .setValueThreshold(89.f, 89.f, thresPaint); 86 | 87 | mChart.show(new Animation().setOverlap(.5f, new int[] {0, 1, 2, 3, 4, 5, 6})); 88 | 89 | return layout; 90 | } 91 | 92 | 93 | @Override 94 | public void onClick(View view) { 95 | 96 | if (mFirstStage) { 97 | mChart.updateValues(0, mValuesOne[2]); 98 | mChart.updateValues(1, mValuesOne[0]); 99 | mChart.updateValues(2, mValuesOne[1]); 100 | } else { 101 | mChart.updateValues(0, mValuesOne[0]); 102 | mChart.updateValues(1, mValuesOne[1]); 103 | mChart.updateValues(2, mValuesOne[2]); 104 | } 105 | mFirstStage = !mFirstStage; 106 | mChart.notifyDataUpdate(); 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /wearable/src/main/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/WilliamChart/b277e0d6ee82711862c667953deb1b9551fb266b/wearable/src/main/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /wearable/src/main/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/WilliamChart/b277e0d6ee82711862c667953deb1b9551fb266b/wearable/src/main/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /wearable/src/main/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/WilliamChart/b277e0d6ee82711862c667953deb1b9551fb266b/wearable/src/main/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /wearable/src/main/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/WilliamChart/b277e0d6ee82711862c667953deb1b9551fb266b/wearable/src/main/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /wearable/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 13 | 14 | -------------------------------------------------------------------------------- /wearable/src/main/res/layout/fragment_bar.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 13 | 14 | -------------------------------------------------------------------------------- /wearable/src/main/res/layout/fragment_line.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 13 | 14 | -------------------------------------------------------------------------------- /wearable/src/main/res/layout/fragment_stacked.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 17 | 18 | -------------------------------------------------------------------------------- /wearable/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/WilliamChart/b277e0d6ee82711862c667953deb1b9551fb266b/wearable/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /wearable/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/WilliamChart/b277e0d6ee82711862c667953deb1b9551fb266b/wearable/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /wearable/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/WilliamChart/b277e0d6ee82711862c667953deb1b9551fb266b/wearable/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /wearable/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/WilliamChart/b277e0d6ee82711862c667953deb1b9551fb266b/wearable/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /wearable/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | williamchart 3 | 4 | -------------------------------------------------------------------------------- /williamchart/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'com.jfrog.bintray' 3 | apply plugin: 'com.github.dcendents.android-maven' 4 | group='com.github.open-android' 5 | 6 | version = '2.4.0' 7 | 8 | android { 9 | compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION) 10 | buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION 11 | 12 | defaultConfig { 13 | minSdkVersion Integer.parseInt(project.ANDROID_BUILD_MIN_SDK_VERSION) 14 | targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION) 15 | } 16 | } 17 | 18 | dependencies { 19 | compile 'com.android.support:support-annotations:25.1.0' 20 | testCompile 'com.android.support:support-annotations:25.1.0' 21 | testCompile 'junit:junit:4.12' 22 | testCompile 'org.mockito:mockito-core:1.10.19' 23 | } 24 | 25 | def siteUrl = 'https://github.com/diogobernardino/WilliamChart' 26 | def gitUrl = 'https://github.com/diogobernardino/WilliamChart.git' 27 | 28 | install { 29 | repositories.mavenInstaller { 30 | pom.project { 31 | packaging 'aar' 32 | name 'WilliamChart' 33 | description = 'Flexible charting library with nice motion effects.' 34 | url siteUrl 35 | 36 | licenses { 37 | license { 38 | name 'The Apache Software License, Version 2.0' 39 | url 'http://www.apache.org/licenses/LICENSE-2.0.txt' 40 | } 41 | } 42 | developers { 43 | developer { 44 | id 'diogobernardino' 45 | name 'Diogo Bernardino' 46 | email 'mail@diogobernardino.com' 47 | } 48 | } 49 | scm { 50 | connection gitUrl 51 | developerConnection gitUrl 52 | url siteUrl 53 | } 54 | } 55 | } 56 | } 57 | 58 | task sourcesJar(type: Jar) { 59 | from android.sourceSets.main.java.srcDirs 60 | classifier = 'sources' 61 | } 62 | 63 | task javadoc(type: Javadoc) { 64 | failOnError false 65 | source = android.sourceSets.main.java.srcDirs 66 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) 67 | } 68 | 69 | task javadocJar(type: Jar, dependsOn: javadoc) { 70 | classifier = 'javadoc' 71 | from javadoc.destinationDir 72 | } 73 | artifacts { 74 | archives javadocJar 75 | archives sourcesJar 76 | } 77 | 78 | Properties properties = new Properties() 79 | properties.load(project.rootProject.file('local.properties').newDataInputStream()) 80 | 81 | bintray { 82 | user = properties.getProperty("bintray.user") 83 | key = properties.getProperty("bintray.apikey") 84 | configurations = ['archives'] 85 | pkg { 86 | repo = 'maven' 87 | name = 'com.diogobernardino:williamchart' 88 | websiteUrl = siteUrl 89 | vcsUrl = gitUrl 90 | licenses = ["Apache-2.0"] 91 | publish = true 92 | override = true 93 | } 94 | } 95 | 96 | -------------------------------------------------------------------------------- /williamchart/gradle.properties: -------------------------------------------------------------------------------- 1 | POM_NAME=WilliamChart Library 2 | POM_ARTIFACT_ID=williamchart 3 | POM_PACKAGING=aar -------------------------------------------------------------------------------- /williamchart/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/diogobernardino/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /williamchart/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /williamchart/src/main/java/com/db/chart/Tools.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Diogo Bernardino 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.db.chart; 18 | 19 | import android.content.res.Resources; 20 | import android.graphics.Bitmap; 21 | import android.graphics.Bitmap.Config; 22 | import android.graphics.Canvas; 23 | import android.graphics.drawable.BitmapDrawable; 24 | import android.graphics.drawable.Drawable; 25 | import android.support.annotation.NonNull; 26 | 27 | 28 | public class Tools { 29 | 30 | 31 | /** 32 | * Converts dp size into pixels. 33 | * 34 | * @param dp dp size to get converted 35 | * 36 | * @return Pixel size 37 | */ 38 | public static float fromDpToPx(float dp) { 39 | 40 | try { 41 | return dp * Resources.getSystem().getDisplayMetrics().density; 42 | } catch (Exception e) { 43 | return dp; 44 | } 45 | } 46 | 47 | 48 | /** 49 | * Converts a {@link android.graphics.drawable.Drawable} into {@link android.graphics.Bitmap}. 50 | * 51 | * @param drawable {@link android.graphics.drawable.Drawable} to be converted 52 | * 53 | * @return {@link android.graphics.Bitmap} object 54 | */ 55 | public static Bitmap drawableToBitmap(@NonNull Drawable drawable) { 56 | 57 | if (drawable instanceof BitmapDrawable) return ((BitmapDrawable) drawable).getBitmap(); 58 | 59 | Bitmap bitmap = 60 | Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), 61 | Config.ARGB_8888); 62 | Canvas canvas = new Canvas(bitmap); 63 | drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); 64 | drawable.draw(canvas); 65 | 66 | return bitmap; 67 | } 68 | 69 | 70 | /** 71 | * Find the Greatest Common Denominator. 72 | * https://en.wikipedia.org/wiki/Euclidean_algorithm 73 | * 74 | * @param min Mininum value 75 | * @param max Maximum value 76 | * 77 | * @return Greatest common denominator 78 | */ 79 | public static int GCD(int min, int max) { 80 | 81 | return max == 0 ? min : GCD(max, min % max); 82 | } 83 | 84 | 85 | /** 86 | * Finds the largest divisor of a number. 87 | * 88 | * @param num Value to be found the largest divisor 89 | * 90 | * @return Largest divisor of parameter given 91 | */ 92 | public static int largestDivisor(int num) { 93 | 94 | if (num > 1) 95 | for (int i = num / 2; i >= 0; i--) 96 | if (num % i == 0) return i; 97 | return 1; 98 | } 99 | 100 | } 101 | -------------------------------------------------------------------------------- /williamchart/src/main/java/com/db/chart/animation/ChartAnimationListener.java: -------------------------------------------------------------------------------- 1 | package com.db.chart.animation; 2 | 3 | import com.db.chart.model.ChartSet; 4 | 5 | import java.util.ArrayList; 6 | 7 | 8 | public interface ChartAnimationListener { 9 | 10 | boolean onAnimationUpdate(ArrayList data); 11 | } 12 | -------------------------------------------------------------------------------- /williamchart/src/main/java/com/db/chart/animation/style/BaseStyleAnimation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Diogo Bernardino 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.db.chart.animation.style; 18 | 19 | import com.db.chart.model.ChartSet; 20 | import com.db.chart.view.ChartView; 21 | 22 | 23 | public abstract class BaseStyleAnimation { 24 | 25 | private static final long DELAY_BETWEEN_UPDATES = 100; 26 | 27 | private ChartView mChartView; 28 | 29 | private ChartSet mSet; 30 | 31 | /** Control animation updates */ 32 | final private Runnable mAnimator = new Runnable() { 33 | @Override 34 | public void run() { 35 | 36 | if (mChartView.canIPleaseAskYouToDraw()) { 37 | mChartView.postInvalidate(); 38 | getUpdate(mSet); 39 | } 40 | } 41 | }; 42 | 43 | 44 | public void play(ChartView lineChartView, ChartSet set) { 45 | 46 | mChartView = lineChartView; 47 | mSet = set; 48 | getUpdate(mSet); 49 | } 50 | 51 | 52 | private void getUpdate(ChartSet set) { 53 | 54 | nextUpdate(set); 55 | mChartView.postDelayed(mAnimator, DELAY_BETWEEN_UPDATES); 56 | } 57 | 58 | 59 | protected abstract void nextUpdate(ChartSet set); 60 | 61 | } 62 | -------------------------------------------------------------------------------- /williamchart/src/main/java/com/db/chart/animation/style/DashAnimation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Diogo Bernardino 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.db.chart.animation.style; 18 | 19 | import com.db.chart.model.ChartSet; 20 | import com.db.chart.model.LineSet; 21 | 22 | 23 | public class DashAnimation extends BaseStyleAnimation { 24 | 25 | 26 | @Override 27 | public void nextUpdate(ChartSet set) { 28 | 29 | LineSet line = (LineSet) set; 30 | line.setDashedPhase(line.getDashedPhase() - 4); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /williamchart/src/main/java/com/db/chart/listener/OnEntryClickListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Diogo Bernardino 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.db.chart.listener; 18 | 19 | import android.graphics.Rect; 20 | 21 | 22 | /** 23 | * Interface to define a listener when an chart entry has been clicked 24 | */ 25 | public interface OnEntryClickListener { 26 | 27 | /** 28 | * Abstract method to define the code when an entry has been clicked 29 | * 30 | * @param setIndex - index of the entry set clicked 31 | * @param entryIndex - index of the entry within set(setIndex) 32 | * @param rect - a Rect covering the entry area. 33 | */ 34 | void onClick(int setIndex, int entryIndex, Rect rect); 35 | 36 | } 37 | -------------------------------------------------------------------------------- /williamchart/src/main/java/com/db/chart/listener/OnTooltipEventListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Diogo Bernardino 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.db.chart.listener; 18 | 19 | import android.view.View; 20 | 21 | 22 | /** 23 | * Interface to define a listener when an chart entry has been clicked 24 | */ 25 | public interface OnTooltipEventListener { 26 | 27 | void onEnter(View view); 28 | 29 | void onExit(View view); 30 | 31 | } 32 | -------------------------------------------------------------------------------- /williamchart/src/main/java/com/db/chart/model/Bar.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Diogo Bernardino 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.db.chart.model; 18 | 19 | import android.support.annotation.NonNull; 20 | 21 | 22 | /** 23 | * Data model that represents a bar in {@link com.db.chart.view.BaseBarChartView} 24 | */ 25 | public class Bar extends ChartEntry { 26 | 27 | private static final String TAG = "chart.model.Bar"; 28 | 29 | private boolean mHasGradientColor; 30 | 31 | private int[] mGradientColors; 32 | 33 | private float[] mGradientPositions; 34 | 35 | 36 | /** 37 | * Constructor. 38 | * 39 | * @param label 40 | * @param value 41 | */ 42 | public Bar(String label, float value) { 43 | 44 | super(label, value); 45 | 46 | isVisible = true; 47 | mHasGradientColor = false; 48 | } 49 | 50 | 51 | /** 52 | * If bar has gradient fill color defined. 53 | * 54 | * @return true if gradient fill property defined. 55 | */ 56 | public boolean hasGradientColor() { 57 | 58 | return mHasGradientColor; 59 | } 60 | 61 | 62 | /* 63 | * ------------- 64 | * Getters 65 | * ------------- 66 | */ 67 | 68 | 69 | /** 70 | * Retrieve set of colors defining the gradient of bar's fill. 71 | * Gradient fill property must have been previously defined. 72 | * 73 | * @return Gradient colors array. 74 | */ 75 | public int[] getGradientColors() { 76 | 77 | return mGradientColors; 78 | } 79 | 80 | 81 | /** 82 | * Retrieve set of positions to define the gradient of bar's fill. 83 | * Gradient fill property must have been previously defined. 84 | * 85 | * @return Gradient positions. 86 | */ 87 | public float[] getGradientPositions() { 88 | 89 | return mGradientPositions; 90 | } 91 | 92 | 93 | /* 94 | * ------------- 95 | * Setters 96 | * ------------- 97 | */ 98 | 99 | 100 | /** 101 | * Set gradient colors to the fill of the {@link com.db.chart.model.Bar}. 102 | * 103 | * @param colors The colors to be distributed among gradient 104 | * @param positions Position/order from which the colors will be place 105 | * 106 | * @return {@link com.db.chart.model.Bar} self-reference. 107 | */ 108 | public Bar setGradientColor(@NonNull int colors[], float[] positions) { 109 | 110 | if (colors == null || colors.length == 0) 111 | throw new IllegalArgumentException("Colors argument can't be null or empty."); 112 | 113 | mHasGradientColor = true; 114 | mGradientColors = colors; 115 | mGradientPositions = positions; 116 | return this; 117 | } 118 | 119 | } 120 | -------------------------------------------------------------------------------- /williamchart/src/main/java/com/db/chart/model/BarSet.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Diogo Bernardino 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.db.chart.model; 18 | 19 | import android.support.annotation.ColorInt; 20 | import android.support.annotation.NonNull; 21 | 22 | 23 | /** 24 | * Data model containing a set of {@link Bar} to be used by {@link com.db.chart.view.BaseBarChartView}. 25 | */ 26 | public class BarSet extends ChartSet { 27 | 28 | 29 | private static final String TAG = "chart.model.BarSet"; 30 | 31 | 32 | /** 33 | * Constructor. 34 | */ 35 | public BarSet() { 36 | 37 | super(); 38 | } 39 | 40 | 41 | /** 42 | * Constructor. 43 | * 44 | * @param labels 45 | * @param values 46 | */ 47 | public BarSet(@NonNull String[] labels, @NonNull float[] values) { 48 | 49 | super(); 50 | 51 | if (labels == null || values == null) 52 | throw new IllegalArgumentException("Labels or/and values can't be null."); 53 | if (labels.length != values.length) 54 | throw new IllegalArgumentException("Arrays size doesn't match."); 55 | 56 | int nEntries = labels.length; 57 | for (int i = 0; i < nEntries; i++) 58 | addBar(labels[i], values[i]); 59 | } 60 | 61 | 62 | /** 63 | * Add new {@link com.db.chart.model.Bar} from a string and a float. 64 | * 65 | * @param label new {@link com.db.chart.model.Bar}'s label 66 | * @param value new {@link com.db.chart.model.Bar}'s value 67 | */ 68 | public void addBar(String label, float value) { 69 | 70 | this.addBar(new Bar(label, value)); 71 | } 72 | 73 | 74 | /** 75 | * Add new {@link com.db.chart.model.Bar}. 76 | * 77 | * @param bar new nonnull {@link com.db.chart.model.Bar} 78 | */ 79 | public void addBar(@NonNull Bar bar) { 80 | 81 | this.addEntry(bar); 82 | } 83 | 84 | 85 | 86 | /* 87 | * -------- 88 | * Getters 89 | * -------- 90 | */ 91 | 92 | 93 | /** 94 | * Retrieve line's color. 95 | * 96 | * @return {@link com.db.chart.model.BarSet} color. 97 | */ 98 | public int getColor() { 99 | 100 | return this.getEntry(0).getColor(); 101 | } 102 | 103 | 104 | 105 | /* 106 | * ------------- 107 | * Setters 108 | * ------------- 109 | */ 110 | 111 | 112 | /** 113 | * Define the color of bars. Previously defined colors will be overridden. 114 | * 115 | * @param color 116 | * 117 | * @return {@link com.db.chart.model.BarSet} self-reference. 118 | */ 119 | public BarSet setColor(@ColorInt int color) { 120 | 121 | for (ChartEntry e : getEntries()) 122 | e.setColor(color); 123 | return this; 124 | } 125 | 126 | 127 | /** 128 | * Define a gradient color to the bars. Previously defined colors will be overridden. 129 | * 130 | * @param colors The colors to be distributed among gradient 131 | * @param positions Position/order from which the colors will be place 132 | * 133 | * @return {@link com.db.chart.model.BarSet} self-reference. 134 | */ 135 | public BarSet setGradientColor(@NonNull int colors[], float[] positions) { 136 | 137 | if (colors == null || colors.length == 0) 138 | throw new IllegalArgumentException("Colors argument can't be null or empty."); 139 | 140 | for (ChartEntry e : getEntries()) 141 | ((Bar) e).setGradientColor(colors, positions); 142 | return this; 143 | } 144 | 145 | } 146 | -------------------------------------------------------------------------------- /williamchart/src/main/java/com/db/chart/model/ChartEntry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Diogo Bernardino 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.db.chart.model; 18 | 19 | import android.graphics.Color; 20 | import android.support.annotation.ColorInt; 21 | 22 | 23 | /** 24 | * Generic Data model of a {@link com.db.chart.view.ChartView} entry 25 | */ 26 | public abstract class ChartEntry implements Comparable { 27 | 28 | /** Default bar color */ 29 | private static final int DEFAULT_COLOR = -16777216; 30 | 31 | 32 | /** Input from user */ 33 | final private String mLabel; 34 | 35 | /** Defines if entry is visible */ 36 | boolean isVisible; 37 | 38 | private float mValue; 39 | 40 | /** Display coordinates */ 41 | private float mX; 42 | 43 | private float mY; 44 | 45 | /** Bar color */ 46 | private int mColor; 47 | 48 | /** Shadow variables */ 49 | private float mShadowRadius; 50 | 51 | private float mShadowDx; 52 | 53 | private float mShadowDy; 54 | 55 | private int[] mShadowColor; 56 | 57 | 58 | /** 59 | * Constructor. 60 | * 61 | * @param label 62 | * @param value 63 | */ 64 | ChartEntry(String label, float value) { 65 | 66 | mLabel = label; 67 | mValue = value; 68 | 69 | mColor = DEFAULT_COLOR; 70 | 71 | mShadowRadius = 0; 72 | mShadowDx = 0; 73 | mShadowDy = 0; 74 | mShadowColor = new int[4]; 75 | } 76 | 77 | 78 | public boolean isVisible() { 79 | 80 | return isVisible; 81 | } 82 | 83 | 84 | public boolean hasShadow() { 85 | 86 | return mShadowRadius != 0; 87 | } 88 | 89 | 90 | 91 | /* 92 | * -------- 93 | * Getters 94 | * -------- 95 | */ 96 | 97 | 98 | public String getLabel() { 99 | 100 | return mLabel; 101 | } 102 | 103 | 104 | public float getValue() { 105 | 106 | return mValue; 107 | } 108 | 109 | 110 | public float getX() { 111 | 112 | return mX; 113 | } 114 | 115 | 116 | public float getY() { 117 | 118 | return mY; 119 | } 120 | 121 | 122 | public int getColor() { 123 | 124 | return mColor; 125 | } 126 | 127 | 128 | public float getShadowRadius() { 129 | 130 | return mShadowRadius; 131 | } 132 | 133 | 134 | public float getShadowDx() { 135 | 136 | return mShadowDx; 137 | } 138 | 139 | 140 | public float getShadowDy() { 141 | 142 | return mShadowDy; 143 | } 144 | 145 | 146 | public int[] getShadowColor() { 147 | 148 | return mShadowColor; 149 | } 150 | 151 | 152 | 153 | /* 154 | * -------- 155 | * Setters 156 | * -------- 157 | */ 158 | 159 | 160 | /** 161 | * Set new entry value. 162 | * 163 | * @param value New value 164 | */ 165 | public void setValue(float value) { 166 | 167 | mValue = value; 168 | } 169 | 170 | 171 | /** 172 | * Set the parsed display coordinates. 173 | * 174 | * @param x display x coordinate. 175 | * @param y display y coordinate. 176 | */ 177 | public void setCoordinates(float x, float y) { 178 | 179 | mX = x; 180 | mY = y; 181 | } 182 | 183 | 184 | /** 185 | * Define the color of the entry. 186 | * 187 | * @param color Color to be set. 188 | */ 189 | public void setColor(@ColorInt int color) { 190 | 191 | isVisible = true; 192 | mColor = color; 193 | } 194 | 195 | 196 | /** 197 | * Define whether this entry will be drawn or not. 198 | * 199 | * @param visible True if entry should be displayed. 200 | */ 201 | public void setVisible(boolean visible) { 202 | 203 | isVisible = visible; 204 | } 205 | 206 | 207 | /** 208 | * @param radius 209 | * @param dx 210 | * @param dy 211 | * @param color 212 | */ 213 | public void setShadow(float radius, float dx, float dy, @ColorInt int color) { 214 | 215 | mShadowRadius = radius; 216 | mShadowDx = dx; 217 | mShadowDy = dy; 218 | mShadowColor[0] = Color.alpha(color); 219 | mShadowColor[1] = Color.red(color); 220 | mShadowColor[2] = Color.blue(color); 221 | mShadowColor[3] = Color.green(color); 222 | } 223 | 224 | 225 | public String toString() { 226 | 227 | return "Label=" + mLabel + " \n" + "Value=" + mValue + "\n" + 228 | "X = " + mX + "\n" + "Y = " + mY; 229 | } 230 | 231 | 232 | public int compareTo(ChartEntry other) { 233 | 234 | return Float.compare(this.getValue(), other.getValue()); 235 | } 236 | 237 | } 238 | -------------------------------------------------------------------------------- /williamchart/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /williamchart/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 2dp 8 | 9 | 5dp 10 | 11 | 12 | 10dp 13 | 14 | 15 | 1dp 16 | 17 | 18 | 19 | 20 | 18dp 21 | 22 | 23 | 24 | 6dp 25 | 3dp 26 | 0dp 27 | 28 | -------------------------------------------------------------------------------- /williamchart/src/test/java/com/db/chart/model/BarSetTest.java: -------------------------------------------------------------------------------- 1 | package com.db.chart.model; 2 | 3 | import android.test.suitebuilder.annotation.SmallTest; 4 | 5 | import org.junit.Before; 6 | import org.junit.Test; 7 | import org.junit.runner.RunWith; 8 | import org.junit.runners.JUnit4; 9 | 10 | import static org.junit.Assert.assertEquals; 11 | 12 | 13 | @RunWith(JUnit4.class) 14 | @SmallTest 15 | public class BarSetTest { 16 | 17 | BarSet set; 18 | 19 | Bar bar; 20 | 21 | 22 | @Before 23 | public void setUp() { 24 | 25 | set = new BarSet(); 26 | for (int i = 0; i < 3; i++) { 27 | bar = new Bar("test" + Integer.toString(i), (float) i); 28 | set.addBar(bar); 29 | } 30 | } 31 | 32 | 33 | /** 34 | * No null point argument. 35 | */ 36 | @Test(expected = IllegalArgumentException.class) 37 | public void pointNullException() { 38 | 39 | set.addBar(null); 40 | } 41 | 42 | 43 | /** 44 | * Test values update. 45 | */ 46 | @Test 47 | public void updateValues() { 48 | 49 | set.updateValues(new float[] {4f, 5f, 6f}); 50 | assertEquals(4f, set.getValue(0), 0f); 51 | assertEquals(5f, set.getValue(1), 0f); 52 | assertEquals(6f, set.getValue(2), 0f); 53 | } 54 | 55 | 56 | /** 57 | * No different size when updating values. 58 | */ 59 | @Test(expected = IllegalArgumentException.class) 60 | public void updateValuesSizeException() { 61 | 62 | set.updateValues(new float[] {1f, 2f}); 63 | } 64 | 65 | 66 | /** 67 | * Gradient colors can't be null. 68 | */ 69 | @Test(expected = IllegalArgumentException.class) 70 | public void barGradientNullException() { 71 | 72 | bar.setGradientColor(null, new float[] {1.f, 2.f}); 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /williamchart/src/test/java/com/db/chart/view/ChartViewTest.java: -------------------------------------------------------------------------------- 1 | package com.db.chart.view; 2 | 3 | import android.content.Context; 4 | import android.content.res.Resources; 5 | import android.graphics.Region; 6 | import android.test.suitebuilder.annotation.MediumTest; 7 | import android.view.MotionEvent; 8 | import android.view.View; 9 | 10 | import com.db.chart.listener.OnEntryClickListener; 11 | import com.db.chart.model.Bar; 12 | import com.db.chart.model.BarSet; 13 | import com.db.chart.model.ChartSet; 14 | import com.db.chart.renderer.XRenderer; 15 | import com.db.chart.renderer.YRenderer; 16 | 17 | import org.junit.Before; 18 | import org.junit.Test; 19 | import org.junit.runner.RunWith; 20 | import org.mockito.Mock; 21 | import org.mockito.runners.MockitoJUnitRunner; 22 | 23 | import java.util.ArrayList; 24 | 25 | import static org.junit.Assert.assertArrayEquals; 26 | import static org.junit.Assert.assertEquals; 27 | import static org.mockito.Mockito.when; 28 | 29 | 30 | @RunWith(MockitoJUnitRunner.class) 31 | @MediumTest 32 | public class ChartViewTest { 33 | 34 | @Mock 35 | private XRenderer mMockXRndr; 36 | 37 | @Mock 38 | private YRenderer mMockYRndr; 39 | 40 | @Mock 41 | private Context mMockContext; 42 | 43 | @Mock 44 | private Resources mMockResources; 45 | 46 | @Mock 47 | private MotionEvent mMockMotionEvent; 48 | 49 | @Mock 50 | private Region mMockRegion; 51 | 52 | @Mock 53 | private OnEntryClickListener mMockEntryListener; 54 | 55 | @Mock 56 | private View.OnClickListener mMockChartListener; 57 | 58 | private LineChartView mChartView; 59 | 60 | private ArrayList mData; 61 | 62 | 63 | @Before 64 | public void setUp() { 65 | 66 | when(mMockContext.getResources()).thenReturn(mMockResources); 67 | when(mMockResources.getDimension(0)).thenReturn(6.f); 68 | 69 | mChartView = new LineChartView(mMockContext); 70 | BarSet set = new BarSet(); 71 | for (int i = 0; i < 2; i++) 72 | set.addBar(new Bar(Integer.toString(i), (float) i)); 73 | mData = new ArrayList<>(); 74 | mData.add(set); 75 | } 76 | 77 | 78 | @Test(expected = IllegalArgumentException.class) 79 | public void addData_NullSet_ThrowIllegalArgumentException() { 80 | 81 | BarSet set = null; 82 | mChartView.addData(set); 83 | } 84 | 85 | 86 | @Test(expected = IllegalArgumentException.class) 87 | public void addData_LesserEntriesSize_ThrowIllegalArgumentException() { 88 | 89 | mChartView.addData(mData); 90 | BarSet set1 = new BarSet(); 91 | set1.addBar(new Bar("3", 1.f)); 92 | mChartView.addData(set1); 93 | } 94 | 95 | 96 | @Test 97 | public void updateValues_Nominal_Result() { 98 | 99 | mChartView.addData(mData); 100 | mChartView.updateValues(0, new float[] {10, 20}); 101 | 102 | assertEquals(10, mChartView.getData().get(0).getEntry(0).getValue(), 0.f); 103 | assertEquals(20, mChartView.getData().get(0).getEntry(1).getValue(), 0.f); 104 | } 105 | 106 | 107 | @Test(expected = IllegalArgumentException.class) 108 | public void updateValues_LesserValues_ThrowIllegalArgumentException() { 109 | 110 | mChartView.addData(mData); 111 | mChartView.updateValues(0, new float[] {10}); 112 | } 113 | 114 | 115 | @Test 116 | public void negotiateInnerChartBounds_Nominal_InnerB() { 117 | 118 | assertArrayEquals(new float[] {2, 2, 11, 11}, 119 | mChartView.negotiateInnerChartBounds(new float[] {1, 1, 12, 12}, 120 | new float[] {2, 2, 11, 11}), 0.f); 121 | } 122 | 123 | 124 | @SuppressWarnings("Range") 125 | @Test(expected = IllegalArgumentException.class) 126 | public void setGrid_RowsSmallerZero_ThrowIllegalArgException() { 127 | 128 | mChartView.setGrid(-1, -1, null); 129 | } 130 | } 131 | --------------------------------------------------------------------------------