├── .gitignore ├── LICENSE ├── README.md └── mp_chart ├── .gitignore ├── .metadata ├── CHANGELOG.md ├── LICENSE ├── README.md ├── example ├── .gitignore ├── .metadata ├── android │ ├── app │ │ ├── build.gradle │ │ └── src │ │ │ ├── debug │ │ │ └── AndroidManifest.xml │ │ │ ├── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── lqy │ │ │ │ │ └── mp_flutter_chart │ │ │ │ │ └── MainActivity.java │ │ │ └── res │ │ │ │ ├── drawable │ │ │ │ └── launch_background.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 │ │ │ │ └── styles.xml │ │ │ └── profile │ │ │ └── AndroidManifest.xml │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ └── gradle-wrapper.properties │ ├── settings.gradle │ └── settings_aar.gradle ├── assets │ ├── cosine.txt │ ├── fonts │ │ ├── OpenSans-Bold.ttf │ │ ├── OpenSans-BoldItalic.ttf │ │ ├── OpenSans-ExtraBold.ttf │ │ ├── OpenSans-ExtraBoldItalic.ttf │ │ ├── OpenSans-Italic.ttf │ │ ├── OpenSans-Light.ttf │ │ ├── OpenSans-LightItalic.ttf │ │ ├── OpenSans-Regular.ttf │ │ ├── OpenSans-Semibold.ttf │ │ └── OpenSans-SemiboldItalic.ttf │ ├── hugecosine.txt │ ├── hugesine.txt │ ├── img │ │ ├── add.png │ │ ├── close.png │ │ └── star.png │ ├── n.txt │ ├── nlogn.txt │ ├── othersine.txt │ ├── sine.txt │ ├── square.txt │ ├── stacked_bars.txt │ └── three.txt ├── ios │ ├── File.swift │ ├── Flutter │ │ ├── AppFrameworkInfo.plist │ │ ├── Debug.xcconfig │ │ └── Release.xcconfig │ ├── Podfile │ ├── Podfile.lock │ ├── Runner-Bridging-Header.h │ ├── Runner.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ │ └── IDEWorkspaceChecks.plist │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ ├── Runner.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ └── WorkspaceSettings.xcsettings │ └── Runner │ │ ├── AppDelegate.h │ │ ├── AppDelegate.m │ │ ├── Assets.xcassets │ │ ├── AppIcon.appiconset │ │ │ ├── Contents.json │ │ │ ├── icon-1024.png │ │ │ ├── icon-20-ipad.png │ │ │ ├── icon-20@2x-ipad.png │ │ │ ├── icon-20@2x.png │ │ │ ├── icon-20@3x.png │ │ │ ├── icon-29-ipad.png │ │ │ ├── icon-29.png │ │ │ ├── icon-29@2x-ipad.png │ │ │ ├── icon-29@2x.png │ │ │ ├── icon-29@3x.png │ │ │ ├── icon-40.png │ │ │ ├── icon-40@2x.png │ │ │ ├── icon-40@3x.png │ │ │ ├── icon-60@2x.png │ │ │ ├── icon-60@3x.png │ │ │ ├── icon-76.png │ │ │ ├── icon-76@2x.png │ │ │ └── icon-83.5@2x.png │ │ └── LaunchImage.imageset │ │ │ ├── Contents.json │ │ │ ├── LaunchImage.png │ │ │ ├── LaunchImage@2x.png │ │ │ ├── LaunchImage@3x.png │ │ │ └── README.md │ │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ │ ├── Info.plist │ │ └── main.m ├── lib │ ├── demo │ │ ├── action_state.dart │ │ ├── bar_chart │ │ │ ├── basic.dart │ │ │ ├── basic2.dart │ │ │ ├── horizontal.dart │ │ │ ├── multiple.dart │ │ │ ├── negative.dart │ │ │ ├── sine.dart │ │ │ ├── stacked.dart │ │ │ └── stacked2.dart │ │ ├── even_more │ │ │ ├── dynamic.dart │ │ │ ├── hourly.dart │ │ │ └── realtime.dart │ │ ├── line_chart │ │ │ ├── basic.dart │ │ │ ├── colorful.dart │ │ │ ├── cubic.dart │ │ │ ├── dual_axis.dart │ │ │ ├── filled.dart │ │ │ ├── invert_axis.dart │ │ │ ├── multiple.dart │ │ │ └── performance.dart │ │ ├── other_chart │ │ │ ├── bubble.dart │ │ │ ├── candlestick.dart │ │ │ ├── combined.dart │ │ │ ├── radar.dart │ │ │ └── scatter_plot.dart │ │ ├── pie_chart │ │ │ ├── basic.dart │ │ │ ├── half_pie.dart │ │ │ └── value_lines.dart │ │ ├── res │ │ │ ├── colors.dart │ │ │ ├── dimens.dart │ │ │ ├── resources.dart │ │ │ └── styles.dart │ │ ├── scrolling_chart │ │ │ ├── many_bar_chart.dart │ │ │ ├── multiple.dart │ │ │ ├── tall_bar.dart │ │ │ └── view_pager.dart │ │ └── util.dart │ └── main.dart ├── pubspec.yaml └── test │ └── widget_test.dart ├── img ├── bar_charts │ ├── basic.png │ ├── basic2.png │ ├── horizontal.png │ ├── multiple.png │ ├── negative.png │ ├── sine.png │ ├── stacked.png │ └── stacked2.png ├── even_more_charts │ ├── dynamic.png │ ├── hourly.png │ └── realtime.png ├── line_charts │ ├── basic.png │ ├── colorful.png │ ├── cubic.png │ ├── dual_axis.png │ ├── filled.png │ ├── invert_axis.png │ ├── multiple.png │ └── performance.png ├── other_charts │ ├── bubble.png │ ├── candle.png │ ├── combined.png │ ├── radar.png │ └── scatter.png ├── pie_charts │ ├── basic.png │ ├── half_pie.png │ └── value_lines.png └── scrolling_charts │ ├── many.png │ ├── multiple.png │ ├── tall.png │ └── view_pager.png ├── killdart.sh ├── lib ├── mp │ ├── chart │ │ ├── bar_chart.dart │ │ ├── bar_line_scatter_candle_bubble_chart.dart │ │ ├── bubble_chart.dart │ │ ├── candlestick_chart.dart │ │ ├── chart.dart │ │ ├── combined_chart.dart │ │ ├── horizontal_bar_chart.dart │ │ ├── line_chart.dart │ │ ├── pie_chart.dart │ │ ├── pie_radar_chart.dart │ │ ├── radar_chart.dart │ │ └── scatter_chart.dart │ ├── controller │ │ ├── bar_chart_controller.dart │ │ ├── bar_line_scatter_candle_bubble_controller.dart │ │ ├── bubble_chart_controller.dart │ │ ├── candlestick_chart_controller.dart │ │ ├── combined_chart_controller.dart │ │ ├── controller.dart │ │ ├── horizontal_bar_chart_controller.dart │ │ ├── line_chart_controller.dart │ │ ├── pie_chart_controller.dart │ │ ├── pie_radar_controller.dart │ │ ├── radar_chart_controller.dart │ │ └── scatter_chart_controller.dart │ ├── core │ │ ├── adapter_android_mp.dart │ │ ├── animator.dart │ │ ├── axis │ │ │ ├── axis_base.dart │ │ │ ├── x_axis.dart │ │ │ └── y_axis.dart │ │ ├── bounds.dart │ │ ├── buffer │ │ │ ├── abstract_buffer.dart │ │ │ ├── bar_buffer.dart │ │ │ └── horizontal_bar_buffer.dart │ │ ├── cache.dart │ │ ├── chart_trans_listener.dart │ │ ├── color │ │ │ └── gradient_color.dart │ │ ├── common_interfaces.dart │ │ ├── component.dart │ │ ├── data │ │ │ ├── bar_data.dart │ │ │ ├── bar_line_scatter_candle_bubble_data.dart │ │ │ ├── bubble_data.dart │ │ │ ├── candle_data.dart │ │ │ ├── chart_data.dart │ │ │ ├── combined_data.dart │ │ │ ├── line_data.dart │ │ │ ├── pie_data.dart │ │ │ ├── radar_data.dart │ │ │ └── scatter_data.dart │ │ ├── data_interfaces │ │ │ ├── i_bar_data_set.dart │ │ │ ├── i_bar_line_scatter_candle_bubble_data_set.dart │ │ │ ├── i_bubble_data_set.dart │ │ │ ├── i_candle_data_set.dart │ │ │ ├── i_data_set.dart │ │ │ ├── i_line_data_set.dart │ │ │ ├── i_line_radar_data_set.dart │ │ │ ├── i_line_scatter_candle_radar_data_set.dart │ │ │ ├── i_pie_data_set.dart │ │ │ ├── i_radar_data_set.dart │ │ │ └── i_scatter_data_set.dart │ │ ├── data_provider │ │ │ ├── bar_data_provider.dart │ │ │ ├── bar_line_scatter_candle_bubble_data_provider.dart │ │ │ ├── bubble_data_provider.dart │ │ │ ├── candle_data_provider.dart │ │ │ ├── chart_interface.dart │ │ │ ├── combined_data_provider.dart │ │ │ ├── line_data_provider.dart │ │ │ └── scatter_data_provider.dart │ │ ├── data_set │ │ │ ├── bar_data_set.dart │ │ │ ├── bar_line_scatter_candle_bubble_data_set.dart │ │ │ ├── base_data_set.dart │ │ │ ├── bubble_data_set.dart │ │ │ ├── candle_data_set.dart │ │ │ ├── data_set.dart │ │ │ ├── line_data_set.dart │ │ │ ├── line_radar_data_set.dart │ │ │ ├── line_scatter_candle_radar_data_set.dart │ │ │ ├── pie_data_set.dart │ │ │ ├── radar_data_set.dart │ │ │ └── scatter_data_set.dart │ │ ├── description.dart │ │ ├── entry │ │ │ ├── bar_entry.dart │ │ │ ├── base_entry.dart │ │ │ ├── bubble_entry.dart │ │ │ ├── candle_entry.dart │ │ │ ├── entry.dart │ │ │ ├── pie_entry.dart │ │ │ └── radar_entry.dart │ │ ├── enums │ │ │ ├── axis_dependency.dart │ │ │ ├── legend_direction.dart │ │ │ ├── legend_form.dart │ │ │ ├── legend_horizontal_alignment.dart │ │ │ ├── legend_orientation.dart │ │ │ ├── legend_vertical_alignment.dart │ │ │ ├── limit_label_postion.dart │ │ │ ├── mode.dart │ │ │ ├── rounding.dart │ │ │ ├── scatter_shape.dart │ │ │ ├── value_position.dart │ │ │ ├── x_axis_position.dart │ │ │ └── y_axis_label_position.dart │ │ ├── fill_formatter │ │ │ ├── default_fill_formatter.dart │ │ │ └── i_fill_formatter.dart │ │ ├── functions.dart │ │ ├── highlight │ │ │ ├── bar_highlighter.dart │ │ │ ├── chart_hightlighter.dart │ │ │ ├── combined_highlighter.dart │ │ │ ├── highlight.dart │ │ │ ├── horizontal_bar_highlighter.dart │ │ │ ├── i_highlighter.dart │ │ │ ├── pie_highlighter.dart │ │ │ ├── pie_radar_highlighter.dart │ │ │ └── radar_highlighter.dart │ │ ├── image_loader.dart │ │ ├── legend │ │ │ ├── legend.dart │ │ │ └── legend_entry.dart │ │ ├── limit_line.dart │ │ ├── marker │ │ │ ├── bar_chart_marker.dart │ │ │ ├── horizontal_bar_chart_marker.dart │ │ │ ├── i_marker.dart │ │ │ ├── line_chart_marker.dart │ │ │ └── radar_chart_marker.dart │ │ ├── poolable │ │ │ ├── point.dart │ │ │ └── size.dart │ │ ├── range.dart │ │ ├── render │ │ │ ├── axis_renderer.dart │ │ │ ├── bar_chart_renderer.dart │ │ │ ├── bar_line_scatter_candle_bubble_renderer.dart │ │ │ ├── bubble_chart_renderer.dart │ │ │ ├── candle_stick_chart_renderer.dart │ │ │ ├── chevron_down_shape_renderer.dart │ │ │ ├── chevron_up_shape_renderer.dart │ │ │ ├── circle_shape_renderer.dart │ │ │ ├── combined_chart_renderer.dart │ │ │ ├── cross_shape_renderer.dart │ │ │ ├── data_renderer.dart │ │ │ ├── horizontal_bar_chart_renderer.dart │ │ │ ├── i_shape_renderer.dart │ │ │ ├── legend_renderer.dart │ │ │ ├── line_chart_renderer.dart │ │ │ ├── line_radar_renderer.dart │ │ │ ├── line_scatter_candle_radar_renderer.dart │ │ │ ├── pie_chart_renderer.dart │ │ │ ├── radar_chart_renderer.dart │ │ │ ├── renderer.dart │ │ │ ├── scatter_chart_renderer.dart │ │ │ ├── square_shape_renderer.dart │ │ │ ├── triangle_shape_renderer.dart │ │ │ ├── x_axis_renderer.dart │ │ │ ├── x_axis_renderer_horizontal_bar_chart.dart │ │ │ ├── x_axis_renderer_radar_chart.dart │ │ │ ├── x_shape_renderer.dart │ │ │ ├── y_axis_renderer.dart │ │ │ ├── y_axis_renderer_horizontal_bar_chart.dart │ │ │ └── y_axis_renderer_radar_chart.dart │ │ ├── touch_listener.dart │ │ ├── transformer │ │ │ ├── transformer.dart │ │ │ └── transformer_horizontal_bar_chart.dart │ │ ├── utils │ │ │ ├── canvas_utils.dart │ │ │ ├── color_utils.dart │ │ │ ├── dart_adapter_utils.dart │ │ │ ├── highlight_utils.dart │ │ │ ├── matrix4_utils.dart │ │ │ ├── painter_utils.dart │ │ │ ├── screen_utils.dart │ │ │ └── utils.dart │ │ ├── value_formatter │ │ │ ├── day_axis_value_formatter.dart │ │ │ ├── default_axis_value_formatter.dart │ │ │ ├── default_value_formatter.dart │ │ │ ├── large_value_formatter.dart │ │ │ ├── my_value_formatter.dart │ │ │ ├── percent_formatter.dart │ │ │ ├── stacked_value_formatter.dart │ │ │ └── value_formatter.dart │ │ └── view_port.dart │ └── painter │ │ ├── bar_chart_painter.dart │ │ ├── bar_line_chart_painter.dart │ │ ├── bubble_chart_painter.dart │ │ ├── candlestick_chart_painter.dart │ │ ├── combined_chart_painter.dart │ │ ├── horizontal_bar_chart_painter.dart │ │ ├── line_chart_painter.dart │ │ ├── painter.dart │ │ ├── pie_chart_painter.dart │ │ ├── pie_redar_chart_painter.dart │ │ ├── radar_chart_painter.dart │ │ └── scatter_chart_painter.dart └── mp_chart.dart ├── pubspec.yaml ├── test └── mp_chart_test.dart └── upload.sh /.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | 12 | # IntelliJ related 13 | *.iml 14 | *.ipr 15 | *.iws 16 | .idea/ 17 | 18 | # The .vscode folder contains launch configuration and tasks you configure in 19 | # VS Code which you may wish to be included in version control, so this line 20 | # is commented out by default. 21 | #.vscode/ 22 | 23 | # Flutter/Dart/Pub related 24 | **/doc/api/ 25 | .dart_tool/ 26 | .flutter-plugins 27 | .packages 28 | .pub-cache/ 29 | .pub/ 30 | /build/ 31 | /mp_flutter_chart/build/ 32 | /mp_chart/build/ 33 | pubspec.lock 34 | 35 | # Android related 36 | **/android/**/gradle-wrapper.jar 37 | **/android/.gradle 38 | **/android/captures/ 39 | **/android/gradlew 40 | **/android/gradlew.bat 41 | **/android/local.properties 42 | **/android/**/GeneratedPluginRegistrant.java 43 | 44 | # iOS/XCode related 45 | **/ios/**/*.mode1v3 46 | **/ios/**/*.mode2v3 47 | **/ios/**/*.moved-aside 48 | **/ios/**/*.pbxuser 49 | **/ios/**/*.perspectivev3 50 | **/ios/**/*sync/ 51 | **/ios/**/.sconsign.dblite 52 | **/ios/**/.tags* 53 | **/ios/**/.vagrant/ 54 | **/ios/**/DerivedData/ 55 | **/ios/**/Icon? 56 | **/ios/**/Pods/ 57 | **/ios/**/.symlinks/ 58 | **/ios/**/profile 59 | **/ios/**/xcuserdata 60 | **/ios/.generated/ 61 | **/ios/Flutter/App.framework 62 | **/ios/Flutter/Flutter.framework 63 | **/ios/Flutter/Generated.xcconfig 64 | **/ios/Flutter/app.flx 65 | **/ios/Flutter/app.zip 66 | **/ios/Flutter/flutter_assets/ 67 | **/ios/ServiceDefinitions.json 68 | **/ios/Runner/GeneratedPluginRegistrant.* 69 | 70 | # Exceptions to above rules. 71 | !**/ios/**/default.mode1v3 72 | !**/ios/**/default.mode2v3 73 | !**/ios/**/default.pbxuser 74 | !**/ios/**/default.perspectivev3 75 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages 76 | -------------------------------------------------------------------------------- /mp_chart/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | 12 | # IntelliJ related 13 | *.iml 14 | *.ipr 15 | *.iws 16 | .idea/ 17 | 18 | # The .vscode folder contains launch configuration and tasks you configure in 19 | # VS Code which you may wish to be included in version control, so this line 20 | # is commented out by default. 21 | #.vscode/ 22 | 23 | # Flutter/Dart/Pub related 24 | **/doc/api/ 25 | .dart_tool/ 26 | .flutter-plugins 27 | .packages 28 | .pub-cache/ 29 | .pub/ 30 | build/ 31 | 32 | # Android related 33 | **/android/**/gradle-wrapper.jar 34 | **/android/.gradle 35 | **/android/captures/ 36 | **/android/gradlew 37 | **/android/gradlew.bat 38 | **/android/local.properties 39 | **/android/**/GeneratedPluginRegistrant.java 40 | 41 | # iOS/XCode related 42 | **/ios/**/*.mode1v3 43 | **/ios/**/*.mode2v3 44 | **/ios/**/*.moved-aside 45 | **/ios/**/*.pbxuser 46 | **/ios/**/*.perspectivev3 47 | **/ios/**/*sync/ 48 | **/ios/**/.sconsign.dblite 49 | **/ios/**/.tags* 50 | **/ios/**/.vagrant/ 51 | **/ios/**/DerivedData/ 52 | **/ios/**/Icon? 53 | **/ios/**/Pods/ 54 | **/ios/**/.symlinks/ 55 | **/ios/**/profile 56 | **/ios/**/xcuserdata 57 | **/ios/.generated/ 58 | **/ios/Flutter/App.framework 59 | **/ios/Flutter/Flutter.framework 60 | **/ios/Flutter/Generated.xcconfig 61 | **/ios/Flutter/app.flx 62 | **/ios/Flutter/app.zip 63 | **/ios/Flutter/flutter_assets/ 64 | **/ios/ServiceDefinitions.json 65 | **/ios/Runner/GeneratedPluginRegistrant.* 66 | 67 | # Exceptions to above rules. 68 | !**/ios/**/default.mode1v3 69 | !**/ios/**/default.mode2v3 70 | !**/ios/**/default.pbxuser 71 | !**/ios/**/default.perspectivev3 72 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages 73 | -------------------------------------------------------------------------------- /mp_chart/.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: 2e540931f73593e35627592ca4f9a4ca3035ed31 8 | channel: unknown 9 | 10 | project_type: package 11 | -------------------------------------------------------------------------------- /mp_chart/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.3.1 2020-10-30 2 | * Updated for Flutter 1.22.0 to use updated Dart intl package 0.17.0-nullsafety.1. 3 | ## 0.3.0 2020-09-18 4 | * Updated for Flutter 1.22.0 to use update optimized_gesture_detector package. 5 | * 0.3.0 is for Flutter 1.22 and newer prior version 0.2.2 is for pre-Flutter 1.22 versions. 6 | ## 0.2.2 2020-06-27 7 | * in a single scale do not change the scale direction 8 | ## 0.2.1 2020-06-07 9 | * add chart control in scrollable view like PageView etc. 10 | ## 0.2.0 2020-05-18 11 | * fix chart data's setValueTextSize setValueTypeface not work 12 | ## 0.1.9 2020-03-18 13 | * Support trans background 14 | * Support legend text color set 15 | * Fix pie radar chart rotateEnabled no used 16 | * Fix bugs when description is enabled 17 | ## 0.1.8 2020-03-08 18 | * Support addEntryByIndex in line scatter bubble candlestick chart 19 | * Support updateEntryByIndex in all chart 20 | ## 0.1.7 2020-02-22 21 | * Updated dependency to include vector_math package. 22 | ## 0.1.6 2020-02-21 23 | * Copied LICENSE file to mp_chart directory [#66](https://github.com/SunPointed/MPFlutterChart/pull/66). 24 | * Updated .gitignore not show modified or generated files e.g., pubspec.lock, .flutter-plugins-dependencies and ios/Flutter/flutter_export_environment.sh [#66](https://github.com/SunPointed/MPFlutterChart/pull/66). 25 | * Removed any checked in pubspec.lock files [#66](https://github.com/SunPointed/MPFlutterChart/pull/66). -------------------------------------------------------------------------------- /mp_chart/example/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated files not intended to be checked in to version control 2 | .flutter-plugins-dependencies 3 | ios/Flutter/flutter_export_environment.sh 4 | -------------------------------------------------------------------------------- /mp_chart/example/.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: 2e540931f73593e35627592ca4f9a4ca3035ed31 8 | channel: unknown 9 | 10 | project_type: app 11 | -------------------------------------------------------------------------------- /mp_chart/example/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | def localProperties = new Properties() 2 | def localPropertiesFile = rootProject.file('local.properties') 3 | if (localPropertiesFile.exists()) { 4 | localPropertiesFile.withReader('UTF-8') { reader -> 5 | localProperties.load(reader) 6 | } 7 | } 8 | 9 | def flutterRoot = localProperties.getProperty('flutter.sdk') 10 | if (flutterRoot == null) { 11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") 12 | } 13 | 14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 15 | if (flutterVersionCode == null) { 16 | flutterVersionCode = '1' 17 | } 18 | 19 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 20 | if (flutterVersionName == null) { 21 | flutterVersionName = '1.0' 22 | } 23 | 24 | apply plugin: 'com.android.application' 25 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 26 | 27 | android { 28 | compileSdkVersion 28 29 | 30 | lintOptions { 31 | disable 'InvalidPackage' 32 | } 33 | 34 | defaultConfig { 35 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 36 | applicationId "com.lqy.example" 37 | minSdkVersion 16 38 | targetSdkVersion 28 39 | versionCode flutterVersionCode.toInteger() 40 | versionName flutterVersionName 41 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 42 | } 43 | 44 | buildTypes { 45 | release { 46 | // TODO: Add your own signing config for the release build. 47 | // Signing with the debug keys for now, so `flutter run --release` works. 48 | signingConfig signingConfigs.debug 49 | } 50 | } 51 | } 52 | 53 | flutter { 54 | source '../..' 55 | } 56 | 57 | dependencies { 58 | testImplementation 'junit:junit:4.12' 59 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 60 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 61 | } 62 | -------------------------------------------------------------------------------- /mp_chart/example/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /mp_chart/example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 12 | 15 | 22 | 26 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /mp_chart/example/android/app/src/main/java/com/lqy/mp_flutter_chart/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.lqy.example; 2 | 3 | import io.flutter.embedding.android.FlutterActivity; 4 | 5 | public class MainActivity extends FlutterActivity { 6 | } 7 | -------------------------------------------------------------------------------- /mp_chart/example/android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /mp_chart/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /mp_chart/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /mp_chart/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /mp_chart/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /mp_chart/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /mp_chart/example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | -------------------------------------------------------------------------------- /mp_chart/example/android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /mp_chart/example/android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | google() 4 | jcenter() 5 | } 6 | 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:3.2.1' 9 | } 10 | } 11 | 12 | allprojects { 13 | repositories { 14 | google() 15 | jcenter() 16 | } 17 | } 18 | 19 | rootProject.buildDir = '../build' 20 | subprojects { 21 | project.buildDir = "${rootProject.buildDir}/${project.name}" 22 | } 23 | subprojects { 24 | project.evaluationDependsOn(':app') 25 | } 26 | 27 | task clean(type: Delete) { 28 | delete rootProject.buildDir 29 | } 30 | -------------------------------------------------------------------------------- /mp_chart/example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | android.enableR8=true 5 | -------------------------------------------------------------------------------- /mp_chart/example/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Jun 23 08:50:38 CEST 2017 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-4.10.2-all.zip 7 | -------------------------------------------------------------------------------- /mp_chart/example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | 3 | def flutterProjectRoot = rootProject.projectDir.parentFile.toPath() 4 | 5 | def plugins = new Properties() 6 | def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins') 7 | if (pluginsFile.exists()) { 8 | pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) } 9 | } 10 | 11 | plugins.each { name, path -> 12 | def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile() 13 | include ":$name" 14 | project(":$name").projectDir = pluginDirectory 15 | } 16 | -------------------------------------------------------------------------------- /mp_chart/example/android/settings_aar.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /mp_chart/example/assets/fonts/OpenSans-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/example/assets/fonts/OpenSans-Bold.ttf -------------------------------------------------------------------------------- /mp_chart/example/assets/fonts/OpenSans-BoldItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/example/assets/fonts/OpenSans-BoldItalic.ttf -------------------------------------------------------------------------------- /mp_chart/example/assets/fonts/OpenSans-ExtraBold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/example/assets/fonts/OpenSans-ExtraBold.ttf -------------------------------------------------------------------------------- /mp_chart/example/assets/fonts/OpenSans-ExtraBoldItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/example/assets/fonts/OpenSans-ExtraBoldItalic.ttf -------------------------------------------------------------------------------- /mp_chart/example/assets/fonts/OpenSans-Italic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/example/assets/fonts/OpenSans-Italic.ttf -------------------------------------------------------------------------------- /mp_chart/example/assets/fonts/OpenSans-Light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/example/assets/fonts/OpenSans-Light.ttf -------------------------------------------------------------------------------- /mp_chart/example/assets/fonts/OpenSans-LightItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/example/assets/fonts/OpenSans-LightItalic.ttf -------------------------------------------------------------------------------- /mp_chart/example/assets/fonts/OpenSans-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/example/assets/fonts/OpenSans-Regular.ttf -------------------------------------------------------------------------------- /mp_chart/example/assets/fonts/OpenSans-Semibold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/example/assets/fonts/OpenSans-Semibold.ttf -------------------------------------------------------------------------------- /mp_chart/example/assets/fonts/OpenSans-SemiboldItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/example/assets/fonts/OpenSans-SemiboldItalic.ttf -------------------------------------------------------------------------------- /mp_chart/example/assets/img/add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/example/assets/img/add.png -------------------------------------------------------------------------------- /mp_chart/example/assets/img/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/example/assets/img/close.png -------------------------------------------------------------------------------- /mp_chart/example/assets/img/star.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/example/assets/img/star.png -------------------------------------------------------------------------------- /mp_chart/example/assets/n.txt: -------------------------------------------------------------------------------- 1 | 0.0#0 2 | 0.05#1 3 | 0.1#2 4 | 0.15#3 5 | 0.2#4 6 | 0.25#5 7 | 0.3#6 8 | 0.35000002#7 9 | 0.40000004#8 10 | 0.45000005#9 11 | 0.50000006#10 12 | 0.5500001#11 13 | 0.6000001#12 14 | 0.6500001#13 15 | 0.7000001#14 16 | 0.7500001#15 17 | 0.80000013#16 18 | 0.85000014#17 19 | 0.90000015#18 20 | 0.95000017#19 21 | 1.0000001#20 22 | 1.0500001#21 23 | 1.1#22 24 | 1.15#23 25 | 1.1999999#24 26 | 1.2499999#25 27 | 1.2999998#26 28 | 1.3499998#27 29 | 1.3999997#28 30 | 1.4499997#29 31 | 1.4999996#30 32 | 1.5499996#31 33 | 1.5999995#32 34 | 1.6499995#33 35 | 1.6999995#34 36 | 1.7499994#35 37 | 1.7999994#36 38 | 1.8499993#37 39 | 1.8999993#38 40 | 1.9499992#39 41 | 1.9999992#40 42 | 2.0499992#41 43 | 2.0999992#42 44 | 2.1499991#43 45 | 2.199999#44 46 | 2.249999#45 47 | 2.299999#46 48 | 2.349999#47 49 | 2.399999#48 50 | 2.4499989#49 51 | 2.4999988#50 52 | 2.5499988#51 53 | 2.5999987#52 54 | 2.6499987#53 55 | 2.6999986#54 56 | 2.7499986#55 57 | 2.7999985#56 58 | 2.8499985#57 59 | 2.8999984#58 60 | 2.9499984#59 61 | 2.9999983#60 62 | 3.0499983#61 63 | 3.0999982#62 64 | 3.1499982#63 65 | 3.1999981#64 66 | 3.249998#65 67 | 3.299998#66 68 | 3.349998#67 69 | 3.399998#68 70 | 3.449998#69 71 | 3.4999979#70 72 | 3.5499978#71 73 | 3.5999978#72 74 | 3.6499977#73 75 | 3.6999977#74 76 | 3.7499976#75 77 | 3.7999976#76 78 | 3.8499975#77 79 | 3.8999975#78 80 | 3.9499974#79 81 | 3.9999974#80 82 | 4.0499973#81 83 | 4.0999975#82 84 | 4.1499977#83 85 | 4.199998#84 86 | 4.249998#85 87 | 4.2999983#86 88 | 4.3499985#87 89 | 4.3999987#88 90 | 4.449999#89 91 | 4.499999#90 92 | 4.549999#91 93 | 4.5999994#92 94 | 4.6499996#93 95 | 4.7#94 96 | 4.75#95 97 | 4.8#96 98 | 4.8500004#97 99 | 4.9000006#98 100 | 4.950001#99 -------------------------------------------------------------------------------- /mp_chart/example/assets/nlogn.txt: -------------------------------------------------------------------------------- 1 | 0.0#0 2 | -0.14978661516463596#1 3 | -0.2302585112404076#2 4 | -0.28456800308013386#3 5 | -0.32188758430308656#4 6 | -0.34657359027997264#5 7 | -0.36119184372932583#6 8 | -0.36743774476238833#7 9 | -0.3665162897559837#8 10 | -0.359328453690093#9 11 | -0.3465735719901158#10 12 | -0.32881032165064733#11 13 | -0.3064953334396977#12 14 | -0.28000884117531694#13 15 | -0.24967239173581385#14 16 | -0.21576146942391214#15 17 | -0.1785147391820012#16 18 | -0.13814097027046854#17 19 | -0.0948243254478918#18 20 | -0.04872847133564503#19 21 | 1.1920929665620834E-7#20 22 | 0.05122974739322425#21 23 | 0.10484122389898727#22 24 | 0.16072620655739048#23 25 | 0.21878578358651998#24 26 | 0.2789292933326941#25 27 | 0.34107333312798316#26 28 | 0.4051409208357928#27 29 | 0.4710607807659298#28 30 | 0.538766731719029#29 31 | 0.6081971595287982#30 32 | 0.6792945600019588#31 33 | 0.7520051408885056#32 34 | 0.8262784736489888#33 35 | 0.9020671874662887#34 36 | 0.9793266992836409#35 37 | 1.0580149747177598#36 38 | 1.1380923155552924#37 39 | 1.219521170237435#38 40 | 1.3022659643057064#39 41 | 1.3862929482479571#40 42 | 1.4715702653505391#41 43 | 1.5580670118770785#42 44 | 1.6457543452870462#43 45 | 1.7346045724760228#44 46 | 1.8245912594493057#45 47 | 1.9156891473526845#46 48 | 2.0078740758078952#47 49 | 2.1011229127752893#48 50 | 2.195413490263484#49 51 | 2.290724545289105#50 52 | 2.3870356655613914#51 53 | 2.4843272394282487#52 54 | 2.582580409673842#53 55 | 2.6817770308042372#54 56 | 2.7818996294980054#55 57 | 2.8829313679339723#56 58 | 2.984856009739134#57 59 | 3.0876578883268277#58 60 | 3.191321877419036#59 61 | 3.2958333635676733#60 62 | 3.401178220508231#61 63 | 3.507342785195528#62 64 | 3.6143138353859015#63 65 | 3.7220785686430475#64 66 | 3.8306245826562813#65 67 | 3.939939856770217#66 68 | 4.050012734634095#67 69 | 4.160831907887155#68 70 | 4.272386400803882#69 71 | 4.384665555829532#70 72 | 4.497659019942356#71 73 | 4.6113567317842685#72 74 | 4.725748909506607#73 75 | 4.840826039281976#74 76 | 4.956578864437172#75 77 | 5.072998375165778#76 78 | 5.190075798782273#77 79 | 5.307802590482506#78 80 | 5.4261704245780376#79 81 | 5.545171186174402#80 82 | 5.664796963265484#81 83 | 5.785040614042304#82 84 | 5.9058940410526075#83 85 | 6.027349897205024#84 86 | 6.149401010352234#85 87 | 6.2720403771158635#86 88 | 6.395261156998629#87 89 | 6.519056666767231#88 90 | 6.643420375090577#89 91 | 6.768345897419035#90 92 | 6.893826991091276#91 93 | 7.019857550656251#92 94 | 7.146431603398553#93 95 | 7.273543305056277#94 96 | 7.401186935721112#95 97 | 7.529356895911067#96 98 | 7.658047702806867#97 99 | 7.787253986643549#98 100 | 7.916970487249359#99 -------------------------------------------------------------------------------- /mp_chart/example/assets/square.txt: -------------------------------------------------------------------------------- 1 | 0.0#0 2 | 0.0025000000745058065#1 3 | 0.010000000298023226#2 4 | 0.02250000178813938#3 5 | 0.040000001192092904#4 6 | 0.0625#5 7 | 0.09000000715255752#6 8 | 0.1225000166893011#7 9 | 0.16000002861023077#8 10 | 0.2025000429153465#9 11 | 0.25000005960464833#10 12 | 0.3025000786781362#11 13 | 0.3600001001358102#12 14 | 0.42250012397767023#13 15 | 0.49000015020371634#14 16 | 0.5625001788139485#15 17 | 0.6400002098083668#16 18 | 0.7225002431869711#17 19 | 0.8100002789497616#18 20 | 0.9025003170967381#19 21 | 1.0000002384185933#20 22 | 1.10250015020371#21 23 | 1.210000052452088#22 24 | 1.3224999451637274#23 25 | 1.4399998283386282#24 26 | 1.5624997019767903#25 27 | 1.6899995660782139#26 28 | 1.8224994206428988#27 29 | 1.9599992656708451#28 30 | 2.102499101162053#29 31 | 2.249998927116522#30 32 | 2.4024987435342524#31 33 | 2.5599985504152443#32 34 | 2.7224983477594975#33 35 | 2.889998135567012#34 36 | 3.062497913837788#35 37 | 3.2399976825718255#36 38 | 3.4224974417691243#37 39 | 3.6099971914296844#38 40 | 3.802496931553506#39 41 | 3.999996662140589#40 42 | 4.202496871948824#41 43 | 4.4099965953833475#42 44 | 4.622496309281132#43 45 | 4.839996013642178#44 46 | 5.062495708466486#45 47 | 5.2899953937540545#46 48 | 5.522495069504885#47 49 | 5.759994735718976#48 50 | 6.002494392396329#49 51 | 6.2499940395369435#50 52 | 6.502493677140819#51 53 | 6.759993305207956#52 54 | 7.022492923738355#53 55 | 7.289992532732015#54 56 | 7.562492132188936#55 57 | 7.839991722109119#56 58 | 8.122491302492563#57 59 | 8.409990873339268#58 60 | 8.702490434649235#59 61 | 8.999989986422463#60 62 | 9.302489528658953#61 63 | 9.609989061358704#62 64 | 9.922488584521716#63 65 | 10.23998809814799#64 66 | 10.562487602237525#65 67 | 10.889987096790321#66 68 | 11.222486581806379#67 69 | 11.559986057285698#68 70 | 11.902485523228279#69 71 | 12.249984979634121#70 72 | 12.602484426503224#71 73 | 12.959983863835589#72 74 | 13.322483291631215#73 75 | 13.689982709890103#74 76 | 14.062482118612252#75 77 | 14.439981517797662#76 78 | 14.822480907446334#77 79 | 15.209980287558267#78 80 | 15.602479658133461#79 81 | 15.999979019171917#80 82 | 16.402478370673634#81 83 | 16.809979667669722#82 84 | 17.222481002812856#83 85 | 17.639982376103035#84 86 | 18.06248378754026#85 87 | 18.48998523712453#86 88 | 18.922486724855844#87 89 | 19.359988250734204#88 90 | 19.80248981475961#89 91 | 20.249991416932062#90 92 | 20.70249305725156#91 93 | 21.1599947357181#92 94 | 21.62249645233169#93 95 | 22.08999820709232#94 96 | 22.5625#95 97 | 23.040001831054724#96 98 | 23.522503700256493#97 99 | 24.010005607605308#98 100 | 24.502507553101168#99 -------------------------------------------------------------------------------- /mp_chart/example/assets/stacked_bars.txt: -------------------------------------------------------------------------------- 1 | 4#2#6#0 2 | 0#2#8#1 3 | 3#8#2#2 4 | 0#7#0#3 5 | 5#5#2#4 6 | 9#0#0#5 7 | 3#3#6#6 -------------------------------------------------------------------------------- /mp_chart/example/assets/three.txt: -------------------------------------------------------------------------------- 1 | 0.0#0 2 | 1.2500000558793553E-4#1 3 | 0.0010000000447034842#2 4 | 0.0033750004023313683#3 5 | 0.008000000357627874#4 6 | 0.015625#5 7 | 0.027000003218650946#6 8 | 0.04287500876188338#7 9 | 0.06400001716613923#8 10 | 0.09112502896786043#9 11 | 0.1250000447034889#10 12 | 0.1663750649094666#11 13 | 0.21600009012223542#12 14 | 0.2746251208782373#13 15 | 0.34300015771391423#14 16 | 0.4218752011657081#15 17 | 0.5120002517700608#16 18 | 0.6141253100634143#17 19 | 0.7290003765822105#18 20 | 0.8573754518628914#19 21 | 1.0000003576279113#20 22 | 1.1576252365708513#21 23 | 1.3310000865459461#22 24 | 1.5208749054074306#23 25 | 1.7279996910095399#24 26 | 1.9531244412065085#25 27 | 2.1969991538525715#26 28 | 2.4603738268019635#27 29 | 2.743998457908919#28 30 | 3.048623045027674#29 31 | 3.374997586012462#30 32 | 3.723872078717519#31 33 | 4.095996520997079#32 34 | 4.492120910705377#33 35 | 4.9129952456966475#34 36 | 5.359369523825126#35 37 | 5.8319937429450475#36 38 | 6.331617900910646#37 39 | 6.858991995576157#38 40 | 7.414866024795816#39 41 | 7.999989986423856#40 42 | 8.615115381244424#41 43 | 9.260989275459615#42 44 | 9.938363097434028#43 45 | 10.647986845021897#44 46 | 11.390610516077459#45 47 | 12.166984108454947#46 48 | 12.977857620008598#47 49 | 13.823981048592644#48 50 | 14.706104392061324#49 51 | 15.624977648268867#50 52 | 16.581350815069513#51 53 | 17.575973890317496#52 54 | 18.609596871867048#53 55 | 19.682969757572405#54 56 | 20.796842545287802#55 57 | 21.951965232867476#56 58 | 23.149087818165658#57 59 | 24.388960299036587#58 60 | 25.672332673334495#59 61 | 26.999954938913618#60 62 | 28.37257709362819#61 63 | 29.790949135332447#62 64 | 31.25582106188062#63 65 | 32.76794287112695#64 66 | 34.32806456092567#65 67 | 35.93693612913101#66 68 | 37.59530757359721#67 69 | 39.303928892178504#68 70 | 41.06355008272912#69 71 | 42.87492114310331#70 72 | 44.73879207115529#71 73 | 46.65591286473931#72 74 | 48.627033521709585#73 75 | 50.65290403992037#74 76 | 52.73427441722589#75 77 | 54.87189465148038#76 78 | 57.06651474053808#77 79 | 59.31888468225323#78 80 | 61.629754474480045#79 81 | 63.99987411507277#80 82 | 66.42999360188564#81 83 | 68.9208749562066#82 84 | 71.47325674254265#83 85 | 74.08788896947685#84 86 | 76.76552164559234#85 87 | 79.50690477947222#86 88 | 82.31278837969957#87 89 | 85.18392245485751#88 90 | 88.12105701352914#89 91 | 91.12494206429756#90 92 | 94.19632761574586#91 93 | 97.33596367645715#92 94 | 100.54460025501454#93 95 | 103.82298736000112#94 96 | 107.171875#95 97 | 110.59201318359428#96 98 | 114.08415191936705#97 99 | 117.64904121590142#98 100 | 121.2874310817805#99 -------------------------------------------------------------------------------- /mp_chart/example/ios/File.swift: -------------------------------------------------------------------------------- 1 | // 2 | // File.swift 3 | // Runner 4 | // 5 | // Created by 罗秋雨 on 2019/9/27. 6 | // Copyright © 2019 The Chromium Authors. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | -------------------------------------------------------------------------------- /mp_chart/example/ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 8.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /mp_chart/example/ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /mp_chart/example/ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /mp_chart/example/ios/Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | # platform :ios, '9.0' 3 | 4 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 5 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 6 | 7 | project 'Runner', { 8 | 'Debug' => :debug, 9 | 'Profile' => :release, 10 | 'Release' => :release, 11 | } 12 | 13 | def parse_KV_file(file, separator='=') 14 | file_abs_path = File.expand_path(file) 15 | if !File.exists? file_abs_path 16 | return []; 17 | end 18 | pods_ary = [] 19 | skip_line_start_symbols = ["#", "/"] 20 | File.foreach(file_abs_path) { |line| 21 | next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ } 22 | plugin = line.split(pattern=separator) 23 | if plugin.length == 2 24 | podname = plugin[0].strip() 25 | path = plugin[1].strip() 26 | podpath = File.expand_path("#{path}", file_abs_path) 27 | pods_ary.push({:name => podname, :path => podpath}); 28 | else 29 | puts "Invalid plugin specification: #{line}" 30 | end 31 | } 32 | return pods_ary 33 | end 34 | 35 | target 'Runner' do 36 | # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock 37 | # referring to absolute paths on developers' machines. 38 | system('rm -rf .symlinks') 39 | system('mkdir -p .symlinks/plugins') 40 | 41 | # Flutter Pods 42 | generated_xcode_build_settings = parse_KV_file('./Flutter/Generated.xcconfig') 43 | if generated_xcode_build_settings.empty? 44 | puts "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first." 45 | end 46 | generated_xcode_build_settings.map { |p| 47 | if p[:name] == 'FLUTTER_FRAMEWORK_DIR' 48 | symlink = File.join('.symlinks', 'flutter') 49 | File.symlink(File.dirname(p[:path]), symlink) 50 | pod 'Flutter', :path => File.join(symlink, File.basename(p[:path])) 51 | end 52 | } 53 | 54 | # Plugin Pods 55 | plugin_pods = parse_KV_file('../.flutter-plugins') 56 | plugin_pods.map { |p| 57 | symlink = File.join('.symlinks', 'plugins', p[:name]) 58 | File.symlink(p[:path], symlink) 59 | pod p[:name], :path => File.join(symlink, 'ios') 60 | } 61 | end 62 | 63 | # Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system. 64 | install! 'cocoapods', :disable_input_output_paths => true 65 | 66 | post_install do |installer| 67 | installer.pods_project.targets.each do |target| 68 | target.build_configurations.each do |config| 69 | config.build_settings['ENABLE_BITCODE'] = 'NO' 70 | end 71 | end 72 | end 73 | -------------------------------------------------------------------------------- /mp_chart/example/ios/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - Flutter (1.0.0) 3 | - image_gallery_saver (0.0.1): 4 | - Flutter 5 | - path_provider (0.0.1): 6 | - Flutter 7 | - permission_handler (3.3.0): 8 | - Flutter 9 | - url_launcher (0.0.1): 10 | - Flutter 11 | 12 | DEPENDENCIES: 13 | - Flutter (from `.symlinks/flutter/ios`) 14 | - image_gallery_saver (from `.symlinks/plugins/image_gallery_saver/ios`) 15 | - path_provider (from `.symlinks/plugins/path_provider/ios`) 16 | - permission_handler (from `.symlinks/plugins/permission_handler/ios`) 17 | - url_launcher (from `.symlinks/plugins/url_launcher/ios`) 18 | 19 | EXTERNAL SOURCES: 20 | Flutter: 21 | :path: ".symlinks/flutter/ios" 22 | image_gallery_saver: 23 | :path: ".symlinks/plugins/image_gallery_saver/ios" 24 | path_provider: 25 | :path: ".symlinks/plugins/path_provider/ios" 26 | permission_handler: 27 | :path: ".symlinks/plugins/permission_handler/ios" 28 | url_launcher: 29 | :path: ".symlinks/plugins/url_launcher/ios" 30 | 31 | SPEC CHECKSUMS: 32 | Flutter: 58dd7d1b27887414a370fcccb9e645c08ffd7a6a 33 | image_gallery_saver: 73b3cd8ad9c950c739878af9c311744d1bf5405d 34 | path_provider: fb74bd0465e96b594bb3b5088ee4a4e7bb1f2a9d 35 | permission_handler: 67637977b227d62d46bfbf524f335f8568de5a73 36 | url_launcher: a1c0cc845906122c4784c542523d8cacbded5626 37 | 38 | PODFILE CHECKSUM: 7fb83752f59ead6285236625b82473f90b1cb932 39 | 40 | COCOAPODS: 1.7.3 41 | -------------------------------------------------------------------------------- /mp_chart/example/ios/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | // 2 | // Use this file to import your target's public headers that you would like to expose to Swift. 3 | // 4 | 5 | -------------------------------------------------------------------------------- /mp_chart/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /mp_chart/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /mp_chart/example/ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /mp_chart/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /mp_chart/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | BuildSystemType 6 | Original 7 | 8 | 9 | -------------------------------------------------------------------------------- /mp_chart/example/ios/Runner/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface AppDelegate : FlutterAppDelegate 5 | 6 | @end 7 | -------------------------------------------------------------------------------- /mp_chart/example/ios/Runner/AppDelegate.m: -------------------------------------------------------------------------------- 1 | #include "AppDelegate.h" 2 | #include "GeneratedPluginRegistrant.h" 3 | 4 | @implementation AppDelegate 5 | 6 | - (BOOL)application:(UIApplication *)application 7 | didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 8 | [GeneratedPluginRegistrant registerWithRegistry:self]; 9 | // Override point for customization after application launch. 10 | return [super application:application didFinishLaunchingWithOptions:launchOptions]; 11 | } 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /mp_chart/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-1024.png -------------------------------------------------------------------------------- /mp_chart/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-20-ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-20-ipad.png -------------------------------------------------------------------------------- /mp_chart/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-20@2x-ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-20@2x-ipad.png -------------------------------------------------------------------------------- /mp_chart/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-20@2x.png -------------------------------------------------------------------------------- /mp_chart/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-20@3x.png -------------------------------------------------------------------------------- /mp_chart/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-29-ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-29-ipad.png -------------------------------------------------------------------------------- /mp_chart/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-29.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-29.png -------------------------------------------------------------------------------- /mp_chart/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-29@2x-ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-29@2x-ipad.png -------------------------------------------------------------------------------- /mp_chart/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-29@2x.png -------------------------------------------------------------------------------- /mp_chart/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-29@3x.png -------------------------------------------------------------------------------- /mp_chart/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-40.png -------------------------------------------------------------------------------- /mp_chart/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-40@2x.png -------------------------------------------------------------------------------- /mp_chart/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-40@3x.png -------------------------------------------------------------------------------- /mp_chart/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-60@2x.png -------------------------------------------------------------------------------- /mp_chart/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-60@3x.png -------------------------------------------------------------------------------- /mp_chart/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-76.png -------------------------------------------------------------------------------- /mp_chart/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-76@2x.png -------------------------------------------------------------------------------- /mp_chart/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-83.5@2x.png -------------------------------------------------------------------------------- /mp_chart/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchImage.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchImage@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchImage@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /mp_chart/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /mp_chart/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /mp_chart/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /mp_chart/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /mp_chart/example/ios/Runner/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /mp_chart/example/ios/Runner/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /mp_chart/example/ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | MPFlutterChart 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | $(FLUTTER_BUILD_NAME) 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(FLUTTER_BUILD_NUMBER) 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UISupportedInterfaceOrientations 30 | 31 | UIInterfaceOrientationPortrait 32 | UIInterfaceOrientationLandscapeLeft 33 | UIInterfaceOrientationLandscapeRight 34 | 35 | UISupportedInterfaceOrientations~ipad 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationPortraitUpsideDown 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | UIViewControllerBasedStatusBarAppearance 43 | 44 | NSPhotoLibraryUsageDescription 45 | photos 46 | NSPhotoLibraryAddUsageDescription 47 | save to gallery needs permission to write photos 48 | 49 | 50 | -------------------------------------------------------------------------------- /mp_chart/example/ios/Runner/main.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import "AppDelegate.h" 4 | 5 | int main(int argc, char* argv[]) { 6 | @autoreleasepool { 7 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /mp_chart/example/lib/demo/res/colors.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class Colours { 4 | static const Color app_main = Color(0xff4688FA); 5 | static const Color bg_color = Color(0xfff1f1f1); 6 | 7 | static const Color text_dark = Color(0xFF333333); 8 | static const Color text_normal = Color(0xFF666666); 9 | static const Color text_gray = Color(0xFF999999); 10 | static const Color text_gray_c = Color(0xFFcccccc); 11 | static const Color bg_gray = Color(0xFFF6F6F6); 12 | static const Color text_blue = Color(0xFF4688FA); 13 | static const Color line = Color(0xFFEEEEEE); 14 | static const Color order_line = Color(0xFFDDDDDD); 15 | static const Color text_red = Color(0xFFFF4759); 16 | 17 | static const Color login_text_disabled = Color(0xFFD4E2FA); 18 | static const Color login_button_disabled = Color(0xFF96BBFA); 19 | } 20 | 21 | -------------------------------------------------------------------------------- /mp_chart/example/lib/demo/res/dimens.dart: -------------------------------------------------------------------------------- 1 | class Dimens { 2 | static const double font_sp10 = 10; 3 | static const double font_sp12 = 12; 4 | static const double font_sp14 = 14; 5 | static const double font_sp16 = 16; 6 | static const double font_sp18 = 18; 7 | 8 | static const double gap_dp5 = 5; 9 | static const double gap_dp10 = 10; 10 | static const double gap_dp12 = 12; 11 | static const double gap_dp15 = 15; 12 | static const double gap_dp16 = 16; 13 | static const double gap_dp50 = 50; 14 | } 15 | -------------------------------------------------------------------------------- /mp_chart/example/lib/demo/res/resources.dart: -------------------------------------------------------------------------------- 1 | export 'colors.dart'; 2 | export 'dimens.dart'; 3 | export 'styles.dart'; -------------------------------------------------------------------------------- /mp_chart/example/lib/demo/util.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui'; 2 | 3 | import 'package:flutter/services.dart' show rootBundle; 4 | import 'package:mp_chart/mp/core/adapter_android_mp.dart'; 5 | import 'package:url_launcher/url_launcher.dart'; 6 | 7 | abstract class Util { 8 | static Future loadAsset(String filename) async { 9 | return await rootBundle.loadString('assets/$filename'); 10 | } 11 | 12 | static int currentTimeMillis() { 13 | return new DateTime.now().millisecondsSinceEpoch; 14 | } 15 | 16 | static void openGithub() { 17 | _launchURL(); 18 | } 19 | 20 | static void _launchURL() async { 21 | const url = 'https://github.com/SunPointed/mp_flutter_chart'; 22 | if (await canLaunch(url)) { 23 | await launch(url); 24 | } else { 25 | throw 'Could not launch $url'; 26 | } 27 | } 28 | 29 | // ignore: non_constant_identifier_names 30 | static TypeFace REGULAR = 31 | TypeFace(fontFamily: "OpenSans", fontWeight: FontWeight.w400); 32 | 33 | // ignore: non_constant_identifier_names 34 | static TypeFace LIGHT = 35 | TypeFace(fontFamily: "OpenSans", fontWeight: FontWeight.w300); 36 | 37 | // ignore: non_constant_identifier_names 38 | static TypeFace BOLD = 39 | TypeFace(fontFamily: "OpenSans", fontWeight: FontWeight.w700); 40 | 41 | 42 | // ignore: non_constant_identifier_names 43 | static TypeFace EXTRA_BOLD = 44 | TypeFace(fontFamily: "OpenSans", fontWeight: FontWeight.w800); 45 | } 46 | -------------------------------------------------------------------------------- /mp_chart/img/bar_charts/basic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/img/bar_charts/basic.png -------------------------------------------------------------------------------- /mp_chart/img/bar_charts/basic2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/img/bar_charts/basic2.png -------------------------------------------------------------------------------- /mp_chart/img/bar_charts/horizontal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/img/bar_charts/horizontal.png -------------------------------------------------------------------------------- /mp_chart/img/bar_charts/multiple.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/img/bar_charts/multiple.png -------------------------------------------------------------------------------- /mp_chart/img/bar_charts/negative.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/img/bar_charts/negative.png -------------------------------------------------------------------------------- /mp_chart/img/bar_charts/sine.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/img/bar_charts/sine.png -------------------------------------------------------------------------------- /mp_chart/img/bar_charts/stacked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/img/bar_charts/stacked.png -------------------------------------------------------------------------------- /mp_chart/img/bar_charts/stacked2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/img/bar_charts/stacked2.png -------------------------------------------------------------------------------- /mp_chart/img/even_more_charts/dynamic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/img/even_more_charts/dynamic.png -------------------------------------------------------------------------------- /mp_chart/img/even_more_charts/hourly.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/img/even_more_charts/hourly.png -------------------------------------------------------------------------------- /mp_chart/img/even_more_charts/realtime.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/img/even_more_charts/realtime.png -------------------------------------------------------------------------------- /mp_chart/img/line_charts/basic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/img/line_charts/basic.png -------------------------------------------------------------------------------- /mp_chart/img/line_charts/colorful.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/img/line_charts/colorful.png -------------------------------------------------------------------------------- /mp_chart/img/line_charts/cubic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/img/line_charts/cubic.png -------------------------------------------------------------------------------- /mp_chart/img/line_charts/dual_axis.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/img/line_charts/dual_axis.png -------------------------------------------------------------------------------- /mp_chart/img/line_charts/filled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/img/line_charts/filled.png -------------------------------------------------------------------------------- /mp_chart/img/line_charts/invert_axis.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/img/line_charts/invert_axis.png -------------------------------------------------------------------------------- /mp_chart/img/line_charts/multiple.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/img/line_charts/multiple.png -------------------------------------------------------------------------------- /mp_chart/img/line_charts/performance.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/img/line_charts/performance.png -------------------------------------------------------------------------------- /mp_chart/img/other_charts/bubble.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/img/other_charts/bubble.png -------------------------------------------------------------------------------- /mp_chart/img/other_charts/candle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/img/other_charts/candle.png -------------------------------------------------------------------------------- /mp_chart/img/other_charts/combined.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/img/other_charts/combined.png -------------------------------------------------------------------------------- /mp_chart/img/other_charts/radar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/img/other_charts/radar.png -------------------------------------------------------------------------------- /mp_chart/img/other_charts/scatter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/img/other_charts/scatter.png -------------------------------------------------------------------------------- /mp_chart/img/pie_charts/basic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/img/pie_charts/basic.png -------------------------------------------------------------------------------- /mp_chart/img/pie_charts/half_pie.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/img/pie_charts/half_pie.png -------------------------------------------------------------------------------- /mp_chart/img/pie_charts/value_lines.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/img/pie_charts/value_lines.png -------------------------------------------------------------------------------- /mp_chart/img/scrolling_charts/many.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/img/scrolling_charts/many.png -------------------------------------------------------------------------------- /mp_chart/img/scrolling_charts/multiple.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/img/scrolling_charts/multiple.png -------------------------------------------------------------------------------- /mp_chart/img/scrolling_charts/tall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/img/scrolling_charts/tall.png -------------------------------------------------------------------------------- /mp_chart/img/scrolling_charts/view_pager.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunPointed/MPFlutterChart/a20af66ad0d85fd5298f05b45bf4dffedb199a25/mp_chart/img/scrolling_charts/view_pager.png -------------------------------------------------------------------------------- /mp_chart/killdart.sh: -------------------------------------------------------------------------------- 1 | killall -9 dart -------------------------------------------------------------------------------- /mp_chart/lib/mp/chart/bar_chart.dart: -------------------------------------------------------------------------------- 1 | import 'package:mp_chart/mp/chart/bar_line_scatter_candle_bubble_chart.dart'; 2 | import 'package:mp_chart/mp/controller/bar_chart_controller.dart'; 3 | 4 | class BarChart extends BarLineScatterCandleBubbleChart { 5 | const BarChart(BarChartController controller) : super(controller); 6 | } 7 | 8 | class BarChartState extends BarLineScatterCandleBubbleState {} 9 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/chart/bubble_chart.dart: -------------------------------------------------------------------------------- 1 | import 'package:mp_chart/mp/chart/bar_line_scatter_candle_bubble_chart.dart'; 2 | import 'package:mp_chart/mp/controller/bubble_chart_controller.dart'; 3 | 4 | class BubbleChart 5 | extends BarLineScatterCandleBubbleChart { 6 | const BubbleChart(BubbleChartController controller) : super(controller); 7 | } 8 | 9 | class BubbleChartState extends BarLineScatterCandleBubbleState {} 10 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/chart/candlestick_chart.dart: -------------------------------------------------------------------------------- 1 | import 'package:mp_chart/mp/chart/bar_line_scatter_candle_bubble_chart.dart'; 2 | import 'package:mp_chart/mp/controller/candlestick_chart_controller.dart'; 3 | 4 | class CandlestickChart 5 | extends BarLineScatterCandleBubbleChart { 6 | const CandlestickChart(CandlestickChartController controller) 7 | : super(controller); 8 | } 9 | 10 | class CandlestickChartState 11 | extends BarLineScatterCandleBubbleState {} 12 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/chart/horizontal_bar_chart.dart: -------------------------------------------------------------------------------- 1 | import 'package:mp_chart/mp/chart/bar_chart.dart'; 2 | import 'package:mp_chart/mp/controller/horizontal_bar_chart_controller.dart'; 3 | 4 | class HorizontalBarChart extends BarChart { 5 | const HorizontalBarChart(HorizontalBarChartController controller) 6 | : super(controller); 7 | } 8 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/chart/line_chart.dart: -------------------------------------------------------------------------------- 1 | import 'package:mp_chart/mp/chart/bar_line_scatter_candle_bubble_chart.dart'; 2 | import 'package:mp_chart/mp/controller/line_chart_controller.dart'; 3 | 4 | class LineChart extends BarLineScatterCandleBubbleChart { 5 | const LineChart(LineChartController controller) : super(controller); 6 | } 7 | 8 | class LineChartState extends BarLineScatterCandleBubbleState {} 9 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/chart/pie_chart.dart: -------------------------------------------------------------------------------- 1 | import 'package:mp_chart/mp/chart/pie_radar_chart.dart'; 2 | import 'package:mp_chart/mp/controller/pie_chart_controller.dart'; 3 | 4 | class PieChart extends PieRadarChart { 5 | const PieChart(PieChartController controller) : super(controller); 6 | } 7 | 8 | class PieChartState extends PieRadarChartState {} 9 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/chart/radar_chart.dart: -------------------------------------------------------------------------------- 1 | import 'package:mp_chart/mp/chart/pie_radar_chart.dart'; 2 | import 'package:mp_chart/mp/controller/radar_chart_controller.dart'; 3 | 4 | class RadarChart extends PieRadarChart { 5 | const RadarChart(RadarChartController controller) : super(controller); 6 | } 7 | 8 | class RadarChartState extends PieRadarChartState {} 9 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/chart/scatter_chart.dart: -------------------------------------------------------------------------------- 1 | import 'package:mp_chart/mp/chart/bar_line_scatter_candle_bubble_chart.dart'; 2 | import 'package:mp_chart/mp/controller/scatter_chart_controller.dart'; 3 | 4 | class ScatterChart 5 | extends BarLineScatterCandleBubbleChart { 6 | const ScatterChart(ScatterChartController controller) : super(controller); 7 | } 8 | 9 | class ScatterChartState extends BarLineScatterCandleBubbleState {} 10 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/controller/pie_radar_controller.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/painting.dart'; 2 | import 'package:mp_chart/mp/controller/controller.dart'; 3 | import 'package:mp_chart/mp/core/common_interfaces.dart'; 4 | import 'package:mp_chart/mp/core/description.dart'; 5 | import 'package:mp_chart/mp/core/functions.dart'; 6 | import 'package:mp_chart/mp/core/marker/i_marker.dart'; 7 | import 'package:mp_chart/mp/core/utils/utils.dart'; 8 | import 'package:mp_chart/mp/painter/pie_redar_chart_painter.dart'; 9 | 10 | abstract class PieRadarController

11 | extends Controller

{ 12 | double rotationAngle; 13 | double rawRotationAngle; 14 | bool rotateEnabled; 15 | double minOffset; 16 | 17 | PieRadarController( 18 | {this.rotationAngle = 270, 19 | this.rawRotationAngle = 270, 20 | this.rotateEnabled = true, 21 | this.minOffset = 30, 22 | IMarker marker, 23 | Description description, 24 | OnChartValueSelectedListener selectionListener, 25 | double maxHighlightDistance = 100.0, 26 | bool highLightPerTapEnabled = true, 27 | double extraTopOffset = 0.0, 28 | double extraRightOffset = 0.0, 29 | double extraBottomOffset = 0.0, 30 | double extraLeftOffset = 0.0, 31 | bool drawMarkers = true, 32 | bool resolveGestureHorizontalConflict = false, 33 | bool resolveGestureVerticalConflict = false, 34 | double descTextSize = 12, 35 | double infoTextSize = 12, 36 | Color descTextColor, 37 | Color infoTextColor, 38 | Color infoBgColor, 39 | String noDataText = "No chart data available.", 40 | XAxisSettingFunction xAxisSettingFunction, 41 | LegendSettingFunction legendSettingFunction, 42 | DataRendererSettingFunction rendererSettingFunction}) 43 | : super( 44 | marker: marker, 45 | noDataText: noDataText, 46 | xAxisSettingFunction: xAxisSettingFunction, 47 | legendSettingFunction: legendSettingFunction, 48 | rendererSettingFunction: rendererSettingFunction, 49 | description: description, 50 | selectionListener: selectionListener, 51 | maxHighlightDistance: maxHighlightDistance, 52 | highLightPerTapEnabled: highLightPerTapEnabled, 53 | extraTopOffset: extraTopOffset, 54 | extraRightOffset: extraRightOffset, 55 | extraBottomOffset: extraBottomOffset, 56 | extraLeftOffset: extraLeftOffset, 57 | drawMarkers: drawMarkers, 58 | resolveGestureHorizontalConflict: resolveGestureHorizontalConflict, 59 | resolveGestureVerticalConflict: resolveGestureVerticalConflict, 60 | descTextSize: descTextSize, 61 | infoTextSize: infoTextSize, 62 | descTextColor: descTextColor, 63 | infoBgColor: infoBgColor, 64 | infoTextColor: infoTextColor); 65 | 66 | @override 67 | void onRotateUpdate(double angle) { 68 | rawRotationAngle = angle; 69 | rotationAngle = Utils.getNormalizedAngle(rawRotationAngle); 70 | state.setStateIfNotDispose(); 71 | } 72 | 73 | P get painter => super.painter; 74 | } 75 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/adapter_android_mp.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui'; 2 | 3 | import 'package:path_drawing/path_drawing.dart'; 4 | 5 | class DashPathEffect { 6 | CircularIntervalList _circularIntervalList; 7 | 8 | DashOffset _dashOffset; 9 | 10 | CircularIntervalList get circularIntervalList => 11 | _circularIntervalList; 12 | 13 | DashPathEffect(double lineLength, double spaceLength, double value) 14 | : _circularIntervalList = 15 | CircularIntervalList([lineLength, spaceLength]), 16 | _dashOffset = DashOffset.absolute(value); 17 | 18 | Path convert2DashPath(Path path) { 19 | if (_circularIntervalList == null) { 20 | return path; 21 | } 22 | return dashPath(path, 23 | dashArray: _circularIntervalList, dashOffset: _dashOffset); 24 | } 25 | 26 | @override 27 | String toString() { 28 | return 'DashPathEffect{_circularIntervalList: $_circularIntervalList,\n _dashOffset: $_dashOffset}'; 29 | } 30 | } 31 | 32 | class TypeFace { 33 | String _fontFamily; 34 | FontWeight _fontWeight; 35 | 36 | TypeFace({String fontFamily, FontWeight fontWeight = FontWeight.w400}) { 37 | _fontFamily = fontFamily; 38 | _fontWeight = fontWeight; 39 | } 40 | 41 | // ignore: unnecessary_getters_setters 42 | FontWeight get fontWeight => _fontWeight; 43 | 44 | // ignore: unnecessary_getters_setters 45 | set fontWeight(FontWeight value) { 46 | _fontWeight = value; 47 | } 48 | 49 | // ignore: unnecessary_getters_setters 50 | String get fontFamily => _fontFamily; 51 | 52 | // ignore: unnecessary_getters_setters 53 | set fontFamily(String value) { 54 | _fontFamily = value; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/axis/x_axis.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/painting.dart'; 2 | import 'package:mp_chart/mp/core/axis/axis_base.dart'; 3 | import 'package:mp_chart/mp/core/enums/x_axis_position.dart'; 4 | import 'package:mp_chart/mp/core/utils/painter_utils.dart'; 5 | import 'package:mp_chart/mp/core/utils/utils.dart'; 6 | 7 | class XAxis extends AxisBase { 8 | /// width of the x-axis labels in pixels - this is automatically 9 | /// calculated by the computeSize() methods in the renderers 10 | int _labelWidth = 1; 11 | 12 | /// height of the x-axis labels in pixels - this is automatically 13 | /// calculated by the computeSize() methods in the renderers 14 | int _labelHeight = 1; 15 | 16 | /// width of the (rotated) x-axis labels in pixels - this is automatically 17 | /// calculated by the computeSize() methods in the renderers 18 | int _labelRotatedWidth = 1; 19 | 20 | /// height of the (rotated) x-axis labels in pixels - this is automatically 21 | /// calculated by the computeSize() methods in the renderers 22 | int _labelRotatedHeight = 1; 23 | 24 | /// This is the angle for drawing the X axis labels (in degrees) 25 | double _labelRotationAngle = 0; 26 | 27 | /// if set to true, the chart will avoid that the first and last label entry 28 | /// in the chart "clip" off the edge of the chart 29 | bool _avoidFirstLastClipping = false; 30 | 31 | /// the position of the x-labels relative to the chart 32 | XAxisPosition _position = XAxisPosition.TOP; 33 | 34 | XAxis() : super() { 35 | yOffset = Utils.convertDpToPixel(4); 36 | } 37 | 38 | // ignore: unnecessary_getters_setters 39 | XAxisPosition get position => _position; 40 | 41 | // ignore: unnecessary_getters_setters 42 | set position(XAxisPosition value) { 43 | _position = value; 44 | } 45 | 46 | // ignore: unnecessary_getters_setters 47 | double get labelRotationAngle => _labelRotationAngle; 48 | 49 | // ignore: unnecessary_getters_setters 50 | set labelRotationAngle(double value) { 51 | _labelRotationAngle = value; 52 | } 53 | 54 | // ignore: unnecessary_getters_setters 55 | bool get avoidFirstLastClipping => _avoidFirstLastClipping; 56 | 57 | // ignore: unnecessary_getters_setters 58 | set avoidFirstLastClipping(bool value) { 59 | _avoidFirstLastClipping = value; 60 | } 61 | 62 | // ignore: unnecessary_getters_setters 63 | int get labelRotatedHeight => _labelRotatedHeight; 64 | 65 | // ignore: unnecessary_getters_setters 66 | set labelRotatedHeight(int value) { 67 | _labelRotatedHeight = value; 68 | } 69 | 70 | // ignore: unnecessary_getters_setters 71 | int get labelRotatedWidth => _labelRotatedWidth; 72 | 73 | // ignore: unnecessary_getters_setters 74 | set labelRotatedWidth(int value) { 75 | _labelRotatedWidth = value; 76 | } 77 | 78 | // ignore: unnecessary_getters_setters 79 | int get labelHeight => _labelHeight; 80 | 81 | // ignore: unnecessary_getters_setters 82 | set labelHeight(int value) { 83 | _labelHeight = value; 84 | } 85 | 86 | // ignore: unnecessary_getters_setters 87 | int get labelWidth => _labelWidth; 88 | 89 | // ignore: unnecessary_getters_setters 90 | set labelWidth(int value) { 91 | _labelWidth = value; 92 | } 93 | 94 | int getRequiredHeightSpace(TextPainter p) { 95 | p = PainterUtils.create(p, null, null, textSize); 96 | 97 | int height = Utils.calcTextHeight(p, "A"); 98 | 99 | return height; 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/bounds.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math' as math; 2 | 3 | import 'package:mp_chart/mp/core/animator.dart'; 4 | import 'package:mp_chart/mp/core/data_interfaces/i_bar_line_scatter_candle_bubble_data_set.dart'; 5 | import 'package:mp_chart/mp/core/data_provider/bar_line_scatter_candle_bubble_data_provider.dart'; 6 | import 'package:mp_chart/mp/core/entry/entry.dart'; 7 | import 'package:mp_chart/mp/core/enums/rounding.dart'; 8 | 9 | class XBounds { 10 | /// minimum visible entry index 11 | int _min; 12 | 13 | /// maximum visible entry index 14 | int _max; 15 | 16 | /// range of visible entry indices 17 | int _range; 18 | 19 | Animator _animator; 20 | 21 | XBounds(this._animator); 22 | 23 | // ignore: unnecessary_getters_setters 24 | int get range => _range; 25 | 26 | // ignore: unnecessary_getters_setters 27 | set range(int value) { 28 | _range = value; 29 | } 30 | 31 | // ignore: unnecessary_getters_setters 32 | int get max => _max; 33 | 34 | // ignore: unnecessary_getters_setters 35 | set max(int value) { 36 | _max = value; 37 | } 38 | 39 | // ignore: unnecessary_getters_setters 40 | int get min => _min; 41 | 42 | // ignore: unnecessary_getters_setters 43 | set min(int value) { 44 | _min = value; 45 | } 46 | 47 | /// Calculates the minimum and maximum x values as well as the range between them. 48 | /// 49 | /// @param chart 50 | /// @param dataSet 51 | void set(BarLineScatterCandleBubbleDataProvider chart, 52 | IBarLineScatterCandleBubbleDataSet dataSet) { 53 | double phaseX = math.max(0.0, math.min(1.0, _animator.getPhaseX())); 54 | 55 | double low = chart.getLowestVisibleX(); 56 | double high = chart.getHighestVisibleX(); 57 | Entry entryFrom = 58 | dataSet.getEntryForXValue1(low, double.nan, Rounding.DOWN); 59 | Entry entryTo = dataSet.getEntryForXValue1(high, double.nan, Rounding.UP); 60 | 61 | _min = entryFrom == null ? 0 : dataSet.getEntryIndex2(entryFrom); 62 | _max = entryTo == null ? 0 : dataSet.getEntryIndex2(entryTo); 63 | 64 | if (_min > _max) { 65 | var t = _min; 66 | _min = _max; 67 | _max = t; 68 | } 69 | 70 | _range = ((_max - _min) * phaseX).toInt(); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/buffer/abstract_buffer.dart: -------------------------------------------------------------------------------- 1 | abstract class AbstractBuffer { 2 | /// index in the buffer 3 | int _index = 0; 4 | 5 | /// double-buffer that holds the data points to draw, order: x,y,x,y,... 6 | List _buffer; 7 | 8 | /// animation phase x-axis 9 | double _phaseX = 1.0; 10 | 11 | /// animation phase y-axis 12 | double _phaseY = 1.0; 13 | 14 | /// indicates from which x-index the visible data begins 15 | // ignore: unused_field 16 | int _mFrom = 0; 17 | 18 | /// indicates to which x-index the visible data ranges 19 | // ignore: unused_field 20 | int _mTo = 0; 21 | 22 | /// Initialization with buffer-size. 23 | /// 24 | /// @param size 25 | AbstractBuffer(int size) { 26 | _index = 0; 27 | _buffer = List(size); 28 | } 29 | 30 | /// limits the drawing on the x-axis 31 | void limitFrom(int from) { 32 | if (from < 0) from = 0; 33 | _mFrom = from; 34 | } 35 | 36 | /// limits the drawing on the x-axis 37 | void limitTo(int to) { 38 | if (to < 0) to = 0; 39 | _mTo = to; 40 | } 41 | 42 | /// Resets the buffer index to 0 and makes the buffer reusable. 43 | void reset() { 44 | _index = 0; 45 | } 46 | 47 | /// Returns the size (length) of the buffer array. 48 | /// 49 | /// @return 50 | int size() { 51 | return _buffer.length; 52 | } 53 | 54 | /// Set the phases used for animations. 55 | /// 56 | /// @param phaseX 57 | /// @param phaseY 58 | void setPhases(double phaseX, double phaseY) { 59 | this._phaseX = phaseX; 60 | this._phaseY = phaseY; 61 | } 62 | 63 | /// Builds up the buffer with the provided data and resets the buffer-index 64 | /// after feed-completion. This needs to run FAST. 65 | /// 66 | /// @param data 67 | void feed(T data); 68 | 69 | List get buffer => _buffer; 70 | 71 | // ignore: unnecessary_getters_setters 72 | int get index => _index; 73 | 74 | // ignore: unnecessary_getters_setters 75 | set index(int value) { 76 | _index = value; 77 | } 78 | 79 | double get phaseX => _phaseX; 80 | 81 | double get phaseY => _phaseY; 82 | } 83 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/buffer/horizontal_bar_buffer.dart: -------------------------------------------------------------------------------- 1 | import 'package:mp_chart/mp/core/buffer/bar_buffer.dart'; 2 | import 'package:mp_chart/mp/core/data_interfaces/i_bar_data_set.dart'; 3 | import 'package:mp_chart/mp/core/entry/bar_entry.dart'; 4 | 5 | class HorizontalBarBuffer extends BarBuffer { 6 | HorizontalBarBuffer(int size, int dataSetCount, bool containsStacks) 7 | : super(size, dataSetCount, containsStacks); 8 | 9 | @override 10 | void feed(IBarDataSet data) { 11 | double size = data.getEntryCount() * phaseX; 12 | double barWidthHalf = barWidth / 2; 13 | 14 | for (int i = 0; i < size; i++) { 15 | BarEntry e = data.getEntryForIndex(i); 16 | 17 | if (e == null) continue; 18 | 19 | double x = e.x; 20 | double y = e.y; 21 | List vals = e.yVals; 22 | 23 | if (!containsStacks || vals == null) { 24 | double bottom = x - barWidthHalf; 25 | double top = x + barWidthHalf; 26 | double left, right; 27 | if (inverted) { 28 | left = y >= 0 ? y : 0; 29 | right = y <= 0 ? y : 0; 30 | } else { 31 | right = y >= 0 ? y : 0; 32 | left = y <= 0 ? y : 0; 33 | } 34 | 35 | // multiply the height of the rect with the phase 36 | if (right > 0) 37 | right *= phaseY; 38 | else 39 | left *= phaseY; 40 | 41 | addBar(left, top, right, bottom); 42 | } else { 43 | double posY = 0; 44 | double negY = -e.negativeSum; 45 | double yStart = 0; 46 | 47 | // fill the stack 48 | for (int k = 0; k < vals.length; k++) { 49 | double value = vals[k]; 50 | 51 | if (value >= 0) { 52 | y = posY; 53 | yStart = posY + value; 54 | posY = yStart; 55 | } else { 56 | y = negY; 57 | yStart = negY + value.abs(); 58 | negY += value.abs(); 59 | } 60 | 61 | double bottom = x - barWidthHalf; 62 | double top = x + barWidthHalf; 63 | double left, right; 64 | if (inverted) { 65 | left = y >= yStart ? y : yStart; 66 | right = y <= yStart ? y : yStart; 67 | } else { 68 | right = y >= yStart ? y : yStart; 69 | left = y <= yStart ? y : yStart; 70 | } 71 | 72 | // multiply the height of the rect with the phase 73 | right *= phaseY; 74 | left *= phaseY; 75 | 76 | addBar(left, top, right, bottom); 77 | } 78 | } 79 | } 80 | 81 | reset(); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/chart_trans_listener.dart: -------------------------------------------------------------------------------- 1 | mixin ChartTransListener{ 2 | void scale(double scaleX, double scaleY, double x, double y); 3 | void translate(double dx, double dy); 4 | } -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/color/gradient_color.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui'; 2 | 3 | class GradientColor { 4 | Color _startColor; 5 | Color _endColor; 6 | 7 | GradientColor(this._startColor, this._endColor); 8 | 9 | // ignore: unnecessary_getters_setters 10 | Color get endColor => _endColor; 11 | 12 | // ignore: unnecessary_getters_setters 13 | set endColor(Color value) { 14 | _endColor = value; 15 | } 16 | 17 | // ignore: unnecessary_getters_setters 18 | Color get startColor => _startColor; 19 | 20 | // ignore: unnecessary_getters_setters 21 | set startColor(Color value) { 22 | _startColor = value; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/common_interfaces.dart: -------------------------------------------------------------------------------- 1 | import 'package:mp_chart/mp/core/highlight/highlight.dart'; 2 | import 'package:mp_chart/mp/core/data_set/data_set.dart'; 3 | import 'package:mp_chart/mp/core/entry/entry.dart'; 4 | 5 | mixin OnDrawListener { 6 | /// Called whenever an entry is added with the finger. Note this is also called for entries that are generated by the 7 | /// library, when the touch gesture is too fast and skips points. 8 | /// 9 | /// @param entry 10 | /// the last drawn entry 11 | void onEntryAdded(Entry entry); 12 | 13 | /// Called whenever an entry is moved by the user after beeing highlighted 14 | /// 15 | /// @param entry 16 | void onEntryMoved(Entry entry); 17 | 18 | /// Called when drawing finger is lifted and the draw is finished. 19 | /// 20 | /// @param dataSet 21 | /// the last drawn DataSet 22 | void onDrawFinished(DataSet dataSet); 23 | } 24 | 25 | /// Listener for callbacks when doing gestures on the chart. 26 | /// 27 | /// @author Philipp Jahoda 28 | mixin OnChartGestureListener { 29 | /// Callbacks when the chart is double-tapped. 30 | /// 31 | /// @param me 32 | void onChartDoubleTapped(double positionX, double positionY); 33 | 34 | /// Callbacks when the chart is single-tapped. 35 | /// 36 | /// @param me 37 | void onChartSingleTapped(double positionX, double positionY); 38 | 39 | /// Callbacks when the chart is scaled / zoomed via pinch zoom gesture. 40 | /// 41 | /// @param me 42 | /// @param scaleX scalefactor on the x-axis 43 | /// @param scaleY scalefactor on the y-axis 44 | void onChartScale( 45 | double positionX, double positionY, double scaleX, double scaleY); 46 | 47 | /// Callbacks when the chart is moved / translated via drag gesture. 48 | /// 49 | /// @param me 50 | /// @param dX translation distance on the x-axis 51 | /// @param dY translation distance on the y-axis 52 | void onChartTranslate( 53 | double positionX, double positionY, double dX, double dY); 54 | } 55 | 56 | /// Listener for callbacks when selecting values inside the chart by 57 | /// touch-gesture. 58 | /// 59 | /// @author Philipp Jahoda 60 | mixin OnChartValueSelectedListener { 61 | /// Called when a value has been selected inside the chart. 62 | /// 63 | /// @param e The selected Entry 64 | /// @param h The corresponding highlight object that contains information 65 | /// about the highlighted position such as dataSetIndex, ... 66 | void onValueSelected(Entry e, Highlight h); 67 | 68 | /// Called when nothing has been selected or an "un-select" has been made. 69 | void onNothingSelected(); 70 | } 71 | 72 | mixin AnimatorUpdateListener { 73 | void onAnimationUpdate(double x, double y); 74 | 75 | void onRotateUpdate(double angle); 76 | } 77 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/component.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/painting.dart'; 2 | import 'package:mp_chart/mp/core/adapter_android_mp.dart'; 3 | import 'package:mp_chart/mp/core/utils/color_utils.dart'; 4 | import 'package:mp_chart/mp/core/utils/utils.dart'; 5 | 6 | abstract class ComponentBase { 7 | /// flag that indicates if this axis / legend is enabled or not 8 | bool _enabled = true; 9 | 10 | /// the offset in pixels this component has on the x-axis 11 | double _xOffset = 5; 12 | 13 | /// the offset in pixels this component has on the Y-axis 14 | double _yOffset = 5; 15 | 16 | /// the typeface used for the labels 17 | TypeFace _typeface; 18 | 19 | /// the text size of the labels 20 | double _textSize = Utils.convertDpToPixel(10); 21 | 22 | /// the text color to use for the labels 23 | Color _textColor = ColorUtils.BLACK; 24 | 25 | // ignore: unnecessary_getters_setters 26 | bool get enabled => _enabled; 27 | 28 | // ignore: unnecessary_getters_setters 29 | set enabled(bool value) { 30 | _enabled = value; 31 | } 32 | 33 | double get xOffset => _xOffset; 34 | 35 | set xOffset(double value) { 36 | _xOffset = Utils.convertDpToPixel(value); 37 | } 38 | 39 | double get yOffset => _yOffset; 40 | 41 | set yOffset(double value) { 42 | _yOffset = Utils.convertDpToPixel(value); 43 | } 44 | 45 | // ignore: unnecessary_getters_setters 46 | TypeFace get typeface => _typeface; 47 | 48 | // ignore: unnecessary_getters_setters 49 | set typeface(TypeFace value) { 50 | _typeface = value; 51 | } 52 | 53 | double get textSize => _textSize; 54 | 55 | set textSize(double value) { 56 | if (value > 24) value = 24; 57 | if (value < 6) value = 6; 58 | _textSize = value; 59 | } 60 | 61 | // ignore: unnecessary_getters_setters 62 | Color get textColor => _textColor; 63 | 64 | // ignore: unnecessary_getters_setters 65 | set textColor(Color value) { 66 | _textColor = value; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/data/bar_data.dart: -------------------------------------------------------------------------------- 1 | import 'package:mp_chart/mp/core/data/bar_line_scatter_candle_bubble_data.dart'; 2 | import 'package:mp_chart/mp/core/data_interfaces/i_bar_data_set.dart'; 3 | import 'package:mp_chart/mp/core/entry/bar_entry.dart'; 4 | 5 | class BarData extends BarLineScatterCandleBubbleData { 6 | /// the width of the bars on the x-axis, in values (not pixels) 7 | double _barWidth = 0.85; 8 | 9 | BarData(List dataSets) : super.fromList(dataSets); 10 | 11 | // ignore: unnecessary_getters_setters 12 | double get barWidth => _barWidth; 13 | 14 | // ignore: unnecessary_getters_setters 15 | set barWidth(double value) { 16 | _barWidth = value; 17 | } 18 | 19 | /// Groups all BarDataSet objects this data object holds together by modifying the x-value of their entries. 20 | /// Previously set x-values of entries will be overwritten. Leaves space between bars and groups as specified 21 | /// by the parameters. 22 | /// Do not forget to call notifyDataSetChanged() on your BarChart object after calling this method. 23 | /// 24 | /// @param fromX the starting point on the x-axis where the grouping should begin 25 | /// @param groupSpace the space between groups of bars in values (not pixels) e.g. 0.8f for bar width 1f 26 | /// @param barSpace the space between individual bars in values (not pixels) e.g. 0.1f for bar width 1f 27 | void groupBars(double fromX, double groupSpace, double barSpace) { 28 | int setCount = dataSets.length; 29 | if (setCount <= 1) { 30 | throw Exception( 31 | "BarData needs to hold at least 2 BarDataSets to allow grouping."); 32 | } 33 | 34 | IBarDataSet max = getMaxEntryCountSet(); 35 | int maxEntryCount = max.getEntryCount(); 36 | 37 | double groupSpaceWidthHalf = groupSpace / 2.0; 38 | double barSpaceHalf = barSpace / 2.0; 39 | double barWidthHalf = _barWidth / 2.0; 40 | 41 | double interval = getGroupWidth(groupSpace, barSpace); 42 | 43 | for (int i = 0; i < maxEntryCount; i++) { 44 | double start = fromX; 45 | fromX += groupSpaceWidthHalf; 46 | 47 | for (IBarDataSet set in dataSets) { 48 | fromX += barSpaceHalf; 49 | fromX += barWidthHalf; 50 | 51 | if (i < set.getEntryCount()) { 52 | BarEntry entry = set.getEntryForIndex(i); 53 | 54 | if (entry != null) { 55 | entry.x = fromX; 56 | } 57 | } 58 | 59 | fromX += barWidthHalf; 60 | fromX += barSpaceHalf; 61 | } 62 | 63 | fromX += groupSpaceWidthHalf; 64 | double end = fromX; 65 | double innerInterval = end - start; 66 | double diff = interval - innerInterval; 67 | 68 | // correct rounding errors 69 | if (diff > 0 || diff < 0) { 70 | fromX += diff; 71 | } 72 | } 73 | 74 | notifyDataChanged(); 75 | } 76 | 77 | /// In case of grouped bars, this method returns the space an individual group of bar needs on the x-axis. 78 | /// 79 | /// @param groupSpace 80 | /// @param barSpace 81 | /// @return 82 | double getGroupWidth(double groupSpace, double barSpace) { 83 | return dataSets.length * (_barWidth + barSpace) + groupSpace; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/data/bar_line_scatter_candle_bubble_data.dart: -------------------------------------------------------------------------------- 1 | import 'package:mp_chart/mp/core/data/chart_data.dart'; 2 | import 'package:mp_chart/mp/core/data_interfaces/i_bar_line_scatter_candle_bubble_data_set.dart'; 3 | import 'package:mp_chart/mp/core/entry/entry.dart'; 4 | 5 | class BarLineScatterCandleBubbleData< 6 | T extends IBarLineScatterCandleBubbleDataSet> extends ChartData { 7 | BarLineScatterCandleBubbleData() : super(); 8 | 9 | BarLineScatterCandleBubbleData.fromList(List sets) : super.fromList(sets); 10 | } 11 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/data/bubble_data.dart: -------------------------------------------------------------------------------- 1 | import 'package:mp_chart/mp/core/data/bar_line_scatter_candle_bubble_data.dart'; 2 | import 'package:mp_chart/mp/core/data_interfaces/i_bubble_data_set.dart'; 3 | 4 | class BubbleData extends BarLineScatterCandleBubbleData { 5 | BubbleData() : super(); 6 | 7 | BubbleData.fromList(List dataSets) : super.fromList(dataSets); 8 | 9 | /// Sets the width of the circle that surrounds the bubble when highlighted 10 | /// for all DataSet objects this data object contains, in dp. 11 | /// 12 | /// @param width 13 | void setHighlightCircleWidth(double width) { 14 | for (IBubbleDataSet set in dataSets) { 15 | set.setHighlightCircleWidth(width); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/data/candle_data.dart: -------------------------------------------------------------------------------- 1 | import 'package:mp_chart/mp/core/data/bar_line_scatter_candle_bubble_data.dart'; 2 | import 'package:mp_chart/mp/core/data_interfaces/i_candle_data_set.dart'; 3 | 4 | class CandleData extends BarLineScatterCandleBubbleData { 5 | CandleData() : super(); 6 | 7 | CandleData.fromList(List dataSets) : super.fromList(dataSets); 8 | } 9 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/data/line_data.dart: -------------------------------------------------------------------------------- 1 | import 'package:mp_chart/mp/core/data/bar_line_scatter_candle_bubble_data.dart'; 2 | import 'package:mp_chart/mp/core/data_interfaces/i_line_data_set.dart'; 3 | 4 | class LineData extends BarLineScatterCandleBubbleData { 5 | LineData() : super(); 6 | 7 | LineData.fromList(List sets) : super.fromList(sets); 8 | } 9 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/data/pie_data.dart: -------------------------------------------------------------------------------- 1 | import 'package:mp_chart/mp/core/data/chart_data.dart'; 2 | import 'package:mp_chart/mp/core/data_interfaces/i_pie_data_set.dart'; 3 | import 'package:mp_chart/mp/core/entry/entry.dart'; 4 | import 'package:mp_chart/mp/core/highlight/highlight.dart'; 5 | import 'package:mp_chart/mp/core/utils/dart_adapter_utils.dart'; 6 | 7 | class PieData extends ChartData { 8 | PieData(IPieDataSet dataSet) : super.fromList(List()..add(dataSet)); 9 | 10 | /// Sets the PieDataSet this data object should represent. 11 | /// 12 | /// @param dataSet 13 | void setDataSet(IPieDataSet dataSet) { 14 | dataSets.clear(); 15 | dataSets.add(dataSet); 16 | notifyDataChanged(); 17 | } 18 | 19 | /// Returns the DataSet this PieData object represents. A PieData object can 20 | /// only contain one DataSet. 21 | /// 22 | /// @return 23 | IPieDataSet getDataSet() { 24 | return dataSets[0]; 25 | } 26 | 27 | /// The PieData object can only have one DataSet. Use getDataSet() method instead. 28 | /// 29 | /// @param index 30 | /// @return 31 | @override 32 | IPieDataSet getDataSetByIndex(int index) { 33 | return index == 0 ? getDataSet() : null; 34 | } 35 | 36 | @override 37 | IPieDataSet getDataSetByLabel(String label, bool ignorecase) { 38 | return ignorecase 39 | ? DartAdapterUtils.equalsIgnoreCase(label, dataSets[0].getLabel()) 40 | ? dataSets[0] 41 | : null 42 | : (label == dataSets[0].getLabel()) ? dataSets[0] : null; 43 | } 44 | 45 | @override 46 | Entry getEntryForHighlight(Highlight highlight) { 47 | return getDataSet().getEntryForIndex(highlight.x.toInt()); 48 | } 49 | 50 | /// Returns the sum of all values in this PieData object. 51 | /// 52 | /// @return 53 | double getYValueSum() { 54 | double sum = 0; 55 | for (int i = 0; i < getDataSet().getEntryCount(); i++) 56 | sum += getDataSet().getEntryForIndex(i).getValue(); 57 | return sum; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/data/radar_data.dart: -------------------------------------------------------------------------------- 1 | import 'package:mp_chart/mp/core/data/chart_data.dart'; 2 | import 'package:mp_chart/mp/core/data_interfaces/i_radar_data_set.dart'; 3 | import 'package:mp_chart/mp/core/entry/entry.dart'; 4 | import 'package:mp_chart/mp/core/highlight/highlight.dart'; 5 | 6 | class RadarData extends ChartData { 7 | List _labels; 8 | 9 | RadarData() : super(); 10 | 11 | RadarData.fromList(List dataSets) : super.fromList(dataSets); 12 | 13 | // ignore: unnecessary_getters_setters 14 | List get labels => _labels; 15 | 16 | // ignore: unnecessary_getters_setters 17 | set labels(List value) { 18 | _labels = value; 19 | } 20 | 21 | @override 22 | Entry getEntryForHighlight(Highlight highlight) { 23 | return getDataSetByIndex(highlight.dataSetIndex) 24 | .getEntryForIndex(highlight.x.toInt()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/data/scatter_data.dart: -------------------------------------------------------------------------------- 1 | import 'package:mp_chart/mp/core/data/bar_line_scatter_candle_bubble_data.dart'; 2 | import 'package:mp_chart/mp/core/data_interfaces/i_scatter_data_set.dart'; 3 | 4 | class ScatterData extends BarLineScatterCandleBubbleData { 5 | ScatterData() : super(); 6 | 7 | ScatterData.fromList(List dataSets) 8 | : super.fromList(dataSets); 9 | 10 | /// Returns the maximum shape-size across all DataSets. 11 | /// 12 | /// @return 13 | double getGreatestShapeSize() { 14 | double max = 0; 15 | 16 | for (IScatterDataSet set in dataSets) { 17 | double size = set.getScatterShapeSize(); 18 | 19 | if (size > max) max = size; 20 | } 21 | 22 | return max; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/data_interfaces/i_bar_data_set.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui'; 2 | 3 | import 'package:mp_chart/mp/core/data_interfaces/i_bar_line_scatter_candle_bubble_data_set.dart'; 4 | import 'package:mp_chart/mp/core/entry/bar_entry.dart'; 5 | 6 | mixin IBarDataSet implements IBarLineScatterCandleBubbleDataSet { 7 | /// Returns true if this DataSet is stacked (stacksize > 1) or not. 8 | /// 9 | /// @return 10 | bool isStacked(); 11 | 12 | /// Returns the maximum number of bars that can be stacked upon another in 13 | /// this DataSet. This should return 1 for non stacked bars, and > 1 for stacked bars. 14 | /// 15 | /// @return 16 | int getStackSize(); 17 | 18 | /// Returns the color used for drawing the bar-shadows. The bar shadows is a 19 | /// surface behind the bar that indicates the maximum value. 20 | /// 21 | /// @return 22 | Color getBarShadowColor(); 23 | 24 | /// Returns the width used for drawing borders around the bars. 25 | /// If borderWidth == 0, no border will be drawn. 26 | /// 27 | /// @return 28 | double getBarBorderWidth(); 29 | 30 | /// Returns the color drawing borders around the bars. 31 | /// 32 | /// @return 33 | Color getBarBorderColor(); 34 | 35 | /// Returns the alpha value (transparency) that is used for drawing the 36 | /// highlight indicator. 37 | /// 38 | /// @return 39 | int getHighLightAlpha(); 40 | 41 | /// Returns the labels used for the different value-stacks in the legend. 42 | /// This is only relevant for stacked bar entries. 43 | /// 44 | /// @return 45 | List getStackLabels(); 46 | } 47 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/data_interfaces/i_bar_line_scatter_candle_bubble_data_set.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui'; 2 | 3 | import 'package:mp_chart/mp/core/data_interfaces/i_data_set.dart'; 4 | import 'package:mp_chart/mp/core/entry/entry.dart'; 5 | 6 | mixin IBarLineScatterCandleBubbleDataSet 7 | implements IDataSet { 8 | /// Returns the color that is used for drawing the highlight indicators. 9 | /// 10 | /// @return 11 | Color getHighLightColor(); 12 | } 13 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/data_interfaces/i_bubble_data_set.dart: -------------------------------------------------------------------------------- 1 | import 'package:mp_chart/mp/core/data_interfaces/i_bar_line_scatter_candle_bubble_data_set.dart'; 2 | import 'package:mp_chart/mp/core/entry/bubble_entry.dart'; 3 | 4 | mixin IBubbleDataSet 5 | implements IBarLineScatterCandleBubbleDataSet { 6 | /// Sets the width of the circle that surrounds the bubble when highlighted, 7 | /// in dp. 8 | /// 9 | /// @param width 10 | void setHighlightCircleWidth(double width); 11 | 12 | double getMaxSize(); 13 | 14 | bool isNormalizeSizeEnabled(); 15 | 16 | /// Returns the width of the highlight-circle that surrounds the bubble 17 | /// @return 18 | double getHighlightCircleWidth(); 19 | } 20 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/data_interfaces/i_candle_data_set.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui'; 2 | 3 | import 'package:mp_chart/mp/core/data_interfaces/i_line_scatter_candle_radar_data_set.dart'; 4 | import 'package:mp_chart/mp/core/entry/candle_entry.dart'; 5 | 6 | mixin ICandleDataSet implements ILineScatterCandleRadarDataSet { 7 | /// Returns the space that is left out on the left and right side of each 8 | /// candle. 9 | /// 10 | /// @return 11 | double getBarSpace(); 12 | 13 | /// Returns whether the candle bars should show? 14 | /// When false, only "ticks" will show 15 | /// 16 | /// - default: true 17 | /// 18 | /// @return 19 | bool getShowCandleBar(); 20 | 21 | /// Returns the width of the candle-shadow-line in pixels. 22 | /// 23 | /// @return 24 | double getShadowWidth(); 25 | 26 | /// Returns shadow color for all entries 27 | /// 28 | /// @return 29 | Color getShadowColor(); 30 | 31 | /// Returns the neutral color (for open == close) 32 | /// 33 | /// @return 34 | Color getNeutralColor(); 35 | 36 | /// Returns the increasing color (for open < close). 37 | /// 38 | /// @return 39 | Color getIncreasingColor(); 40 | 41 | /// Returns the decreasing color (for open > close). 42 | /// 43 | /// @return 44 | Color getDecreasingColor(); 45 | 46 | /// Returns paint style when open < close 47 | /// 48 | /// @return 49 | PaintingStyle getIncreasingPaintStyle(); 50 | 51 | /// Returns paint style when open > close 52 | /// 53 | /// @return 54 | PaintingStyle getDecreasingPaintStyle(); 55 | 56 | /// Is the shadow color same as the candle color? 57 | /// 58 | /// @return 59 | bool getShadowColorSameAsCandle(); 60 | } 61 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/data_interfaces/i_data_set.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui' as ui; 2 | 3 | import 'package:mp_chart/mp/core/adapter_android_mp.dart'; 4 | import 'package:mp_chart/mp/core/color/gradient_color.dart'; 5 | import 'package:mp_chart/mp/core/entry/entry.dart'; 6 | import 'package:mp_chart/mp/core/enums/axis_dependency.dart'; 7 | import 'package:mp_chart/mp/core/enums/legend_form.dart'; 8 | import 'package:mp_chart/mp/core/enums/rounding.dart'; 9 | import 'package:mp_chart/mp/core/poolable/point.dart'; 10 | import 'package:mp_chart/mp/core/value_formatter/value_formatter.dart'; 11 | 12 | mixin IDataSet { 13 | double getYMin(); 14 | 15 | double getYMax(); 16 | 17 | double getXMin(); 18 | 19 | double getXMax(); 20 | 21 | int getEntryCount(); 22 | 23 | void calcMinMax(); 24 | 25 | void calcMinMaxY(double fromX, double toX); 26 | 27 | T getEntryForXValue1(double xValue, double closestToY, Rounding rounding); 28 | 29 | T getEntryForXValue2(double xValue, double closestToY); 30 | 31 | List getEntriesForXValue(double xValue); 32 | 33 | T getEntryForIndex(int index); 34 | 35 | int getEntryIndex1(double xValue, double closestToY, Rounding rounding); 36 | 37 | int getEntryIndex2(T e); 38 | 39 | int getIndexInEntries(int xIndex); 40 | 41 | bool addEntry(T e); 42 | 43 | bool addEntryByIndex(int index, T e); 44 | 45 | bool updateEntryByIndex(int index, T e); 46 | 47 | void addEntryOrdered(T e); 48 | 49 | bool removeFirst(); 50 | 51 | bool removeLast(); 52 | 53 | bool removeEntry1(T e); 54 | 55 | bool removeEntryByXValue(double xValue); 56 | 57 | bool removeEntry2(int index); 58 | 59 | bool contains(T entry); 60 | 61 | void clear(); 62 | 63 | String getLabel(); 64 | 65 | void setLabel(String label); 66 | 67 | AxisDependency getAxisDependency(); 68 | 69 | void setAxisDependency(AxisDependency dependency); 70 | 71 | List getColors(); 72 | 73 | ui.Color getColor1(); 74 | 75 | GradientColor getGradientColor1(); 76 | 77 | List getGradientColors(); 78 | 79 | GradientColor getGradientColor2(int index); 80 | 81 | ui.Color getColor2(int index); 82 | 83 | bool isHighlightEnabled(); 84 | 85 | void setHighlightEnabled(bool enabled); 86 | 87 | void setValueFormatter(ValueFormatter f); 88 | 89 | ValueFormatter getValueFormatter(); 90 | 91 | bool needsFormatter(); 92 | 93 | void setValueTextColor(ui.Color color); 94 | 95 | void setValueTextColors(List colors); 96 | 97 | void setValueTypeface(TypeFace ts); 98 | 99 | void setValueTextSize(double size); 100 | 101 | ui.Color getValueTextColor1(); 102 | 103 | ui.Color getValueTextColor2(int index); 104 | 105 | TypeFace getValueTypeface(); 106 | 107 | double getValueTextSize(); 108 | 109 | LegendForm getForm(); 110 | 111 | double getFormSize(); 112 | 113 | double getFormLineWidth(); 114 | 115 | DashPathEffect getFormLineDashEffect(); 116 | 117 | void setDrawValues(bool enabled); 118 | 119 | bool isDrawValuesEnabled(); 120 | 121 | void setDrawIcons(bool enabled); 122 | 123 | bool isDrawIconsEnabled(); 124 | 125 | void setIconsOffset(MPPointF offset); 126 | 127 | MPPointF getIconsOffset(); 128 | 129 | void setVisible(bool visible); 130 | 131 | bool isVisible(); 132 | } 133 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/data_interfaces/i_line_data_set.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui'; 2 | 3 | import 'package:mp_chart/mp/core/adapter_android_mp.dart'; 4 | import 'package:mp_chart/mp/core/data_interfaces/i_line_radar_data_set.dart'; 5 | import 'package:mp_chart/mp/core/entry/entry.dart'; 6 | import 'package:mp_chart/mp/core/enums/mode.dart'; 7 | import 'package:mp_chart/mp/core/fill_formatter/i_fill_formatter.dart'; 8 | 9 | mixin ILineDataSet implements ILineRadarDataSet { 10 | /// Returns the drawing mode for this line dataset 11 | /// 12 | /// @return 13 | Mode getMode(); 14 | 15 | /// Returns the intensity of the cubic lines (the effect intensity). 16 | /// Max = 1f = very cubic, Min = 0.05f = low cubic effect, Default: 0.2f 17 | /// 18 | /// @return 19 | double getCubicIntensity(); 20 | 21 | bool isDrawCubicEnabled(); 22 | 23 | bool isDrawSteppedEnabled(); 24 | 25 | /// Returns the size of the drawn circles. 26 | double getCircleRadius(); 27 | 28 | /// Returns the hole radius of the drawn circles. 29 | double getCircleHoleRadius(); 30 | 31 | /// Returns the color at the given index of the DataSet's circle-color array. 32 | /// Performs a IndexOutOfBounds check by modulus. 33 | /// 34 | /// @param index 35 | /// @return 36 | Color getCircleColor(int index); 37 | 38 | /// Returns the number of colors in this DataSet's circle-color array. 39 | /// 40 | /// @return 41 | int getCircleColorCount(); 42 | 43 | /// Returns true if drawing circles for this DataSet is enabled, false if not 44 | /// 45 | /// @return 46 | bool isDrawCirclesEnabled(); 47 | 48 | /// Returns the color of the inner circle (the circle-hole). 49 | /// 50 | /// @return 51 | Color getCircleHoleColor(); 52 | 53 | /// Returns true if drawing the circle-holes is enabled, false if not. 54 | /// 55 | /// @return 56 | bool isDrawCircleHoleEnabled(); 57 | 58 | /// Returns the DashPathEffect that is used for drawing the lines. 59 | /// 60 | /// @return 61 | DashPathEffect getDashPathEffect(); 62 | 63 | /// Returns true if the dashed-line effect is enabled, false if not. 64 | /// If the DashPathEffect object is null, also return false here. 65 | /// 66 | /// @return 67 | bool isDashedLineEnabled(); 68 | 69 | /// Returns the IFillFormatter that is set for this DataSet. 70 | /// 71 | /// @return 72 | IFillFormatter getFillFormatter(); 73 | } 74 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/data_interfaces/i_line_radar_data_set.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui'; 2 | 3 | import 'package:mp_chart/mp/core/data_interfaces/i_line_scatter_candle_radar_data_set.dart'; 4 | import 'package:mp_chart/mp/core/entry/entry.dart'; 5 | 6 | mixin ILineRadarDataSet 7 | implements ILineScatterCandleRadarDataSet { 8 | /// Returns the color that is used for filling the line surface area. 9 | /// 10 | /// @return 11 | Color getFillColor(); 12 | 13 | /// Returns the drawable used for filling the area below the line. 14 | /// 15 | /// @return 16 | // Drawable getFillDrawable(); todo 17 | 18 | /// Returns the alpha value that is used for filling the line surface, 19 | /// default: 85 20 | /// 21 | /// @return 22 | int getFillAlpha(); 23 | 24 | /// Returns the stroke-width of the drawn line 25 | /// 26 | /// @return 27 | double getLineWidth(); 28 | 29 | /// Returns true if filled drawing is enabled, false if not 30 | /// 31 | /// @return 32 | bool isDrawFilledEnabled(); 33 | 34 | /// Set to true if the DataSet should be drawn filled (surface), and not just 35 | /// as a line, disabling this will give great performance boost. Please note that this method 36 | /// uses the canvas.clipPath(...) method for drawing the filled area. 37 | /// For devices with API level < 18 (Android 4.3), hardware acceleration of the chart should 38 | /// be turned off. Default: false 39 | /// 40 | /// @param enabled 41 | void setDrawFilled(bool enabled); 42 | 43 | bool isGradientEnabled(); 44 | 45 | void setGradientFilled(bool enabled); 46 | } 47 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/data_interfaces/i_line_scatter_candle_radar_data_set.dart: -------------------------------------------------------------------------------- 1 | import 'package:mp_chart/mp/core/adapter_android_mp.dart'; 2 | import 'package:mp_chart/mp/core/data_interfaces/i_bar_line_scatter_candle_bubble_data_set.dart'; 3 | import 'package:mp_chart/mp/core/entry/entry.dart'; 4 | 5 | mixin ILineScatterCandleRadarDataSet 6 | implements IBarLineScatterCandleBubbleDataSet { 7 | /// Returns true if vertical highlight indicator lines are enabled (drawn) 8 | /// @return 9 | bool isVerticalHighlightIndicatorEnabled(); 10 | 11 | /// Returns true if vertical highlight indicator lines are enabled (drawn) 12 | /// @return 13 | bool isHorizontalHighlightIndicatorEnabled(); 14 | 15 | /// Returns the line-width in which highlight lines are to be drawn. 16 | /// @return 17 | double getHighlightLineWidth(); 18 | 19 | /// Returns the DashPathEffect that is used for highlighting. 20 | /// @return 21 | DashPathEffect getDashPathEffectHighlight(); 22 | } 23 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/data_interfaces/i_pie_data_set.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui'; 2 | 3 | import 'package:mp_chart/mp/core/data_interfaces/i_data_set.dart'; 4 | import 'package:mp_chart/mp/core/entry/pie_entry.dart'; 5 | import 'package:mp_chart/mp/core/enums/value_position.dart'; 6 | 7 | mixin IPieDataSet implements IDataSet { 8 | /// Returns the space that is set to be between the piechart-slices of this 9 | /// DataSet, in pixels. 10 | /// 11 | /// @return 12 | double getSliceSpace(); 13 | 14 | /// When enabled, slice spacing will be 0.0 when the smallest value is going to be 15 | /// smaller than the slice spacing itself. 16 | /// 17 | /// @return 18 | bool isAutomaticallyDisableSliceSpacingEnabled(); 19 | 20 | /// Returns the distance a highlighted piechart slice is "shifted" away from 21 | /// the chart-center in dp. 22 | /// 23 | /// @return 24 | double getSelectionShift(); 25 | 26 | ValuePosition getXValuePosition(); 27 | 28 | ValuePosition getYValuePosition(); 29 | 30 | /// When valuePosition is OutsideSlice, use slice colors as line color if true 31 | /// */ 32 | bool isUsingSliceColorAsValueLineColor(); 33 | 34 | /// When valuePosition is OutsideSlice, indicates line color 35 | /// */ 36 | Color getValueLineColor(); 37 | 38 | /// When valuePosition is OutsideSlice, indicates line width 39 | /// */ 40 | double getValueLineWidth(); 41 | 42 | /// When valuePosition is OutsideSlice, indicates offset as percentage out of the slice size 43 | /// */ 44 | double getValueLinePart1OffsetPercentage(); 45 | 46 | /// When valuePosition is OutsideSlice, indicates length of first half of the line 47 | /// */ 48 | double getValueLinePart1Length(); 49 | 50 | /// When valuePosition is OutsideSlice, indicates length of second half of the line 51 | /// */ 52 | double getValueLinePart2Length(); 53 | 54 | /// When valuePosition is OutsideSlice, this allows variable line length 55 | /// */ 56 | bool isValueLineVariableLength(); 57 | } 58 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/data_interfaces/i_radar_data_set.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui'; 2 | 3 | import 'package:mp_chart/mp/core/data_interfaces/i_line_radar_data_set.dart'; 4 | import 'package:mp_chart/mp/core/entry/radar_entry.dart'; 5 | 6 | mixin IRadarDataSet implements ILineRadarDataSet { 7 | /// flag indicating whether highlight circle should be drawn or not 8 | bool isDrawHighlightCircleEnabled(); 9 | 10 | /// Sets whether highlight circle should be drawn or not 11 | void setDrawHighlightCircleEnabled(bool enabled); 12 | 13 | Color getHighlightCircleFillColor(); 14 | 15 | /// The stroke color for highlight circle. 16 | /// If Utils.COLOR_NONE, the color of the dataset is taken. 17 | Color getHighlightCircleStrokeColor(); 18 | 19 | int getHighlightCircleStrokeAlpha(); 20 | 21 | double getHighlightCircleInnerRadius(); 22 | 23 | double getHighlightCircleOuterRadius(); 24 | 25 | double getHighlightCircleStrokeWidth(); 26 | } 27 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/data_interfaces/i_scatter_data_set.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui'; 2 | 3 | import 'package:mp_chart/mp/core/data_interfaces/i_line_scatter_candle_radar_data_set.dart'; 4 | import 'package:mp_chart/mp/core/entry/entry.dart'; 5 | import 'package:mp_chart/mp/core/render/i_shape_renderer.dart'; 6 | 7 | mixin IScatterDataSet implements ILineScatterCandleRadarDataSet { 8 | /// Returns the currently set scatter shape size 9 | /// 10 | /// @return 11 | double getScatterShapeSize(); 12 | 13 | /// Returns radius of the hole in the shape 14 | /// 15 | /// @return 16 | double getScatterShapeHoleRadius(); 17 | 18 | /// Returns the color for the hole in the shape 19 | /// 20 | /// @return 21 | Color getScatterShapeHoleColor(); 22 | 23 | /// Returns the IShapeRenderer responsible for rendering this DataSet. 24 | /// 25 | /// @return 26 | IShapeRenderer getShapeRenderer(); 27 | } 28 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/data_provider/bar_data_provider.dart: -------------------------------------------------------------------------------- 1 | import 'package:mp_chart/mp/core/data/bar_data.dart'; 2 | import 'package:mp_chart/mp/core/data_provider/bar_line_scatter_candle_bubble_data_provider.dart'; 3 | 4 | mixin BarDataProvider implements BarLineScatterCandleBubbleDataProvider { 5 | BarData getBarData(); 6 | 7 | bool isDrawBarShadowEnabled(); 8 | 9 | bool isDrawValueAboveBarEnabled(); 10 | 11 | bool isHighlightFullBarEnabled(); 12 | } 13 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/data_provider/bar_line_scatter_candle_bubble_data_provider.dart: -------------------------------------------------------------------------------- 1 | import 'package:mp_chart/mp/core/data/bar_line_scatter_candle_bubble_data.dart'; 2 | import 'package:mp_chart/mp/core/data_provider/chart_interface.dart'; 3 | import 'package:mp_chart/mp/core/enums/axis_dependency.dart'; 4 | import 'package:mp_chart/mp/core/transformer/transformer.dart'; 5 | 6 | mixin BarLineScatterCandleBubbleDataProvider implements ChartInterface { 7 | Transformer getTransformer(AxisDependency axis); 8 | 9 | bool isInverted(AxisDependency axis); 10 | 11 | double getLowestVisibleX(); 12 | 13 | double getHighestVisibleX(); 14 | 15 | BarLineScatterCandleBubbleData getData(); 16 | } 17 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/data_provider/bubble_data_provider.dart: -------------------------------------------------------------------------------- 1 | import 'package:mp_chart/mp/core/data/bubble_data.dart'; 2 | import 'package:mp_chart/mp/core/data_provider/bar_line_scatter_candle_bubble_data_provider.dart'; 3 | 4 | mixin BubbleDataProvider implements BarLineScatterCandleBubbleDataProvider { 5 | BubbleData getBubbleData(); 6 | } 7 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/data_provider/candle_data_provider.dart: -------------------------------------------------------------------------------- 1 | import 'package:mp_chart/mp/core/data/candle_data.dart'; 2 | import 'package:mp_chart/mp/core/data_provider/bar_line_scatter_candle_bubble_data_provider.dart'; 3 | 4 | mixin CandleDataProvider implements BarLineScatterCandleBubbleDataProvider { 5 | CandleData getCandleData(); 6 | } 7 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/data_provider/chart_interface.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui'; 2 | 3 | import 'package:mp_chart/mp/core/data/chart_data.dart'; 4 | import 'package:mp_chart/mp/core/poolable/point.dart'; 5 | import 'package:mp_chart/mp/core/value_formatter/value_formatter.dart'; 6 | 7 | mixin ChartInterface { 8 | /// Returns the minimum y value of the chart, regardless of zoom or translation. 9 | /// 10 | /// @return 11 | double getYChartMin(); 12 | 13 | /// Returns the maximum y value of the chart, regardless of zoom or translation. 14 | /// 15 | /// @return 16 | double getYChartMax(); 17 | 18 | /// Returns the maximum distance in scren dp a touch can be away from an entry to cause it to get highlighted. 19 | /// 20 | /// @return 21 | double getMaxHighlightDistance(); 22 | 23 | MPPointF getCenter(Size size); 24 | 25 | MPPointF getCenterOffsets(); 26 | 27 | ValueFormatter getDefaultValueFormatter(); 28 | 29 | int getMaxVisibleCount(); 30 | 31 | ChartData getData(); 32 | } 33 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/data_provider/combined_data_provider.dart: -------------------------------------------------------------------------------- 1 | import 'package:mp_chart/mp/core/data/combined_data.dart'; 2 | import 'package:mp_chart/mp/core/data_provider/bar_data_provider.dart'; 3 | import 'package:mp_chart/mp/core/data_provider/bubble_data_provider.dart'; 4 | import 'package:mp_chart/mp/core/data_provider/candle_data_provider.dart'; 5 | import 'package:mp_chart/mp/core/data_provider/line_data_provider.dart'; 6 | import 'package:mp_chart/mp/core/data_provider/scatter_data_provider.dart'; 7 | 8 | mixin CombinedDataProvider 9 | implements 10 | LineDataProvider, 11 | BarDataProvider, 12 | BubbleDataProvider, 13 | CandleDataProvider, 14 | ScatterDataProvider { 15 | CombinedData getCombinedData(); 16 | } 17 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/data_provider/line_data_provider.dart: -------------------------------------------------------------------------------- 1 | import 'package:mp_chart/mp/core/axis/y_axis.dart'; 2 | import 'package:mp_chart/mp/core/data/line_data.dart'; 3 | import 'package:mp_chart/mp/core/data_provider/bar_line_scatter_candle_bubble_data_provider.dart'; 4 | import 'package:mp_chart/mp/core/enums/axis_dependency.dart'; 5 | 6 | mixin LineDataProvider implements BarLineScatterCandleBubbleDataProvider { 7 | LineData getLineData(); 8 | 9 | YAxis getAxis(AxisDependency dependency); 10 | } 11 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/data_provider/scatter_data_provider.dart: -------------------------------------------------------------------------------- 1 | import 'package:mp_chart/mp/core/data/scatter_data.dart'; 2 | import 'package:mp_chart/mp/core/data_provider/bar_line_scatter_candle_bubble_data_provider.dart'; 3 | 4 | mixin ScatterDataProvider implements BarLineScatterCandleBubbleDataProvider { 5 | ScatterData getScatterData(); 6 | } 7 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/data_set/bar_line_scatter_candle_bubble_data_set.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui'; 2 | 3 | import 'package:mp_chart/mp/core/data_interfaces/i_bar_line_scatter_candle_bubble_data_set.dart'; 4 | import 'package:mp_chart/mp/core/data_set/base_data_set.dart'; 5 | import 'package:mp_chart/mp/core/data_set/data_set.dart'; 6 | import 'package:mp_chart/mp/core/entry/entry.dart'; 7 | 8 | abstract class BarLineScatterCandleBubbleDataSet 9 | extends DataSet implements IBarLineScatterCandleBubbleDataSet { 10 | Color _highLightColor = Color.fromARGB(255, 255, 187, 115); 11 | 12 | BarLineScatterCandleBubbleDataSet(List yVals, String label) 13 | : super(yVals, label); 14 | 15 | /// Sets the color that is used for drawing the highlight indicators. Dont 16 | /// forget to resolve the color using getResources().getColor(...) or 17 | /// Color.rgb(...). 18 | /// 19 | /// @param color 20 | void setHighLightColor(Color color) { 21 | _highLightColor = color; 22 | } 23 | 24 | @override 25 | Color getHighLightColor() { 26 | return _highLightColor; 27 | } 28 | 29 | @override 30 | void copy(BaseDataSet baseDataSet) { 31 | super.copy(baseDataSet); 32 | if (baseDataSet is BarLineScatterCandleBubbleDataSet) { 33 | var barLineScatterCandleBubbleDataSet = baseDataSet; 34 | barLineScatterCandleBubbleDataSet._highLightColor = _highLightColor; 35 | } 36 | } 37 | 38 | @override 39 | String toString() { 40 | return '${super.toString()}\nBarLineScatterCandleBubbleDataSet{_highLightColor: $_highLightColor}'; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/data_set/bubble_data_set.dart: -------------------------------------------------------------------------------- 1 | import 'package:mp_chart/mp/core/data_interfaces/i_bubble_data_set.dart'; 2 | import 'package:mp_chart/mp/core/data_set/bar_line_scatter_candle_bubble_data_set.dart'; 3 | import 'package:mp_chart/mp/core/data_set/base_data_set.dart'; 4 | import 'package:mp_chart/mp/core/data_set/data_set.dart'; 5 | import 'package:mp_chart/mp/core/entry/bubble_entry.dart'; 6 | import 'package:mp_chart/mp/core/utils/utils.dart'; 7 | 8 | class BubbleDataSet extends BarLineScatterCandleBubbleDataSet 9 | implements IBubbleDataSet { 10 | double _maxSize = 0.0; 11 | bool _normalizeSize = true; 12 | 13 | double _highlightCircleWidth = 2.5; 14 | 15 | BubbleDataSet(List yVals, String label) : super(yVals, label); 16 | 17 | @override 18 | void setHighlightCircleWidth(double width) { 19 | _highlightCircleWidth = Utils.convertDpToPixel(width); 20 | } 21 | 22 | @override 23 | double getHighlightCircleWidth() { 24 | return _highlightCircleWidth; 25 | } 26 | 27 | @override 28 | void calcMinMax1(BubbleEntry e) { 29 | super.calcMinMax1(e); 30 | 31 | final double size = e.size; 32 | 33 | if (size > _maxSize) { 34 | _maxSize = size; 35 | } 36 | } 37 | 38 | @override 39 | DataSet copy1() { 40 | List entries = List(); 41 | for (int i = 0; i < values.length; i++) { 42 | entries.add(values[i].copy()); 43 | } 44 | BubbleDataSet copied = BubbleDataSet(entries, getLabel()); 45 | copy(copied); 46 | return copied; 47 | } 48 | 49 | void copy(BaseDataSet baseDataSet) { 50 | super.copy(baseDataSet); 51 | if (baseDataSet is BubbleDataSet) { 52 | var bubbleDataSet = baseDataSet; 53 | bubbleDataSet._highlightCircleWidth = _highlightCircleWidth; 54 | bubbleDataSet._normalizeSize = _normalizeSize; 55 | } 56 | } 57 | 58 | @override 59 | double getMaxSize() { 60 | return _maxSize; 61 | } 62 | 63 | @override 64 | bool isNormalizeSizeEnabled() { 65 | return _normalizeSize; 66 | } 67 | 68 | void setNormalizeSizeEnabled(bool normalizeSize) { 69 | _normalizeSize = normalizeSize; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/description.dart: -------------------------------------------------------------------------------- 1 | import 'dart:core'; 2 | import 'dart:ui'; 3 | 4 | import 'package:mp_chart/mp/core/component.dart'; 5 | import 'package:mp_chart/mp/core/poolable/point.dart'; 6 | import 'package:mp_chart/mp/core/utils/utils.dart'; 7 | 8 | class Description extends ComponentBase { 9 | /// the text used in the description 10 | String _text = "Description Label"; 11 | 12 | /// the custom position of the description text 13 | MPPointF _position; 14 | 15 | /// the alignment of the description text 16 | TextAlign _textAlign = TextAlign.center; 17 | 18 | Description() : super() { 19 | // default size 20 | textSize = Utils.convertDpToPixel(8); 21 | } 22 | 23 | // ignore: unnecessary_getters_setters 24 | String get text => _text; 25 | 26 | // ignore: unnecessary_getters_setters 27 | set text(String value) { 28 | _text = value; 29 | } 30 | 31 | /// Sets a custom position for the description text in pixels on the screen. 32 | /// 33 | /// @param x - xcoordinate 34 | /// @param y - ycoordinate 35 | void setPosition(double x, double y) { 36 | if (_position == null) { 37 | _position = MPPointF.getInstance1(x, y); 38 | } else { 39 | _position.x = x; 40 | _position.y = y; 41 | } 42 | } 43 | 44 | MPPointF get position => _position; 45 | 46 | // ignore: unnecessary_getters_setters 47 | TextAlign get textAlign => _textAlign; 48 | 49 | // ignore: unnecessary_getters_setters 50 | set textAlign(TextAlign value) { 51 | _textAlign = value; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/entry/base_entry.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui' as ui; 2 | 3 | abstract class BaseEntry { 4 | /// the y value 5 | double _y = 0; 6 | 7 | /// optional spot for additional data this Entry represents 8 | Object _data; 9 | 10 | /// optional icon image 11 | ui.Image _icon; 12 | 13 | BaseEntry({double y, ui.Image icon, Object data}) { 14 | this._y = y; 15 | this._icon = icon; 16 | this._data = data; 17 | } 18 | 19 | // ignore: unnecessary_getters_setters 20 | ui.Image get mIcon => _icon; 21 | 22 | // ignore: unnecessary_getters_setters 23 | set mIcon(ui.Image value) { 24 | _icon = value; 25 | } 26 | 27 | // ignore: unnecessary_getters_setters 28 | Object get mData => _data; 29 | 30 | // ignore: unnecessary_getters_setters 31 | set mData(Object value) { 32 | _data = value; 33 | } 34 | 35 | // ignore: unnecessary_getters_setters 36 | double get y => _y; 37 | 38 | // ignore: unnecessary_getters_setters 39 | set y(double value) { 40 | _y = value; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/entry/bubble_entry.dart: -------------------------------------------------------------------------------- 1 | import 'package:mp_chart/mp/core/entry/entry.dart'; 2 | import 'dart:ui' as ui; 3 | 4 | class BubbleEntry extends Entry { 5 | /// size value 6 | double _size = 0; 7 | 8 | /// Constructor. 9 | /// 10 | /// @param x The value on the x-axis. 11 | /// @param y The value on the y-axis. 12 | /// @param size The size of the bubble. 13 | BubbleEntry({double x, double y, double size, Object data, ui.Image icon}) 14 | : super(x: x, y: y, data: data, icon: icon) { 15 | this._size = size; 16 | } 17 | 18 | BubbleEntry copy() { 19 | BubbleEntry c = BubbleEntry(x: x, y: y, size: _size, data: mData); 20 | return c; 21 | } 22 | 23 | // ignore: unnecessary_getters_setters 24 | double get size => _size; 25 | 26 | // ignore: unnecessary_getters_setters 27 | set size(double value) { 28 | _size = value; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/entry/candle_entry.dart: -------------------------------------------------------------------------------- 1 | import 'package:mp_chart/mp/core/entry/entry.dart'; 2 | import 'dart:ui' as ui; 3 | 4 | class CandleEntry extends Entry { 5 | /// shadow-high value 6 | double _shadowHigh = 0; 7 | 8 | /// shadow-low value 9 | double _shadowLow = 0; 10 | 11 | /// close value 12 | double _close = 0; 13 | 14 | /// open value 15 | double _open = 0; 16 | 17 | CandleEntry( 18 | {double x, 19 | double shadowH, 20 | double shadowL, 21 | double open, 22 | double close, 23 | ui.Image icon, 24 | Object data}) 25 | : super(x: x, y: (shadowH + shadowL) / 2, icon: icon, data: data) { 26 | this._shadowHigh = shadowH; 27 | this._shadowLow = shadowL; 28 | this._open = open; 29 | this._close = close; 30 | } 31 | 32 | /// Returns the overall range (difference) between shadow-high and 33 | /// shadow-low. 34 | /// 35 | /// @return 36 | double getShadowRange() { 37 | return (_shadowHigh - _shadowLow).abs(); 38 | } 39 | 40 | /// Returns the body size (difference between open and close). 41 | /// 42 | /// @return 43 | double getBodyRange() { 44 | return (_open - _close).abs(); 45 | } 46 | 47 | CandleEntry copy() { 48 | CandleEntry c = CandleEntry( 49 | x: x, 50 | shadowH: _shadowHigh, 51 | shadowL: _shadowLow, 52 | open: _open, 53 | close: _close, 54 | data: mData); 55 | return c; 56 | } 57 | 58 | // ignore: unnecessary_getters_setters 59 | double get open => _open; 60 | 61 | // ignore: unnecessary_getters_setters 62 | set open(double value) { 63 | _open = value; 64 | } 65 | 66 | // ignore: unnecessary_getters_setters 67 | double get close => _close; 68 | 69 | // ignore: unnecessary_getters_setters 70 | set close(double value) { 71 | _close = value; 72 | } 73 | 74 | // ignore: unnecessary_getters_setters 75 | double get shadowLow => _shadowLow; 76 | 77 | // ignore: unnecessary_getters_setters 78 | set shadowLow(double value) { 79 | _shadowLow = value; 80 | } 81 | 82 | // ignore: unnecessary_getters_setters 83 | double get shadowHigh => _shadowHigh; 84 | 85 | // ignore: unnecessary_getters_setters 86 | set shadowHigh(double value) { 87 | _shadowHigh = value; 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/entry/entry.dart: -------------------------------------------------------------------------------- 1 | import 'package:mp_chart/mp/core/entry/base_entry.dart'; 2 | import 'dart:ui' as ui; 3 | 4 | class Entry extends BaseEntry { 5 | double _x = 0; 6 | 7 | Entry({double x, double y, ui.Image icon, Object data}) 8 | : this._x = x, 9 | super(y: y, icon: icon, data: data); 10 | 11 | Entry copy() { 12 | Entry e = Entry(x: _x, y: y, data: mData); 13 | return e; 14 | } 15 | 16 | // ignore: unnecessary_getters_setters 17 | double get x => _x; 18 | 19 | // ignore: unnecessary_getters_setters 20 | set x(double value) { 21 | _x = value; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/entry/pie_entry.dart: -------------------------------------------------------------------------------- 1 | import 'package:mp_chart/mp/core/entry/entry.dart'; 2 | import 'dart:ui' as ui; 3 | 4 | import 'package:mp_chart/mp/core/utils/color_utils.dart'; 5 | import 'package:mp_chart/mp/core/utils/utils.dart'; 6 | 7 | class PieEntry extends Entry { 8 | String _label; 9 | double _labelTextSize; 10 | ui.Color _labelColor; 11 | 12 | PieEntry( 13 | {double value, 14 | String label, 15 | ui.Image icon, 16 | Object data, 17 | double labelTextSize, 18 | ui.Color labelColor}) 19 | : super(x: 0, y: value, icon: icon, data: data) { 20 | this._label = label; 21 | this._labelTextSize = labelTextSize ?? Utils.convertDpToPixel(10); 22 | this._labelColor = labelColor ?? ColorUtils.WHITE; 23 | } 24 | 25 | double getValue() { 26 | return y; 27 | } 28 | 29 | PieEntry copy() { 30 | PieEntry e = PieEntry(value: getValue(), label: _label, data: mData); 31 | return e; 32 | } 33 | 34 | // ignore: unnecessary_getters_setters 35 | String get label => _label; 36 | 37 | double get labelTextSize => _labelTextSize; 38 | 39 | ui.Color get labelColor => _labelColor; 40 | 41 | // ignore: unnecessary_getters_setters 42 | set label(String value) { 43 | _label = value; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/entry/radar_entry.dart: -------------------------------------------------------------------------------- 1 | import 'package:mp_chart/mp/core/entry/entry.dart'; 2 | import 'dart:ui' as ui; 3 | 4 | class RadarEntry extends Entry { 5 | RadarEntry({double value, Object data, ui.Image icon}) 6 | : super(x: 0, y: value, icon: icon, data: data); 7 | 8 | /// This is the same as getY(). Returns the value of the RadarEntry. 9 | /// 10 | /// @return 11 | double getValue() { 12 | return y; 13 | } 14 | 15 | RadarEntry copy() { 16 | RadarEntry e = RadarEntry(value: y, data: mData); 17 | return e; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/enums/axis_dependency.dart: -------------------------------------------------------------------------------- 1 | enum AxisDependency { LEFT, RIGHT } 2 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/enums/legend_direction.dart: -------------------------------------------------------------------------------- 1 | enum LegendDirection { LEFT_TO_RIGHT, RIGHT_TO_LEFT } 2 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/enums/legend_form.dart: -------------------------------------------------------------------------------- 1 | enum LegendForm { 2 | /// Avoid drawing a form 3 | NONE, 4 | 5 | /// Do not draw the a form, but leave space for it 6 | EMPTY, 7 | 8 | /// Use default (default dataset's form to the legend's form) 9 | DEFAULT, 10 | 11 | /// Draw a square 12 | SQUARE, 13 | 14 | /// Draw a circle 15 | CIRCLE, 16 | 17 | /// Draw a horizontal line 18 | LINE 19 | } 20 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/enums/legend_horizontal_alignment.dart: -------------------------------------------------------------------------------- 1 | enum LegendHorizontalAlignment { LEFT, CENTER, RIGHT } 2 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/enums/legend_orientation.dart: -------------------------------------------------------------------------------- 1 | enum LegendOrientation { HORIZONTAL, VERTICAL } 2 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/enums/legend_vertical_alignment.dart: -------------------------------------------------------------------------------- 1 | enum LegendVerticalAlignment { TOP, CENTER, BOTTOM } 2 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/enums/limit_label_postion.dart: -------------------------------------------------------------------------------- 1 | enum LimitLabelPosition { 2 | LEFT_TOP, 3 | LEFT_BOTTOM, 4 | RIGHT_TOP, 5 | RIGHT_BOTTOM, 6 | /// RIGHT_CENTER, LEFT_CENTER use in y axis and x axis horizontal 7 | RIGHT_CENTER, 8 | LEFT_CENTER, 9 | //// CENTER_TOP, CENTER_BOTTOM use in x axis and y axis horizontal 10 | CENTER_TOP, 11 | CENTER_BOTTOM 12 | } 13 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/enums/mode.dart: -------------------------------------------------------------------------------- 1 | enum Mode { LINEAR, STEPPED, CUBIC_BEZIER, HORIZONTAL_BEZIER } 2 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/enums/rounding.dart: -------------------------------------------------------------------------------- 1 | enum Rounding { 2 | UP, 3 | DOWN, 4 | CLOSEST, 5 | } 6 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/enums/scatter_shape.dart: -------------------------------------------------------------------------------- 1 | enum ScatterShape { 2 | SQUARE, 3 | CIRCLE, 4 | TRIANGLE, 5 | CROSS, 6 | X, 7 | CHEVRON_UP, 8 | CHEVRON_DOWN 9 | } 10 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/enums/value_position.dart: -------------------------------------------------------------------------------- 1 | enum ValuePosition { INSIDE_SLICE, OUTSIDE_SLICE } 2 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/enums/x_axis_position.dart: -------------------------------------------------------------------------------- 1 | enum XAxisPosition { TOP, BOTTOM, BOTH_SIDED, TOP_INSIDE, BOTTOM_INSIDE } 2 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/enums/y_axis_label_position.dart: -------------------------------------------------------------------------------- 1 | enum YAxisLabelPosition { OUTSIDE_CHART, INSIDE_CHART } 2 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/fill_formatter/default_fill_formatter.dart: -------------------------------------------------------------------------------- 1 | import 'package:mp_chart/mp/core/data/line_data.dart'; 2 | import 'package:mp_chart/mp/core/data_interfaces/i_line_data_set.dart'; 3 | import 'package:mp_chart/mp/core/data_provider/line_data_provider.dart'; 4 | import 'package:mp_chart/mp/core/fill_formatter/i_fill_formatter.dart'; 5 | 6 | class DefaultFillFormatter implements IFillFormatter { 7 | @override 8 | double getFillLinePosition( 9 | ILineDataSet dataSet, LineDataProvider dataProvider) { 10 | double fillMin = 0; 11 | double chartMaxY = dataProvider.getYChartMax(); 12 | double chartMinY = dataProvider.getYChartMin(); 13 | 14 | LineData data = dataProvider.getLineData(); 15 | 16 | if (dataSet.getYMax() > 0 && dataSet.getYMin() < 0) { 17 | fillMin = 0; 18 | } else { 19 | double max, min; 20 | 21 | if (data.getYMax1() > 0) 22 | max = 0; 23 | else 24 | max = chartMaxY; 25 | if (data.getYMin1() < 0) 26 | min = 0; 27 | else 28 | min = chartMinY; 29 | 30 | fillMin = dataSet.getYMin() >= 0 ? min : max; 31 | } 32 | return fillMin; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/fill_formatter/i_fill_formatter.dart: -------------------------------------------------------------------------------- 1 | import 'package:mp_chart/mp/core/data_interfaces/i_line_data_set.dart'; 2 | import 'package:mp_chart/mp/core/data_provider/line_data_provider.dart'; 3 | 4 | mixin IFillFormatter { 5 | double getFillLinePosition( 6 | ILineDataSet dataSet, LineDataProvider dataProvider); 7 | } 8 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/functions.dart: -------------------------------------------------------------------------------- 1 | import 'package:mp_chart/mp/controller/bar_line_scatter_candle_bubble_controller.dart'; 2 | import 'package:mp_chart/mp/controller/controller.dart'; 3 | import 'package:mp_chart/mp/controller/radar_chart_controller.dart'; 4 | import 'package:mp_chart/mp/core/axis/x_axis.dart'; 5 | import 'package:mp_chart/mp/core/axis/y_axis.dart'; 6 | import 'package:mp_chart/mp/core/legend/legend.dart'; 7 | import 'package:mp_chart/mp/core/render/data_renderer.dart'; 8 | 9 | typedef XAxisSettingFunction = void Function( 10 | XAxis xAxis, Controller controller); 11 | typedef LegendSettingFunction = void Function( 12 | Legend legend, Controller controller); 13 | typedef YAxisSettingFunction = void Function( 14 | YAxis yAxis, RadarChartController controller); 15 | typedef AxisLeftSettingFunction = void Function( 16 | YAxis axisLeft, BarLineScatterCandleBubbleController controller); 17 | typedef AxisRightSettingFunction = void Function( 18 | YAxis axisRight, BarLineScatterCandleBubbleController controller); 19 | typedef DataRendererSettingFunction = void Function(DataRenderer renderer); 20 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/highlight/combined_highlighter.dart: -------------------------------------------------------------------------------- 1 | import 'package:mp_chart/mp/core/data/bar_data.dart'; 2 | import 'package:mp_chart/mp/core/data/bar_line_scatter_candle_bubble_data.dart'; 3 | import 'package:mp_chart/mp/core/data/chart_data.dart'; 4 | import 'package:mp_chart/mp/core/data_interfaces/i_data_set.dart'; 5 | import 'package:mp_chart/mp/core/data_provider/bar_data_provider.dart'; 6 | import 'package:mp_chart/mp/core/data_provider/combined_data_provider.dart'; 7 | import 'package:mp_chart/mp/core/enums/rounding.dart'; 8 | import 'package:mp_chart/mp/core/highlight/bar_highlighter.dart'; 9 | import 'package:mp_chart/mp/core/highlight/chart_hightlighter.dart'; 10 | import 'package:mp_chart/mp/core/highlight/highlight.dart'; 11 | import 'package:mp_chart/mp/core/highlight/i_highlighter.dart'; 12 | 13 | class CombinedHighlighter extends ChartHighlighter 14 | implements IHighlighter { 15 | /// bar highlighter for supporting stacked highlighting 16 | BarHighlighter _barHighlighter; 17 | 18 | CombinedHighlighter(CombinedDataProvider chart, BarDataProvider barChart) 19 | : super(chart) { 20 | // if there is BarData, create a BarHighlighter 21 | _barHighlighter = 22 | barChart.getBarData() == null ? null : BarHighlighter(barChart); 23 | } 24 | 25 | @override 26 | List getHighlightsAtXValue(double xVal, double x, double y) { 27 | highlightBuffer.clear(); 28 | 29 | List dataObjects = 30 | provider.getCombinedData().getAllData(); 31 | 32 | for (int i = 0; i < dataObjects.length; i++) { 33 | ChartData dataObject = dataObjects[i]; 34 | 35 | // in case of BarData, let the BarHighlighter take over 36 | if (_barHighlighter != null && dataObject is BarData) { 37 | Highlight high = _barHighlighter.getHighlight(x, y); 38 | 39 | if (high != null) { 40 | high.dataIndex = (i); 41 | highlightBuffer.add(high); 42 | } 43 | } else { 44 | for (int j = 0, dataSetCount = dataObject.getDataSetCount(); 45 | j < dataSetCount; 46 | j++) { 47 | IDataSet dataSet = dataObjects[i].getDataSetByIndex(j); 48 | 49 | // don't include datasets that cannot be highlighted 50 | if (!dataSet.isHighlightEnabled()) continue; 51 | 52 | List highs = 53 | buildHighlights(dataSet, j, xVal, Rounding.CLOSEST); 54 | for (Highlight high in highs) { 55 | high.dataIndex = (i); 56 | highlightBuffer.add(high); 57 | } 58 | } 59 | } 60 | } 61 | 62 | return highlightBuffer; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/highlight/highlight.dart: -------------------------------------------------------------------------------- 1 | import 'package:mp_chart/mp/core/enums/axis_dependency.dart'; 2 | 3 | class Highlight { 4 | /// the x-value of the highlighted value 5 | double _x = double.nan; 6 | 7 | /// the y-value of the highlighted value 8 | double _y = double.nan; 9 | 10 | /// the x-pixel of the highlight 11 | double _xPx; 12 | 13 | /// the y-pixel of the highlight 14 | double _yPx; 15 | 16 | /// the index of the data object - in case it refers to more than one 17 | int _dataIndex = -1; 18 | 19 | /// 20 | /// the index of the datase 21 | /// t the highlighted value is in 22 | int _dataSetIndex; 23 | 24 | /// index which value of a stacked bar entry is highlighted, default -1 25 | int _stackIndex = -1; 26 | 27 | /// the axis the highlighted value belongs to 28 | AxisDependency _axis; 29 | 30 | /// the x-position (pixels) on which this highlight object was last drawn 31 | double _drawX; 32 | 33 | /// the y-position (pixels) on which this highlight object was last drawn 34 | double _drawY; 35 | 36 | Highlight( 37 | {double x = double.nan, 38 | double y = double.nan, 39 | double xPx = 0, 40 | double yPx = 0, 41 | int dataSetIndex = 0, 42 | int stackIndex = -1, 43 | // ignore: avoid_init_to_null 44 | AxisDependency axis = null}) { 45 | this._x = x; 46 | this._y = y; 47 | this._xPx = xPx; 48 | this._yPx = yPx; 49 | this._dataSetIndex = dataSetIndex; 50 | this._axis = axis; 51 | this._stackIndex = stackIndex; 52 | } 53 | 54 | double get x => _x; 55 | 56 | double get y => _y; 57 | 58 | double get xPx => _xPx; 59 | 60 | double get yPx => _yPx; 61 | 62 | // ignore: unnecessary_getters_setters 63 | int get dataIndex => _dataIndex; 64 | 65 | // ignore: unnecessary_getters_setters 66 | set dataIndex(int value) { 67 | _dataIndex = value; 68 | } 69 | 70 | int get dataSetIndex => _dataSetIndex; 71 | 72 | int get stackIndex => _stackIndex; 73 | 74 | bool isStacked() { 75 | return _stackIndex >= 0; 76 | } 77 | 78 | AxisDependency get axis => _axis; 79 | 80 | /// Sets the x- and y-position (pixels) where this highlight was last drawn. 81 | /// 82 | /// @param x 83 | /// @param y 84 | void setDraw(double x, double y) { 85 | this._drawX = x; 86 | this._drawY = y; 87 | } 88 | 89 | double get drawX => _drawX; 90 | 91 | double get drawY => _drawY; 92 | 93 | /// Returns true if this highlight object is equal to the other (compares 94 | /// xIndex and dataSetIndex) 95 | /// 96 | /// @param h 97 | /// @return 98 | bool equalTo(Highlight h) { 99 | if (h == null) 100 | return false; 101 | else { 102 | if (this._dataSetIndex == h._dataSetIndex && 103 | this._x == h._x && 104 | this._stackIndex == h._stackIndex && 105 | this._dataIndex == h._dataIndex) 106 | return true; 107 | else 108 | return false; 109 | } 110 | } 111 | 112 | @override 113 | String toString() { 114 | return "Highlight, x: $_x, y: $_y, dataSetIndex: $_dataSetIndex, stackIndex (only stacked barentry): $_stackIndex"; 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/highlight/horizontal_bar_highlighter.dart: -------------------------------------------------------------------------------- 1 | import 'package:mp_chart/mp/core/data/bar_data.dart'; 2 | import 'package:mp_chart/mp/core/data_interfaces/i_bar_data_set.dart'; 3 | import 'package:mp_chart/mp/core/data_interfaces/i_data_set.dart'; 4 | import 'package:mp_chart/mp/core/data_provider/bar_data_provider.dart'; 5 | import 'package:mp_chart/mp/core/entry/entry.dart'; 6 | import 'package:mp_chart/mp/core/enums/rounding.dart'; 7 | import 'package:mp_chart/mp/core/highlight/bar_highlighter.dart'; 8 | import 'package:mp_chart/mp/core/highlight/highlight.dart'; 9 | import 'package:mp_chart/mp/core/poolable/point.dart'; 10 | 11 | class HorizontalBarHighlighter extends BarHighlighter { 12 | HorizontalBarHighlighter(BarDataProvider chart) : super(chart); 13 | 14 | @override 15 | Highlight getHighlight(double x, double y) { 16 | BarData barData = provider.getBarData(); 17 | 18 | MPPointD pos = getValsForTouch(y, x); 19 | 20 | Highlight high = getHighlightForX(pos.y, y, x); 21 | if (high == null) return null; 22 | 23 | IBarDataSet set = barData.getDataSetByIndex(high.dataSetIndex); 24 | if (set.isStacked()) { 25 | return getStackedHighlight(high, set, pos.y, pos.x); 26 | } 27 | 28 | MPPointD.recycleInstance2(pos); 29 | 30 | return high; 31 | } 32 | 33 | @override 34 | List buildHighlights( 35 | IDataSet set, int dataSetIndex, double xVal, Rounding rounding) { 36 | List highlights = List(); 37 | 38 | //noinspection unchecked 39 | List entries = set.getEntriesForXValue(xVal); 40 | if (entries.length == 0) { 41 | // Try to find closest x-value and take all entries for that x-value 42 | final Entry closest = set.getEntryForXValue1(xVal, double.nan, rounding); 43 | if (closest != null) { 44 | //noinspection unchecked 45 | entries = set.getEntriesForXValue(closest.x); 46 | } 47 | } 48 | 49 | if (entries.length == 0) return highlights; 50 | 51 | for (Entry e in entries) { 52 | MPPointD pixels = provider 53 | .getTransformer(set.getAxisDependency()) 54 | .getPixelForValues(e.y, e.x); 55 | 56 | highlights.add(Highlight( 57 | x: e.x, 58 | y: e.y, 59 | xPx: pixels.x, 60 | yPx: pixels.y, 61 | dataSetIndex: dataSetIndex, 62 | axis: set.getAxisDependency())); 63 | } 64 | 65 | return highlights; 66 | } 67 | 68 | @override 69 | double getDistance(double x1, double y1, double x2, double y2) { 70 | return (y1 - y2).abs(); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/highlight/i_highlighter.dart: -------------------------------------------------------------------------------- 1 | import 'package:mp_chart/mp/core/highlight/highlight.dart'; 2 | 3 | mixin IHighlighter { 4 | Highlight getHighlight(double x, double y); 5 | } 6 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/highlight/pie_highlighter.dart: -------------------------------------------------------------------------------- 1 | import 'package:mp_chart/mp/core/data/pie_data.dart'; 2 | import 'package:mp_chart/mp/core/data_interfaces/i_pie_data_set.dart'; 3 | import 'package:mp_chart/mp/core/entry/entry.dart'; 4 | import 'package:mp_chart/mp/core/highlight/highlight.dart'; 5 | import 'package:mp_chart/mp/core/highlight/pie_radar_highlighter.dart'; 6 | import 'package:mp_chart/mp/painter/pie_chart_painter.dart'; 7 | 8 | class PieHighlighter extends PieRadarHighlighter { 9 | PieHighlighter(PieChartPainter chart) : super(chart); 10 | 11 | @override 12 | Highlight getClosestHighlight(int index, double x, double y) { 13 | IPieDataSet set = (painter.getData() as PieData).getDataSet(); 14 | 15 | final Entry entry = set.getEntryForIndex(index); 16 | 17 | return new Highlight( 18 | x: index.toDouble(), 19 | y: entry.y, 20 | xPx: x, 21 | yPx: y, 22 | dataSetIndex: 0, 23 | axis: set.getAxisDependency()); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/highlight/pie_radar_highlighter.dart: -------------------------------------------------------------------------------- 1 | import 'package:mp_chart/mp/core/highlight/highlight.dart'; 2 | import 'package:mp_chart/mp/core/highlight/i_highlighter.dart'; 3 | import 'package:mp_chart/mp/painter/pie_chart_painter.dart'; 4 | import 'package:mp_chart/mp/painter/pie_redar_chart_painter.dart'; 5 | 6 | abstract class PieRadarHighlighter 7 | implements IHighlighter { 8 | T _painter; 9 | 10 | /// buffer for storing previously highlighted values 11 | List _highlightBuffer = List(); 12 | 13 | PieRadarHighlighter(T painter) { 14 | this._painter = painter; 15 | } 16 | 17 | List get highlightBuffer => _highlightBuffer; 18 | 19 | T get painter => _painter; 20 | 21 | @override 22 | Highlight getHighlight(double x, double y) { 23 | double touchDistanceToCenter = _painter.distanceToCenter(x, y); 24 | 25 | // check if a slice was touched 26 | if (touchDistanceToCenter > _painter.getRadius()) { 27 | // if no slice was touched, highlight nothing 28 | return null; 29 | } else { 30 | double angle = _painter.getAngleForPoint(x, y); 31 | 32 | if (_painter is PieChartPainter) { 33 | angle /= _painter.animator.getPhaseY(); 34 | } 35 | 36 | int index = _painter.getIndexForAngle(angle); 37 | 38 | // check if the index could be found 39 | if (index < 0 || 40 | index >= _painter.getData().getMaxEntryCountSet().getEntryCount()) { 41 | return null; 42 | } else { 43 | return getClosestHighlight(index, x, y); 44 | } 45 | } 46 | } 47 | 48 | /// Returns the closest Highlight object of the given objects based on the touch position inside the chart. 49 | /// 50 | /// @param index 51 | /// @param x 52 | /// @param y 53 | /// @return 54 | Highlight getClosestHighlight(int index, double x, double y); 55 | } 56 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/highlight/radar_highlighter.dart: -------------------------------------------------------------------------------- 1 | import 'package:mp_chart/mp/core/data_interfaces/i_data_set.dart'; 2 | import 'package:mp_chart/mp/core/entry/entry.dart'; 3 | import 'package:mp_chart/mp/core/highlight/highlight.dart'; 4 | import 'package:mp_chart/mp/core/highlight/pie_radar_highlighter.dart'; 5 | import 'package:mp_chart/mp/painter/radar_chart_painter.dart'; 6 | import 'package:mp_chart/mp/core/poolable/point.dart'; 7 | import 'package:mp_chart/mp/core/utils/utils.dart'; 8 | 9 | class RadarHighlighter extends PieRadarHighlighter { 10 | RadarHighlighter(RadarChartPainter chart) : super(chart); 11 | 12 | @override 13 | Highlight getClosestHighlight(int index, double x, double y) { 14 | List highlights = getHighlightsAtIndex(index); 15 | 16 | double distanceToCenter = 17 | painter.distanceToCenter(x, y) / painter.getFactor(); 18 | 19 | Highlight closest; 20 | double distance = double.infinity; 21 | 22 | for (int i = 0; i < highlights.length; i++) { 23 | Highlight high = highlights[i]; 24 | 25 | double cdistance = (high.y - distanceToCenter).abs(); 26 | if (cdistance < distance) { 27 | closest = high; 28 | distance = cdistance; 29 | } 30 | } 31 | 32 | return closest; 33 | } 34 | 35 | /// Returns an array of Highlight objects for the given index. The Highlight 36 | /// objects give information about the value at the selected index and the 37 | /// DataSet it belongs to. INFORMATION: This method does calculations at 38 | /// runtime. Do not over-use in performance critical situations. 39 | /// 40 | /// @param index 41 | /// @return 42 | List getHighlightsAtIndex(int index) { 43 | highlightBuffer.clear(); 44 | 45 | double phaseX = painter.animator.getPhaseX(); 46 | double phaseY = painter.animator.getPhaseY(); 47 | double sliceangle = painter.getSliceAngle(); 48 | double factor = painter.getFactor(); 49 | 50 | MPPointF pOut = MPPointF.getInstance1(0, 0); 51 | for (int i = 0; i < painter.getData().getDataSetCount(); i++) { 52 | IDataSet dataSet = painter.getData().getDataSetByIndex(i); 53 | 54 | final Entry entry = dataSet.getEntryForIndex(index); 55 | 56 | double y = (entry.y - painter.getYChartMin()); 57 | 58 | Utils.getPosition(painter.getCenterOffsets(), y * factor * phaseY, 59 | sliceangle * index * phaseX + painter.getRotationAngle(), pOut); 60 | 61 | highlightBuffer.add(Highlight( 62 | x: index.toDouble(), 63 | y: entry.y, 64 | xPx: pOut.x, 65 | yPx: pOut.y, 66 | dataSetIndex: i, 67 | axis: dataSet.getAxisDependency())); 68 | } 69 | 70 | return highlightBuffer; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/image_loader.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | import 'dart:typed_data'; 3 | import 'dart:ui'; 4 | 5 | import 'package:flutter/services.dart'; 6 | 7 | abstract class ImageLoader { 8 | // images/start.jpg 9 | static Future loadImage(String path) async { 10 | final ByteData data = await rootBundle.load(path); 11 | List img = Uint8List.view(data.buffer); 12 | final Completer completer = Completer(); 13 | decodeImageFromList(img, (Image img) { 14 | return completer.complete(img); 15 | }); 16 | return await completer.future; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/legend/legend_entry.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui'; 2 | 3 | import 'package:mp_chart/mp/core/adapter_android_mp.dart'; 4 | import 'package:mp_chart/mp/core/enums/legend_form.dart'; 5 | import 'package:mp_chart/mp/core/utils/color_utils.dart'; 6 | 7 | class LegendEntry { 8 | LegendEntry.empty(); 9 | 10 | LegendEntry( 11 | String label, 12 | LegendForm form, 13 | double formSize, 14 | double formLineWidth, 15 | DashPathEffect formLineDashEffect, 16 | Color formColor) { 17 | this._label = label; 18 | this._form = form; 19 | this._formSize = formSize; 20 | this._formLineWidth = formLineWidth; 21 | this.formLineDashEffect = formLineDashEffect; 22 | this._formColor = formColor; 23 | } 24 | 25 | /// The legend entry text. 26 | /// A `null` label will start a group. 27 | String _label; 28 | 29 | /// The form to draw for this entry. 30 | /// 31 | /// `NONE` will avoid drawing a form, and any related space. 32 | /// `EMPTY` will avoid drawing a form, but keep its space. 33 | /// `DEFAULT` will use the Legend's default. 34 | LegendForm _form = LegendForm.DEFAULT; 35 | 36 | /// Form size will be considered except for when .None is used 37 | /// 38 | /// Set as NaN to use the legend's default 39 | double _formSize = double.nan; 40 | 41 | /// Line width used for shapes that consist of lines. 42 | /// 43 | /// Set as NaN to use the legend's default 44 | double _formLineWidth = double.nan; 45 | 46 | /// Line dash path effect used for shapes that consist of lines. 47 | /// 48 | /// Set to null to use the legend's default 49 | DashPathEffect formLineDashEffect; 50 | 51 | /// The color for drawing the form 52 | Color _formColor = ColorUtils.COLOR_NONE; 53 | 54 | // ignore: unnecessary_getters_setters 55 | String get label => _label; 56 | 57 | // ignore: unnecessary_getters_setters 58 | set label(String value) { 59 | _label = value; 60 | } 61 | 62 | // ignore: unnecessary_getters_setters 63 | LegendForm get form => _form; 64 | 65 | // ignore: unnecessary_getters_setters 66 | set form(LegendForm value) { 67 | _form = value; 68 | } 69 | 70 | // ignore: unnecessary_getters_setters 71 | double get formSize => _formSize; 72 | 73 | // ignore: unnecessary_getters_setters 74 | set formSize(double value) { 75 | _formSize = value; 76 | } 77 | 78 | // ignore: unnecessary_getters_setters 79 | double get formLineWidth => _formLineWidth; 80 | 81 | // ignore: unnecessary_getters_setters 82 | set formLineWidth(double value) { 83 | _formLineWidth = value; 84 | } 85 | 86 | // ignore: unnecessary_getters_setters 87 | Color get formColor => _formColor; 88 | 89 | // ignore: unnecessary_getters_setters 90 | set formColor(Color value) { 91 | _formColor = value; 92 | } 93 | 94 | @override 95 | String toString() { 96 | return 'LegendEntry{_form: $_form,\n _formSize: $_formSize,\n _formLineWidth: $_formLineWidth}'; 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/marker/bar_chart_marker.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui'; 2 | 3 | import 'package:mp_chart/mp/core/marker/line_chart_marker.dart'; 4 | 5 | class BarChartMarker extends LineChartMarker { 6 | BarChartMarker({Color textColor, Color backColor, double fontSize}) 7 | : super(textColor: textColor, backColor: backColor, fontSize: fontSize); 8 | 9 | @override 10 | Offset calculatePos(double posX, double posY, double textW, double textH) { 11 | return Offset(posX - textW / 2, posY - textH * 2); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/marker/horizontal_bar_chart_marker.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui'; 2 | 3 | import 'package:mp_chart/mp/core/marker/line_chart_marker.dart'; 4 | 5 | class HorizontalBarChartMarker extends LineChartMarker { 6 | HorizontalBarChartMarker({Color textColor, Color backColor, double fontSize}) 7 | : super(textColor: textColor, backColor: backColor, fontSize: fontSize); 8 | } 9 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/marker/i_marker.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui'; 2 | 3 | import 'package:mp_chart/mp/core/entry/entry.dart'; 4 | import 'package:mp_chart/mp/core/highlight/highlight.dart'; 5 | import 'package:mp_chart/mp/core/poolable/point.dart'; 6 | 7 | mixin IMarker { 8 | /// @return The desired (general) offset you wish the IMarker to have on the x- and y-axis. 9 | /// By returning x: -(width / 2) you will center the IMarker horizontally. 10 | /// By returning y: -(height / 2) you will center the IMarker vertically. 11 | MPPointF getOffset(); 12 | 13 | /// @return The offset for drawing at the specific `point`. This allows conditional adjusting of the Marker position. 14 | /// If you have no adjustments to make, return getOffset(). 15 | /// 16 | /// @param posX This is the X position at which the marker wants to be drawn. 17 | /// You can adjust the offset conditionally based on this argument. 18 | /// @param posY This is the X position at which the marker wants to be drawn. 19 | /// You can adjust the offset conditionally based on this argument. 20 | MPPointF getOffsetForDrawingAtPoint(double posX, double posY); 21 | 22 | /// This method enables a specified custom IMarker to update it's content every time the IMarker is redrawn. 23 | /// 24 | /// @param e The Entry the IMarker belongs to. This can also be any subclass of Entry, like BarEntry or 25 | /// CandleEntry, simply cast it at runtime. 26 | /// @param highlight The highlight object contains information about the highlighted value such as it's dataset-index, the 27 | /// selected range or stack-index (only stacked bar entries). 28 | void refreshContent(Entry e, Highlight highlight); 29 | 30 | /// Draws the IMarker on the given position on the screen with the given Canvas object. 31 | /// 32 | /// @param canvas 33 | /// @param posX 34 | /// @param posY 35 | void draw(Canvas canvas, double posX, double posY); 36 | } 37 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/marker/line_chart_marker.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui'; 2 | 3 | import 'package:flutter/painting.dart'; 4 | import 'package:mp_chart/mp/core/entry/entry.dart'; 5 | import 'package:mp_chart/mp/core/highlight/highlight.dart'; 6 | import 'package:mp_chart/mp/core/marker/i_marker.dart'; 7 | import 'package:mp_chart/mp/core/poolable/point.dart'; 8 | import 'package:mp_chart/mp/core/utils/color_utils.dart'; 9 | import 'package:mp_chart/mp/core/utils/painter_utils.dart'; 10 | import 'package:mp_chart/mp/core/utils/utils.dart'; 11 | import 'package:mp_chart/mp/core/value_formatter/default_value_formatter.dart'; 12 | 13 | class LineChartMarker implements IMarker { 14 | Entry _entry; 15 | // ignore: unused_field 16 | Highlight _highlight; 17 | double _dx = 0.0; 18 | double _dy = 0.0; 19 | 20 | DefaultValueFormatter _formatter; 21 | Color _textColor; 22 | Color _backColor; 23 | double _fontSize; 24 | 25 | LineChartMarker({Color textColor, Color backColor, double fontSize}) 26 | : _textColor = textColor, 27 | _backColor = backColor, 28 | _fontSize = fontSize { 29 | _formatter = DefaultValueFormatter(0); 30 | this._textColor ??= ColorUtils.PURPLE; 31 | // _backColor ??= Color.fromARGB((_textColor.alpha * 0.5).toInt(), 32 | // _textColor.red, _textColor.green, _textColor.blue); 33 | this._backColor ??= ColorUtils.WHITE; 34 | this._fontSize ??= Utils.convertDpToPixel(10); 35 | } 36 | 37 | @override 38 | void draw(Canvas canvas, double posX, double posY) { 39 | TextPainter painter = PainterUtils.create( 40 | null, 41 | "${_formatter.getFormattedValue1(_entry.x)},${_formatter.getFormattedValue1(_entry.y)}", 42 | _textColor, 43 | _fontSize); 44 | Paint paint = Paint() 45 | ..color = _backColor 46 | ..strokeWidth = 2 47 | ..isAntiAlias = true 48 | ..style = PaintingStyle.fill; 49 | 50 | MPPointF offset = getOffsetForDrawingAtPoint(posX, posY); 51 | 52 | canvas.save(); 53 | // translate to the correct position and draw 54 | // canvas.translate(posX + offset.x, posY + offset.y); 55 | painter.layout(); 56 | Offset pos = calculatePos( 57 | posX + offset.x, posY + offset.y, painter.width, painter.height); 58 | canvas.drawRRect( 59 | RRect.fromLTRBR(pos.dx - 5, pos.dy - 5, pos.dx + painter.width + 5, 60 | pos.dy + painter.height + 5, Radius.circular(5)), 61 | paint); 62 | painter.paint(canvas, pos); 63 | canvas.restore(); 64 | } 65 | 66 | Offset calculatePos(double posX, double posY, double textW, double textH) { 67 | return Offset(posX - textW / 2, posY - textH / 2); 68 | } 69 | 70 | @override 71 | MPPointF getOffset() { 72 | return MPPointF.getInstance1(_dx, _dy); 73 | } 74 | 75 | @override 76 | MPPointF getOffsetForDrawingAtPoint(double posX, double posY) { 77 | return getOffset(); 78 | } 79 | 80 | @override 81 | void refreshContent(Entry e, Highlight highlight) { 82 | _entry = e; 83 | highlight = highlight; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/marker/radar_chart_marker.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui'; 2 | 3 | import 'package:flutter/painting.dart'; 4 | import 'package:mp_chart/mp/core/entry/entry.dart'; 5 | import 'package:mp_chart/mp/core/highlight/highlight.dart'; 6 | import 'package:mp_chart/mp/core/marker/i_marker.dart'; 7 | import 'package:mp_chart/mp/core/poolable/point.dart'; 8 | import 'package:mp_chart/mp/core/utils/color_utils.dart'; 9 | import 'package:mp_chart/mp/core/utils/painter_utils.dart'; 10 | import 'package:mp_chart/mp/core/utils/utils.dart'; 11 | import 'package:mp_chart/mp/core/value_formatter/default_value_formatter.dart'; 12 | 13 | class RadarChartMarker implements IMarker { 14 | Entry _entry; 15 | // ignore: unused_field 16 | Highlight _highlight; 17 | double _dx = 0.0; 18 | double _dy = 0.0; 19 | 20 | DefaultValueFormatter _formatter; 21 | Color _textColor; 22 | Color _backColor; 23 | double _fontSize; 24 | 25 | RadarChartMarker({Color textColor, Color backColor, double fontSize}) 26 | : _textColor = textColor, 27 | _backColor = backColor, 28 | _fontSize = fontSize { 29 | _formatter = DefaultValueFormatter(0); 30 | this._textColor ??= ColorUtils.PURPLE; 31 | this._backColor ??= ColorUtils.WHITE; 32 | this._fontSize ??= Utils.convertDpToPixel(10); 33 | } 34 | 35 | @override 36 | void draw(Canvas canvas, double posX, double posY) { 37 | TextPainter painter = PainterUtils.create(null, 38 | "${_formatter.getFormattedValue1(_entry.y)}", _textColor, _fontSize); 39 | Paint paint = Paint() 40 | ..color = _backColor 41 | ..strokeWidth = 2 42 | ..isAntiAlias = true 43 | ..style = PaintingStyle.fill; 44 | 45 | MPPointF offset = getOffsetForDrawingAtPoint(posX, posY); 46 | 47 | canvas.save(); 48 | painter.layout(); 49 | Offset pos = calculatePos( 50 | posX + offset.x, posY + offset.y, painter.width, painter.height); 51 | canvas.drawRRect( 52 | RRect.fromLTRBR(pos.dx - 5, pos.dy - 5, pos.dx + painter.width + 5, 53 | pos.dy + painter.height + 5, Radius.circular(5)), 54 | paint); 55 | painter.paint(canvas, pos); 56 | canvas.restore(); 57 | } 58 | 59 | Offset calculatePos(double posX, double posY, double textW, double textH) { 60 | return Offset(posX - textW / 2, posY - textH * 2); 61 | } 62 | 63 | @override 64 | MPPointF getOffset() { 65 | return MPPointF.getInstance1(_dx, _dy); 66 | } 67 | 68 | @override 69 | MPPointF getOffsetForDrawingAtPoint(double posX, double posY) { 70 | return getOffset(); 71 | } 72 | 73 | @override 74 | void refreshContent(Entry e, Highlight highlight) { 75 | _entry = e; 76 | highlight = highlight; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/poolable/size.dart: -------------------------------------------------------------------------------- 1 | import 'package:mp_chart/mp/core/poolable/point.dart'; 2 | 3 | class FSize extends Poolable { 4 | double _width; 5 | double _height; 6 | 7 | static ObjectPool pool = ObjectPool.create(256, FSize(0, 0)) 8 | ..setReplenishPercentage(0.5); 9 | 10 | @override 11 | Poolable instantiate() { 12 | return FSize(0, 0); 13 | } 14 | 15 | // ignore: unnecessary_getters_setters 16 | double get width => _width; 17 | 18 | // ignore: unnecessary_getters_setters 19 | set width(double value) { 20 | _width = value; 21 | } 22 | 23 | // ignore: unnecessary_getters_setters 24 | double get height => _height; 25 | 26 | // ignore: unnecessary_getters_setters 27 | set height(double value) { 28 | _height = value; 29 | } 30 | 31 | static FSize getInstance(final double width, final double height) { 32 | FSize result = pool.get(); 33 | result._width = width; 34 | result._height = height; 35 | return result; 36 | } 37 | 38 | static void recycleInstance(FSize instance) { 39 | pool.recycle1(instance); 40 | } 41 | 42 | static void recycleInstances(List instances) { 43 | pool.recycle2(instances); 44 | } 45 | 46 | FSize(this._width, this._height); 47 | 48 | bool equals(final Object obj) { 49 | if (obj == null) { 50 | return false; 51 | } 52 | if (this == obj) { 53 | return true; 54 | } 55 | if (obj is FSize) { 56 | final FSize other = obj; 57 | return _width == other._width && _height == other._height; 58 | } 59 | return false; 60 | } 61 | 62 | @override 63 | String toString() { 64 | return "${_width}x$_height"; 65 | } 66 | 67 | @override 68 | // ignore: hash_and_equals 69 | int get hashCode { 70 | return _width.toInt() ^ _height.toInt(); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/range.dart: -------------------------------------------------------------------------------- 1 | class Range { 2 | double _from; 3 | double _to; 4 | 5 | Range(this._from, this._to); 6 | 7 | /// Returns true if this range contains (if the value is in between) the given value, false if not. 8 | /// 9 | /// @param value 10 | /// @return 11 | bool contains(double value) { 12 | if (value > _from && value <= _to) 13 | return true; 14 | else 15 | return false; 16 | } 17 | 18 | bool isLarger(double value) { 19 | return value > _to; 20 | } 21 | 22 | bool isSmaller(double value) { 23 | return value < _from; 24 | } 25 | 26 | // ignore: unnecessary_getters_setters 27 | double get from => _from; 28 | 29 | // ignore: unnecessary_getters_setters 30 | set from(double value) { 31 | _from = value; 32 | } 33 | 34 | // ignore: unnecessary_getters_setters 35 | double get to => _to; 36 | 37 | // ignore: unnecessary_getters_setters 38 | set to(double value) { 39 | _to = value; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/render/bar_line_scatter_candle_bubble_renderer.dart: -------------------------------------------------------------------------------- 1 | import 'package:mp_chart/mp/core/bounds.dart'; 2 | import 'package:mp_chart/mp/core/animator.dart'; 3 | import 'package:mp_chart/mp/core/data_interfaces/i_bar_line_scatter_candle_bubble_data_set.dart'; 4 | import 'package:mp_chart/mp/core/data_interfaces/i_data_set.dart'; 5 | import 'package:mp_chart/mp/core/entry/entry.dart'; 6 | import 'package:mp_chart/mp/core/render/data_renderer.dart'; 7 | import 'package:mp_chart/mp/core/view_port.dart'; 8 | 9 | abstract class BarLineScatterCandleBubbleRenderer extends DataRenderer { 10 | /// buffer for storing the current minimum and maximum visible x 11 | XBounds _xBounds; 12 | 13 | BarLineScatterCandleBubbleRenderer( 14 | Animator animator, ViewPortHandler viewPortHandler) 15 | : super(animator, viewPortHandler) { 16 | _xBounds = XBounds(this.animator); 17 | } 18 | 19 | // ignore: unnecessary_getters_setters 20 | XBounds get xBounds => _xBounds; 21 | 22 | // ignore: unnecessary_getters_setters 23 | set xBounds(XBounds value) { 24 | _xBounds = value; 25 | } 26 | 27 | /// Returns true if the DataSet values should be drawn, false if not. 28 | /// 29 | /// @param set 30 | /// @return 31 | bool shouldDrawValues(IDataSet set) { 32 | return set.isVisible() && 33 | (set.isDrawValuesEnabled() || set.isDrawIconsEnabled()); 34 | } 35 | 36 | /// Checks if the provided entry object is in bounds for drawing considering the current animation phase. 37 | /// 38 | /// @param e 39 | /// @param set 40 | /// @return 41 | bool isInBoundsX(Entry e, IBarLineScatterCandleBubbleDataSet set) { 42 | if (e == null) return false; 43 | 44 | double entryIndex = set.getEntryIndex2(e).toDouble(); 45 | 46 | if (e == null || entryIndex >= set.getEntryCount() * animator.getPhaseX()) { 47 | return false; 48 | } else { 49 | return true; 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/render/chevron_down_shape_renderer.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui'; 2 | 3 | import 'package:mp_chart/mp/core/data_interfaces/i_scatter_data_set.dart'; 4 | import 'package:mp_chart/mp/core/render/i_shape_renderer.dart'; 5 | import 'package:mp_chart/mp/core/view_port.dart'; 6 | import 'package:mp_chart/mp/core/utils/utils.dart'; 7 | 8 | class ChevronDownShapeRenderer implements IShapeRenderer { 9 | @override 10 | void renderShape( 11 | Canvas c, 12 | IScatterDataSet dataSet, 13 | ViewPortHandler viewPortHandler, 14 | double posX, 15 | double posY, 16 | Paint renderPaint) { 17 | final double shapeHalf = dataSet.getScatterShapeSize() / 2; 18 | 19 | renderPaint 20 | ..style = PaintingStyle.stroke 21 | ..strokeWidth = Utils.convertDpToPixel(1); 22 | 23 | c.drawLine(Offset(posX, posY + (2 * shapeHalf)), 24 | Offset(posX + (2 * shapeHalf), posY), renderPaint); 25 | 26 | c.drawLine(Offset(posX, posY + (2 * shapeHalf)), 27 | Offset(posX - (2 * shapeHalf), posY), renderPaint); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/render/chevron_up_shape_renderer.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui'; 2 | 3 | import 'package:mp_chart/mp/core/data_interfaces/i_scatter_data_set.dart'; 4 | import 'package:mp_chart/mp/core/render/i_shape_renderer.dart'; 5 | import 'package:mp_chart/mp/core/view_port.dart'; 6 | import 'package:mp_chart/mp/core/utils/utils.dart'; 7 | 8 | class ChevronUpShapeRenderer implements IShapeRenderer { 9 | @override 10 | void renderShape( 11 | Canvas c, 12 | IScatterDataSet dataSet, 13 | ViewPortHandler viewPortHandler, 14 | double posX, 15 | double posY, 16 | Paint renderPaint) { 17 | final double shapeHalf = dataSet.getScatterShapeSize() / 2; 18 | 19 | renderPaint 20 | ..style = PaintingStyle.stroke 21 | ..strokeWidth = Utils.convertDpToPixel(1); 22 | 23 | c.drawLine(Offset(posX, posY - (2 * shapeHalf)), 24 | Offset(posX + (2 * shapeHalf), posY), renderPaint); 25 | 26 | c.drawLine(Offset(posX, posY - (2 * shapeHalf)), 27 | Offset(posX - (2 * shapeHalf), posY), renderPaint); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/render/circle_shape_renderer.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui'; 2 | 3 | import 'package:mp_chart/mp/core/data_interfaces/i_scatter_data_set.dart'; 4 | import 'package:mp_chart/mp/core/render/i_shape_renderer.dart'; 5 | import 'package:mp_chart/mp/core/utils/color_utils.dart'; 6 | import 'package:mp_chart/mp/core/view_port.dart'; 7 | import 'package:mp_chart/mp/core/utils/utils.dart'; 8 | 9 | class CircleShapeRenderer implements IShapeRenderer { 10 | @override 11 | void renderShape( 12 | Canvas c, 13 | IScatterDataSet dataSet, 14 | ViewPortHandler viewPortHandler, 15 | double posX, 16 | double posY, 17 | Paint renderPaint) { 18 | final double shapeSize = dataSet.getScatterShapeSize(); 19 | final double shapeHalf = shapeSize / 2; 20 | final double shapeHoleSizeHalf = 21 | Utils.convertDpToPixel(dataSet.getScatterShapeHoleRadius()); 22 | final double shapeHoleSize = shapeHoleSizeHalf * 2.0; 23 | final double shapeStrokeSize = (shapeSize - shapeHoleSize) / 2.0; 24 | final double shapeStrokeSizeHalf = shapeStrokeSize / 2.0; 25 | 26 | final Color shapeHoleColor = dataSet.getScatterShapeHoleColor(); 27 | 28 | if (shapeSize > 0.0) { 29 | renderPaint 30 | ..style = PaintingStyle.stroke 31 | ..strokeWidth = shapeStrokeSize; 32 | 33 | c.drawCircle(Offset(posX, posY), shapeHoleSizeHalf + shapeStrokeSizeHalf, 34 | renderPaint); 35 | 36 | if (shapeHoleColor != ColorUtils.COLOR_NONE) { 37 | renderPaint 38 | ..style = PaintingStyle.fill 39 | ..color = shapeHoleColor; 40 | 41 | c.drawCircle(Offset(posX, posY), shapeHoleSizeHalf, renderPaint); 42 | } 43 | } else { 44 | renderPaint.style = PaintingStyle.fill; 45 | 46 | c.drawCircle(Offset(posX, posY), shapeHalf, renderPaint); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/render/cross_shape_renderer.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui'; 2 | 3 | import 'package:mp_chart/mp/core/data_interfaces/i_scatter_data_set.dart'; 4 | import 'package:mp_chart/mp/core/render/i_shape_renderer.dart'; 5 | import 'package:mp_chart/mp/core/view_port.dart'; 6 | import 'package:mp_chart/mp/core/utils/utils.dart'; 7 | 8 | class CrossShapeRenderer implements IShapeRenderer { 9 | @override 10 | void renderShape( 11 | Canvas c, 12 | IScatterDataSet dataSet, 13 | ViewPortHandler viewPortHandler, 14 | double posX, 15 | double posY, 16 | Paint renderPaint) { 17 | final double shapeHalf = dataSet.getScatterShapeSize() / 2; 18 | 19 | renderPaint 20 | ..style = PaintingStyle.stroke 21 | ..strokeWidth = Utils.convertDpToPixel(1); 22 | 23 | c.drawLine(Offset(posX - shapeHalf, posY), Offset(posX + shapeHalf, posY), 24 | renderPaint); 25 | c.drawLine(Offset(posX, posY - shapeHalf), Offset(posX, posY + shapeHalf), 26 | renderPaint); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/render/i_shape_renderer.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui'; 2 | 3 | import 'package:mp_chart/mp/core/data_interfaces/i_scatter_data_set.dart'; 4 | import 'package:mp_chart/mp/core/view_port.dart'; 5 | 6 | mixin IShapeRenderer { 7 | /// Renders the provided ScatterDataSet with a shape. 8 | /// 9 | /// @param c Canvas object for drawing the shape 10 | /// @param dataSet The DataSet to be drawn 11 | /// @param viewPortHandler Contains information about the current state of the view 12 | /// @param posX Position to draw the shape at 13 | /// @param posY Position to draw the shape at 14 | /// @param renderPaint Paint object used for styling and drawing 15 | void renderShape( 16 | Canvas c, 17 | IScatterDataSet dataSet, 18 | ViewPortHandler viewPortHandler, 19 | double posX, 20 | double posY, 21 | Paint renderPaint); 22 | } 23 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/render/line_scatter_candle_radar_renderer.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/painting.dart'; 2 | import 'package:mp_chart/mp/core/animator.dart'; 3 | import 'package:mp_chart/mp/core/data_interfaces/i_line_scatter_candle_radar_data_set.dart'; 4 | import 'package:mp_chart/mp/core/render/bar_line_scatter_candle_bubble_renderer.dart'; 5 | import 'package:mp_chart/mp/core/view_port.dart'; 6 | 7 | abstract class LineScatterCandleRadarRenderer 8 | extends BarLineScatterCandleBubbleRenderer { 9 | /// path that is used for drawing highlight-lines (drawLines(...) cannot be used because of dashes) 10 | Path _highlightLinePath = Path(); 11 | 12 | LineScatterCandleRadarRenderer( 13 | Animator animator, ViewPortHandler viewPortHandler) 14 | : super(animator, viewPortHandler); 15 | 16 | /// Draws vertical & horizontal highlight-lines if enabled. 17 | /// 18 | /// @param c 19 | /// @param x x-position of the highlight line intersection 20 | /// @param y y-position of the highlight line intersection 21 | /// @param set the currently drawn dataset 22 | void drawHighlightLines( 23 | Canvas c, double x, double y, ILineScatterCandleRadarDataSet set) { 24 | // set color and stroke-width 25 | highlightPaint 26 | ..color = set.getHighLightColor() 27 | ..strokeWidth = set.getHighlightLineWidth(); 28 | 29 | // draw vertical highlight lines 30 | if (set.isVerticalHighlightIndicatorEnabled()) { 31 | // create vertical path 32 | _highlightLinePath.reset(); 33 | _highlightLinePath.moveTo(x, viewPortHandler.contentTop()); 34 | _highlightLinePath.lineTo(x, viewPortHandler.contentBottom()); 35 | 36 | if (set.getDashPathEffectHighlight() != null) { 37 | _highlightLinePath = set 38 | .getDashPathEffectHighlight() 39 | .convert2DashPath(_highlightLinePath); 40 | } 41 | c.drawPath(_highlightLinePath, highlightPaint); 42 | } 43 | 44 | // draw horizontal highlight lines 45 | if (set.isHorizontalHighlightIndicatorEnabled()) { 46 | // create horizontal path 47 | _highlightLinePath.reset(); 48 | _highlightLinePath.moveTo(viewPortHandler.contentLeft(), y); 49 | _highlightLinePath.lineTo(viewPortHandler.contentRight(), y); 50 | 51 | if (set.getDashPathEffectHighlight() != null) { 52 | _highlightLinePath = set 53 | .getDashPathEffectHighlight() 54 | .convert2DashPath(_highlightLinePath); 55 | } 56 | c.drawPath(_highlightLinePath, highlightPaint); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/render/renderer.dart: -------------------------------------------------------------------------------- 1 | import 'package:mp_chart/mp/core/view_port.dart'; 2 | 3 | abstract class Renderer { 4 | /// the component that handles the drawing area of the chart and it's offsets 5 | ViewPortHandler _viewPortHandler; 6 | 7 | Renderer(this._viewPortHandler); 8 | 9 | // ignore: unnecessary_getters_setters 10 | ViewPortHandler get viewPortHandler => _viewPortHandler; 11 | 12 | // ignore: unnecessary_getters_setters 13 | set viewPortHandler(ViewPortHandler value) { 14 | _viewPortHandler = value; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/render/square_shape_renderer.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui'; 2 | 3 | import 'package:mp_chart/mp/core/data_interfaces/i_scatter_data_set.dart'; 4 | import 'package:mp_chart/mp/core/render/i_shape_renderer.dart'; 5 | import 'package:mp_chart/mp/core/utils/color_utils.dart'; 6 | import 'package:mp_chart/mp/core/view_port.dart'; 7 | import 'package:mp_chart/mp/core/utils/utils.dart'; 8 | 9 | class SquareShapeRenderer implements IShapeRenderer { 10 | @override 11 | void renderShape( 12 | Canvas c, 13 | IScatterDataSet dataSet, 14 | ViewPortHandler viewPortHandler, 15 | double posX, 16 | double posY, 17 | Paint renderPaint) { 18 | final double shapeSize = dataSet.getScatterShapeSize(); 19 | final double shapeHalf = shapeSize / 2; 20 | final double shapeHoleSizeHalf = 21 | Utils.convertDpToPixel(dataSet.getScatterShapeHoleRadius()); 22 | final double shapeHoleSize = shapeHoleSizeHalf * 2.0; 23 | final double shapeStrokeSize = (shapeSize - shapeHoleSize) / 2.0; 24 | final double shapeStrokeSizeHalf = shapeStrokeSize / 2.0; 25 | 26 | final Color shapeHoleColor = dataSet.getScatterShapeHoleColor(); 27 | 28 | if (shapeSize > 0.0) { 29 | renderPaint 30 | ..style = PaintingStyle.stroke 31 | ..strokeWidth = shapeStrokeSize; 32 | 33 | c.drawRect( 34 | Rect.fromLTRB( 35 | posX - shapeHoleSizeHalf - shapeStrokeSizeHalf, 36 | posY - shapeHoleSizeHalf - shapeStrokeSizeHalf, 37 | posX + shapeHoleSizeHalf + shapeStrokeSizeHalf, 38 | posY + shapeHoleSizeHalf + shapeStrokeSizeHalf), 39 | renderPaint); 40 | 41 | if (shapeHoleColor != ColorUtils.COLOR_NONE) { 42 | renderPaint 43 | ..style = PaintingStyle.fill 44 | ..color = shapeHoleColor; 45 | 46 | c.drawRect( 47 | Rect.fromLTRB(posX - shapeHoleSizeHalf, posY - shapeHoleSizeHalf, 48 | posX + shapeHoleSizeHalf, posY + shapeHoleSizeHalf), 49 | renderPaint); 50 | } 51 | } else { 52 | renderPaint.style = PaintingStyle.fill; 53 | 54 | c.drawRect( 55 | Rect.fromLTRB(posX - shapeHalf, posY - shapeHalf, posX + shapeHalf, 56 | posY + shapeHalf), 57 | renderPaint); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/render/triangle_shape_renderer.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui'; 2 | 3 | import 'package:mp_chart/mp/core/data_interfaces/i_scatter_data_set.dart'; 4 | import 'package:mp_chart/mp/core/render/i_shape_renderer.dart'; 5 | import 'package:mp_chart/mp/core/utils/color_utils.dart'; 6 | import 'package:mp_chart/mp/core/view_port.dart'; 7 | import 'package:mp_chart/mp/core/utils/utils.dart'; 8 | 9 | class TriangleShapeRenderer implements IShapeRenderer { 10 | Path _trianglePathBuffer = Path(); 11 | 12 | @override 13 | void renderShape( 14 | Canvas c, 15 | IScatterDataSet dataSet, 16 | ViewPortHandler viewPortHandler, 17 | double posX, 18 | double posY, 19 | Paint renderPaint) { 20 | final double shapeSize = dataSet.getScatterShapeSize(); 21 | final double shapeHalf = shapeSize / 2; 22 | final double shapeHoleSizeHalf = 23 | Utils.convertDpToPixel(dataSet.getScatterShapeHoleRadius()); 24 | final double shapeHoleSize = shapeHoleSizeHalf * 2.0; 25 | final double shapeStrokeSize = (shapeSize - shapeHoleSize) / 2.0; 26 | 27 | final Color shapeHoleColor = dataSet.getScatterShapeHoleColor(); 28 | 29 | renderPaint.style = PaintingStyle.fill; 30 | 31 | // create a triangle path 32 | Path tri = _trianglePathBuffer; 33 | tri.reset(); 34 | 35 | tri.moveTo(posX, posY - shapeHalf); 36 | tri.lineTo(posX + shapeHalf, posY + shapeHalf); 37 | tri.lineTo(posX - shapeHalf, posY + shapeHalf); 38 | 39 | if (shapeSize > 0.0) { 40 | tri.lineTo(posX, posY - shapeHalf); 41 | 42 | tri.moveTo(posX - shapeHalf + shapeStrokeSize, 43 | posY + shapeHalf - shapeStrokeSize); 44 | tri.lineTo(posX + shapeHalf - shapeStrokeSize, 45 | posY + shapeHalf - shapeStrokeSize); 46 | tri.lineTo(posX, posY - shapeHalf + shapeStrokeSize); 47 | tri.lineTo(posX - shapeHalf + shapeStrokeSize, 48 | posY + shapeHalf - shapeStrokeSize); 49 | } 50 | 51 | tri.close(); 52 | 53 | c.drawPath(tri, renderPaint); 54 | tri.reset(); 55 | 56 | if (shapeSize > 0.0 && shapeHoleColor != ColorUtils.COLOR_NONE) { 57 | renderPaint.color = shapeHoleColor; 58 | 59 | tri.moveTo(posX, posY - shapeHalf + shapeStrokeSize); 60 | tri.lineTo(posX + shapeHalf - shapeStrokeSize, 61 | posY + shapeHalf - shapeStrokeSize); 62 | tri.lineTo(posX - shapeHalf + shapeStrokeSize, 63 | posY + shapeHalf - shapeStrokeSize); 64 | tri.close(); 65 | 66 | c.drawPath(tri, renderPaint); 67 | tri.reset(); 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/render/x_axis_renderer_radar_chart.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/painting.dart'; 2 | import 'package:mp_chart/mp/core/axis/x_axis.dart'; 3 | import 'package:mp_chart/mp/core/enums/x_axis_position.dart'; 4 | import 'package:mp_chart/mp/core/render/x_axis_renderer.dart'; 5 | import 'package:mp_chart/mp/core/utils/painter_utils.dart'; 6 | import 'package:mp_chart/mp/core/view_port.dart'; 7 | import 'package:mp_chart/mp/painter/radar_chart_painter.dart'; 8 | import 'package:mp_chart/mp/core/poolable/point.dart'; 9 | import 'package:mp_chart/mp/core/utils/utils.dart'; 10 | 11 | class XAxisRendererRadarChart extends XAxisRenderer { 12 | RadarChartPainter _painter; 13 | 14 | XAxisRendererRadarChart( 15 | ViewPortHandler viewPortHandler, XAxis xAxis, RadarChartPainter chart) 16 | : super(viewPortHandler, xAxis, null) { 17 | _painter = chart; 18 | } 19 | 20 | @override 21 | void renderAxisLabels(Canvas c) { 22 | if (!xAxis.enabled || !xAxis.drawLabels) return; 23 | 24 | final double labelRotationAngleDegrees = xAxis.labelRotationAngle; 25 | final MPPointF drawLabelAnchor = MPPointF.getInstance1(0.5, 0.25); 26 | 27 | axisLabelPaint = PainterUtils.create( 28 | null, null, xAxis.textColor, xAxis.textSize, 29 | fontWeight: xAxis.typeface?.fontWeight, 30 | fontFamily: xAxis.typeface?.fontFamily); 31 | 32 | double sliceangle = _painter.getSliceAngle(); 33 | 34 | // calculate the factor that is needed for transforming the value to 35 | // pixels 36 | double factor = _painter.getFactor(); 37 | 38 | MPPointF center = _painter.getCenterOffsets(); 39 | MPPointF pOut = MPPointF.getInstance1(0, 0); 40 | for (int i = 0; 41 | i < _painter.getData().getMaxEntryCountSet().getEntryCount(); 42 | i++) { 43 | String label = 44 | xAxis.getValueFormatter().getAxisLabel(i.toDouble(), xAxis); 45 | 46 | double angle = (sliceangle * i + _painter.getRotationAngle()) % 360; 47 | 48 | Utils.getPosition( 49 | center, 50 | _painter.yAxis.axisRange * factor + xAxis.labelRotatedWidth / 2, 51 | angle, 52 | pOut); 53 | 54 | drawLabel(c, label, pOut.x, pOut.y - xAxis.labelRotatedHeight / 2.0, 55 | drawLabelAnchor, labelRotationAngleDegrees, xAxis.position); 56 | } 57 | 58 | MPPointF.recycleInstance(center); 59 | MPPointF.recycleInstance(pOut); 60 | MPPointF.recycleInstance(drawLabelAnchor); 61 | } 62 | 63 | void drawLabel(Canvas c, String formattedLabel, double x, double y, 64 | MPPointF anchor, double angleDegrees, XAxisPosition position) { 65 | Utils.drawRadarXAxisValue(c, formattedLabel, x, y, axisLabelPaint, anchor, 66 | angleDegrees, position); 67 | } 68 | 69 | /// XAxis LimitLines on RadarChart not yet supported. 70 | /// 71 | /// @param c 72 | @override 73 | void renderLimitLines(Canvas c) { 74 | // this space intentionally left blank 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/render/x_shape_renderer.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui'; 2 | 3 | import 'package:mp_chart/mp/core/data_interfaces/i_scatter_data_set.dart'; 4 | import 'package:mp_chart/mp/core/render/i_shape_renderer.dart'; 5 | import 'package:mp_chart/mp/core/view_port.dart'; 6 | import 'package:mp_chart/mp/core/utils/utils.dart'; 7 | 8 | class XShapeRenderer implements IShapeRenderer { 9 | @override 10 | void renderShape( 11 | Canvas c, 12 | IScatterDataSet dataSet, 13 | ViewPortHandler viewPortHandler, 14 | double posX, 15 | double posY, 16 | Paint renderPaint) { 17 | final double shapeHalf = dataSet.getScatterShapeSize() / 2; 18 | 19 | renderPaint 20 | ..style = PaintingStyle.stroke 21 | ..strokeWidth = Utils.convertDpToPixel(1); 22 | 23 | c.drawLine(Offset(posX - shapeHalf, posY - shapeHalf), 24 | Offset(posX + shapeHalf, posY + shapeHalf), renderPaint); 25 | c.drawLine(Offset(posX + shapeHalf, posY - shapeHalf), 26 | Offset(posX - shapeHalf, posY + shapeHalf), renderPaint); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/touch_listener.dart: -------------------------------------------------------------------------------- 1 | mixin OnTouchEventListener { 2 | TouchValueType valueType(); 3 | void onTapDown(double x, double y); 4 | void onSingleTapUp(double x, double y); 5 | void onDoubleTapUp(double x, double y); 6 | void onMoveStart(double x, double y); 7 | void onMoveUpdate(double x, double y); 8 | void onMoveEnd(double x, double y); 9 | void onScaleStart(double x, double y); 10 | void onScaleUpdate(double x, double y); 11 | void onScaleEnd(double x, double y); 12 | void onDragStart(double x, double y); 13 | void onDragUpdate(double x, double y); 14 | void onDragEnd(double x, double y); 15 | } 16 | 17 | enum TouchValueType{ 18 | SCREEN,LOCAL,CHART 19 | } -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/transformer/transformer_horizontal_bar_chart.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/rendering.dart'; 2 | import 'package:mp_chart/mp/core/transformer/transformer.dart'; 3 | import 'package:mp_chart/mp/core/utils/matrix4_utils.dart'; 4 | import 'package:mp_chart/mp/core/view_port.dart'; 5 | 6 | class TransformerHorizontalBarChart extends Transformer { 7 | TransformerHorizontalBarChart(ViewPortHandler viewPortHandler) 8 | : super(viewPortHandler); 9 | 10 | /// Prepares the matrix that contains all offsets. 11 | /// 12 | /// @param inverted 13 | void prepareMatrixOffset(bool inverted) { 14 | matrixOffset = Matrix4.identity(); 15 | 16 | // offset.postTranslate(mOffsetLeft, getHeight() - mOffsetBottom); 17 | 18 | if (!inverted) 19 | Matrix4Utils.postTranslate(matrixOffset, viewPortHandler.offsetLeft(), 20 | viewPortHandler.getChartHeight() - viewPortHandler.offsetBottom()); 21 | else { 22 | Matrix4Utils.setTranslate( 23 | matrixOffset, 24 | -(viewPortHandler.getChartWidth() - viewPortHandler.offsetRight()), 25 | viewPortHandler.getChartHeight() - viewPortHandler.offsetBottom()); 26 | Matrix4Utils.postScale(matrixOffset, -1.0, 1.0); 27 | } 28 | 29 | // matrixOffset.set(offset); 30 | 31 | // matrixOffset.reset(); 32 | // 33 | // matrixOffset.postTranslate(mOffsetLeft, getHeight() - 34 | // mOffsetBottom); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/utils/canvas_utils.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui' as ui; 2 | 3 | import 'package:flutter/painting.dart'; 4 | import 'package:mp_chart/mp/core/adapter_android_mp.dart'; 5 | import 'package:mp_chart/mp/core/limit_line.dart'; 6 | 7 | abstract class CanvasUtils { 8 | static void drawLines( 9 | ui.Canvas canvas, List pts, int offset, int count, ui.Paint paint, 10 | {DashPathEffect effect}) { 11 | if (effect == null) { 12 | for (int i = offset; i < count; i += 4) { 13 | canvas.drawLine(ui.Offset(pts[i], pts[i + 1]), 14 | ui.Offset(pts[i + 2], pts[i + 3]), paint); 15 | } 16 | } else { 17 | var path = Path(); 18 | for (int i = offset; i < count; i += 4) { 19 | path.reset(); 20 | path.moveTo(pts[i], pts[i + 1]); 21 | path.lineTo(pts[i + 2], pts[i + 3]); 22 | path = effect.convert2DashPath(path); 23 | canvas.drawPath(path, paint); 24 | } 25 | } 26 | } 27 | 28 | static void drawImage(ui.Canvas canvas, Offset position, ui.Image img, 29 | ui.Size dstSize, ui.Paint paint) { 30 | var imgSize = ui.Size(img.width.toDouble(), img.height.toDouble()); 31 | 32 | FittedSizes sizes = applyBoxFit(BoxFit.contain, imgSize, dstSize); 33 | 34 | final ui.Rect inputRect = Alignment.center.inscribe(sizes.source, 35 | Rect.fromLTWH(0, 0, sizes.source.width, sizes.source.height)); 36 | final ui.Rect outputRect = Alignment.center.inscribe( 37 | sizes.destination, 38 | Rect.fromLTWH( 39 | position.dx - dstSize.width / 2, 40 | position.dy - dstSize.height / 2, 41 | sizes.destination.width, 42 | sizes.destination.height)); 43 | canvas.drawImageRect(img, inputRect, outputRect, paint); 44 | } 45 | 46 | static const double LABEL_SPACE = 2; 47 | 48 | static void renderLimitLabelBackground(Canvas canvas, TextPainter textPainter, 49 | Offset offset, LimitLine limitLine) { 50 | if (limitLine.drawBackground) { 51 | Paint paint = Paint()..color = limitLine.backgroundColor; 52 | canvas.drawRect( 53 | Rect.fromLTRB( 54 | offset.dx - LABEL_SPACE, 55 | offset.dy - LABEL_SPACE, 56 | offset.dx + LABEL_SPACE + textPainter.width, 57 | offset.dy + LABEL_SPACE + textPainter.height), 58 | paint); 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/utils/dart_adapter_utils.dart: -------------------------------------------------------------------------------- 1 | abstract class DartAdapterUtils { 2 | static bool equalsIgnoreCase(String string1, String string2) { 3 | return string1?.toLowerCase() == string2?.toLowerCase(); 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/utils/highlight_utils.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui'; 2 | 3 | import 'package:mp_chart/mp/core/highlight/highlight.dart'; 4 | import 'package:mp_chart/mp/painter/painter.dart'; 5 | 6 | abstract class HighlightUtils { 7 | static Highlight performHighlight( 8 | ChartPainter painter, Highlight curHighlight, Highlight lastHighlight) { 9 | if (curHighlight == null || curHighlight.equalTo(lastHighlight)) { 10 | painter.highlightValue6(null, true); 11 | lastHighlight = null; 12 | } else { 13 | painter.highlightValue6(curHighlight, true); 14 | lastHighlight = curHighlight; 15 | } 16 | return lastHighlight; 17 | } 18 | 19 | static Highlight performHighlightDrag( 20 | ChartPainter painter, Highlight lastHighlight, Offset offset) { 21 | Highlight h = painter.getHighlightByTouchPoint(offset.dx, offset.dy); 22 | 23 | if (h != null && !h.equalTo(lastHighlight)) { 24 | lastHighlight = h; 25 | painter.highlightValue6(h, true); 26 | } 27 | 28 | return lastHighlight; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/utils/painter_utils.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/rendering.dart'; 2 | import 'package:mp_chart/mp/core/utils/color_utils.dart'; 3 | import 'package:mp_chart/mp/core/utils/utils.dart'; 4 | 5 | abstract class PainterUtils { 6 | static TextPainter create( 7 | TextPainter painter, String text, Color color, double fontSize, 8 | {String fontFamily, FontWeight fontWeight = FontWeight.w400}) { 9 | if (painter == null) { 10 | return _create(text, color, fontSize, 11 | fontFamily: fontFamily, fontWeight: fontWeight); 12 | } 13 | 14 | if (painter.text != null && (painter.text is TextSpan)) { 15 | var preText = (painter.text as TextSpan).text; 16 | var preColor = painter.text.style.color; 17 | preColor = preColor == null ? ColorUtils.BLACK : preColor; 18 | var preFontSize = painter.text.style.fontSize; 19 | preFontSize = 20 | preFontSize == null ? Utils.convertDpToPixel(13) : preFontSize; 21 | return _create( 22 | text == null ? preText : text, 23 | color == null ? preColor : color, 24 | fontSize == null ? preFontSize : fontSize, 25 | fontFamily: fontFamily, 26 | fontWeight: fontWeight); 27 | } else { 28 | return _create(text, color, fontSize, 29 | fontFamily: fontFamily, fontWeight: fontWeight); 30 | } 31 | } 32 | 33 | static TextPainter _create(String text, Color color, double fontSize, 34 | {String fontFamily, FontWeight fontWeight = FontWeight.w400}) { 35 | return TextPainter( 36 | textAlign: TextAlign.center, 37 | textDirection: TextDirection.ltr, 38 | text: TextSpan( 39 | text: text, 40 | style: createTextStyle(color, fontSize, 41 | fontFamily: fontFamily, fontWeight: fontWeight))); 42 | } 43 | 44 | static TextStyle createTextStyle(Color color, double fontSize, 45 | {String fontFamily, FontWeight fontWeight = FontWeight.w400}) { 46 | if (fontWeight == null) { 47 | fontWeight = FontWeight.w400; 48 | } 49 | return TextStyle( 50 | color: color, 51 | fontSize: fontSize, 52 | fontFamily: fontFamily, 53 | fontWeight: fontWeight); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/value_formatter/default_axis_value_formatter.dart: -------------------------------------------------------------------------------- 1 | import 'package:intl/intl.dart'; 2 | import 'package:mp_chart/mp/core/value_formatter/value_formatter.dart'; 3 | 4 | class DefaultAxisValueFormatter extends ValueFormatter { 5 | /// decimalformat for formatting 6 | NumberFormat _format; 7 | 8 | /// the number of decimal digits this formatter uses 9 | int _digits; 10 | 11 | /// Constructor that specifies to how many digits the value should be 12 | /// formatted. 13 | /// 14 | /// @param digits 15 | DefaultAxisValueFormatter(int digits) { 16 | this._digits = digits; 17 | 18 | StringBuffer b = StringBuffer(); 19 | for (int i = 0; i < digits; i++) { 20 | if (i == 0) b.write("."); 21 | b.write("0"); 22 | } 23 | 24 | _format = NumberFormat("###,###,###,##0" + b.toString()); 25 | } 26 | 27 | @override 28 | String getFormattedValue1(double value) { 29 | // avoid memory allocations here (for performance) 30 | return _format.format(value); 31 | } 32 | 33 | int get digits => _digits; 34 | } 35 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/value_formatter/default_value_formatter.dart: -------------------------------------------------------------------------------- 1 | import 'package:intl/intl.dart'; 2 | import 'package:mp_chart/mp/core/value_formatter/value_formatter.dart'; 3 | 4 | class DefaultValueFormatter extends ValueFormatter { 5 | /// DecimalFormat for formatting 6 | NumberFormat _format; 7 | 8 | int _decimalDigits; 9 | 10 | /// Constructor that specifies to how many digits the value should be 11 | /// formatted. 12 | /// 13 | /// @param digits 14 | DefaultValueFormatter(int digits) { 15 | setup(digits); 16 | } 17 | 18 | /// Sets up the formatter with a given number of decimal digits. 19 | /// 20 | /// @param digits 21 | void setup(int digits) { 22 | this._decimalDigits = digits; 23 | 24 | if (digits < 1) { 25 | digits = 1; 26 | } 27 | 28 | StringBuffer b = StringBuffer(); 29 | b.write("."); 30 | for (int i = 0; i < digits; i++) { 31 | b.write("0"); 32 | } 33 | _format = NumberFormat("###,###,###,##0" + b.toString()); 34 | } 35 | 36 | @override 37 | String getFormattedValue1(double value) { 38 | // put more logic here ... 39 | // avoid memory allocations here (for performance reasons) 40 | 41 | return _format.format(value); 42 | } 43 | 44 | @override 45 | String toString() { 46 | return _format.toString(); 47 | } 48 | 49 | int get decimalDigits => _decimalDigits; 50 | } 51 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/value_formatter/large_value_formatter.dart: -------------------------------------------------------------------------------- 1 | import 'package:intl/intl.dart'; 2 | import 'package:mp_chart/mp/core/value_formatter/value_formatter.dart'; 3 | 4 | class LargeValueFormatter extends ValueFormatter { 5 | List _suffix = List() 6 | ..add("") 7 | ..add("k") 8 | ..add("m") 9 | ..add("b") 10 | ..add("t"); 11 | int _maxLength = 5; 12 | NumberFormat _format; 13 | String _text = ""; 14 | 15 | /// Creates a formatter that appends a specified text to the result string 16 | /// 17 | /// @param appendix a text that will be appended 18 | LargeValueFormatter({String appendix = ""}) { 19 | _format = new NumberFormat("###E00"); 20 | _text = appendix; 21 | } 22 | 23 | @override 24 | String getFormattedValue1(double value) { 25 | return makePretty(value) + _text; 26 | } 27 | 28 | /// Set an appendix text to be added at the end of the formatted value. 29 | /// 30 | /// @param appendix 31 | void setAppendix(String appendix) { 32 | this._text = appendix; 33 | } 34 | 35 | /// Set custom suffix to be appended after the values. 36 | /// Default suffix: ["", "k", "m", "b", "t"] 37 | /// 38 | /// @param suffix new suffix 39 | void setSuffix(List suffix) { 40 | this._suffix = suffix; 41 | } 42 | 43 | void setMaxLength(int maxLength) { 44 | this._maxLength = maxLength; 45 | } 46 | 47 | /// Formats each number properly. Special thanks to Roman Gromov 48 | /// (https://github.com/romangromov) for this piece of code. 49 | String makePretty(double number) { 50 | String r = _format.format(number); 51 | int numericValue1 = int.tryParse(r[r.length - 1]); 52 | int numericValue2 = int.tryParse(r[r.length - 2]); 53 | int combined = int.parse("$numericValue2$numericValue1"); 54 | 55 | r = r.replaceAllMapped( 56 | RegExp( 57 | r"E[0-9][0-9]", 58 | caseSensitive: false, 59 | multiLine: false, 60 | ), 61 | (match) => _suffix[combined ~/ 3]); 62 | 63 | while (r.length > _maxLength || 64 | RegExp( 65 | r"[0-9]+\\.[a-z]", 66 | caseSensitive: false, 67 | multiLine: false, 68 | ).hasMatch(r)) { 69 | r = r.substring(0, r.length - 2) + r.substring(r.length - 1); 70 | } 71 | 72 | return r; 73 | } 74 | 75 | int getDecimalDigits() { 76 | return 0; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/value_formatter/my_value_formatter.dart: -------------------------------------------------------------------------------- 1 | import 'package:intl/intl.dart'; 2 | import 'package:mp_chart/mp/core/axis/axis_base.dart'; 3 | import 'package:mp_chart/mp/core/axis/x_axis.dart'; 4 | import 'package:mp_chart/mp/core/value_formatter/value_formatter.dart'; 5 | 6 | class MyValueFormatter extends ValueFormatter { 7 | NumberFormat _format; 8 | String _suffix; 9 | 10 | MyValueFormatter(String suffix) { 11 | _format = NumberFormat("###,###,###,##0.0"); 12 | this._suffix = suffix; 13 | } 14 | 15 | @override 16 | String getFormattedValue1(double value) { 17 | return _format.format(value) + _suffix; 18 | } 19 | 20 | @override 21 | String getAxisLabel(double value, AxisBase axis) { 22 | if (axis is XAxis) { 23 | return _format.format(value); 24 | } else if (value > 0) { 25 | return _format.format(value) + _suffix; 26 | } else { 27 | return _format.format(value); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/value_formatter/percent_formatter.dart: -------------------------------------------------------------------------------- 1 | import 'package:intl/intl.dart'; 2 | import 'package:mp_chart/mp/controller/pie_chart_controller.dart'; 3 | import 'package:mp_chart/mp/core/entry/pie_entry.dart'; 4 | import 'package:mp_chart/mp/core/value_formatter/value_formatter.dart'; 5 | 6 | class PercentFormatter extends ValueFormatter { 7 | NumberFormat _format; 8 | PieChartController _controller; 9 | bool _percentSignSeparated; 10 | 11 | PercentFormatter() { 12 | _format = NumberFormat("###,###,##0.0"); 13 | _percentSignSeparated = true; 14 | } 15 | 16 | setPieChartPainter(PieChartController controller) { 17 | _controller = controller; 18 | } 19 | 20 | @override 21 | String getFormattedValue1(double value) { 22 | return _format.format(value) + (_percentSignSeparated ? " %" : "%"); 23 | } 24 | 25 | @override 26 | String getPieLabel(double value, PieEntry pieEntry) { 27 | if (_controller != null && 28 | _controller.painter != null && 29 | _controller.painter.isUsePercentValuesEnabled()) { 30 | // Converted to percent 31 | return getFormattedValue1(value); 32 | } else { 33 | // raw value, skip percent sign 34 | return _format.format(value); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/value_formatter/stacked_value_formatter.dart: -------------------------------------------------------------------------------- 1 | import 'package:intl/intl.dart'; 2 | import 'package:mp_chart/mp/core/entry/bar_entry.dart'; 3 | import 'package:mp_chart/mp/core/value_formatter/value_formatter.dart'; 4 | 5 | class StackedValueFormatter extends ValueFormatter { 6 | /// if true, all stack values of the stacked bar entry are drawn, else only top 7 | bool _drawWholeStack; 8 | 9 | /// a string that should be appended behind the value 10 | String _suffix; 11 | 12 | NumberFormat _format; 13 | 14 | /// Constructor. 15 | /// 16 | /// @param drawWholeStack if true, all stack values of the stacked bar entry are drawn, else only top 17 | /// @param suffix a string that should be appended behind the value 18 | /// @param decimals the number of decimal digits to use 19 | StackedValueFormatter(bool drawWholeStack, String suffix, int decimals) { 20 | this._drawWholeStack = drawWholeStack; 21 | this._suffix = suffix; 22 | 23 | StringBuffer b = new StringBuffer(); 24 | for (int i = 0; i < decimals; i++) { 25 | if (i == 0) b.write("."); 26 | b.write("0"); 27 | } 28 | 29 | this._format = NumberFormat("###,###,###,##0" + b.toString()); 30 | } 31 | 32 | @override 33 | String getBarStackedLabel(double value, BarEntry entry) { 34 | if (!_drawWholeStack) { 35 | List vals = entry.yVals; 36 | 37 | if (vals != null) { 38 | // find out if we are on top of the stack 39 | if (vals[vals.length - 1] == value) { 40 | // return the "sum" across all stack values 41 | return _format.format(entry.y) + _suffix; 42 | } else { 43 | return ""; // return empty 44 | } 45 | } 46 | } 47 | // return the "proposed" value 48 | return _format.format(value) + _suffix; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /mp_chart/lib/mp/core/value_formatter/value_formatter.dart: -------------------------------------------------------------------------------- 1 | import 'package:mp_chart/mp/core/axis/axis_base.dart'; 2 | import 'package:mp_chart/mp/core/entry/bar_entry.dart'; 3 | import 'package:mp_chart/mp/core/entry/bubble_entry.dart'; 4 | import 'package:mp_chart/mp/core/entry/candle_entry.dart'; 5 | import 'package:mp_chart/mp/core/entry/entry.dart'; 6 | import 'package:mp_chart/mp/core/entry/pie_entry.dart'; 7 | import 'package:mp_chart/mp/core/entry/radar_entry.dart'; 8 | import 'package:mp_chart/mp/core/view_port.dart'; 9 | 10 | abstract class ValueFormatter { 11 | String getFormattedValue2(double value, AxisBase axis) { 12 | return getFormattedValue1(value); 13 | } 14 | 15 | String getFormattedValue3(double value, Entry entry, int dataSetIndex, 16 | ViewPortHandler viewPortHandler) { 17 | return getFormattedValue1(value); 18 | } 19 | 20 | String getFormattedValue1(double value) { 21 | return value.toString(); 22 | } 23 | 24 | String getAxisLabel(double value, AxisBase axis) { 25 | return getFormattedValue1(value); 26 | } 27 | 28 | String getBarLabel(BarEntry barEntry) { 29 | return getFormattedValue1(barEntry.y); 30 | } 31 | 32 | String getBarStackedLabel(double value, BarEntry stackedEntry) { 33 | return getFormattedValue1(value); 34 | } 35 | 36 | String getPointLabel(Entry entry) { 37 | return getFormattedValue1(entry.y); 38 | } 39 | 40 | String getPieLabel(double value, PieEntry pieEntry) { 41 | return getFormattedValue1(value); 42 | } 43 | 44 | String getRadarLabel(RadarEntry radarEntry) { 45 | return getFormattedValue1(radarEntry.getValue()); 46 | } 47 | 48 | String getBubbleLabel(BubbleEntry bubbleEntry) { 49 | return getFormattedValue1(bubbleEntry.size); 50 | } 51 | 52 | String getCandleLabel(CandleEntry candleEntry) { 53 | return getFormattedValue1(candleEntry.shadowHigh); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /mp_chart/lib/mp_chart.dart: -------------------------------------------------------------------------------- 1 | library mp_chart; 2 | 3 | /// A Calculator. 4 | class Calculator { 5 | /// Returns [value] plus 1. 6 | int addOne(int value) => value + 1; 7 | } 8 | -------------------------------------------------------------------------------- /mp_chart/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: mp_chart 2 | description: A Flutter chart package just like AndroidMPChart, apply easy to use chart for Flutter. 3 | version: 0.3.1 4 | author: SunPointed<410338643@qq.com> 5 | homepage: https://github.com/SunPointed/MPFlutterChart 6 | 7 | environment: 8 | sdk: ">=2.1.0 <3.0.0" 9 | 10 | dependencies: 11 | intl: ^0.17.0 12 | path_provider: ^2.0.1 13 | screenshot: ^1.0.0-nullsafety.1 14 | path_drawing: ^0.5.0 15 | image_gallery_saver: ^1.6.9 16 | optimized_gesture_detector: ^0.0.6 17 | vector_math: ^2.1.0 18 | flutter: 19 | sdk: flutter 20 | 21 | dev_dependencies: 22 | flutter_test: 23 | sdk: flutter 24 | 25 | # For information on the generic Dart part of this file, see the 26 | # following page: https://dart.dev/tools/pub/pubspec 27 | 28 | # The following section is specific to Flutter. 29 | flutter: 30 | 31 | # To add assets to your package, add an assets section, like this: 32 | # assets: 33 | # - images/a_dot_burr.jpeg 34 | # - images/a_dot_ham.jpeg 35 | # 36 | # For details regarding assets in packages, see 37 | # https://flutter.dev/assets-and-images/#from-packages 38 | # 39 | # An image asset can refer to one or more resolution-specific "variants", see 40 | # https://flutter.dev/assets-and-images/#resolution-aware. 41 | 42 | # To add custom fonts to your package, add a fonts section here, 43 | # in this "flutter" section. Each entry in this list should have a 44 | # "family" key with the font family name, and a "fonts" key with a 45 | # list giving the asset and other descriptors for the font. For 46 | # example: 47 | # fonts: 48 | # - family: Schyler 49 | # fonts: 50 | # - asset: fonts/Schyler-Regular.ttf 51 | # - asset: fonts/Schyler-Italic.ttf 52 | # style: italic 53 | # - family: Trajan Pro 54 | # fonts: 55 | # - asset: fonts/TrajanPro.ttf 56 | # - asset: fonts/TrajanPro_Bold.ttf 57 | # weight: 700 58 | # 59 | # For details regarding fonts in packages, see 60 | # https://flutter.dev/custom-fonts/#from-packages 61 | -------------------------------------------------------------------------------- /mp_chart/test/mp_chart_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_test/flutter_test.dart'; 2 | import 'package:mp_chart/mp/core/utils/matrix4_utils.dart'; 3 | 4 | import 'package:mp_chart/mp_chart.dart'; 5 | import 'package:vector_math/vector_math_64.dart'; 6 | 7 | void main() { 8 | test('adds one to input values', () { 9 | final calculator = Calculator(); 10 | expect(calculator.addOne(2), 3); 11 | expect(calculator.addOne(-7), -6); 12 | expect(calculator.addOne(0), 1); 13 | expect(() => calculator.addOne(null), throwsNoSuchMethodError); 14 | }); 15 | 16 | /** 17 | * a test to see the print value equal to the same Android logic 18 | */ 19 | test('test postScale', () { 20 | Matrix4 m = Matrix4.identity(); 21 | print(m); 22 | print('\n'); 23 | Matrix4Utils.postTranslate(m, 3, 5); 24 | print(m); 25 | print('\n'); 26 | Matrix4Utils.postScale(m, 3, 0.5); 27 | print(m); 28 | print('\n'); 29 | Matrix4Utils.postScaleByPoint(m, 0.4, 6, 2, 3); 30 | print(m); 31 | }); 32 | } 33 | -------------------------------------------------------------------------------- /mp_chart/upload.sh: -------------------------------------------------------------------------------- 1 | sudo /usr/local/sbin/privoxy /usr/local/etc/privoxy/config 2 | export http_proxy='http://localhost:8119' 3 | export https_proxy='http://localhost:8119' 4 | pub publish --server=https://pub.dartlang.org 5 | unset http_proxy 6 | unset https_proxy 7 | sudo service privoxy stop --------------------------------------------------------------------------------