├── test └── chart_it_tests.dart ├── example ├── linux │ ├── .gitignore │ ├── main.cc │ ├── flutter │ │ ├── generated_plugin_registrant.cc │ │ ├── generated_plugin_registrant.h │ │ ├── generated_plugins.cmake │ │ └── CMakeLists.txt │ ├── my_application.h │ └── my_application.cc ├── test │ └── widget_test.dart ├── ios │ ├── Runner │ │ ├── Runner-Bridging-Header.h │ │ ├── Assets.xcassets │ │ │ ├── LaunchImage.imageset │ │ │ │ ├── LaunchImage.png │ │ │ │ ├── LaunchImage@2x.png │ │ │ │ ├── LaunchImage@3x.png │ │ │ │ ├── README.md │ │ │ │ └── Contents.json │ │ │ └── AppIcon.appiconset │ │ │ │ ├── Icon-App-20x20@1x.png │ │ │ │ ├── Icon-App-20x20@2x.png │ │ │ │ ├── Icon-App-20x20@3x.png │ │ │ │ ├── Icon-App-29x29@1x.png │ │ │ │ ├── Icon-App-29x29@2x.png │ │ │ │ ├── Icon-App-29x29@3x.png │ │ │ │ ├── Icon-App-40x40@1x.png │ │ │ │ ├── Icon-App-40x40@2x.png │ │ │ │ ├── Icon-App-40x40@3x.png │ │ │ │ ├── Icon-App-60x60@2x.png │ │ │ │ ├── Icon-App-60x60@3x.png │ │ │ │ ├── Icon-App-76x76@1x.png │ │ │ │ ├── Icon-App-76x76@2x.png │ │ │ │ ├── Icon-App-1024x1024@1x.png │ │ │ │ ├── Icon-App-83.5x83.5@2x.png │ │ │ │ └── Contents.json │ │ ├── AppDelegate.swift │ │ ├── Base.lproj │ │ │ ├── Main.storyboard │ │ │ └── LaunchScreen.storyboard │ │ └── Info.plist │ ├── Flutter │ │ ├── Debug.xcconfig │ │ ├── Release.xcconfig │ │ └── AppFrameworkInfo.plist │ ├── Runner.xcodeproj │ │ ├── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ │ ├── WorkspaceSettings.xcsettings │ │ │ │ └── IDEWorkspaceChecks.plist │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ ├── Runner.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ ├── WorkspaceSettings.xcsettings │ │ │ └── IDEWorkspaceChecks.plist │ ├── Podfile.lock │ ├── .gitignore │ └── Podfile ├── web │ ├── favicon.png │ ├── icons │ │ ├── Icon-192.png │ │ ├── Icon-512.png │ │ ├── Icon-maskable-192.png │ │ └── Icon-maskable-512.png │ ├── manifest.json │ └── index.html ├── android │ ├── gradle.properties │ ├── app │ │ ├── src │ │ │ ├── main │ │ │ │ ├── res │ │ │ │ │ ├── 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 │ │ │ │ │ ├── drawable │ │ │ │ │ │ └── launch_background.xml │ │ │ │ │ ├── drawable-v21 │ │ │ │ │ │ └── launch_background.xml │ │ │ │ │ ├── values │ │ │ │ │ │ └── styles.xml │ │ │ │ │ └── values-night │ │ │ │ │ │ └── styles.xml │ │ │ │ ├── kotlin │ │ │ │ │ └── com │ │ │ │ │ │ └── wednesday │ │ │ │ │ │ └── example │ │ │ │ │ │ └── MainActivity.kt │ │ │ │ └── AndroidManifest.xml │ │ │ ├── debug │ │ │ │ └── AndroidManifest.xml │ │ │ └── profile │ │ │ │ └── AndroidManifest.xml │ │ └── build.gradle │ ├── gradle │ │ └── wrapper │ │ │ └── gradle-wrapper.properties │ ├── .gitignore │ ├── settings.gradle │ └── build.gradle ├── macos │ ├── Runner │ │ ├── Configs │ │ │ ├── Debug.xcconfig │ │ │ ├── Release.xcconfig │ │ │ ├── Warnings.xcconfig │ │ │ └── AppInfo.xcconfig │ │ ├── Assets.xcassets │ │ │ └── AppIcon.appiconset │ │ │ │ ├── app_icon_128.png │ │ │ │ ├── app_icon_16.png │ │ │ │ ├── app_icon_256.png │ │ │ │ ├── app_icon_32.png │ │ │ │ ├── app_icon_512.png │ │ │ │ ├── app_icon_64.png │ │ │ │ ├── app_icon_1024.png │ │ │ │ └── Contents.json │ │ ├── AppDelegate.swift │ │ ├── Release.entitlements │ │ ├── MainFlutterWindow.swift │ │ ├── DebugProfile.entitlements │ │ └── Info.plist │ ├── .gitignore │ ├── Flutter │ │ ├── Flutter-Debug.xcconfig │ │ ├── Flutter-Release.xcconfig │ │ └── GeneratedPluginRegistrant.swift │ ├── Runner.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ ├── Runner.xcodeproj │ │ ├── project.xcworkspace │ │ │ └── xcshareddata │ │ │ │ └── IDEWorkspaceChecks.plist │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ ├── Podfile.lock │ └── Podfile ├── fonts │ └── zangezi_regular.otf ├── windows │ ├── runner │ │ ├── resources │ │ │ └── app_icon.ico │ │ ├── resource.h │ │ ├── utils.h │ │ ├── runner.exe.manifest │ │ ├── flutter_window.h │ │ ├── main.cpp │ │ ├── utils.cpp │ │ ├── CMakeLists.txt │ │ ├── flutter_window.cpp │ │ ├── Runner.rc │ │ └── win32_window.h │ ├── flutter │ │ ├── generated_plugin_registrant.cc │ │ ├── generated_plugin_registrant.h │ │ ├── generated_plugins.cmake │ │ └── CMakeLists.txt │ ├── .gitignore │ └── CMakeLists.txt ├── lib │ ├── main.dart │ ├── tools │ │ └── current_device.dart │ ├── themes │ │ ├── dark_theme.dart │ │ └── light_theme.dart │ ├── showcase.dart │ └── screens │ │ ├── pie_charts_animation.dart │ │ ├── pie_chart.dart │ │ ├── pie_chart_interaction.dart │ │ └── bar_chart.dart ├── README.md ├── pubspec.yaml ├── .gitignore ├── graphics │ └── main_logo_shorthand.svg ├── analysis_options.yaml └── .metadata ├── lib ├── src │ ├── charts │ │ ├── widgets │ │ │ ├── widgets.dart │ │ │ ├── line_chart.dart │ │ │ ├── cartesian_chart.dart │ │ │ └── pie_chart.dart │ │ ├── data │ │ │ ├── pie.dart │ │ │ ├── bars.dart │ │ │ ├── core.dart │ │ │ ├── core │ │ │ │ ├── radial │ │ │ │ │ └── radial_styling.dart │ │ │ │ ├── shared │ │ │ │ │ ├── fuzziness.dart │ │ │ │ │ └── chart_text_style.dart │ │ │ │ └── cartesian │ │ │ │ │ ├── cartesian_range.dart │ │ │ │ │ ├── cartesian_data.dart │ │ │ │ │ └── cartesian_data_internal.dart │ │ │ ├── bars │ │ │ │ ├── simple_bar.dart │ │ │ │ ├── bar_data_style.dart │ │ │ │ ├── bar_group.dart │ │ │ │ ├── multi_bar.dart │ │ │ │ └── bar_data.dart │ │ │ └── pie │ │ │ │ ├── pie_interactions.dart │ │ │ │ ├── slice_data.dart │ │ │ │ └── slice_data_style.dart │ │ ├── painters │ │ │ ├── radial │ │ │ │ ├── radial_painter.dart │ │ │ │ └── radial_chart_painter.dart │ │ │ ├── cartesian │ │ │ │ ├── cartesian_painter.dart │ │ │ │ └── cartesian_chart_painter.dart │ │ │ └── text │ │ │ │ └── chart_text_painter.dart │ │ ├── state │ │ │ ├── pie_series_state.dart │ │ │ ├── bar_series_state.dart │ │ │ └── painting_state.dart │ │ └── constants │ │ │ └── defaults.dart │ ├── interactions │ │ ├── interactions.dart │ │ ├── data │ │ │ ├── touch_interactions.dart │ │ │ └── touch_interaction_events.dart │ │ └── hit_test │ │ │ └── interaction_dispatcher.dart │ ├── animations │ │ ├── tweens.dart │ │ ├── lerps.dart │ │ ├── refresh_rate_ticker.dart │ │ └── chart_animations.dart │ └── extensions │ │ ├── paint_objects.dart │ │ ├── interactions.dart │ │ ├── data_conversions.dart │ │ └── primitives.dart └── chart_it.dart ├── pub_images ├── bar-charts-read-me.gif └── pie-charts-read-me.gif ├── .github ├── pull_request_template.md └── workflows │ └── ci.yml ├── analysis_options.yaml ├── .metadata ├── sonar-project.properties ├── .gitignore ├── CHANGELOG.md ├── LICENSE └── pubspec.yaml /test/chart_it_tests.dart: -------------------------------------------------------------------------------- 1 | void main() {} 2 | -------------------------------------------------------------------------------- /example/linux/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral 2 | -------------------------------------------------------------------------------- /example/test/widget_test.dart: -------------------------------------------------------------------------------- 1 | void main() {} 2 | -------------------------------------------------------------------------------- /example/ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /example/web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wednesday-solutions/chart_it/HEAD/example/web/favicon.png -------------------------------------------------------------------------------- /lib/src/charts/widgets/widgets.dart: -------------------------------------------------------------------------------- 1 | export 'bar_chart.dart'; 2 | export 'line_chart.dart'; 3 | export 'pie_chart.dart'; 4 | -------------------------------------------------------------------------------- /example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | -------------------------------------------------------------------------------- /example/macos/Runner/Configs/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Debug.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /example/web/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wednesday-solutions/chart_it/HEAD/example/web/icons/Icon-192.png -------------------------------------------------------------------------------- /example/web/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wednesday-solutions/chart_it/HEAD/example/web/icons/Icon-512.png -------------------------------------------------------------------------------- /example/fonts/zangezi_regular.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wednesday-solutions/chart_it/HEAD/example/fonts/zangezi_regular.otf -------------------------------------------------------------------------------- /example/macos/Runner/Configs/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Release.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /pub_images/bar-charts-read-me.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wednesday-solutions/chart_it/HEAD/pub_images/bar-charts-read-me.gif -------------------------------------------------------------------------------- /pub_images/pie-charts-read-me.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wednesday-solutions/chart_it/HEAD/pub_images/pie-charts-read-me.gif -------------------------------------------------------------------------------- /example/macos/.gitignore: -------------------------------------------------------------------------------- 1 | # Flutter-related 2 | **/Flutter/ephemeral/ 3 | **/Pods/ 4 | 5 | # Xcode-related 6 | **/dgph 7 | **/xcuserdata/ 8 | -------------------------------------------------------------------------------- /example/web/icons/Icon-maskable-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wednesday-solutions/chart_it/HEAD/example/web/icons/Icon-maskable-192.png -------------------------------------------------------------------------------- /example/web/icons/Icon-maskable-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wednesday-solutions/chart_it/HEAD/example/web/icons/Icon-maskable-512.png -------------------------------------------------------------------------------- /example/ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /example/ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /example/windows/runner/resources/app_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wednesday-solutions/chart_it/HEAD/example/windows/runner/resources/app_icon.ico -------------------------------------------------------------------------------- /example/macos/Flutter/Flutter-Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "ephemeral/Flutter-Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /lib/src/charts/data/pie.dart: -------------------------------------------------------------------------------- 1 | export 'pie/pie_interactions.dart'; 2 | export 'pie/pie_series.dart'; 3 | export 'pie/slice_data.dart'; 4 | export 'pie/slice_data_style.dart'; 5 | -------------------------------------------------------------------------------- /example/macos/Flutter/Flutter-Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "ephemeral/Flutter-Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /lib/src/interactions/interactions.dart: -------------------------------------------------------------------------------- 1 | export 'data/touch_interaction_events.dart'; 2 | export 'data/touch_interactions.dart'; 3 | export 'hit_test/interaction_dispatcher.dart'; 4 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wednesday-solutions/chart_it/HEAD/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wednesday-solutions/chart_it/HEAD/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wednesday-solutions/chart_it/HEAD/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wednesday-solutions/chart_it/HEAD/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | # Description, Motivation and Context: 2 | 3 | # Link to the resources (Ticket, Links): 4 | 5 | Ticket Link - 6 | 7 | # Screenshot / GIF (if any): 8 | 9 | -------------------------------------------------------------------------------- /analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:flutter_lints/flutter.yaml 2 | 3 | # Additional information about this file can be found at 4 | # https://dart.dev/guides/language/analysis-options 5 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wednesday-solutions/chart_it/HEAD/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wednesday-solutions/chart_it/HEAD/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wednesday-solutions/chart_it/HEAD/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wednesday-solutions/chart_it/HEAD/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wednesday-solutions/chart_it/HEAD/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wednesday-solutions/chart_it/HEAD/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wednesday-solutions/chart_it/HEAD/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wednesday-solutions/chart_it/HEAD/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wednesday-solutions/chart_it/HEAD/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wednesday-solutions/chart_it/HEAD/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wednesday-solutions/chart_it/HEAD/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wednesday-solutions/chart_it/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wednesday-solutions/chart_it/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wednesday-solutions/chart_it/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wednesday-solutions/chart_it/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wednesday-solutions/chart_it/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wednesday-solutions/chart_it/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wednesday-solutions/chart_it/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wednesday-solutions/chart_it/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wednesday-solutions/chart_it/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wednesday-solutions/chart_it/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wednesday-solutions/chart_it/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wednesday-solutions/chart_it/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wednesday-solutions/chart_it/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wednesday-solutions/chart_it/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wednesday-solutions/chart_it/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /example/android/app/src/main/kotlin/com/wednesday/example/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.wednesday.example 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | 5 | class MainActivity : FlutterActivity() { 6 | } 7 | -------------------------------------------------------------------------------- /example/linux/main.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | int main(int argc, char** argv) { 4 | g_autoptr(MyApplication) app = my_application_new(); 5 | return g_application_run(G_APPLICATION(app), argc, argv); 6 | } 7 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /lib/chart_it.dart: -------------------------------------------------------------------------------- 1 | library chart_it; 2 | 3 | export 'src/animations/refresh_rate_ticker.dart'; 4 | export 'src/charts/data/bars.dart'; 5 | export 'src/charts/data/core.dart'; 6 | export 'src/charts/data/pie.dart'; 7 | export 'src/charts/widgets/widgets.dart'; 8 | -------------------------------------------------------------------------------- /example/linux/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | 10 | void fl_register_plugins(FlPluginRegistry* registry) { 11 | } 12 | -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip 6 | -------------------------------------------------------------------------------- /example/windows/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | 10 | void RegisterPlugins(flutter::PluginRegistry* registry) { 11 | } 12 | -------------------------------------------------------------------------------- /lib/src/charts/data/bars.dart: -------------------------------------------------------------------------------- 1 | export 'bars/bar_data.dart'; 2 | export 'bars/bar_data_style.dart'; 3 | export 'bars/bar_group.dart'; 4 | export 'bars/bar_interactions.dart'; 5 | export 'bars/bar_series.dart'; 6 | export 'bars/multi_bar.dart'; 7 | export 'bars/simple_bar.dart'; 8 | -------------------------------------------------------------------------------- /example/macos/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | @NSApplicationMain 5 | class AppDelegate: FlutterAppDelegate { 6 | override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { 7 | return true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/macos/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /lib/src/charts/data/core.dart: -------------------------------------------------------------------------------- 1 | export 'core/cartesian/cartesian_data.dart'; 2 | export 'core/cartesian/cartesian_range.dart'; 3 | export 'core/cartesian/cartesian_styling.dart'; 4 | export 'core/radial/radial_data.dart'; 5 | export 'core/radial/radial_styling.dart'; 6 | export 'core/shared/chart_text_style.dart'; 7 | export 'core/shared/fuzziness.dart'; 8 | -------------------------------------------------------------------------------- /.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: 32fb2f948e9b1a2d1b876ebee3558be7f51b457f 8 | channel: stable 9 | 10 | project_type: package 11 | -------------------------------------------------------------------------------- /example/android/.gitignore: -------------------------------------------------------------------------------- 1 | gradle-wrapper.jar 2 | /.gradle 3 | /captures/ 4 | /gradlew 5 | /gradlew.bat 6 | /local.properties 7 | GeneratedPluginRegistrant.java 8 | 9 | # Remember to never publicly share your keystore. 10 | # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app 11 | key.properties 12 | **/*.keystore 13 | **/*.jks 14 | -------------------------------------------------------------------------------- /example/macos/Flutter/GeneratedPluginRegistrant.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | import FlutterMacOS 6 | import Foundation 7 | 8 | import path_provider_foundation 9 | 10 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { 11 | PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) 12 | } 13 | -------------------------------------------------------------------------------- /example/macos/Runner/Release.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.network.client 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /example/windows/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral/ 2 | 3 | # Visual Studio user-specific files. 4 | *.suo 5 | *.user 6 | *.userosscache 7 | *.sln.docstates 8 | 9 | # Visual Studio build-related files. 10 | x64/ 11 | x86/ 12 | 13 | # Visual Studio cache files 14 | # files ending in .cache can be ignored 15 | *.[Cc]ache 16 | # but keep track of directories ending in .cache 17 | !*.[Cc]ache/ 18 | -------------------------------------------------------------------------------- /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 4 | this directory. 5 | 6 | You can also do it by opening your Flutter project's Xcode project 7 | with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and 8 | dropping in the desired images. -------------------------------------------------------------------------------- /example/linux/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void fl_register_plugins(FlPluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /example/windows/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void RegisterPlugins(flutter::PluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /sonar-project.properties: -------------------------------------------------------------------------------- 1 | sonar.projectKey=wednesday-solutions_chart_it_AYoMQ2EZrZfBECKNeX8y 2 | sonar.projectName=chart_it 3 | sonar.host.url=https://sonar.wednesday.is 4 | sonar.sources=lib 5 | sonar.tests=test 6 | sonar.sourceEncoding=UTF-8 7 | sonar.exclusions=test/mocks/**/*.dart,lib/**/*.g.dart,lib/**/*.freezed.dart,lib/**/*.gr.dart,assets/** 8 | sonar.test.inclusions=**/*_test.dart 9 | sonar.test.exclusions=**/mocks/**/*.dart -------------------------------------------------------------------------------- /lib/src/charts/widgets/line_chart.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class LineChart extends StatefulWidget { 4 | const LineChart({Key? key}) : super(key: key); 5 | 6 | @override 7 | State createState() => _LineChartState(); 8 | } 9 | 10 | class _LineChartState extends State { 11 | @override 12 | Widget build(BuildContext context) { 13 | return const Placeholder(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /example/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Flutter 3 | 4 | @UIApplicationMain 5 | @objc class AppDelegate: FlutterAppDelegate { 6 | override func application( 7 | _ application: UIApplication, 8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 9 | ) -> Bool { 10 | GeneratedPluginRegistrant.register(with: self) 11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /example/linux/my_application.h: -------------------------------------------------------------------------------- 1 | #ifndef FLUTTER_MY_APPLICATION_H_ 2 | #define FLUTTER_MY_APPLICATION_H_ 3 | 4 | #include 5 | 6 | G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, 7 | GtkApplication) 8 | 9 | /** 10 | * my_application_new: 11 | * 12 | * Creates a new Flutter-based application. 13 | * 14 | * Returns: a new #MyApplication. 15 | */ 16 | MyApplication* my_application_new(); 17 | 18 | #endif // FLUTTER_MY_APPLICATION_H_ 19 | -------------------------------------------------------------------------------- /example/macos/Runner/MainFlutterWindow.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | class MainFlutterWindow: NSWindow { 5 | override func awakeFromNib() { 6 | let flutterViewController = FlutterViewController.init() 7 | let windowFrame = self.frame 8 | self.contentViewController = flutterViewController 9 | self.setFrame(windowFrame, display: true) 10 | 11 | RegisterGeneratedPlugins(registry: flutterViewController) 12 | 13 | super.awakeFromNib() 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /example/macos/Runner/DebugProfile.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.cs.allow-jit 8 | 9 | com.apple.security.network.server 10 | 11 | com.apple.security.network.client 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /example/windows/runner/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by Runner.rc 4 | // 5 | #define IDI_APP_ICON 101 6 | 7 | // Next default values for new objects 8 | // 9 | #ifdef APSTUDIO_INVOKED 10 | #ifndef APSTUDIO_READONLY_SYMBOLS 11 | #define _APS_NEXT_RESOURCE_VALUE 102 12 | #define _APS_NEXT_COMMAND_VALUE 40001 13 | #define _APS_NEXT_CONTROL_VALUE 1001 14 | #define _APS_NEXT_SYMED_VALUE 101 15 | #endif 16 | #endif 17 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 11 | 12 | -------------------------------------------------------------------------------- /example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | 3 | def localPropertiesFile = new File(rootProject.projectDir, "local.properties") 4 | def properties = new Properties() 5 | 6 | assert localPropertiesFile.exists() 7 | localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } 8 | 9 | def flutterSdkPath = properties.getProperty("flutter.sdk") 10 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 11 | apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" 12 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable-v21/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 11 | 12 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /example/lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:example/showcase.dart'; 2 | import 'package:example/tools/current_device.dart'; 3 | import 'package:flutter/material.dart'; 4 | import 'package:flutter_displaymode/flutter_displaymode.dart'; 5 | 6 | void main() { 7 | ///Call this first to make sure we can make other system level calls safely 8 | WidgetsFlutterBinding.ensureInitialized(); 9 | if (CurrentDevice.isAndroid) { 10 | FlutterDisplayMode.setHighRefreshRate(); 11 | } 12 | // runApp(const MyApp()); 13 | runApp(const ShowcaseApp()); 14 | } 15 | -------------------------------------------------------------------------------- /lib/src/charts/painters/radial/radial_painter.dart: -------------------------------------------------------------------------------- 1 | import 'package:chart_it/src/charts/data/core.dart'; 2 | import 'package:chart_it/src/charts/painters/radial/radial_chart_painter.dart'; 3 | import 'package:chart_it/src/interactions/interactions.dart'; 4 | import 'package:flutter/material.dart'; 5 | 6 | abstract class RadialPainter { 7 | T? hitTest(TouchInteractionType type, Offset localPosition); 8 | 9 | void paint( 10 | RadialSeries lerp, 11 | Canvas canvas, 12 | RadialChartPainter chart, 13 | RadialConfig config, 14 | ); 15 | } 16 | -------------------------------------------------------------------------------- /example/README.md: -------------------------------------------------------------------------------- 1 | # example 2 | 3 | A new Flutter project. 4 | 5 | ## Getting Started 6 | 7 | This project is a starting point for a Flutter application. 8 | 9 | A few resources to get you started if this is your first Flutter project: 10 | 11 | - [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab) 12 | - [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook) 13 | 14 | For help getting started with Flutter development, view the 15 | [online documentation](https://docs.flutter.dev/), which offers tutorials, 16 | samples, guidance on mobile development, and a full API reference. 17 | -------------------------------------------------------------------------------- /example/macos/Runner/Configs/Warnings.xcconfig: -------------------------------------------------------------------------------- 1 | WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings 2 | GCC_WARN_UNDECLARED_SELECTOR = YES 3 | CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES 4 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE 5 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES 6 | CLANG_WARN_PRAGMA_PACK = YES 7 | CLANG_WARN_STRICT_PROTOTYPES = YES 8 | CLANG_WARN_COMMA = YES 9 | GCC_WARN_STRICT_SELECTOR_MATCH = YES 10 | CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES 11 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES 12 | GCC_WARN_SHADOW = YES 13 | CLANG_WARN_UNREACHABLE_CODE = YES 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | migrate_working_dir/ 12 | 13 | # IntelliJ related 14 | *.iml 15 | *.ipr 16 | *.iws 17 | .idea/ 18 | 19 | # The .vscode folder contains launch configuration and tasks you configure in 20 | # VS Code which you may wish to be included in version control, so this line 21 | # is commented out by default. 22 | #.vscode/ 23 | 24 | # Flutter/Dart/Pub related 25 | # Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. 26 | /pubspec.lock 27 | **/doc/api/ 28 | .dart_tool/ 29 | .packages 30 | build/ 31 | -------------------------------------------------------------------------------- /example/macos/Runner/Configs/AppInfo.xcconfig: -------------------------------------------------------------------------------- 1 | // Application-level settings for the Runner target. 2 | // 3 | // This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the 4 | // future. If not, the values below would default to using the project name when this becomes a 5 | // 'flutter create' template. 6 | 7 | // The application's name. By default this is also the title of the Flutter window. 8 | PRODUCT_NAME = example 9 | 10 | // The application's bundle identifier 11 | PRODUCT_BUNDLE_IDENTIFIER = com.wednesday.example 12 | 13 | // The copyright displayed in application information 14 | PRODUCT_COPYRIGHT = Copyright © 2023 com.wednesday. All rights reserved. 15 | -------------------------------------------------------------------------------- /example/ios/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - Flutter (1.0.0) 3 | - path_provider_foundation (0.0.1): 4 | - Flutter 5 | - FlutterMacOS 6 | 7 | DEPENDENCIES: 8 | - Flutter (from `Flutter`) 9 | - path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`) 10 | 11 | EXTERNAL SOURCES: 12 | Flutter: 13 | :path: Flutter 14 | path_provider_foundation: 15 | :path: ".symlinks/plugins/path_provider_foundation/darwin" 16 | 17 | SPEC CHECKSUMS: 18 | Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 19 | path_provider_foundation: c68054786f1b4f3343858c1e1d0caaded73f0be9 20 | 21 | PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3 22 | 23 | COCOAPODS: 1.12.1 24 | -------------------------------------------------------------------------------- /lib/src/charts/painters/cartesian/cartesian_painter.dart: -------------------------------------------------------------------------------- 1 | import 'package:chart_it/src/charts/data/core.dart'; 2 | import 'package:chart_it/src/charts/data/core/cartesian/cartesian_data_internal.dart'; 3 | import 'package:chart_it/src/interactions/data/touch_interactions.dart'; 4 | import 'package:flutter/material.dart'; 5 | 6 | abstract class CartesianPainter { 7 | T? hitTest(TouchInteractionType type, Offset localPosition); 8 | 9 | void paint({ 10 | required CartesianSeries lerpSeries, 11 | required Canvas canvas, 12 | required CartesianPaintingGeometryData chart, 13 | required CartesianConfig config, 14 | required CartesianChartStylingData style, 15 | }); 16 | } 17 | -------------------------------------------------------------------------------- /lib/src/animations/tweens.dart: -------------------------------------------------------------------------------- 1 | import 'package:chart_it/src/extensions/primitives.dart'; 2 | import 'package:flutter/animation.dart'; 3 | 4 | /// Defines method signature to return a [Tween] of type [T] for 5 | /// [current] and [target] values 6 | typedef TweenBuilder = Tween Function(T? current, T target); 7 | 8 | /// Constructs a List of [Tween] for two Lists of type [T]. 9 | /// The [builder] method must be provided to construct a Tween for object of type [T]. 10 | List>? buildTweens( 11 | List? current, 12 | List target, { 13 | required TweenBuilder builder, 14 | }) => 15 | List.generate( 16 | target.length, 17 | (i) => builder(current?.getOrNull(i), target[i]), 18 | ); 19 | -------------------------------------------------------------------------------- /example/ios/.gitignore: -------------------------------------------------------------------------------- 1 | **/dgph 2 | *.mode1v3 3 | *.mode2v3 4 | *.moved-aside 5 | *.pbxuser 6 | *.perspectivev3 7 | **/*sync/ 8 | .sconsign.dblite 9 | .tags* 10 | **/.vagrant/ 11 | **/DerivedData/ 12 | Icon? 13 | **/Pods/ 14 | **/.symlinks/ 15 | profile 16 | xcuserdata 17 | **/.generated/ 18 | Flutter/App.framework 19 | Flutter/Flutter.framework 20 | Flutter/Flutter.podspec 21 | Flutter/Generated.xcconfig 22 | Flutter/ephemeral/ 23 | Flutter/app.flx 24 | Flutter/app.zip 25 | Flutter/flutter_assets/ 26 | Flutter/flutter_export_environment.sh 27 | ServiceDefinitions.json 28 | Runner/GeneratedPluginRegistrant.* 29 | 30 | # Exceptions to above rules. 31 | !default.mode1v3 32 | !default.mode2v3 33 | !default.pbxuser 34 | !default.perspectivev3 35 | -------------------------------------------------------------------------------- /example/android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.7.10' 3 | repositories { 4 | google() 5 | mavenCentral() 6 | } 7 | 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:7.2.0' 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | } 12 | } 13 | 14 | allprojects { 15 | repositories { 16 | google() 17 | mavenCentral() 18 | } 19 | } 20 | 21 | rootProject.buildDir = '../build' 22 | subprojects { 23 | project.buildDir = "${rootProject.buildDir}/${project.name}" 24 | } 25 | subprojects { 26 | project.evaluationDependsOn(':app') 27 | } 28 | 29 | tasks.register("clean", Delete) { 30 | delete rootProject.buildDir 31 | } 32 | -------------------------------------------------------------------------------- /lib/src/animations/lerps.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui'; 2 | 3 | import 'package:chart_it/src/extensions/primitives.dart'; 4 | 5 | /// Defines method signature of a Lerp Function 6 | typedef Lerp = T Function(T?, T, double); 7 | 8 | /// Lerps between two integer values for factor [t] 9 | int? lerpInt(int? current, int? target, double t) => 10 | lerpDouble(current, target, t)?.round(); 11 | 12 | /// Lerps between two lists of Type [T]. 13 | /// The [lerp] method must be provided to lerp between the values. 14 | List lerpList( 15 | List? current, 16 | List target, 17 | double t, { 18 | required Lerp lerp, 19 | }) => 20 | List.generate( 21 | target.length, 22 | (i) => lerp(current?.getOrNull(i), target[i], t), 23 | ); 24 | -------------------------------------------------------------------------------- /example/windows/runner/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_UTILS_H_ 2 | #define RUNNER_UTILS_H_ 3 | 4 | #include 5 | #include 6 | 7 | // Creates a console for the process, and redirects stdout and stderr to 8 | // it for both the runner and the Flutter library. 9 | void CreateAndAttachConsole(); 10 | 11 | // Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string 12 | // encoded in UTF-8. Returns an empty std::string on failure. 13 | std::string Utf8FromUtf16(const wchar_t* utf16_string); 14 | 15 | // Gets the command line arguments passed in as a std::vector, 16 | // encoded in UTF-8. Returns an empty std::vector on failure. 17 | std::vector GetCommandLineArguments(); 18 | 19 | #endif // RUNNER_UTILS_H_ 20 | -------------------------------------------------------------------------------- /example/macos/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - FlutterMacOS (1.0.0) 3 | - path_provider_foundation (0.0.1): 4 | - Flutter 5 | - FlutterMacOS 6 | 7 | DEPENDENCIES: 8 | - FlutterMacOS (from `Flutter/ephemeral`) 9 | - path_provider_foundation (from `Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin`) 10 | 11 | EXTERNAL SOURCES: 12 | FlutterMacOS: 13 | :path: Flutter/ephemeral 14 | path_provider_foundation: 15 | :path: Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin 16 | 17 | SPEC CHECKSUMS: 18 | FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24 19 | path_provider_foundation: c68054786f1b4f3343858c1e1d0caaded73f0be9 20 | 21 | PODFILE CHECKSUM: 353c8bcc5d5b0994e508d035b5431cfe18c1dea7 22 | 23 | COCOAPODS: 1.12.1 24 | -------------------------------------------------------------------------------- /example/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: example 2 | description: A new Flutter project. 3 | version: 1.0.0+1 4 | publish_to: 'none' 5 | 6 | environment: 7 | sdk: '>=2.19.2 <3.0.0' 8 | 9 | dependencies: 10 | flutter: 11 | sdk: flutter 12 | chart_it: 13 | path: ../ 14 | cupertino_icons: ^1.0.5 15 | flutter_svg: ^2.0.4 16 | google_fonts: ^4.0.3 17 | universal_platform: ^1.0.0+1 18 | responsive_sizer: ^3.1.1 19 | sidebarx: ^0.15.0 20 | flutter_displaymode: 21 | 22 | dev_dependencies: 23 | flutter_test: 24 | sdk: flutter 25 | flutter_lints: ^2.0.1 26 | 27 | 28 | flutter: 29 | uses-material-design: true 30 | assets: 31 | - graphics/main_logo.svg 32 | - graphics/main_logo_shorthand.svg 33 | fonts: 34 | - family: Zangezi 35 | fonts: 36 | - asset: fonts/zangezi_regular.otf 37 | weight: 700 -------------------------------------------------------------------------------- /lib/src/charts/state/pie_series_state.dart: -------------------------------------------------------------------------------- 1 | import 'package:chart_it/src/charts/data/pie.dart'; 2 | import 'package:chart_it/src/charts/painters/radial/pie_painter.dart'; 3 | import 'package:chart_it/src/charts/state/painting_state.dart'; 4 | 5 | class PieSeriesState 6 | extends PaintingState { 7 | PieSeriesState({ 8 | required super.data, 9 | required super.config, 10 | required super.painter, 11 | }); 12 | 13 | static PieSeriesState lerp( 14 | PaintingState? current, 15 | PaintingState target, 16 | double t, 17 | ) { 18 | return PieSeriesState( 19 | data: PieSeries.lerp(current?.data, target.data, t), 20 | config: target.config, 21 | painter: target.painter, 22 | ); 23 | } 24 | 25 | @override 26 | List get props => [super.data]; 27 | } 28 | -------------------------------------------------------------------------------- /lib/src/charts/state/bar_series_state.dart: -------------------------------------------------------------------------------- 1 | import 'package:chart_it/src/charts/data/bars/bar_series.dart'; 2 | import 'package:chart_it/src/charts/painters/cartesian/bar_painter.dart'; 3 | import 'package:chart_it/src/charts/state/painting_state.dart'; 4 | 5 | class BarSeriesState 6 | extends PaintingState { 7 | BarSeriesState({ 8 | required super.data, 9 | required super.config, 10 | required super.painter, 11 | }); 12 | 13 | static BarSeriesState lerp( 14 | PaintingState? current, 15 | PaintingState target, 16 | double t, 17 | ) { 18 | return BarSeriesState( 19 | data: BarSeries.lerp(current?.data, target.data, t), 20 | config: target.config, 21 | painter: target.painter, 22 | ); 23 | } 24 | 25 | @override 26 | List get props => [super.data]; 27 | } 28 | -------------------------------------------------------------------------------- /example/linux/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | ) 7 | 8 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 9 | ) 10 | 11 | set(PLUGIN_BUNDLED_LIBRARIES) 12 | 13 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 14 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) 15 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 16 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 18 | endforeach(plugin) 19 | 20 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 21 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) 22 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 23 | endforeach(ffi_plugin) 24 | -------------------------------------------------------------------------------- /example/windows/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | ) 7 | 8 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 9 | ) 10 | 11 | set(PLUGIN_BUNDLED_LIBRARIES) 12 | 13 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 14 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) 15 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 16 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 18 | endforeach(plugin) 19 | 20 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 21 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) 22 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 23 | endforeach(ffi_plugin) 24 | -------------------------------------------------------------------------------- /lib/src/charts/constants/defaults.dart: -------------------------------------------------------------------------------- 1 | import 'package:chart_it/src/charts/data/bars/bar_data_style.dart'; 2 | import 'package:chart_it/src/charts/data/core/radial/radial_styling.dart'; 3 | import 'package:chart_it/src/charts/data/core/shared/chart_text_style.dart'; 4 | import 'package:chart_it/src/charts/data/pie/slice_data_style.dart'; 5 | import 'package:flutter/material.dart'; 6 | 7 | const defaultRadialChartStyle = RadialChartStyle(); 8 | 9 | const defaultBarSeriesStyle = BarDataStyle( 10 | barColor: Color(0xFFCBB6F7), 11 | strokeWidth: 2.0, 12 | strokeColor: Color(0xFF6A4FA3), 13 | ); 14 | 15 | const defaultPieSeriesStyle = SliceDataStyle( 16 | radius: 200.0, 17 | color: Color(0xFFCBB6F7), 18 | strokeWidth: 2.0, 19 | strokeColor: Color(0xFF6A4FA3), 20 | ); 21 | 22 | const defaultChartTextStyle = ChartTextStyle( 23 | textStyle: TextStyle(color: Colors.black45), 24 | ); 25 | -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | migrate_working_dir/ 12 | 13 | # IntelliJ related 14 | *.iml 15 | *.ipr 16 | *.iws 17 | .idea/ 18 | 19 | # The .vscode folder contains launch configuration and tasks you configure in 20 | # VS Code which you may wish to be included in version control, so this line 21 | # is commented out by default. 22 | #.vscode/ 23 | 24 | # Flutter/Dart/Pub related 25 | **/doc/api/ 26 | **/ios/Flutter/.last_build_id 27 | .dart_tool/ 28 | .flutter-plugins 29 | .flutter-plugins-dependencies 30 | .packages 31 | .pub-cache/ 32 | .pub/ 33 | /build/ 34 | 35 | # Symbolication related 36 | app.*.symbols 37 | 38 | # Obfuscation related 39 | app.*.map.json 40 | 41 | # Android Studio will place build artifacts here 42 | /android/app/debug 43 | /android/app/profile 44 | /android/app/release 45 | -------------------------------------------------------------------------------- /example/ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 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 | 11.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /example/web/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example", 3 | "short_name": "example", 4 | "start_url": ".", 5 | "display": "standalone", 6 | "background_color": "#0175C2", 7 | "theme_color": "#0175C2", 8 | "description": "A new Flutter project.", 9 | "orientation": "portrait-primary", 10 | "prefer_related_applications": false, 11 | "icons": [ 12 | { 13 | "src": "icons/Icon-192.png", 14 | "sizes": "192x192", 15 | "type": "image/png" 16 | }, 17 | { 18 | "src": "icons/Icon-512.png", 19 | "sizes": "512x512", 20 | "type": "image/png" 21 | }, 22 | { 23 | "src": "icons/Icon-maskable-192.png", 24 | "sizes": "192x192", 25 | "type": "image/png", 26 | "purpose": "maskable" 27 | }, 28 | { 29 | "src": "icons/Icon-maskable-512.png", 30 | "sizes": "512x512", 31 | "type": "image/png", 32 | "purpose": "maskable" 33 | } 34 | ] 35 | } 36 | -------------------------------------------------------------------------------- /example/windows/runner/runner.exe.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PerMonitorV2 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /lib/src/interactions/data/touch_interactions.dart: -------------------------------------------------------------------------------- 1 | import 'package:equatable/equatable.dart'; 2 | import 'package:flutter/gestures.dart'; 3 | 4 | /// {@template TouchInteractionResult} 5 | /// [TouchInteractionResult] is the base class for interaction result of charts. 6 | /// {@endtemplate} 7 | abstract class TouchInteractionResult with EquatableMixin { 8 | /// The offset of the interaction relative to the chart. 9 | final Offset? localPosition; 10 | 11 | /// The [TouchInteractionType] of this interaction. 12 | final TouchInteractionType interactionType; 13 | 14 | /// {@macro TouchInteractionResult} 15 | TouchInteractionResult({ 16 | required this.localPosition, 17 | required this.interactionType, 18 | }); 19 | } 20 | 21 | /// [TouchInteractionType] represents the type of interaction for [TouchInteractionResult]. 22 | enum TouchInteractionType { 23 | tap, 24 | tapUp, 25 | tapDown, 26 | doubleTap, 27 | dragStart, 28 | dragUpdate, 29 | dragEnd, 30 | } 31 | -------------------------------------------------------------------------------- /lib/src/animations/refresh_rate_ticker.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/scheduler.dart'; 2 | 3 | class RefreshRateTickerProvider extends TickerProvider { 4 | final int fps; 5 | Function(Duration)? onTick; 6 | 7 | Ticker? _ticker; 8 | Duration _duration = const Duration(); 9 | 10 | RefreshRateTickerProvider({required this.fps}); 11 | 12 | @override 13 | Ticker createTicker(TickerCallback onTick) { 14 | this.onTick = onTick; 15 | _ticker = Ticker(_durationTick); 16 | return _ticker!; 17 | } 18 | 19 | _durationTick(Duration duration) { 20 | final diff = duration - _duration; 21 | if (diff.inMilliseconds < 0) { 22 | _duration = const Duration(); 23 | return; 24 | } 25 | 26 | if (diff.inMilliseconds >= 1000 / fps) { 27 | SchedulerBinding.instance 28 | .addPostFrameCallback((timeStamp) => _onTick(duration)); 29 | _duration = duration; 30 | } 31 | } 32 | 33 | _onTick(Duration duration) { 34 | onTick?.call(duration); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /example/lib/tools/current_device.dart: -------------------------------------------------------------------------------- 1 | import 'package:responsive_sizer/responsive_sizer.dart' as rz; 2 | import 'package:universal_platform/universal_platform.dart'; 3 | 4 | class CurrentDevice { 5 | static bool get isMobile => 6 | _isMobileOS && rz.Device.screenType == rz.ScreenType.mobile; 7 | 8 | static bool get isTablet => 9 | _isMobileOS && rz.Device.screenType == rz.ScreenType.tablet; 10 | 11 | static bool get isDesktop => UniversalPlatform.isDesktop; 12 | 13 | static bool get isWeb => UniversalPlatform.isWeb; 14 | 15 | static bool get isAndroid => UniversalPlatform.isAndroid; 16 | 17 | static bool get isIOS => UniversalPlatform.isIOS; 18 | 19 | static bool get isFuchsia => UniversalPlatform.isFuchsia; 20 | 21 | static bool get _isMobileOS => isAndroid || isIOS || isFuchsia; 22 | 23 | static bool get isWindows => UniversalPlatform.isWindows; 24 | 25 | static bool get isLinux => UniversalPlatform.isLinux; 26 | 27 | static bool get isMacOS => UniversalPlatform.isMacOS; 28 | } 29 | -------------------------------------------------------------------------------- /example/windows/runner/flutter_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_FLUTTER_WINDOW_H_ 2 | #define RUNNER_FLUTTER_WINDOW_H_ 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include "win32_window.h" 10 | 11 | // A window that does nothing but host a Flutter view. 12 | class FlutterWindow : public Win32Window { 13 | public: 14 | // Creates a new FlutterWindow hosting a Flutter view running |project|. 15 | explicit FlutterWindow(const flutter::DartProject& project); 16 | virtual ~FlutterWindow(); 17 | 18 | protected: 19 | // Win32Window: 20 | bool OnCreate() override; 21 | void OnDestroy() override; 22 | LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, 23 | LPARAM const lparam) noexcept override; 24 | 25 | private: 26 | // The project to run. 27 | flutter::DartProject project_; 28 | 29 | // The Flutter instance hosted by this window. 30 | std::unique_ptr flutter_controller_; 31 | }; 32 | 33 | #endif // RUNNER_FLUTTER_WINDOW_H_ 34 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.2.2 2 | * Fix deprecated class issue. 3 | 4 | ## 0.2.1 5 | * Add implementation of Stacked Bars for Bar Chart Widget. 6 | 7 | ## 0.2.0 8 | * [BREAKING] New class `CartesianChartStylingData` to replace the earlier chart style. 9 | * [BREAKING] New class `CartesianChartStructureData` created. Min max values and unit count values need to be moved here. 10 | * [BREAKING] Separate Bar padding into separate value. Each `BarGroup` has a `padding`. `MultiBar` can additionally specify a `spacing` value which is used for adding space between bars of the same group. 11 | * [BREAKING] New class `AxisLabels` and `AxisLabelConfig` to provide labels along the axis lines. 12 | 13 | ## 0.1.0 14 | 15 | * Add Interaction support for charts. 16 | 17 | ## 0.0.4 18 | 19 | * Bug Fixes for Chart Widgets Styling options. 20 | 21 | ## 0.0.3 22 | 23 | * Bug Fixes for BarChart widget. 24 | * Performance Optimizations for All Chart Widgets. 25 | 26 | ## 0.0.2 27 | 28 | * Added Animation for Bar Chart 29 | * Added Animation for Pie and Donut Chart 30 | 31 | ## 0.0.1 32 | 33 | * Initial release. 34 | * Add Simple and Multi Bar Chart 35 | * Add Pie and Donut Chart 36 | -------------------------------------------------------------------------------- /lib/src/extensions/paint_objects.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui' as ui; 2 | 3 | import 'package:flutter/painting.dart'; 4 | 5 | extension PaintObjects on Canvas { 6 | // Helper method to draw given objects rotated 7 | void drawRotated(Offset center, double angle, VoidCallback drawObjects) { 8 | save(); 9 | translate(center.dx, center.dy); 10 | rotate(angle); 11 | translate(-center.dx, -center.dy); 12 | drawObjects.call(); 13 | restore(); 14 | } 15 | } 16 | 17 | extension ShaderConvert on Gradient { 18 | ui.Shader toShader(Rect shape) { 19 | switch (runtimeType) { 20 | case LinearGradient: 21 | return (this as LinearGradient).createShader( 22 | shape, 23 | textDirection: TextDirection.ltr, 24 | ); 25 | case RadialGradient: 26 | return (this as RadialGradient).createShader( 27 | shape, 28 | textDirection: TextDirection.ltr, 29 | ); 30 | case SweepGradient: 31 | return (this as SweepGradient).createShader( 32 | shape, 33 | textDirection: TextDirection.ltr, 34 | ); 35 | default: 36 | throw TypeError(); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /example/macos/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleVersion 22 | $(FLUTTER_BUILD_NUMBER) 23 | LSMinimumSystemVersion 24 | $(MACOSX_DEPLOYMENT_TARGET) 25 | NSHumanReadableCopyright 26 | $(PRODUCT_COPYRIGHT) 27 | NSMainNibFile 28 | MainMenu 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /example/graphics/main_logo_shorthand.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /lib/src/extensions/interactions.dart: -------------------------------------------------------------------------------- 1 | import 'package:chart_it/chart_it.dart'; 2 | import 'package:chart_it/src/interactions/data/touch_interactions.dart'; 3 | 4 | extension BarSnapExtension on SnapToBarConfig { 5 | bool shouldSnapToHeight(TouchInteractionType type) { 6 | switch (type) { 7 | case TouchInteractionType.tap: 8 | case TouchInteractionType.tapUp: 9 | case TouchInteractionType.tapDown: 10 | return snapToHeightOnTap; 11 | case TouchInteractionType.doubleTap: 12 | return snapToHeightOnDoubleTap; 13 | case TouchInteractionType.dragStart: 14 | case TouchInteractionType.dragUpdate: 15 | case TouchInteractionType.dragEnd: 16 | return snapToHeightOnDrag; 17 | } 18 | } 19 | 20 | bool shouldSnapToWidth(TouchInteractionType type) { 21 | switch (type) { 22 | case TouchInteractionType.tap: 23 | case TouchInteractionType.tapUp: 24 | case TouchInteractionType.tapDown: 25 | return snapToWidthOnTap; 26 | case TouchInteractionType.doubleTap: 27 | return snapToWidthOnDoubleTap; 28 | case TouchInteractionType.dragStart: 29 | case TouchInteractionType.dragUpdate: 30 | case TouchInteractionType.dragEnd: 31 | return snapToWidthOnDrag; 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /example/lib/themes/dark_theme.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | const darkTheme = ColorScheme( 4 | brightness: Brightness.dark, 5 | primary: Color(0xFFD2BBFF), 6 | onPrimary: Color(0xFF3B1D71), 7 | primaryContainer: Color(0xFF523689), 8 | onPrimaryContainer: Color(0xFFEADDFF), 9 | secondary: Color(0xFFCDC2DB), 10 | onSecondary: Color(0xFF342D40), 11 | secondaryContainer: Color(0xFF4B4358), 12 | onSecondaryContainer: Color(0xFFE9DEF8), 13 | tertiary: Color(0xFFFFB86E), 14 | onTertiary: Color(0xFF492900), 15 | tertiaryContainer: Color(0xFF693C00), 16 | onTertiaryContainer: Color(0xFFFFDCBD), 17 | error: Color(0xFFFFB4AB), 18 | errorContainer: Color(0xFF93000A), 19 | onError: Color(0xFF690005), 20 | onErrorContainer: Color(0xFFFFDAD6), 21 | background: Color(0xFF1D1B1E), 22 | onBackground: Color(0xFFE6E1E6), 23 | surface: Color(0xFF1D1B1E), 24 | onSurface: Color(0xFFE6E1E6), 25 | surfaceVariant: Color(0xFF49454E), 26 | onSurfaceVariant: Color(0xFFCBC4CF), 27 | outline: Color(0xFF948F99), 28 | onInverseSurface: Color(0xFF1D1B1E), 29 | inverseSurface: Color(0xFFE6E1E6), 30 | inversePrimary: Color(0xFF6A4FA3), 31 | shadow: Color(0xFF000000), 32 | surfaceTint: Color(0xFFD2BBFF), 33 | outlineVariant: Color(0xFF49454E), 34 | scrim: Color(0xFF000000), 35 | ); 36 | -------------------------------------------------------------------------------- /example/lib/themes/light_theme.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | const lightTheme = ColorScheme( 4 | brightness: Brightness.light, 5 | primary: Color(0xFF6A4FA3), 6 | onPrimary: Color(0xFFFFFFFF), 7 | primaryContainer: Color(0xFFEADDFF), 8 | onPrimaryContainer: Color(0xFF25005A), 9 | secondary: Color(0xFF635B70), 10 | onSecondary: Color(0xFFFFFFFF), 11 | secondaryContainer: Color(0xFFE9DEF8), 12 | onSecondaryContainer: Color(0xFF1E182B), 13 | tertiary: Color(0xFF8A5100), 14 | onTertiary: Color(0xFFFFFFFF), 15 | tertiaryContainer: Color(0xFFFFDCBD), 16 | onTertiaryContainer: Color(0xFF2C1600), 17 | error: Color(0xFFBA1A1A), 18 | errorContainer: Color(0xFFFFDAD6), 19 | onError: Color(0xFFFFFFFF), 20 | onErrorContainer: Color(0xFF410002), 21 | background: Color(0xFFFFFBFF), 22 | onBackground: Color(0xFF1D1B1E), 23 | surface: Color(0xFFFFFBFF), 24 | onSurface: Color(0xFF1D1B1E), 25 | surfaceVariant: Color(0xFFE7E0EB), 26 | onSurfaceVariant: Color(0xFF49454E), 27 | outline: Color(0xFF7A757F), 28 | onInverseSurface: Color(0xFFF5EFF4), 29 | inverseSurface: Color(0xFF323033), 30 | inversePrimary: Color(0xFFD2BBFF), 31 | shadow: Color(0xFF000000), 32 | surfaceTint: Color(0xFF6A4FA3), 33 | outlineVariant: Color(0xFFCBC4CF), 34 | scrim: Color(0xFF000000), 35 | ); 36 | -------------------------------------------------------------------------------- /lib/src/charts/data/core/radial/radial_styling.dart: -------------------------------------------------------------------------------- 1 | import 'package:chart_it/src/charts/data/core/radial/radial_data.dart'; 2 | import 'package:equatable/equatable.dart'; 3 | import 'package:flutter/material.dart'; 4 | 5 | /// Provides the Styling options for any Radial Chart. 6 | /// 7 | /// Customization Options include BackgroundColor, Start Angle and Axis Styling. 8 | class RadialChartStyle extends Equatable { 9 | /// The Background Color of the Chart. 10 | final Color backgroundColor; 11 | 12 | /// The Angle from which the Initial Data Should begin. 13 | /// Defaults to zero and starts Vertically Upright. 14 | final double initAngle; 15 | 16 | /// Styling for the Axis Lines. 17 | final RadialAxis? axis; 18 | 19 | const RadialChartStyle({ 20 | this.backgroundColor = const Color(0xFFF7FFF7), 21 | this.initAngle = 0.0, 22 | this.axis, 23 | }) : assert( 24 | initAngle >= 0.0 || initAngle < 360.0, 25 | "initAngle should be between 0 to 360 degrees", 26 | ); 27 | 28 | @override 29 | List get props => [backgroundColor, initAngle]; 30 | 31 | RadialChartStyle copyWith({ 32 | Color? backgroundColor, 33 | double? initAngle, 34 | }) { 35 | return RadialChartStyle( 36 | backgroundColor: backgroundColor ?? this.backgroundColor, 37 | initAngle: initAngle ?? this.initAngle, 38 | ); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /example/windows/runner/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "flutter_window.h" 6 | #include "utils.h" 7 | 8 | int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, 9 | _In_ wchar_t *command_line, _In_ int show_command) { 10 | // Attach to console when present (e.g., 'flutter run') or create a 11 | // new console when running with a debugger. 12 | if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { 13 | CreateAndAttachConsole(); 14 | } 15 | 16 | // Initialize COM, so that it is available for use in the library and/or 17 | // plugins. 18 | ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); 19 | 20 | flutter::DartProject project(L"data"); 21 | 22 | std::vector command_line_arguments = 23 | GetCommandLineArguments(); 24 | 25 | project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); 26 | 27 | FlutterWindow window(project); 28 | Win32Window::Point origin(10, 10); 29 | Win32Window::Size size(1280, 720); 30 | if (!window.Create(L"example", origin, size)) { 31 | return EXIT_FAILURE; 32 | } 33 | window.SetQuitOnClose(true); 34 | 35 | ::MSG msg; 36 | while (::GetMessage(&msg, nullptr, 0, 0)) { 37 | ::TranslateMessage(&msg); 38 | ::DispatchMessage(&msg); 39 | } 40 | 41 | ::CoUninitialize(); 42 | return EXIT_SUCCESS; 43 | } 44 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | pull_request: 5 | push: 6 | branches: 7 | - main 8 | - dev 9 | 10 | jobs: 11 | lint: 12 | name: Lint 13 | runs-on: ubuntu-latest 14 | steps: 15 | - uses: actions/checkout@v3 16 | - uses: subosito/flutter-action@v2 17 | with: 18 | channel: 'stable' 19 | - name: Get Dependencies 20 | run: flutter pub get 21 | - name: Format 22 | run: dart format --set-exit-if-changed . 23 | - name: Lint 24 | run: flutter analyze --fatal-infos --fatal-warnings 25 | 26 | sonar: 27 | name: SonarScan 28 | runs-on: ubuntu-latest 29 | steps: 30 | - uses: actions/checkout@v3 31 | with: 32 | fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis 33 | - uses: sonarsource/sonarqube-scan-action@master 34 | env: 35 | SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} 36 | SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} 37 | # If you wish to fail your job when the Quality Gate is red, uncomment the 38 | # following lines. This would typically be used to fail a deployment. 39 | # We do not recommend to use this in a pull request. Prefer using pull request 40 | # decoration instead. 41 | # - uses: sonarsource/sonarqube-quality-gate-action@master 42 | # timeout-minutes: 5 43 | # env: 44 | # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} 45 | -------------------------------------------------------------------------------- /example/macos/Podfile: -------------------------------------------------------------------------------- 1 | platform :osx, '10.14' 2 | 3 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 4 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 5 | 6 | project 'Runner', { 7 | 'Debug' => :debug, 8 | 'Profile' => :release, 9 | 'Release' => :release, 10 | } 11 | 12 | def flutter_root 13 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) 14 | unless File.exist?(generated_xcode_build_settings_path) 15 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" 16 | end 17 | 18 | File.foreach(generated_xcode_build_settings_path) do |line| 19 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 20 | return matches[1].strip if matches 21 | end 22 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" 23 | end 24 | 25 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 26 | 27 | flutter_macos_podfile_setup 28 | 29 | target 'Runner' do 30 | use_frameworks! 31 | use_modular_headers! 32 | 33 | flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) 34 | end 35 | 36 | post_install do |installer| 37 | installer.pods_project.targets.each do |target| 38 | flutter_additional_macos_build_settings(target) 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /example/ios/Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | # platform :ios, '11.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 flutter_root 14 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) 15 | unless File.exist?(generated_xcode_build_settings_path) 16 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" 17 | end 18 | 19 | File.foreach(generated_xcode_build_settings_path) do |line| 20 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 21 | return matches[1].strip if matches 22 | end 23 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" 24 | end 25 | 26 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 27 | 28 | flutter_ios_podfile_setup 29 | 30 | target 'Runner' do 31 | use_frameworks! 32 | use_modular_headers! 33 | 34 | flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) 35 | end 36 | 37 | post_install do |installer| 38 | installer.pods_project.targets.each do |target| 39 | flutter_additional_ios_build_settings(target) 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /lib/src/charts/data/bars/simple_bar.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui'; 2 | 3 | import 'package:chart_it/src/charts/data/bars/bar_data.dart'; 4 | import 'package:chart_it/src/charts/data/bars/bar_data_style.dart'; 5 | import 'package:chart_it/src/charts/data/bars/bar_group.dart'; 6 | 7 | /// Defines a Simple singular Bar with a Single Y-Value 8 | /// 9 | /// See Also: [BarGroup] 10 | class SimpleBar extends BarGroup { 11 | /// The Y-Value data ([BarData]) for this Bar. 12 | final BarData yValue; 13 | 14 | /// Defines a Simple singular Bar with a Single Y-Value 15 | /// 16 | /// See Also: [BarGroup] 17 | SimpleBar({ 18 | required super.xValue, 19 | required this.yValue, 20 | super.style, 21 | super.padding, 22 | }); 23 | 24 | /// Lerps between two [SimpleBar]s for a factor [t] 25 | static SimpleBar lerp(BarGroup? current, BarGroup target, double t) { 26 | if ((current is SimpleBar?) && target is SimpleBar) { 27 | return SimpleBar( 28 | xValue: lerpDouble(current?.xValue, target.xValue, t) as num, 29 | yValue: BarData.lerp(current?.yValue, target.yValue, t), 30 | style: BarDataStyle.lerp( 31 | current?.style, 32 | target.style, 33 | t, 34 | ), 35 | padding: lerpDouble(current?.padding, target.padding, t) ?? 0.0, 36 | ); 37 | } else { 38 | throw Exception('Both current & target data should be of same series!'); 39 | } 40 | } 41 | 42 | @override 43 | List get props => [xValue, yValue, style, padding]; 44 | } 45 | -------------------------------------------------------------------------------- /lib/src/charts/data/core/shared/fuzziness.dart: -------------------------------------------------------------------------------- 1 | import 'package:equatable/equatable.dart'; 2 | 3 | /// {@template Fuzziness} 4 | /// [Fuzziness] extends the boundaries for touch detection. 5 | /// 6 | /// For example: If [Fuzziness.all(10)] is applied, the area for touch detection 7 | /// will be increased by 10 in all directions. 8 | /// {@endtemplate} 9 | class Fuzziness extends Equatable { 10 | final double top; 11 | final double bottom; 12 | final double left; 13 | final double right; 14 | 15 | /// {@macro Fuzziness} 16 | const Fuzziness({ 17 | required this.top, 18 | required this.bottom, 19 | required this.left, 20 | required this.right, 21 | }); 22 | 23 | /// {@macro Fuzziness} 24 | const Fuzziness.only({ 25 | this.top = 0, 26 | this.bottom = 0, 27 | this.left = 0, 28 | this.right = 0, 29 | }); 30 | 31 | /// {@macro Fuzziness} 32 | const Fuzziness.all(double fuzziness) 33 | : top = fuzziness, 34 | bottom = fuzziness, 35 | left = fuzziness, 36 | right = fuzziness; 37 | 38 | /// {@macro Fuzziness} 39 | const Fuzziness.symmetric({ 40 | required double width, 41 | required double height, 42 | }) : top = height, 43 | bottom = height, 44 | left = width, 45 | right = width; 46 | 47 | /// {@macro Fuzziness} 48 | const Fuzziness.zero() 49 | : top = 0, 50 | bottom = 0, 51 | left = 0, 52 | right = 0; 53 | 54 | @override 55 | List get props => [left, right, top, bottom]; 56 | } 57 | -------------------------------------------------------------------------------- /example/lib/showcase.dart: -------------------------------------------------------------------------------- 1 | import 'package:example/screens/navigation/multi_platform_content.dart'; 2 | import 'package:example/themes/dark_theme.dart'; 3 | import 'package:example/themes/light_theme.dart'; 4 | import 'package:flutter/material.dart'; 5 | import 'package:google_fonts/google_fonts.dart'; 6 | import 'package:responsive_sizer/responsive_sizer.dart'; 7 | 8 | class ShowcaseApp extends StatefulWidget { 9 | const ShowcaseApp({ 10 | Key? key, 11 | }) : super(key: key); 12 | 13 | @override 14 | State createState() => _ShowcaseAppState(); 15 | } 16 | 17 | class _ShowcaseAppState extends State { 18 | @override 19 | Widget build(BuildContext context) { 20 | return ResponsiveSizer( 21 | builder: (context, orientation, deviceType) { 22 | return MaterialApp( 23 | title: 'Flutter Charts', 24 | debugShowCheckedModeBanner: false, 25 | themeMode: ThemeMode.system, 26 | theme: ThemeData( 27 | useMaterial3: true, 28 | colorScheme: lightTheme, 29 | textTheme: GoogleFonts.poppinsTextTheme( 30 | Theme.of(context).textTheme, 31 | ), 32 | ), 33 | darkTheme: ThemeData( 34 | useMaterial3: true, 35 | colorScheme: darkTheme, 36 | textTheme: GoogleFonts.poppinsTextTheme( 37 | Theme.of(context).textTheme, 38 | ), 39 | ), 40 | home: const MultiPlatformContent(), 41 | ); 42 | }, 43 | ); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /lib/src/charts/painters/cartesian/cartesian_chart_painter.dart: -------------------------------------------------------------------------------- 1 | import 'package:chart_it/src/charts/data/core.dart'; 2 | import 'package:chart_it/src/charts/data/core/cartesian/cartesian_data_internal.dart'; 3 | import 'package:chart_it/src/charts/data/core/cartesian/cartesian_grid_units.dart'; 4 | import 'package:chart_it/src/charts/state/bar_series_state.dart'; 5 | import 'package:chart_it/src/charts/state/painting_state.dart'; 6 | import 'package:flutter/material.dart'; 7 | 8 | class CartesianChartPainter { 9 | CartesianChartStylingData style; 10 | CartesianChartStructureData structure; 11 | List states; 12 | CartesianGridUnitsData gridUnitsData; 13 | 14 | CartesianChartPainter({ 15 | required this.style, 16 | required this.states, 17 | required this.structure, 18 | required this.gridUnitsData, 19 | }); 20 | 21 | void paint(Canvas canvas, Size size, 22 | CartesianPaintingGeometryData paintingGeometryData) { 23 | // we will construct a painter and handover 24 | // the canvas to them to draw the data sets into the required chart 25 | for (var i = 0; i < states.length; i++) { 26 | var state = states[i]; 27 | if (state is BarSeriesState) { 28 | state.painter.paint( 29 | lerpSeries: state.data, 30 | canvas: canvas, 31 | chart: paintingGeometryData, 32 | config: state.config, 33 | style: style, 34 | ); 35 | } else { 36 | throw ArgumentError('No State of this type exists!'); 37 | } 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /example/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # This file configures the analyzer, which statically analyzes Dart code to 2 | # check for errors, warnings, and lints. 3 | # 4 | # The issues identified by the analyzer are surfaced in the UI of Dart-enabled 5 | # IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be 6 | # invoked from the command line by running `flutter analyze`. 7 | 8 | # The following line activates a set of recommended lints for Flutter apps, 9 | # packages, and plugins designed to encourage good coding practices. 10 | include: package:flutter_lints/flutter.yaml 11 | 12 | linter: 13 | # The lint rules applied to this project can be customized in the 14 | # section below to disable rules from the `package:flutter_lints/flutter.yaml` 15 | # included above or to enable additional rules. A list of all available lints 16 | # and their documentation is published at 17 | # https://dart-lang.github.io/linter/lints/index.html. 18 | # 19 | # Instead of disabling a lint rule for the entire project in the 20 | # section below, it can also be suppressed for a single line of code 21 | # or a specific dart file by using the `// ignore: name_of_lint` and 22 | # `// ignore_for_file: name_of_lint` syntax on the line or in the file 23 | # producing the lint. 24 | rules: 25 | # avoid_print: false # Uncomment to disable the `avoid_print` rule 26 | # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule 27 | 28 | # Additional information about this file can be found at 29 | # https://dart.dev/guides/language/analysis-options 30 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2023, Wednesday Solutions 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, this 9 | list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright notice, 12 | this list of conditions and the following disclaimer in the documentation 13 | and/or other materials provided with the distribution. 14 | 15 | 3. Neither the name of the copyright holder nor the names of its 16 | contributors may be used to endorse or promote products derived from 17 | this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 23 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images": [ 3 | { 4 | "size": "16x16", 5 | "idiom": "mac", 6 | "filename": "app_icon_16.png", 7 | "scale": "1x" 8 | }, 9 | { 10 | "size": "16x16", 11 | "idiom": "mac", 12 | "filename": "app_icon_32.png", 13 | "scale": "2x" 14 | }, 15 | { 16 | "size": "32x32", 17 | "idiom": "mac", 18 | "filename": "app_icon_32.png", 19 | "scale": "1x" 20 | }, 21 | { 22 | "size": "32x32", 23 | "idiom": "mac", 24 | "filename": "app_icon_64.png", 25 | "scale": "2x" 26 | }, 27 | { 28 | "size": "128x128", 29 | "idiom": "mac", 30 | "filename": "app_icon_128.png", 31 | "scale": "1x" 32 | }, 33 | { 34 | "size": "128x128", 35 | "idiom": "mac", 36 | "filename": "app_icon_256.png", 37 | "scale": "2x" 38 | }, 39 | { 40 | "size": "256x256", 41 | "idiom": "mac", 42 | "filename": "app_icon_256.png", 43 | "scale": "1x" 44 | }, 45 | { 46 | "size": "256x256", 47 | "idiom": "mac", 48 | "filename": "app_icon_512.png", 49 | "scale": "2x" 50 | }, 51 | { 52 | "size": "512x512", 53 | "idiom": "mac", 54 | "filename": "app_icon_512.png", 55 | "scale": "1x" 56 | }, 57 | { 58 | "size": "512x512", 59 | "idiom": "mac", 60 | "filename": "app_icon_1024.png", 61 | "scale": "2x" 62 | } 63 | ], 64 | "info": { 65 | "version": 1, 66 | "author": "xcode" 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /lib/src/charts/data/core/shared/chart_text_style.dart: -------------------------------------------------------------------------------- 1 | import 'package:equatable/equatable.dart'; 2 | import 'package:flutter/cupertino.dart'; 3 | 4 | /// Provides Uniform Text Styling across All Charts 5 | class ChartTextStyle extends Equatable { 6 | /// Styling for the Text 7 | final TextStyle? textStyle; 8 | 9 | /// Max Lines to Show for a Text. 10 | /// Defaults to 1 11 | final int maxLines; 12 | 13 | /// Show/Hide Ellipses on TextOverflow 14 | final bool ellipsize; 15 | 16 | /// Alignment of the Text 17 | final TextAlign align; 18 | 19 | const ChartTextStyle({ 20 | this.textStyle, 21 | this.align = TextAlign.center, 22 | this.maxLines = 1, 23 | this.ellipsize = true, 24 | }); 25 | 26 | static ChartTextStyle? lerp( 27 | ChartTextStyle? current, 28 | ChartTextStyle? target, 29 | double t, 30 | ) { 31 | if (target != null) { 32 | return ChartTextStyle( 33 | textStyle: target.textStyle, 34 | maxLines: target.maxLines, 35 | align: target.align, 36 | ellipsize: target.ellipsize, 37 | ); 38 | } 39 | return null; 40 | } 41 | 42 | @override 43 | List get props => [textStyle, maxLines, ellipsize, align]; 44 | 45 | ChartTextStyle copyWith({ 46 | TextStyle? textStyle, 47 | int? maxLines, 48 | bool? ellipsize, 49 | TextAlign? align, 50 | }) { 51 | return ChartTextStyle( 52 | textStyle: textStyle ?? this.textStyle, 53 | maxLines: maxLines ?? this.maxLines, 54 | ellipsize: ellipsize ?? this.ellipsize, 55 | align: align ?? this.align, 56 | ); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /lib/src/charts/widgets/cartesian_chart.dart: -------------------------------------------------------------------------------- 1 | import 'package:chart_it/src/charts/data/core.dart'; 2 | import 'package:flutter/widgets.dart'; 3 | 4 | abstract class CartesianChart extends StatefulWidget { 5 | /// Width of the Chart 6 | final double? width; 7 | 8 | /// Height of the Chart 9 | final double? height; 10 | 11 | /// Animates the Charts from zero values to given Data when the 12 | /// Chart loads for the first time. 13 | /// 14 | /// Defaults to true. 15 | final bool animateOnLoad; 16 | 17 | /// Controls if the charts should auto animate any updates to the data 18 | /// 19 | /// Defaults to true. 20 | final bool animateOnUpdate; 21 | 22 | /// The Duration for which the chart should animate 23 | final Duration animationDuration; 24 | 25 | /// A custom Animation controller to drive the chart animations 26 | final AnimationController? animation; 27 | 28 | /// Styling data to alter the visual appearance of the chart. 29 | final CartesianChartStylingData chartStylingData; 30 | 31 | /// Data to alter the structuring of the chart. 32 | /// Such as max values of the chart and the value of a single grid unit. 33 | final CartesianChartStructureData chartStructureData; 34 | 35 | /// Builder to create labels along all the axis. 36 | final AxisLabels axisLabels; 37 | 38 | const CartesianChart({ 39 | Key? key, 40 | this.width, 41 | this.height, 42 | required this.animateOnLoad, 43 | required this.animateOnUpdate, 44 | required this.animationDuration, 45 | this.animation, 46 | this.chartStylingData = const CartesianChartStylingData(), 47 | this.chartStructureData = const CartesianChartStructureData(), 48 | this.axisLabels = const AxisLabels(), 49 | }) : super(key: key); 50 | } 51 | -------------------------------------------------------------------------------- /lib/src/charts/state/painting_state.dart: -------------------------------------------------------------------------------- 1 | import 'package:chart_it/src/animations/lerps.dart'; 2 | import 'package:chart_it/src/charts/state/bar_series_state.dart'; 3 | import 'package:chart_it/src/charts/state/pie_series_state.dart'; 4 | import 'package:equatable/equatable.dart'; 5 | 6 | abstract class PaintingState with EquatableMixin { 7 | SERIES data; 8 | CONFIG config; 9 | PAINTER painter; 10 | 11 | PaintingState({ 12 | required this.data, 13 | required this.config, 14 | required this.painter, 15 | }); 16 | 17 | static PaintingState lerp( 18 | PaintingState? current, 19 | PaintingState target, 20 | double t, 21 | ) { 22 | final currentValue = 23 | current == null || current.runtimeType != target.runtimeType 24 | ? null 25 | : current; 26 | return target._when( 27 | barState: () => BarSeriesState.lerp(currentValue, target, t), 28 | pieState: () => PieSeriesState.lerp(currentValue, target, t), 29 | ); 30 | } 31 | 32 | /// Lerps between two Lists of [PaintingState] for a factor [t]. 33 | static List lerpStateList( 34 | List? current, 35 | List target, 36 | double t, 37 | ) => 38 | lerpList(current, target, t, lerp: lerp); 39 | 40 | /// Helper method to capture [runtimeType] checks for the subtype of 41 | /// [PaintingState] object, and provides callback method for the matching type. 42 | T _when({ 43 | required T Function() barState, 44 | required T Function() pieState, 45 | }) { 46 | switch (runtimeType) { 47 | case BarSeriesState: 48 | return barState(); 49 | case PieSeriesState: 50 | return pieState(); 51 | default: 52 | throw TypeError(); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /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. 5 | 6 | version: 7 | revision: 32fb2f948e9b1a2d1b876ebee3558be7f51b457f 8 | channel: stable 9 | 10 | project_type: app 11 | 12 | # Tracks metadata for the flutter migrate command 13 | migration: 14 | platforms: 15 | - platform: root 16 | create_revision: 32fb2f948e9b1a2d1b876ebee3558be7f51b457f 17 | base_revision: 32fb2f948e9b1a2d1b876ebee3558be7f51b457f 18 | - platform: android 19 | create_revision: 32fb2f948e9b1a2d1b876ebee3558be7f51b457f 20 | base_revision: 32fb2f948e9b1a2d1b876ebee3558be7f51b457f 21 | - platform: ios 22 | create_revision: 32fb2f948e9b1a2d1b876ebee3558be7f51b457f 23 | base_revision: 32fb2f948e9b1a2d1b876ebee3558be7f51b457f 24 | - platform: linux 25 | create_revision: 32fb2f948e9b1a2d1b876ebee3558be7f51b457f 26 | base_revision: 32fb2f948e9b1a2d1b876ebee3558be7f51b457f 27 | - platform: macos 28 | create_revision: 32fb2f948e9b1a2d1b876ebee3558be7f51b457f 29 | base_revision: 32fb2f948e9b1a2d1b876ebee3558be7f51b457f 30 | - platform: web 31 | create_revision: 32fb2f948e9b1a2d1b876ebee3558be7f51b457f 32 | base_revision: 32fb2f948e9b1a2d1b876ebee3558be7f51b457f 33 | - platform: windows 34 | create_revision: 32fb2f948e9b1a2d1b876ebee3558be7f51b457f 35 | base_revision: 32fb2f948e9b1a2d1b876ebee3558be7f51b457f 36 | 37 | # User provided section 38 | 39 | # List of Local paths (relative to this file) that should be 40 | # ignored by the migrate tool. 41 | # 42 | # Files that are not part of the templates will be ignored by default. 43 | unmanaged_files: 44 | - 'lib/main.dart' 45 | - 'ios/Runner.xcodeproj/project.pbxproj' 46 | -------------------------------------------------------------------------------- /lib/src/extensions/data_conversions.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | 3 | import 'package:chart_it/src/charts/data/bars/bar_data.dart'; 4 | import 'package:chart_it/src/charts/data/bars/bar_group.dart'; 5 | import 'package:chart_it/src/charts/data/bars/multi_bar.dart'; 6 | import 'package:chart_it/src/charts/data/bars/simple_bar.dart'; 7 | import 'package:chart_it/src/charts/data/core/cartesian/cartesian_data.dart'; 8 | import 'package:chart_it/src/charts/data/core/radial/radial_data.dart'; 9 | import 'package:flutter/cupertino.dart'; 10 | 11 | extension YValueGetter on BarGroup { 12 | // Helper method to strip group data into data object with raw values 13 | List yValues() { 14 | switch (runtimeType) { 15 | case SimpleBar: 16 | return [(this as SimpleBar).yValue]; 17 | case MultiBar: 18 | return (this as MultiBar).yValues; 19 | default: 20 | throw ArgumentError('Y values must be present!'); 21 | } 22 | } 23 | } 24 | 25 | extension CartesianIterators on List { 26 | int maxIterations() { 27 | var count = 0; 28 | forEach((series) { 29 | series.when( 30 | onBarSeries: (series) { 31 | count = max(count, series.barData.length); 32 | }, 33 | ); 34 | }); 35 | return count; 36 | } 37 | } 38 | 39 | extension RadialIterators on List { 40 | int maxIterations() { 41 | var count = 0; 42 | forEach((series) { 43 | series.when( 44 | onPieSeries: (series) { 45 | count = max(count, series.slices.length); 46 | }, 47 | ); 48 | }); 49 | return count; 50 | } 51 | } 52 | 53 | EdgeInsets maxInsets(EdgeInsets a, EdgeInsets b) { 54 | return EdgeInsets.only( 55 | left: max(a.left, b.left), 56 | right: max(a.right, b.right), 57 | top: max(a.top, b.top), 58 | bottom: max(a.bottom, b.bottom), 59 | ); 60 | } 61 | -------------------------------------------------------------------------------- /example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 10 | 18 | 22 | 25 | 26 | 27 | 28 | 29 | 30 | 32 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /example/ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleDisplayName 8 | Example 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | example 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | $(FLUTTER_BUILD_NUMBER) 25 | LSRequiresIPhoneOS 26 | 27 | UILaunchStoryboardName 28 | LaunchScreen 29 | UIMainStoryboardFile 30 | Main 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | UIViewControllerBasedStatusBarAppearance 45 | 46 | CADisableMinimumFrameDurationOnPhone 47 | 48 | UIApplicationSupportsIndirectInputEvents 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: chart_it 2 | description: A customisable charts library with seamless animations for flutter. 3 | version: 0.2.2 4 | homepage: https://flutter.wednesday.is/charts/chart-it 5 | repository: https://github.com/wednesday-solutions/chart_it 6 | 7 | environment: 8 | sdk: ">=3.0.0 <4.0.0" 9 | 10 | dependencies: 11 | flutter: 12 | sdk: flutter 13 | equatable: ^2.0.5 14 | vector_math: ^2.1.4 15 | 16 | dev_dependencies: 17 | flutter_test: 18 | sdk: flutter 19 | flutter_lints: ^2.0.1 20 | 21 | # For information on the generic Dart part of this file, see the 22 | # following page: https://dart.dev/tools/pub/pubspec 23 | 24 | # The following section is specific to Flutter packages. 25 | flutter: 26 | 27 | # To add assets to your package, add an assets section, like this: 28 | # assets: 29 | # - images/a_dot_burr.jpeg 30 | # - images/a_dot_ham.jpeg 31 | # 32 | # For details regarding assets in packages, see 33 | # https://flutter.dev/assets-and-images/#from-packages 34 | # 35 | # An image asset can refer to one or more resolution-specific "variants", see 36 | # https://flutter.dev/assets-and-images/#resolution-aware 37 | 38 | # To add custom fonts to your package, add a fonts section here, 39 | # in this "flutter" section. Each entry in this list should have a 40 | # "family" key with the font family name, and a "fonts" key with a 41 | # list giving the asset and other descriptors for the font. For 42 | # example: 43 | # fonts: 44 | # - family: Schyler 45 | # fonts: 46 | # - asset: fonts/Schyler-Regular.ttf 47 | # - asset: fonts/Schyler-Italic.ttf 48 | # style: italic 49 | # - family: Trajan Pro 50 | # fonts: 51 | # - asset: fonts/TrajanPro.ttf 52 | # - asset: fonts/TrajanPro_Bold.ttf 53 | # weight: 700 54 | # 55 | # For details regarding fonts in packages, see 56 | # https://flutter.dev/custom-fonts/#from-packages 57 | -------------------------------------------------------------------------------- /example/windows/runner/utils.cpp: -------------------------------------------------------------------------------- 1 | #include "utils.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | void CreateAndAttachConsole() { 11 | if (::AllocConsole()) { 12 | FILE *unused; 13 | if (freopen_s(&unused, "CONOUT$", "w", stdout)) { 14 | _dup2(_fileno(stdout), 1); 15 | } 16 | if (freopen_s(&unused, "CONOUT$", "w", stderr)) { 17 | _dup2(_fileno(stdout), 2); 18 | } 19 | std::ios::sync_with_stdio(); 20 | FlutterDesktopResyncOutputStreams(); 21 | } 22 | } 23 | 24 | std::vector GetCommandLineArguments() { 25 | // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. 26 | int argc; 27 | wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); 28 | if (argv == nullptr) { 29 | return std::vector(); 30 | } 31 | 32 | std::vector command_line_arguments; 33 | 34 | // Skip the first argument as it's the binary name. 35 | for (int i = 1; i < argc; i++) { 36 | command_line_arguments.push_back(Utf8FromUtf16(argv[i])); 37 | } 38 | 39 | ::LocalFree(argv); 40 | 41 | return command_line_arguments; 42 | } 43 | 44 | std::string Utf8FromUtf16(const wchar_t* utf16_string) { 45 | if (utf16_string == nullptr) { 46 | return std::string(); 47 | } 48 | int target_length = ::WideCharToMultiByte( 49 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 50 | -1, nullptr, 0, nullptr, nullptr); 51 | std::string utf8_string; 52 | if (target_length == 0 || target_length > utf8_string.max_size()) { 53 | return utf8_string; 54 | } 55 | utf8_string.resize(target_length); 56 | int converted_length = ::WideCharToMultiByte( 57 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 58 | -1, utf8_string.data(), 59 | target_length, nullptr, nullptr); 60 | if (converted_length == 0) { 61 | return std::string(); 62 | } 63 | return utf8_string; 64 | } 65 | -------------------------------------------------------------------------------- /example/windows/runner/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | project(runner LANGUAGES CXX) 3 | 4 | # Define the application target. To change its name, change BINARY_NAME in the 5 | # top-level CMakeLists.txt, not the value here, or `flutter run` will no longer 6 | # work. 7 | # 8 | # Any new source files that you add to the application should be added here. 9 | add_executable(${BINARY_NAME} WIN32 10 | "flutter_window.cpp" 11 | "main.cpp" 12 | "utils.cpp" 13 | "win32_window.cpp" 14 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 15 | "Runner.rc" 16 | "runner.exe.manifest" 17 | ) 18 | 19 | # Apply the standard set of build settings. This can be removed for applications 20 | # that need different build settings. 21 | apply_standard_settings(${BINARY_NAME}) 22 | 23 | # Add preprocessor definitions for the build version. 24 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") 25 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") 26 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") 27 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") 28 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") 29 | 30 | # Disable Windows macros that collide with C++ standard library functions. 31 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") 32 | 33 | # Add dependency libraries and include directories. Add any application-specific 34 | # dependencies here. 35 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) 36 | target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") 37 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") 38 | 39 | # Run the Flutter tool portions of the build. This must not be removed. 40 | add_dependencies(${BINARY_NAME} flutter_assemble) 41 | -------------------------------------------------------------------------------- /example/windows/runner/flutter_window.cpp: -------------------------------------------------------------------------------- 1 | #include "flutter_window.h" 2 | 3 | #include 4 | 5 | #include "flutter/generated_plugin_registrant.h" 6 | 7 | FlutterWindow::FlutterWindow(const flutter::DartProject& project) 8 | : project_(project) {} 9 | 10 | FlutterWindow::~FlutterWindow() {} 11 | 12 | bool FlutterWindow::OnCreate() { 13 | if (!Win32Window::OnCreate()) { 14 | return false; 15 | } 16 | 17 | RECT frame = GetClientArea(); 18 | 19 | // The size here must match the window dimensions to avoid unnecessary surface 20 | // creation / destruction in the startup path. 21 | flutter_controller_ = std::make_unique( 22 | frame.right - frame.left, frame.bottom - frame.top, project_); 23 | // Ensure that basic setup of the controller was successful. 24 | if (!flutter_controller_->engine() || !flutter_controller_->view()) { 25 | return false; 26 | } 27 | RegisterPlugins(flutter_controller_->engine()); 28 | SetChildContent(flutter_controller_->view()->GetNativeWindow()); 29 | 30 | flutter_controller_->engine()->SetNextFrameCallback([&]() { 31 | this->Show(); 32 | }); 33 | 34 | return true; 35 | } 36 | 37 | void FlutterWindow::OnDestroy() { 38 | if (flutter_controller_) { 39 | flutter_controller_ = nullptr; 40 | } 41 | 42 | Win32Window::OnDestroy(); 43 | } 44 | 45 | LRESULT 46 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message, 47 | WPARAM const wparam, 48 | LPARAM const lparam) noexcept { 49 | // Give Flutter, including plugins, an opportunity to handle window messages. 50 | if (flutter_controller_) { 51 | std::optional result = 52 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, 53 | lparam); 54 | if (result) { 55 | return *result; 56 | } 57 | } 58 | 59 | switch (message) { 60 | case WM_FONTCHANGE: 61 | flutter_controller_->engine()->ReloadSystemFonts(); 62 | break; 63 | } 64 | 65 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam); 66 | } 67 | -------------------------------------------------------------------------------- /lib/src/charts/data/core/cartesian/cartesian_range.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui'; 2 | 3 | import 'package:equatable/equatable.dart'; 4 | 5 | /// Defines a Callback that returns a [CartesianRangeResult] for the 6 | /// provided [context] of type [CartesianRangeContext]. 7 | typedef CalculateCartesianRange = CartesianRangeResult Function( 8 | CartesianRangeContext context, 9 | ); 10 | 11 | /// Wraps the Minimum & Maximum values for X & Y values in a Cartesian Chart 12 | class CartesianRangeContext with EquatableMixin { 13 | double maxX; 14 | double maxY; 15 | double minX; 16 | double minY; 17 | 18 | CartesianRangeContext(this.maxX, this.maxY, this.minX, this.minY); 19 | 20 | @override 21 | List get props => [maxX, minX, maxY, minY]; 22 | } 23 | 24 | /// A Result Wrapper that provides the X & Y Ranges and the unit values. 25 | class CartesianRangeResult with EquatableMixin { 26 | double xUnitValue; 27 | double yUnitValue; 28 | 29 | double maxXRange; 30 | double maxYRange; 31 | double minXRange; 32 | double minYRange; 33 | 34 | CartesianRangeResult({ 35 | required this.xUnitValue, 36 | required this.yUnitValue, 37 | required this.maxXRange, 38 | required this.maxYRange, 39 | required this.minXRange, 40 | required this.minYRange, 41 | }); 42 | 43 | static CartesianRangeResult lerp( 44 | CartesianRangeResult? current, 45 | CartesianRangeResult target, 46 | double t, 47 | ) { 48 | return CartesianRangeResult( 49 | xUnitValue: lerpDouble(current?.xUnitValue, target.xUnitValue, t) ?? 1, 50 | yUnitValue: lerpDouble(current?.yUnitValue, target.yUnitValue, t) ?? 1, 51 | maxXRange: lerpDouble(current?.maxXRange, target.maxXRange, t) ?? 0, 52 | maxYRange: lerpDouble(current?.maxYRange, target.maxYRange, t) ?? 0, 53 | minXRange: lerpDouble(current?.minXRange, target.minXRange, t) ?? 0, 54 | minYRange: lerpDouble(current?.minYRange, target.minYRange, t) ?? 0, 55 | ); 56 | } 57 | 58 | @override 59 | List get props => [ 60 | xUnitValue, 61 | yUnitValue, 62 | maxXRange, 63 | maxYRange, 64 | minXRange, 65 | minYRange, 66 | ]; 67 | } 68 | -------------------------------------------------------------------------------- /lib/src/charts/data/pie/pie_interactions.dart: -------------------------------------------------------------------------------- 1 | import 'package:chart_it/chart_it.dart'; 2 | import 'package:chart_it/src/interactions/interactions.dart'; 3 | import 'package:equatable/equatable.dart'; 4 | import 'package:flutter/gestures.dart'; 5 | 6 | /// {@template PieInteractionEvents} 7 | /// 8 | /// [PieInteractionEvents] the interaction behaviour and callbacks for [PieChart] 9 | /// 10 | /// {@endtemplate} 11 | class PieInteractionEvents extends TouchInteractionEvents 12 | with EquatableMixin { 13 | /// {@macro PieInteractionEvents} 14 | const PieInteractionEvents({ 15 | required super.isEnabled, 16 | super.onTap, 17 | super.onTapDown, 18 | super.onTapUp, 19 | super.onDoubleTap, 20 | super.onDragStart, 21 | super.onDrag, 22 | super.onDragEnd, 23 | }); 24 | 25 | @override 26 | List get props => [isEnabled]; 27 | } 28 | 29 | /// {@template PieInteractionResult} 30 | /// [PieInteractionResult] represents the result of an interaction with the [PieChart]. 31 | /// 32 | /// See also: 33 | /// * [TouchInteractionType] 34 | /// {@endtemplate} 35 | class PieInteractionResult extends TouchInteractionResult with EquatableMixin { 36 | /// The [SliceData] matching the interaction. 37 | final SliceData slice; 38 | 39 | /// The index of [slice] in [PieSeries]. 40 | final int sliceDataIndex; 41 | 42 | /// {@macro PieInteractionResult} 43 | PieInteractionResult({ 44 | required this.slice, 45 | required this.sliceDataIndex, 46 | required super.localPosition, 47 | required super.interactionType, 48 | }); 49 | 50 | PieInteractionResult copyWith({ 51 | SliceData? slice, 52 | int? sliceDataIndex, 53 | Offset? localPosition, 54 | TouchInteractionType? interactionType, 55 | }) { 56 | return PieInteractionResult( 57 | slice: slice ?? this.slice, 58 | sliceDataIndex: sliceDataIndex ?? this.sliceDataIndex, 59 | localPosition: localPosition ?? this.localPosition, 60 | interactionType: interactionType ?? this.interactionType, 61 | ); 62 | } 63 | 64 | @override 65 | List get props => 66 | [slice, sliceDataIndex, localPosition, interactionType]; 67 | } 68 | -------------------------------------------------------------------------------- /lib/src/charts/data/core/cartesian/cartesian_data.dart: -------------------------------------------------------------------------------- 1 | import 'package:chart_it/src/charts/data/bars/bar_series.dart'; 2 | import 'package:chart_it/src/interactions/interactions.dart'; 3 | import 'package:equatable/equatable.dart'; 4 | 5 | /// Callback for Mapping a String Value to a Label 6 | typedef LabelMapper = String Function(num value); 7 | 8 | /// Orientation of the Chart 9 | enum CartesianChartOrientation { 10 | vertical, 11 | // Horizontal not yet supported 12 | // horizontal, 13 | } 14 | 15 | /// Base Series for any type of Data which can be plotted 16 | /// on a Cartesian Chart. 17 | abstract class CartesianSeries 18 | with EquatableMixin { 19 | final E interactionEvents; 20 | 21 | CartesianSeries({required this.interactionEvents}); 22 | 23 | /// Checks the Subclass Type and returns the casted instance 24 | /// to the matched callback. All callbacks must be provided. 25 | T when({ 26 | required T Function(BarSeries series) onBarSeries, 27 | }) { 28 | switch (runtimeType) { 29 | case BarSeries: 30 | return onBarSeries(this as BarSeries); 31 | default: 32 | throw TypeError(); 33 | } 34 | } 35 | 36 | /// Checks the Subclass Type and returns the casted instance 37 | /// to the matched callback. 38 | /// 39 | /// [orElse] is triggered if the callback for the matched type is not provided. 40 | T maybeWhen({ 41 | T Function(BarSeries series)? onBarSeries, 42 | required T Function() orElse, 43 | }) { 44 | switch (runtimeType) { 45 | case BarSeries: 46 | return onBarSeries?.call(this as BarSeries) ?? orElse(); 47 | default: 48 | throw TypeError(); 49 | } 50 | } 51 | 52 | /// Static method to Check the Subclass Type when we do not have 53 | /// an instance for an object extending this class. 54 | /// 55 | /// Does the same operation as [maybeWhen]. 56 | static T whenType( 57 | Type type, { 58 | T Function()? onBarSeries, 59 | required T Function() orElse, 60 | }) { 61 | switch (type) { 62 | case BarSeries: 63 | return onBarSeries?.call() ?? orElse(); 64 | default: 65 | throw TypeError(); 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /lib/src/charts/data/pie/slice_data.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui'; 2 | 3 | import 'package:chart_it/src/animations/lerps.dart'; 4 | import 'package:chart_it/src/charts/data/core/radial/radial_data.dart'; 5 | import 'package:chart_it/src/charts/data/core/shared/chart_text_style.dart'; 6 | import 'package:chart_it/src/charts/data/pie/slice_data_style.dart'; 7 | import 'package:equatable/equatable.dart'; 8 | 9 | /// Defines the Data of a Pie Slice in the Pie/Donut chart 10 | /// 11 | /// Holds the Numeric Value, label and styling for this Slice 12 | class SliceData extends Equatable { 13 | /// Sets uniform styling for the Pie/Slice in this [SliceData]. 14 | /// 15 | /// {@macro slice_styling_order} 16 | final SliceDataStyle? style; 17 | 18 | /// Text Styling for the [label]. 19 | final ChartTextStyle? labelStyle; 20 | 21 | /// Callback for Label for the Style 22 | final SliceMapper? label; 23 | 24 | /// Numeric Value of this Slice. 25 | final num value; 26 | 27 | /// Defines the Data of a Pie Slice in the Pie/Donut chart 28 | /// 29 | /// Holds the Numeric Value, label and styling for this Slice 30 | const SliceData({ 31 | required this.value, 32 | this.labelStyle, 33 | this.label, 34 | this.style, 35 | }); 36 | 37 | /// Lerps between two [SliceData] values for a factor [t] 38 | static SliceData lerp( 39 | SliceData? current, 40 | SliceData target, 41 | double donutRadius, 42 | double t, 43 | ) { 44 | return SliceData( 45 | value: lerpDouble(current?.value, target.value, t) as num, 46 | labelStyle: ChartTextStyle.lerp( 47 | current?.labelStyle, 48 | target.labelStyle, 49 | t, 50 | ), 51 | label: target.label, 52 | style: SliceDataStyle.lerp(current?.style, target.style, donutRadius, t), 53 | ); 54 | } 55 | 56 | /// Lerps between two [SliceData] Lists for a factor [t] 57 | static List lerpSliceDataList( 58 | List? current, 59 | List target, 60 | double donutRadius, 61 | double t, 62 | ) => 63 | lerpList(current, target, t, lerp: (begin, end, t) { 64 | return SliceData.lerp(begin, end, donutRadius, t); 65 | }); 66 | 67 | @override 68 | List get props => [style, labelStyle, value]; 69 | } 70 | -------------------------------------------------------------------------------- /lib/src/charts/painters/radial/radial_chart_painter.dart: -------------------------------------------------------------------------------- 1 | import 'package:chart_it/src/charts/data/core.dart'; 2 | import 'package:chart_it/src/charts/state/painting_state.dart'; 3 | import 'package:chart_it/src/charts/state/pie_series_state.dart'; 4 | import 'package:flutter/material.dart'; 5 | 6 | class RadialChartPainter { 7 | late double graphWidth; 8 | late double graphHeight; 9 | late Offset graphOrigin; 10 | late Rect graphConstraints; 11 | 12 | late double maxRadius; 13 | 14 | late double unitStep; 15 | 16 | RadialChartStyle style; 17 | List states; 18 | 19 | late Paint _bgPaint; 20 | 21 | RadialChartPainter({ 22 | required this.style, 23 | required this.states, 24 | }) { 25 | _bgPaint = Paint(); 26 | } 27 | 28 | void paint(Canvas canvas, Size size) { 29 | // Calculate constraints for the graph 30 | _calculateGraphConstraints(size); 31 | // TODO: Construct a radial grid for polar or radar charts if required 32 | // Paint the background 33 | canvas.clipRect(Offset.zero & size); 34 | canvas.drawPaint(_bgPaint..color = style.backgroundColor); 35 | 36 | // Finally for every data series, we will construct a painter and handover 37 | // the canvas to them to draw the data sets into the required chart 38 | for (var i = 0; i < states.length; i++) { 39 | var state = states[i]; 40 | if (state is PieSeriesState) { 41 | state.painter.paint(state.data, canvas, this, state.config); 42 | } else { 43 | throw ArgumentError('No State of this type exists!'); 44 | } 45 | } 46 | } 47 | 48 | _calculateGraphConstraints(Size widgetSize) { 49 | // TODO: Calculate the effective width & height of the graph 50 | graphOrigin = Offset(widgetSize.width * 0.5, widgetSize.height * 0.5); 51 | graphWidth = widgetSize.width * 0.8; 52 | graphHeight = widgetSize.height * 0.8; 53 | 54 | graphConstraints = Rect.fromCenter( 55 | center: graphOrigin, 56 | width: graphWidth, 57 | height: graphHeight, 58 | ); 59 | 60 | // Get the shortest side with 20% margin 61 | var shortestSide = graphConstraints.shortestSide; 62 | // Our Largest Radius cannot escape this length 63 | maxRadius = shortestSide * 0.5; 64 | 65 | // TODO: Calculate Unit Step by bounding the max value's Circle within graph 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /lib/src/charts/data/bars/bar_data_style.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui'; 2 | 3 | import 'package:chart_it/src/charts/data/bars/bar_data.dart'; 4 | import 'package:chart_it/src/charts/data/bars/bar_group.dart'; 5 | import 'package:chart_it/src/charts/data/bars/bar_series.dart'; 6 | import 'package:chart_it/src/charts/widgets/bar_chart.dart'; 7 | import 'package:equatable/equatable.dart'; 8 | import 'package:flutter/material.dart'; 9 | import 'package:flutter/painting.dart'; 10 | 11 | /// Encapsulates all the Styling options required for a [BarChart]. 12 | /// {@template bar_styling_order} 13 | /// The order of priority in styling is 14 | /// 1. barStyle in [BarData] 15 | /// 2. groupStyle in [BarGroup] 16 | /// 3. seriesStyle in [BarSeries] 17 | /// 4. Default [BarDataStyle] Style 18 | /// {@endtemplate} 19 | class BarDataStyle extends Equatable { 20 | /// The fill color of the Bar 21 | final Color? barColor; 22 | 23 | /// The gradient fill of the Bar 24 | final Gradient? gradient; 25 | 26 | /// The Width of the Stroke/Border around the Bar 27 | final double? strokeWidth; 28 | 29 | /// The Color of the Stroke/Border around the Bar 30 | final Color? strokeColor; 31 | 32 | /// Radius for the Bar Rectangle's Corners 33 | final BorderRadius? cornerRadius; 34 | 35 | /// Encapsulates all the Styling options required for a [BarChart]. 36 | /// {@macro bar_styling_order} 37 | const BarDataStyle({ 38 | this.barColor, 39 | this.gradient, 40 | this.strokeWidth, 41 | this.strokeColor, 42 | this.cornerRadius, 43 | }); 44 | 45 | /// Lerps between two [BarDataStyle]'s for a factor [t] 46 | static BarDataStyle? lerp( 47 | BarDataStyle? current, 48 | BarDataStyle? target, 49 | double t, 50 | ) { 51 | if (target != null) { 52 | return BarDataStyle( 53 | barColor: Color.lerp(current?.barColor, target.barColor, t), 54 | gradient: Gradient.lerp(current?.gradient, target.gradient, t), 55 | strokeWidth: lerpDouble(current?.strokeWidth, target.strokeWidth, t), 56 | strokeColor: Color.lerp(current?.strokeColor, target.strokeColor, t), 57 | cornerRadius: 58 | BorderRadius.lerp(current?.cornerRadius, target.cornerRadius, t), 59 | ); 60 | } 61 | return null; 62 | } 63 | 64 | @override 65 | List get props => 66 | [barColor, gradient, strokeWidth, strokeColor, cornerRadius]; 67 | } 68 | -------------------------------------------------------------------------------- /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 plugin: 'kotlin-android' 26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 27 | 28 | android { 29 | compileSdkVersion flutter.compileSdkVersion 30 | ndkVersion flutter.ndkVersion 31 | 32 | compileOptions { 33 | sourceCompatibility JavaVersion.VERSION_1_8 34 | targetCompatibility JavaVersion.VERSION_1_8 35 | } 36 | 37 | kotlinOptions { 38 | jvmTarget = '1.8' 39 | } 40 | 41 | sourceSets { 42 | main.java.srcDirs += 'src/main/kotlin' 43 | } 44 | 45 | defaultConfig { 46 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 47 | applicationId "com.wednesday.example" 48 | // You can update the following values to match your application needs. 49 | // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. 50 | minSdkVersion flutter.minSdkVersion 51 | targetSdkVersion flutter.targetSdkVersion 52 | versionCode flutterVersionCode.toInteger() 53 | versionName flutterVersionName 54 | } 55 | 56 | buildTypes { 57 | release { 58 | // TODO: Add your own signing config for the release build. 59 | // Signing with the debug keys for now, so `flutter run --release` works. 60 | signingConfig signingConfigs.debug 61 | } 62 | } 63 | } 64 | 65 | flutter { 66 | source '../..' 67 | } 68 | 69 | dependencies { 70 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 71 | } 72 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /lib/src/charts/painters/text/chart_text_painter.dart: -------------------------------------------------------------------------------- 1 | import 'package:chart_it/src/charts/data/core.dart'; 2 | import 'package:flutter/cupertino.dart'; 3 | 4 | const String _ellipsis = '\u2026'; 5 | 6 | class ChartTextPainter { 7 | final String text; 8 | final TextStyle? style; 9 | final bool showEllipsis; 10 | final TextDirection direction; 11 | final TextAlign align; 12 | final int maxLines; 13 | final double? maxWidth; 14 | 15 | late TextPainter _painter; 16 | Size? textConstraints; 17 | 18 | ChartTextPainter({ 19 | required this.text, 20 | required this.style, 21 | required this.showEllipsis, 22 | this.direction = TextDirection.ltr, 23 | this.align = TextAlign.center, 24 | this.maxLines = 1, 25 | this.maxWidth, 26 | }) { 27 | // We will initialize our textPainter on instance 28 | _painter = TextPainter( 29 | text: TextSpan(text: text, style: style), 30 | textDirection: direction, 31 | maxLines: maxLines, 32 | ); 33 | } 34 | 35 | ChartTextPainter.fromChartTextStyle({ 36 | required this.text, 37 | required ChartTextStyle chartTextStyle, 38 | this.maxWidth, 39 | }) : style = chartTextStyle.textStyle, 40 | direction = TextDirection.ltr, 41 | maxLines = chartTextStyle.maxLines, 42 | showEllipsis = chartTextStyle.ellipsize, 43 | align = chartTextStyle.align { 44 | // We will initialize our textPainter on instance 45 | _painter = TextPainter( 46 | text: TextSpan(text: text, style: style), 47 | textDirection: direction, 48 | maxLines: maxLines, 49 | ); 50 | } 51 | 52 | void layout() { 53 | if (showEllipsis) { 54 | _painter.ellipsis = _ellipsis; 55 | } 56 | 57 | _painter.layout(maxWidth: maxWidth ?? double.infinity); 58 | } 59 | 60 | double get width => _painter.width; 61 | double get height => _painter.height; 62 | 63 | void paint( 64 | {required Canvas canvas, 65 | required Offset offset, 66 | bool shouldLayout = false}) { 67 | if (shouldLayout) { 68 | layout(); 69 | } 70 | 71 | var alignOffset = 0.5; 72 | switch (align) { 73 | case TextAlign.start: 74 | alignOffset = 0; 75 | break; 76 | case TextAlign.center: 77 | alignOffset = 0.5; 78 | break; 79 | case TextAlign.end: 80 | alignOffset = 1.0; 81 | break; 82 | default: 83 | alignOffset = 0.5; 84 | } 85 | 86 | final position = Offset( 87 | offset.dx - (_painter.width * alignOffset), 88 | offset.dy - (_painter.height * 0.5), 89 | ); 90 | 91 | _painter.paint(canvas, position); 92 | textConstraints = _painter.size; 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /lib/src/extensions/primitives.dart: -------------------------------------------------------------------------------- 1 | import 'package:equatable/equatable.dart'; 2 | 3 | extension AsExtension on Object? { 4 | X as() => this as X; 5 | 6 | X? asOrNull() { 7 | var currObject = this; 8 | return currObject is X ? currObject : null; 9 | } 10 | 11 | X asOrDefault(X defaultValue) { 12 | var currObject = this; 13 | return currObject.asOrNull() ?? defaultValue; 14 | } 15 | } 16 | 17 | extension Precision on num { 18 | double toPrecision(int n) => double.parse(toStringAsFixed(n)); 19 | 20 | bool isBetween(num from, num to) { 21 | return from < this && this < to; 22 | } 23 | } 24 | 25 | class EquatableList extends Equatable { 26 | final List list; 27 | 28 | const EquatableList(this.list); 29 | 30 | @override 31 | List get props => [list]; 32 | } 33 | 34 | extension ListTransforms on List { 35 | T get(int index, T defaultValue) { 36 | if (index >= length) { 37 | return defaultValue; 38 | } else { 39 | return this[index]; 40 | } 41 | } 42 | 43 | T? getOrNull(int index) { 44 | if (index >= length) { 45 | return null; 46 | } else { 47 | return this[index]; 48 | } 49 | } 50 | 51 | List distinct() => toSet().toList(); 52 | 53 | List distinctTypes() => map((e) => e.runtimeType).toSet().toList(); 54 | 55 | List withNullableItems() => whereType().toList(); 56 | 57 | void forEachIndexed(void Function(int index, T item) action) { 58 | for (var index = 0; index < length; index++) { 59 | action(index, this[index]); 60 | } 61 | } 62 | 63 | List fastMap(K Function(T t) convertTo) { 64 | List mappedList = List.empty(growable: true); 65 | 66 | for (var i = 0; i < length; i++) { 67 | mappedList.add(convertTo(this[i])); 68 | } 69 | return mappedList; 70 | } 71 | } 72 | 73 | extension ContainsKey on Map { 74 | V? getOrNull(K key) { 75 | if (containsKey(key)) return this[key]; 76 | return null; 77 | } 78 | 79 | createAndUpdate( 80 | K key, { 81 | required V Function() onCreate, 82 | Function(V? value)? onUpdate, 83 | }) { 84 | var isKeyPresent = containsKey(key); 85 | if (!isKeyPresent) { 86 | // Create new entry for this key 87 | this[key] = onCreate(); 88 | } 89 | 90 | if (onUpdate != null) { 91 | onUpdate(this[key]); 92 | } 93 | } 94 | } 95 | 96 | extension BoolExtension on bool { 97 | get isFalse => this == false; 98 | } 99 | 100 | extension NullChecker on Object? { 101 | get isNull => this == null; 102 | 103 | get isNotNull => this != null; 104 | } 105 | -------------------------------------------------------------------------------- /lib/src/charts/data/bars/bar_group.dart: -------------------------------------------------------------------------------- 1 | import 'package:chart_it/src/animations/lerps.dart'; 2 | import 'package:chart_it/src/charts/data/bars/bar_data_style.dart'; 3 | import 'package:chart_it/src/charts/data/bars/multi_bar.dart'; 4 | import 'package:chart_it/src/charts/data/bars/simple_bar.dart'; 5 | import 'package:equatable/equatable.dart'; 6 | 7 | /// Sets the Arrangement for all the bars in a [BarGroup]. 8 | /// 9 | /// * Use [series] to have all the bars arranged alongside each other. 10 | /// * Use [stack] to create a stack of all the bars in a group. 11 | enum BarGroupArrangement { series, stack } 12 | 13 | /// {@template bar_group} 14 | /// Defines the structure of a Group of Bars. 15 | /// 16 | /// Holds the X-Value, Labels and Styling. 17 | /// {@endtemplate} 18 | abstract class BarGroup with EquatableMixin { 19 | /// The Value along X-Axis for this [BarGroup]. 20 | /// 21 | /// This value is not used for plotting on X-Axis. 22 | /// The plotting is done based on the index of this item in the list. 23 | final num xValue; 24 | 25 | /// Styling for the Bars in this [BarGroup]. 26 | /// 27 | /// {@macro bar_styling_order} 28 | final BarDataStyle? style; 29 | 30 | /// The amount of padding applied to either side of the bars. 31 | final double padding; 32 | 33 | /// {@macro bar_group} 34 | BarGroup({required this.xValue, this.style, this.padding = 10}); 35 | 36 | /// Lerps between two [BarGroup] objects for a factor [t]. 37 | /// 38 | /// If subtypes of the two objects are not identical, then it lerps 39 | /// from null to [target] object's type. 40 | static BarGroup lerp(BarGroup? current, BarGroup target, double t) { 41 | final currentValue = 42 | current == null || current.runtimeType != target.runtimeType 43 | ? null 44 | : current; 45 | return target._when( 46 | simpleBar: () => SimpleBar.lerp(currentValue, target, t), 47 | multiBar: () => MultiBar.lerp(currentValue, target, t), 48 | ); 49 | } 50 | 51 | /// Lerps between two Lists of [BarGroup] for a factor [t]. 52 | static List lerpBarGroupList( 53 | List? current, 54 | List target, 55 | double t, 56 | ) => 57 | lerpList(current, target, t, lerp: lerp); 58 | 59 | /// Helper method to capture [runtimeType] checks for the subtype of 60 | /// [BarGroup] object, and provides callback method for the matching type. 61 | T _when({ 62 | required T Function() simpleBar, 63 | required T Function() multiBar, 64 | }) { 65 | switch (runtimeType) { 66 | case SimpleBar: 67 | return simpleBar(); 68 | case MultiBar: 69 | return multiBar(); 70 | default: 71 | throw TypeError(); 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /lib/src/charts/data/bars/multi_bar.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui'; 2 | 3 | import 'package:chart_it/src/charts/data/bars/bar_data.dart'; 4 | import 'package:chart_it/src/charts/data/bars/bar_data_style.dart'; 5 | import 'package:chart_it/src/charts/data/bars/bar_group.dart'; 6 | import 'package:chart_it/src/extensions/primitives.dart'; 7 | 8 | /// Defines a Group of Multiple Bars 9 | /// 10 | /// A list of [BarData] needs to be provided which will 11 | /// provide us the Y-Value for each individual bar in the group. 12 | /// 13 | /// See Also: [BarGroup] 14 | class MultiBar extends BarGroup { 15 | /// The list of [BarData] which gives us the Y-Value and 16 | /// the styling for each individual bars in this group. 17 | final List yValues; 18 | 19 | /// Defines how all the bars in this group should be arranged 20 | /// * Use [BarGroupArrangement.series] to arrange in series 21 | /// * Use [BarGroupArrangement.stack] to arrange in stack 22 | final BarGroupArrangement arrangement; 23 | 24 | /// The space between consecutive bars in a series arrangement. 25 | /// 26 | /// **Note:** If you've chosen [arrangement] as stack, then [spacing] will 27 | /// be ignored. 28 | final double spacing; 29 | 30 | /// Defines a Group of Multiple Bars 31 | /// 32 | /// A list of [BarData] needs to be provided which will 33 | /// provide us the Y-Value for each individual bar in the group. 34 | /// 35 | /// See Also: [BarGroup] 36 | /// 37 | MultiBar({ 38 | required super.xValue, 39 | required this.yValues, 40 | // defaults to series i.e. side by side 41 | this.arrangement = BarGroupArrangement.series, 42 | this.spacing = 10.0, 43 | super.style, 44 | super.padding, 45 | }) : assert(yValues.isNotEmpty, "At least one yValue is required!"), 46 | assert(spacing >= 0.0, "groupSpacing cannot be Negative!"); 47 | 48 | /// Lerps between two [MultiBar]s for a factor [t] 49 | static MultiBar lerp(BarGroup? current, BarGroup target, double t) { 50 | if ((current is MultiBar?) && target is MultiBar) { 51 | return MultiBar( 52 | xValue: lerpDouble(current?.xValue, target.xValue, t) as num, 53 | yValues: BarData.lerpBarDataList(current?.yValues, target.yValues, t), 54 | arrangement: target.arrangement, 55 | spacing: lerpDouble( 56 | current?.spacing, 57 | target.spacing, 58 | t, 59 | ).asOrDefault(0.0), 60 | style: BarDataStyle.lerp( 61 | current?.style, 62 | target.style, 63 | t, 64 | ), 65 | padding: lerpDouble(current?.padding, target.padding, t) ?? 0.0, 66 | ); 67 | } else { 68 | throw Exception('Both current & target data should be of same series!'); 69 | } 70 | } 71 | 72 | @override 73 | List get props => 74 | [xValue, yValues, style, spacing, arrangement, padding]; 75 | } 76 | -------------------------------------------------------------------------------- /lib/src/charts/data/pie/slice_data_style.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui'; 2 | 3 | import 'package:chart_it/src/charts/data/pie/pie_series.dart'; 4 | import 'package:chart_it/src/charts/data/pie/slice_data.dart'; 5 | import 'package:chart_it/src/charts/widgets/pie_chart.dart'; 6 | import 'package:equatable/equatable.dart'; 7 | import 'package:flutter/material.dart'; 8 | 9 | /// Encapsulates all the Styling options required for a [PieChart]. 10 | /// {@template slice_styling_order} 11 | /// The order of priority in styling is 12 | /// 1. style in [SliceData] 13 | /// 2. seriesStyle in [PieSeries] 14 | /// 4. Default [SliceDataStyle] Style 15 | /// {@endtemplate} 16 | class SliceDataStyle extends Equatable { 17 | /// The radius of the Pie/Slice. 18 | /// Maximum Radius size will be auto-calculated and 19 | /// will prevent Slice to Clip Out of Bounds 20 | final double radius; 21 | 22 | /// Defines the Position of the Label for Slice 23 | /// Along the length of the radius. 24 | final double? labelPosition; 25 | 26 | /// The color of the slice 27 | final Color? color; 28 | 29 | /// The Gradient of the slice 30 | final Gradient? gradient; 31 | 32 | /// The Width of the Stroke/Border around the Pie/Slice 33 | final double? strokeWidth; 34 | 35 | /// The Color of the Stroke/Border around the Pie/Slice 36 | final Color? strokeColor; 37 | 38 | /// Encapsulates all the Styling options required for a [PieChart]. 39 | /// {@macro slice_styling_order} 40 | const SliceDataStyle({ 41 | required this.radius, 42 | this.labelPosition, 43 | this.color = Colors.amber, 44 | this.gradient, 45 | this.strokeColor = Colors.deepOrange, 46 | this.strokeWidth = 0.0, 47 | }); 48 | 49 | @override 50 | List get props => 51 | [radius, color, gradient, strokeWidth, strokeColor]; 52 | 53 | /// Lerps between two [SliceDataStyle]'s for a factor [t] 54 | static SliceDataStyle? lerp( 55 | SliceDataStyle? current, 56 | SliceDataStyle? target, 57 | double donutRadius, 58 | double t, 59 | ) { 60 | if (target != null) { 61 | var shouldLerpFromDonut = 62 | donutRadius > 0.0 && donutRadius > (current?.radius ?? 0); 63 | var beginRadius = shouldLerpFromDonut ? donutRadius : current?.radius; 64 | var beginLabel = 65 | shouldLerpFromDonut ? donutRadius : current?.labelPosition; 66 | return SliceDataStyle( 67 | radius: lerpDouble(beginRadius, target.radius, t) ?? 0, 68 | labelPosition: lerpDouble(beginLabel, target.labelPosition, t), 69 | color: Color.lerp(current?.color, target.color, t), 70 | gradient: Gradient.lerp(current?.gradient, target.gradient, t), 71 | strokeWidth: lerpDouble(current?.strokeWidth, target.strokeWidth, t), 72 | strokeColor: Color.lerp(current?.strokeColor, target.strokeColor, t), 73 | ); 74 | } 75 | return null; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /example/web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | example 33 | 34 | 35 | 40 | 41 | 42 | 43 | 44 | 48 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images": [ 3 | { 4 | "size": "20x20", 5 | "idiom": "iphone", 6 | "filename": "Icon-App-20x20@2x.png", 7 | "scale": "2x" 8 | }, 9 | { 10 | "size": "20x20", 11 | "idiom": "iphone", 12 | "filename": "Icon-App-20x20@3x.png", 13 | "scale": "3x" 14 | }, 15 | { 16 | "size": "29x29", 17 | "idiom": "iphone", 18 | "filename": "Icon-App-29x29@1x.png", 19 | "scale": "1x" 20 | }, 21 | { 22 | "size": "29x29", 23 | "idiom": "iphone", 24 | "filename": "Icon-App-29x29@2x.png", 25 | "scale": "2x" 26 | }, 27 | { 28 | "size": "29x29", 29 | "idiom": "iphone", 30 | "filename": "Icon-App-29x29@3x.png", 31 | "scale": "3x" 32 | }, 33 | { 34 | "size": "40x40", 35 | "idiom": "iphone", 36 | "filename": "Icon-App-40x40@2x.png", 37 | "scale": "2x" 38 | }, 39 | { 40 | "size": "40x40", 41 | "idiom": "iphone", 42 | "filename": "Icon-App-40x40@3x.png", 43 | "scale": "3x" 44 | }, 45 | { 46 | "size": "60x60", 47 | "idiom": "iphone", 48 | "filename": "Icon-App-60x60@2x.png", 49 | "scale": "2x" 50 | }, 51 | { 52 | "size": "60x60", 53 | "idiom": "iphone", 54 | "filename": "Icon-App-60x60@3x.png", 55 | "scale": "3x" 56 | }, 57 | { 58 | "size": "20x20", 59 | "idiom": "ipad", 60 | "filename": "Icon-App-20x20@1x.png", 61 | "scale": "1x" 62 | }, 63 | { 64 | "size": "20x20", 65 | "idiom": "ipad", 66 | "filename": "Icon-App-20x20@2x.png", 67 | "scale": "2x" 68 | }, 69 | { 70 | "size": "29x29", 71 | "idiom": "ipad", 72 | "filename": "Icon-App-29x29@1x.png", 73 | "scale": "1x" 74 | }, 75 | { 76 | "size": "29x29", 77 | "idiom": "ipad", 78 | "filename": "Icon-App-29x29@2x.png", 79 | "scale": "2x" 80 | }, 81 | { 82 | "size": "40x40", 83 | "idiom": "ipad", 84 | "filename": "Icon-App-40x40@1x.png", 85 | "scale": "1x" 86 | }, 87 | { 88 | "size": "40x40", 89 | "idiom": "ipad", 90 | "filename": "Icon-App-40x40@2x.png", 91 | "scale": "2x" 92 | }, 93 | { 94 | "size": "76x76", 95 | "idiom": "ipad", 96 | "filename": "Icon-App-76x76@1x.png", 97 | "scale": "1x" 98 | }, 99 | { 100 | "size": "76x76", 101 | "idiom": "ipad", 102 | "filename": "Icon-App-76x76@2x.png", 103 | "scale": "2x" 104 | }, 105 | { 106 | "size": "83.5x83.5", 107 | "idiom": "ipad", 108 | "filename": "Icon-App-83.5x83.5@2x.png", 109 | "scale": "2x" 110 | }, 111 | { 112 | "size": "1024x1024", 113 | "idiom": "ios-marketing", 114 | "filename": "Icon-App-1024x1024@1x.png", 115 | "scale": "1x" 116 | } 117 | ], 118 | "info": { 119 | "version": 1, 120 | "author": "xcode" 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /lib/src/charts/data/bars/bar_data.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui'; 2 | 3 | import 'package:chart_it/src/animations/lerps.dart'; 4 | import 'package:chart_it/src/charts/constants/defaults.dart'; 5 | import 'package:chart_it/src/charts/data/bars/bar_data_style.dart'; 6 | import 'package:chart_it/src/charts/data/bars/multi_bar.dart'; 7 | import 'package:chart_it/src/charts/data/core/cartesian/cartesian_data.dart'; 8 | import 'package:chart_it/src/charts/data/core/shared/chart_text_style.dart'; 9 | import 'package:chart_it/src/extensions/primitives.dart'; 10 | import 'package:equatable/equatable.dart'; 11 | 12 | /// Defines the Data of Each Individual Bar in a [MultiBar] group 13 | /// 14 | /// Holds the Y-Value, label and styling for this BarData 15 | class BarData extends Equatable { 16 | /// The LowerBound Value of Y-Axis. Only useful to control the Height 17 | /// of the drawn Bar in Stack Arrangement. 18 | final num? startYFrom; 19 | 20 | /// The UpperBound Value that's to be plotted along the Y-Axis. 21 | /// This will be drawn as the Height of the Bar 22 | final num yValue; 23 | 24 | /// Callback for the label along the Y-Axis in this [BarData] 25 | /// The Y-Value is provided as a param, and a string is to be returned 26 | final LabelMapper? label; 27 | 28 | /// Text Styling for the [label]. 29 | final ChartTextStyle? labelStyle; 30 | 31 | /// Determines the position of the Bar Label. 32 | final BarLabelPosition labelPosition; 33 | 34 | /// Styling for the Individual Bar in this [BarData]. 35 | /// 36 | /// {@macro bar_styling_order} 37 | final BarDataStyle? barStyle; 38 | 39 | /// Defines the Data of Each Individual Bar in a [MultiBar] group 40 | /// 41 | /// Holds the Y-Value, label and styling for this BarData 42 | const BarData({ 43 | this.startYFrom, 44 | required this.yValue, 45 | this.label, 46 | this.labelStyle = defaultChartTextStyle, 47 | this.barStyle, 48 | this.labelPosition = BarLabelPosition.insideBar, 49 | }); 50 | 51 | /// Lerps between two [BarData] values for a factor [t] 52 | static BarData lerp(BarData? current, BarData? target, double t) { 53 | return BarData( 54 | startYFrom: lerpDouble(current?.startYFrom, target?.startYFrom, t), 55 | yValue: 56 | lerpDouble(current?.yValue, target?.yValue, t).asOrDefault(0), 57 | label: target?.label, 58 | labelStyle: ChartTextStyle.lerp( 59 | current?.labelStyle, 60 | target?.labelStyle, 61 | t, 62 | ), 63 | barStyle: BarDataStyle.lerp(current?.barStyle, target?.barStyle, t), 64 | labelPosition: target?.labelPosition ?? BarLabelPosition.insideBar, 65 | ); 66 | } 67 | 68 | /// Lerps between two [BarData] Lists for a factor [t] 69 | static List lerpBarDataList( 70 | List? current, 71 | List target, 72 | double t, 73 | ) => 74 | lerpList(current, target, t, lerp: lerp); 75 | 76 | @override 77 | List get props => 78 | [startYFrom, yValue, labelStyle, barStyle, labelPosition]; 79 | } 80 | 81 | /// Determines the position of the Bar Label. 82 | enum BarLabelPosition { 83 | /// Draws the label inside of the bar. 84 | insideBar, 85 | 86 | /// Draws the label outside of the bar. 87 | outsideBar 88 | } 89 | -------------------------------------------------------------------------------- /lib/src/animations/chart_animations.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | /// Handles updating [tweenSeries] with new data and manages the [animation]. 4 | /// 5 | /// To start listening to animation updates and update data along with notifying painters on each update 6 | /// call [animateDataUpdates]. 7 | /// 8 | /// To update the tween when new data is available and animate to the new state call [updateDataSeries]. 9 | mixin ChartAnimationsMixin on ChangeNotifier { 10 | @protected 11 | Tween get tweenData; 12 | 13 | K? latestDataDispatchedToPainting; 14 | 15 | set tweenData(Tween newTween); 16 | 17 | AnimationController get animation; 18 | 19 | bool get animateOnLoad; 20 | 21 | bool get animateOnUpdate; 22 | 23 | K setData(List data, bool forceUpdate); 24 | 25 | void setAnimatableData(K data); 26 | 27 | Tween getTweens({ 28 | required K newData, 29 | required bool isInitPhase, 30 | }); 31 | 32 | /// **Should be called in the constructor of the class using [ChartAnimations].** 33 | /// 34 | /// Adds a listener on [animation]. 35 | /// 36 | /// On every update calls : 37 | /// 1. [setAnimatableData] with the values of [tweenSeries] evaluated at current value of [animation]. 38 | /// 2. [notifyListeners] so that [CustomPainter.paint] is called on the painters registered with this controller. 39 | void animateDataUpdates() { 40 | animation.addListener(() { 41 | setAnimatableData(tweenData.evaluate(animation)); 42 | // Finally trigger a rebuild for all the painters 43 | notifyListeners(); 44 | }); 45 | } 46 | 47 | K constructState(List newData); 48 | 49 | /// Call to update the controller with new/updated chart data and start the [animation] if applicable. 50 | /// 51 | /// [updateDataSeries] does the following: 52 | /// 1. Updates the [tweenSeries] with tween created from the [newSeries] data. 53 | /// 2. [setData] with the [newSeries]. 54 | /// 3. Starts the [animation] if applicable. 55 | @protected 56 | void updateDataSeries( 57 | List newSeries, { 58 | bool isInitPhase = false, 59 | bool forceUpdate = false, 60 | }) { 61 | // Update the Target Data to the newest value 62 | final targetData = setData(newSeries, forceUpdate); 63 | 64 | if (latestDataDispatchedToPainting != null && 65 | latestDataDispatchedToPainting == targetData && 66 | !forceUpdate) { 67 | return; 68 | } else { 69 | latestDataDispatchedToPainting = targetData; 70 | } 71 | 72 | // Tween a List of Tweens for any DataSeries 73 | tweenData = getTweens(newData: targetData, isInitPhase: isInitPhase); 74 | 75 | // Finally animate the differences 76 | final shouldAnimateOnLoad = isInitPhase && animateOnLoad; 77 | final shouldAnimateOnUpdate = !isInitPhase && animateOnUpdate; 78 | if (shouldAnimateOnLoad || shouldAnimateOnUpdate) { 79 | animation 80 | ..stop() 81 | ..reset() 82 | ..forward(); 83 | } else { 84 | // We are to not animate the data updates 85 | setAnimatableData(targetData); 86 | notifyListeners(); 87 | } 88 | } 89 | 90 | @override 91 | void dispose() { 92 | super.dispose(); 93 | // We no longer need this animation controller 94 | animation.dispose(); 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /example/linux/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This file controls Flutter-level build steps. It should not be edited. 2 | cmake_minimum_required(VERSION 3.10) 3 | 4 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 5 | 6 | # Configuration provided via flutter tool. 7 | include(${EPHEMERAL_DIR}/generated_config.cmake) 8 | 9 | # TODO: Move the rest of this into files in ephemeral. See 10 | # https://github.com/flutter/flutter/issues/57146. 11 | 12 | # Serves the same purpose as list(TRANSFORM ... PREPEND ...), 13 | # which isn't available in 3.10. 14 | function(list_prepend LIST_NAME PREFIX) 15 | set(NEW_LIST "") 16 | foreach (element ${${LIST_NAME}}) 17 | list(APPEND NEW_LIST "${PREFIX}${element}") 18 | endforeach (element) 19 | set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) 20 | endfunction() 21 | 22 | # === Flutter Library === 23 | # System-level dependencies. 24 | find_package(PkgConfig REQUIRED) 25 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) 26 | pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) 27 | pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) 28 | 29 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") 30 | 31 | # Published to parent scope for install step. 32 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 33 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 34 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 35 | set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) 36 | 37 | list(APPEND FLUTTER_LIBRARY_HEADERS 38 | "fl_basic_message_channel.h" 39 | "fl_binary_codec.h" 40 | "fl_binary_messenger.h" 41 | "fl_dart_project.h" 42 | "fl_engine.h" 43 | "fl_json_message_codec.h" 44 | "fl_json_method_codec.h" 45 | "fl_message_codec.h" 46 | "fl_method_call.h" 47 | "fl_method_channel.h" 48 | "fl_method_codec.h" 49 | "fl_method_response.h" 50 | "fl_plugin_registrar.h" 51 | "fl_plugin_registry.h" 52 | "fl_standard_message_codec.h" 53 | "fl_standard_method_codec.h" 54 | "fl_string_codec.h" 55 | "fl_value.h" 56 | "fl_view.h" 57 | "flutter_linux.h" 58 | ) 59 | list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") 60 | add_library(flutter INTERFACE) 61 | target_include_directories(flutter INTERFACE 62 | "${EPHEMERAL_DIR}" 63 | ) 64 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") 65 | target_link_libraries(flutter INTERFACE 66 | PkgConfig::GTK 67 | PkgConfig::GLIB 68 | PkgConfig::GIO 69 | ) 70 | add_dependencies(flutter flutter_assemble) 71 | 72 | # === Flutter tool backend === 73 | # _phony_ is a non-existent file to force this command to run every time, 74 | # since currently there's no way to get a full input/output list from the 75 | # flutter tool. 76 | add_custom_command( 77 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 78 | ${CMAKE_CURRENT_BINARY_DIR}/_phony_ 79 | COMMAND ${CMAKE_COMMAND} -E env 80 | ${FLUTTER_TOOL_ENVIRONMENT} 81 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" 82 | ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} 83 | VERBATIM 84 | ) 85 | add_custom_target(flutter_assemble DEPENDS 86 | "${FLUTTER_LIBRARY}" 87 | ${FLUTTER_LIBRARY_HEADERS} 88 | ) 89 | -------------------------------------------------------------------------------- /example/lib/screens/pie_charts_animation.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | 3 | import 'package:chart_it/chart_it.dart'; 4 | import 'package:flutter/material.dart'; 5 | import 'package:google_fonts/google_fonts.dart'; 6 | 7 | var rng = Random(); 8 | 9 | class TestPieChartsAnimation extends StatefulWidget { 10 | const TestPieChartsAnimation({Key? key}) : super(key: key); 11 | 12 | @override 13 | State createState() => _TestPieChartsAnimationState(); 14 | } 15 | 16 | class _TestPieChartsAnimationState extends State { 17 | final LinearGradient titleGradient = const LinearGradient( 18 | begin: Alignment.bottomLeft, 19 | end: Alignment.topRight, 20 | stops: [ 21 | 0.1, 22 | 0.4, 23 | 0.95, 24 | ], 25 | colors: [ 26 | Color(0xFFE39F56), 27 | Color(0xFFBDA2F4), 28 | Color(0xFFE39F56), 29 | ], 30 | ); 31 | 32 | @override 33 | Widget build(BuildContext context) { 34 | final isDonut = rng.nextBool(); 35 | var theme = Theme.of(context); 36 | return PieChart( 37 | height: 400, 38 | title: const Text('Demo Chart'), 39 | chartStyle: RadialChartStyle( 40 | backgroundColor: theme.canvasColor, 41 | ), 42 | data: PieSeries( 43 | donutRadius: isDonut ? 50.0 : 0.0, 44 | donutSpaceColor: Colors.transparent, 45 | donutLabelStyle: ChartTextStyle( 46 | textStyle: GoogleFonts.poppins( 47 | color: theme.colorScheme.inverseSurface, 48 | ), 49 | ), 50 | interactionEvents: PieInteractionEvents( 51 | isEnabled: true, 52 | onTap: (_) { 53 | setState(() {}); 54 | }), 55 | donutLabel: isDonut ? () => 'Crypto' : null, 56 | slices: makeSliceData(context), 57 | ), 58 | ); 59 | } 60 | } 61 | 62 | List makeSliceData(BuildContext context) { 63 | var theme = Theme.of(context); 64 | double next(num min, num max) => rng.nextDouble() * (max - min) + min; 65 | 66 | List barSeries = List.generate(5, (index) { 67 | return SliceData( 68 | value: rng.nextInt(100), 69 | label: (percent, value) => getCryptoName(index), 70 | labelStyle: ChartTextStyle( 71 | textStyle: GoogleFonts.poppins( 72 | color: theme.colorScheme.inverseSurface, 73 | ), 74 | ), 75 | style: SliceDataStyle( 76 | radius: next(90.0, 150.0), 77 | color: getColorForPiece(index), 78 | strokeWidth: 0.0, 79 | strokeColor: const Color(0xFF0D116D), 80 | ), 81 | ); 82 | }); 83 | 84 | return barSeries; 85 | } 86 | 87 | String getCryptoName(int index) { 88 | switch (index) { 89 | case 0: 90 | return 'Bitcoin'; 91 | case 1: 92 | return 'Ethereum'; 93 | case 2: 94 | return 'Binance'; 95 | case 3: 96 | return 'Tether'; 97 | case 4: 98 | return 'DOGE'; 99 | default: 100 | return ''; 101 | } 102 | } 103 | 104 | Color getColorForPiece(int index) { 105 | switch (index) { 106 | case 0: 107 | return const Color(0xFFBDA2F4); 108 | case 1: 109 | return const Color(0xFF7136E7); 110 | case 2: 111 | return const Color(0xFF693C00); 112 | case 3: 113 | return const Color(0xFF9295F2); 114 | case 4: 115 | return const Color(0xFFFFB86E); 116 | default: 117 | return Colors.transparent; 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /lib/src/interactions/data/touch_interaction_events.dart: -------------------------------------------------------------------------------- 1 | import 'package:chart_it/src/interactions/data/touch_interactions.dart'; 2 | import 'package:equatable/equatable.dart'; 3 | 4 | /// {@template TouchInteractionEvents} 5 | /// [TouchInteractionEvents] provides callback to receive interaction events 6 | /// for the chart. 7 | /// {@endtemplate} 8 | abstract class TouchInteractionEvents 9 | with EquatableMixin { 10 | /// Set if interaction is enabled. 11 | final bool isEnabled; 12 | 13 | /// [onRawInteraction] receives all types of interaction events. 14 | final void Function(T interactionResult)? onRawInteraction; 15 | 16 | /// [onTap] is be called after a tap gesture is completed. 17 | /// It is called right after [onTapUp]. 18 | final void Function(T interactionResult)? onTap; 19 | 20 | /// [onTapUp] is called when the pointer that will trigger a tap gesture 21 | /// stops making contact with the screen. 22 | final void Function(T interactionResult)? onTapUp; 23 | 24 | /// [onTapDown] is called when the pointer that will trigger a tap gesture 25 | /// comes in contact with the screen. 26 | final void Function(T interactionResult)? onTapDown; 27 | 28 | /// [onDoubleTap] is be called after a double tap gesture is detected. 29 | final void Function(T interactionResult)? onDoubleTap; 30 | 31 | /// [onDragStart] is called when a pointer comes in contact with the screen 32 | /// and starts moving triggering a drag gesture. 33 | final void Function(T interactionResult)? onDragStart; 34 | 35 | /// [onDrag] is called when the pointer location is updated for the pointer that started 36 | /// the drag gesture. 37 | final void Function(T interactionResult)? onDrag; 38 | 39 | /// [onDragEnd] is called when the pointer that triggered the drag gesture 40 | /// stop moving ending the drag gesture. 41 | final void Function(T interactionResult)? onDragEnd; 42 | 43 | /// {@macro TouchInteractionEvents} 44 | const TouchInteractionEvents({ 45 | required this.isEnabled, 46 | this.onTap, 47 | this.onTapUp, 48 | this.onTapDown, 49 | this.onDoubleTap, 50 | this.onDragStart, 51 | this.onDrag, 52 | this.onDragEnd, 53 | this.onRawInteraction, 54 | }); 55 | 56 | void onInteraction(T interactionResult) { 57 | onRawInteraction?.call(interactionResult); 58 | switch (interactionResult.interactionType) { 59 | case TouchInteractionType.doubleTap: 60 | onDoubleTap?.call(interactionResult); 61 | break; 62 | case TouchInteractionType.dragUpdate: 63 | onDrag?.call(interactionResult); 64 | break; 65 | case TouchInteractionType.dragStart: 66 | onDragStart?.call(interactionResult); 67 | break; 68 | case TouchInteractionType.dragEnd: 69 | onDragEnd?.call(interactionResult); 70 | break; 71 | case TouchInteractionType.tapUp: 72 | onTap?.call(interactionResult); 73 | break; 74 | case TouchInteractionType.tapDown: 75 | onTapDown?.call(interactionResult); 76 | break; 77 | case TouchInteractionType.tap: 78 | onTap?.call(interactionResult); 79 | break; 80 | } 81 | } 82 | 83 | bool get shouldHitTest => 84 | isEnabled && 85 | (onRawInteraction != null || 86 | onTap != null || 87 | onTapDown != null || 88 | onTapUp != null || 89 | onDoubleTap != null || 90 | onDragStart != null || 91 | onDragEnd != null || 92 | onDrag != null); 93 | } 94 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 69 | 71 | 77 | 78 | 79 | 80 | 82 | 83 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /example/lib/screens/pie_chart.dart: -------------------------------------------------------------------------------- 1 | import 'package:example/screens/pie_chart_interaction.dart'; 2 | import 'package:example/screens/pie_charts_animation.dart'; 3 | import 'package:flutter/material.dart'; 4 | import 'package:responsive_sizer/responsive_sizer.dart'; 5 | 6 | class TestPieChart extends StatelessWidget { 7 | const TestPieChart({Key? key}) : super(key: key); 8 | 9 | final LinearGradient titleGradient = const LinearGradient( 10 | begin: Alignment.bottomLeft, 11 | end: Alignment.topRight, 12 | stops: [ 13 | 0.1, 14 | 0.4, 15 | 0.95, 16 | ], 17 | colors: [ 18 | Color(0xFFE39F56), 19 | Color(0xFFBDA2F4), 20 | Color(0xFFE39F56), 21 | ], 22 | ); 23 | 24 | @override 25 | Widget build(BuildContext context) { 26 | return Scaffold( 27 | body: Column( 28 | children: [ 29 | Align( 30 | alignment: Alignment.centerLeft, 31 | child: Padding( 32 | padding: const EdgeInsets.all(20.0), 33 | child: ShaderMask( 34 | blendMode: BlendMode.srcIn, 35 | shaderCallback: (Rect bounds) => titleGradient.createShader( 36 | Rect.fromLTWH(0.0, 0.0, bounds.width, bounds.height), 37 | ), 38 | child: Text( 39 | 'Pie Charts', 40 | style: TextStyle( 41 | fontSize: 26.sp, 42 | fontWeight: FontWeight.bold, 43 | ), 44 | ), 45 | ), 46 | ), 47 | ), 48 | Expanded( 49 | child: ListView( 50 | children: [ 51 | Padding( 52 | padding: const EdgeInsets.all(8.0), 53 | child: Text("Bar Chart State Changes", 54 | textAlign: TextAlign.center, 55 | style: TextStyle( 56 | fontSize: 22, 57 | color: Theme.of(context).colorScheme.onBackground)), 58 | ), 59 | const Padding( 60 | padding: EdgeInsets.all(8.0), 61 | child: TestPieChartsAnimation(), 62 | ), 63 | Text("Tap the chart to change data.", 64 | textAlign: TextAlign.center, 65 | style: TextStyle( 66 | fontSize: 18, 67 | color: Theme.of(context).colorScheme.onBackground)), 68 | const Divider( 69 | height: 100, 70 | thickness: 20, 71 | ), 72 | Padding( 73 | padding: const EdgeInsets.all(8.0), 74 | child: Text("Bar Chart Interactions", 75 | textAlign: TextAlign.center, 76 | style: TextStyle( 77 | fontSize: 22, 78 | color: Theme.of(context).colorScheme.onBackground)), 79 | ), 80 | const Padding( 81 | padding: EdgeInsets.all(8.0), 82 | child: TestPieChartsInteraction(), 83 | ), 84 | Text("Tap to interact with the chart.", 85 | textAlign: TextAlign.center, 86 | style: TextStyle( 87 | fontSize: 18, 88 | color: Theme.of(context).colorScheme.onBackground)), 89 | const SizedBox( 90 | height: 50, 91 | ) 92 | ], 93 | )), 94 | ], 95 | ), 96 | ); 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 69 | 71 | 77 | 78 | 79 | 80 | 82 | 83 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /example/lib/screens/pie_chart_interaction.dart: -------------------------------------------------------------------------------- 1 | import 'package:chart_it/chart_it.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:google_fonts/google_fonts.dart'; 4 | 5 | class TestPieChartsInteraction extends StatefulWidget { 6 | const TestPieChartsInteraction({Key? key}) : super(key: key); 7 | 8 | @override 9 | State createState() => 10 | _TestPieChartsInteractionState(); 11 | } 12 | 13 | class _TestPieChartsInteractionState extends State { 14 | int interactionIndex = -1; 15 | 16 | final LinearGradient titleGradient = const LinearGradient( 17 | begin: Alignment.bottomLeft, 18 | end: Alignment.topRight, 19 | stops: [ 20 | 0.1, 21 | 0.4, 22 | 0.95, 23 | ], 24 | colors: [ 25 | Color(0xFFE39F56), 26 | Color(0xFFBDA2F4), 27 | Color(0xFFE39F56), 28 | ], 29 | ); 30 | 31 | @override 32 | Widget build(BuildContext context) { 33 | var theme = Theme.of(context); 34 | return PieChart( 35 | height: 400, 36 | animationDuration: const Duration(milliseconds: 300), 37 | title: const Text('Demo Chart'), 38 | chartStyle: RadialChartStyle( 39 | backgroundColor: theme.canvasColor, 40 | ), 41 | data: PieSeries( 42 | donutRadius: 40.0, 43 | donutSpaceColor: Colors.transparent, 44 | donutLabelStyle: ChartTextStyle( 45 | textStyle: GoogleFonts.poppins( 46 | color: theme.colorScheme.inverseSurface, 47 | ), 48 | ), 49 | donutLabel: () => 'Crypto', 50 | interactionEvents: PieInteractionEvents( 51 | isEnabled: true, 52 | onTap: (PieInteractionResult result) { 53 | setState(() { 54 | interactionIndex = result.sliceDataIndex; 55 | }); 56 | }, 57 | ), 58 | slices: makeSliceData(context), 59 | ), 60 | ); 61 | } 62 | 63 | List makeSliceData(BuildContext context) { 64 | var theme = Theme.of(context); 65 | 66 | List barSeries = List.generate(5, (index) { 67 | return SliceData( 68 | value: 50 * index / 2, 69 | label: (percent, value) => getCryptoName(index), 70 | labelStyle: ChartTextStyle( 71 | textStyle: GoogleFonts.poppins( 72 | color: theme.colorScheme.inverseSurface, 73 | ), 74 | ), 75 | style: SliceDataStyle( 76 | radius: index == interactionIndex ? 120 : 110, 77 | color: getColorForPiece(index), 78 | strokeWidth: 0.0, 79 | strokeColor: const Color(0xFF0D116D), 80 | ), 81 | ); 82 | }); 83 | 84 | return barSeries; 85 | } 86 | } 87 | 88 | String getCryptoName(int index) { 89 | switch (index) { 90 | case 0: 91 | return 'Bitcoin'; 92 | case 1: 93 | return 'Ethereum'; 94 | case 2: 95 | return 'Binance'; 96 | case 3: 97 | return 'Tether'; 98 | case 4: 99 | return 'DOGE'; 100 | default: 101 | return ''; 102 | } 103 | } 104 | 105 | Color getColorForPiece(int index) { 106 | switch (index) { 107 | case 0: 108 | return const Color(0xFFBDA2F4); 109 | case 1: 110 | return const Color(0xFF7136E7); 111 | case 2: 112 | return const Color(0xFF693C00); 113 | case 3: 114 | return const Color(0xFF9295F2); 115 | case 4: 116 | return const Color(0xFFFFB86E); 117 | default: 118 | return Colors.transparent; 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /example/windows/runner/Runner.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #pragma code_page(65001) 4 | #include "resource.h" 5 | 6 | #define APSTUDIO_READONLY_SYMBOLS 7 | ///////////////////////////////////////////////////////////////////////////// 8 | // 9 | // Generated from the TEXTINCLUDE 2 resource. 10 | // 11 | #include "winres.h" 12 | 13 | ///////////////////////////////////////////////////////////////////////////// 14 | #undef APSTUDIO_READONLY_SYMBOLS 15 | 16 | ///////////////////////////////////////////////////////////////////////////// 17 | // English (United States) resources 18 | 19 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 20 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 21 | 22 | #ifdef APSTUDIO_INVOKED 23 | ///////////////////////////////////////////////////////////////////////////// 24 | // 25 | // TEXTINCLUDE 26 | // 27 | 28 | 1 TEXTINCLUDE 29 | BEGIN 30 | "resource.h\0" 31 | END 32 | 33 | 2 TEXTINCLUDE 34 | BEGIN 35 | "#include ""winres.h""\r\n" 36 | "\0" 37 | END 38 | 39 | 3 TEXTINCLUDE 40 | BEGIN 41 | "\r\n" 42 | "\0" 43 | END 44 | 45 | #endif // APSTUDIO_INVOKED 46 | 47 | 48 | ///////////////////////////////////////////////////////////////////////////// 49 | // 50 | // Icon 51 | // 52 | 53 | // Icon with lowest ID value placed first to ensure application icon 54 | // remains consistent on all systems. 55 | IDI_APP_ICON ICON "resources\\app_icon.ico" 56 | 57 | 58 | ///////////////////////////////////////////////////////////////////////////// 59 | // 60 | // Version 61 | // 62 | 63 | #if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD) 64 | #define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD 65 | #else 66 | #define VERSION_AS_NUMBER 1,0,0,0 67 | #endif 68 | 69 | #if defined(FLUTTER_VERSION) 70 | #define VERSION_AS_STRING FLUTTER_VERSION 71 | #else 72 | #define VERSION_AS_STRING "1.0.0" 73 | #endif 74 | 75 | VS_VERSION_INFO VERSIONINFO 76 | FILEVERSION VERSION_AS_NUMBER 77 | PRODUCTVERSION VERSION_AS_NUMBER 78 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 79 | #ifdef _DEBUG 80 | FILEFLAGS VS_FF_DEBUG 81 | #else 82 | FILEFLAGS 0x0L 83 | #endif 84 | FILEOS VOS__WINDOWS32 85 | FILETYPE VFT_APP 86 | FILESUBTYPE 0x0L 87 | BEGIN 88 | BLOCK "StringFileInfo" 89 | BEGIN 90 | BLOCK "040904e4" 91 | BEGIN 92 | VALUE "CompanyName", "com.wednesday" "\0" 93 | VALUE "FileDescription", "example" "\0" 94 | VALUE "FileVersion", VERSION_AS_STRING "\0" 95 | VALUE "InternalName", "example" "\0" 96 | VALUE "LegalCopyright", "Copyright (C) 2023 com.wednesday. All rights reserved." "\0" 97 | VALUE "OriginalFilename", "example.exe" "\0" 98 | VALUE "ProductName", "example" "\0" 99 | VALUE "ProductVersion", VERSION_AS_STRING "\0" 100 | END 101 | END 102 | BLOCK "VarFileInfo" 103 | BEGIN 104 | VALUE "Translation", 0x409, 1252 105 | END 106 | END 107 | 108 | #endif // English (United States) resources 109 | ///////////////////////////////////////////////////////////////////////////// 110 | 111 | 112 | 113 | #ifndef APSTUDIO_INVOKED 114 | ///////////////////////////////////////////////////////////////////////////// 115 | // 116 | // Generated from the TEXTINCLUDE 3 resource. 117 | // 118 | 119 | 120 | ///////////////////////////////////////////////////////////////////////////// 121 | #endif // not APSTUDIO_INVOKED 122 | -------------------------------------------------------------------------------- /lib/src/charts/widgets/pie_chart.dart: -------------------------------------------------------------------------------- 1 | import 'package:chart_it/src/charts/constants/defaults.dart'; 2 | import 'package:chart_it/src/charts/data/core.dart'; 3 | import 'package:chart_it/src/charts/data/pie.dart'; 4 | import 'package:chart_it/src/charts/renderers/radial_renderer.dart'; 5 | import 'package:chart_it/src/controllers/radial_controller.dart'; 6 | import 'package:flutter/material.dart'; 7 | 8 | /// Draws a PieChart or Donut Chart for the Provided Data 9 | class PieChart extends StatefulWidget { 10 | /// Title of the Chart 11 | final Text? title; 12 | 13 | /// Width of the Chart 14 | final double? width; 15 | 16 | /// Height of the Chart 17 | final double? height; 18 | 19 | /// Animates the Charts from zero values to given Data when the 20 | /// Chart loads for the first time. 21 | /// 22 | /// Defaults to true. 23 | final bool animateOnLoad; 24 | 25 | /// Controls if the charts should auto animate any updates to the data 26 | /// 27 | /// Defaults to true. 28 | final bool animateOnUpdate; 29 | 30 | /// The Duration for which the chart should animate 31 | final Duration animationDuration; 32 | 33 | /// A custom Animation controller to drive the chart animations 34 | final AnimationController? animation; 35 | 36 | /// Styling for the Chart. Includes options like 37 | /// Background, StartAngle, etc. 38 | final RadialChartStyle? chartStyle; 39 | 40 | /// The Data which will be Drawn as Pieces of Pie 41 | final PieSeries data; 42 | 43 | const PieChart({ 44 | Key? key, 45 | this.title, 46 | this.width, 47 | this.height, 48 | this.animateOnLoad = true, 49 | this.animateOnUpdate = true, 50 | this.animationDuration = const Duration(milliseconds: 500), 51 | this.animation, 52 | this.chartStyle, 53 | required this.data, 54 | }) : super(key: key); 55 | 56 | @override 57 | State createState() => _PieChartState(); 58 | } 59 | 60 | class _PieChartState extends State 61 | with SingleTickerProviderStateMixin { 62 | late RadialController _controller; 63 | late AnimationController _defaultAnimation; 64 | 65 | @override 66 | void initState() { 67 | super.initState(); 68 | // Initialize default animation controller 69 | _defaultAnimation = AnimationController( 70 | duration: widget.animationDuration, 71 | vsync: this, 72 | ); 73 | // provide the chart details to the controller 74 | _controller = RadialController( 75 | data: [widget.data], 76 | animation: _provideAnimation(), 77 | animateOnLoad: widget.animateOnLoad, 78 | animateOnUpdate: widget.animateOnUpdate, 79 | ); 80 | } 81 | 82 | @override 83 | void didUpdateWidget(covariant PieChart oldWidget) { 84 | super.didUpdateWidget(oldWidget); 85 | // We will update our Chart when new data is provided 86 | _controller.update( 87 | data: [widget.data], 88 | animation: _provideAnimation(), 89 | animateOnLoad: widget.animateOnLoad, 90 | animateOnUpdate: widget.animateOnUpdate, 91 | ); 92 | } 93 | 94 | @override 95 | Widget build(BuildContext context) { 96 | var style = widget.chartStyle ?? defaultRadialChartStyle; 97 | return AnimatedBuilder( 98 | animation: _controller, 99 | builder: (context, _) { 100 | return RadialRenderer( 101 | width: widget.width, 102 | height: widget.height, 103 | style: style, 104 | states: _controller.currentData.states, 105 | interactionDispatcher: _controller, 106 | ); 107 | }, 108 | ); 109 | } 110 | 111 | AnimationController _provideAnimation() => 112 | widget.animation ?? _defaultAnimation 113 | ..duration = widget.animationDuration; 114 | 115 | @override 116 | void dispose() { 117 | _controller.dispose(); 118 | super.dispose(); 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /example/lib/screens/bar_chart.dart: -------------------------------------------------------------------------------- 1 | import 'package:example/screens/bar_chart_animation.dart'; 2 | import 'package:example/screens/bar_charts_interaction.dart'; 3 | import 'package:flutter/material.dart'; 4 | import 'package:responsive_sizer/responsive_sizer.dart'; 5 | 6 | class TestBarChart extends StatelessWidget { 7 | const TestBarChart({Key? key}) : super(key: key); 8 | 9 | final LinearGradient titleGradient = const LinearGradient( 10 | begin: Alignment.bottomLeft, 11 | end: Alignment.topRight, 12 | stops: [ 13 | 0.1, 14 | 0.4, 15 | 0.95, 16 | ], 17 | colors: [ 18 | Color(0xFFE39F56), 19 | Color(0xFFBDA2F4), 20 | Color(0xFFE39F56), 21 | ], 22 | ); 23 | 24 | @override 25 | Widget build(BuildContext context) { 26 | return Scaffold( 27 | body: Column( 28 | children: [ 29 | Align( 30 | alignment: Alignment.centerLeft, 31 | child: Padding( 32 | padding: const EdgeInsets.all(20.0), 33 | child: ShaderMask( 34 | blendMode: BlendMode.srcIn, 35 | shaderCallback: (Rect bounds) => titleGradient.createShader( 36 | Rect.fromLTWH(0.0, 0.0, bounds.width, bounds.height), 37 | ), 38 | child: Text( 39 | 'Bar Charts', 40 | style: TextStyle( 41 | fontSize: 26.sp, 42 | fontWeight: FontWeight.bold, 43 | ), 44 | ), 45 | ), 46 | ), 47 | ), 48 | Expanded( 49 | child: ListView( 50 | children: [ 51 | Padding( 52 | padding: const EdgeInsets.all(8.0), 53 | child: Text( 54 | "Bar Chart State Changes", 55 | textAlign: TextAlign.center, 56 | style: TextStyle( 57 | fontSize: 22, 58 | color: Theme.of(context).colorScheme.onBackground, 59 | ), 60 | ), 61 | ), 62 | const Padding( 63 | padding: EdgeInsets.all(8.0), 64 | child: TestBarChartsAnimation(), 65 | ), 66 | Text( 67 | "Tap the chart to change data.", 68 | textAlign: TextAlign.center, 69 | style: TextStyle( 70 | fontSize: 18, 71 | color: Theme.of(context).colorScheme.onBackground, 72 | ), 73 | ), 74 | const Divider( 75 | height: 100, 76 | thickness: 20, 77 | ), 78 | Padding( 79 | padding: const EdgeInsets.all(8.0), 80 | child: Text( 81 | "Bar Chart Interactions", 82 | textAlign: TextAlign.center, 83 | style: TextStyle( 84 | fontSize: 22, 85 | color: Theme.of(context).colorScheme.onBackground, 86 | ), 87 | ), 88 | ), 89 | const Padding( 90 | padding: EdgeInsets.all(8.0), 91 | child: TestBarChartsInteraction(), 92 | ), 93 | Text( 94 | "Tap or drag to interact with the chart.", 95 | textAlign: TextAlign.center, 96 | style: TextStyle( 97 | fontSize: 18, 98 | color: Theme.of(context).colorScheme.onBackground, 99 | ), 100 | ), 101 | const SizedBox( 102 | height: 50, 103 | ) 104 | ], 105 | ), 106 | ), 107 | ], 108 | ), 109 | ); 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /example/windows/runner/win32_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_WIN32_WINDOW_H_ 2 | #define RUNNER_WIN32_WINDOW_H_ 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | // A class abstraction for a high DPI-aware Win32 Window. Intended to be 11 | // inherited from by classes that wish to specialize with custom 12 | // rendering and input handling 13 | class Win32Window { 14 | public: 15 | struct Point { 16 | unsigned int x; 17 | unsigned int y; 18 | Point(unsigned int x, unsigned int y) : x(x), y(y) {} 19 | }; 20 | 21 | struct Size { 22 | unsigned int width; 23 | unsigned int height; 24 | Size(unsigned int width, unsigned int height) 25 | : width(width), height(height) {} 26 | }; 27 | 28 | Win32Window(); 29 | virtual ~Win32Window(); 30 | 31 | // Creates a win32 window with |title| that is positioned and sized using 32 | // |origin| and |size|. New windows are created on the default monitor. Window 33 | // sizes are specified to the OS in physical pixels, hence to ensure a 34 | // consistent size this function will scale the inputted width and height as 35 | // as appropriate for the default monitor. The window is invisible until 36 | // |Show| is called. Returns true if the window was created successfully. 37 | bool Create(const std::wstring& title, const Point& origin, const Size& size); 38 | 39 | // Show the current window. Returns true if the window was successfully shown. 40 | bool Show(); 41 | 42 | // Release OS resources associated with window. 43 | void Destroy(); 44 | 45 | // Inserts |content| into the window tree. 46 | void SetChildContent(HWND content); 47 | 48 | // Returns the backing Window handle to enable clients to set icon and other 49 | // window properties. Returns nullptr if the window has been destroyed. 50 | HWND GetHandle(); 51 | 52 | // If true, closing this window will quit the application. 53 | void SetQuitOnClose(bool quit_on_close); 54 | 55 | // Return a RECT representing the bounds of the current client area. 56 | RECT GetClientArea(); 57 | 58 | protected: 59 | // Processes and route salient window messages for mouse handling, 60 | // size change and DPI. Delegates handling of these to member overloads that 61 | // inheriting classes can handle. 62 | virtual LRESULT MessageHandler(HWND window, 63 | UINT const message, 64 | WPARAM const wparam, 65 | LPARAM const lparam) noexcept; 66 | 67 | // Called when CreateAndShow is called, allowing subclass window-related 68 | // setup. Subclasses should return false if setup fails. 69 | virtual bool OnCreate(); 70 | 71 | // Called when Destroy is called. 72 | virtual void OnDestroy(); 73 | 74 | private: 75 | friend class WindowClassRegistrar; 76 | 77 | // OS callback called by message pump. Handles the WM_NCCREATE message which 78 | // is passed when the non-client area is being created and enables automatic 79 | // non-client DPI scaling so that the non-client area automatically 80 | // responsponds to changes in DPI. All other messages are handled by 81 | // MessageHandler. 82 | static LRESULT CALLBACK WndProc(HWND const window, 83 | UINT const message, 84 | WPARAM const wparam, 85 | LPARAM const lparam) noexcept; 86 | 87 | // Retrieves a class instance pointer for |window| 88 | static Win32Window* GetThisFromHandle(HWND const window) noexcept; 89 | 90 | // Update the window frame's theme to match the system theme. 91 | static void UpdateTheme(HWND const window); 92 | 93 | bool quit_on_close_ = false; 94 | 95 | // window handle for top level window. 96 | HWND window_handle_ = nullptr; 97 | 98 | // window handle for hosted content. 99 | HWND child_content_ = nullptr; 100 | }; 101 | 102 | #endif // RUNNER_WIN32_WINDOW_H_ 103 | -------------------------------------------------------------------------------- /lib/src/interactions/hit_test/interaction_dispatcher.dart: -------------------------------------------------------------------------------- 1 | import 'package:chart_it/src/extensions/primitives.dart'; 2 | import 'package:chart_it/src/interactions/data/touch_interaction_events.dart'; 3 | import 'package:chart_it/src/interactions/data/touch_interactions.dart'; 4 | import 'package:flutter/material.dart'; 5 | 6 | mixin InteractionDispatcher { 7 | Offset? _latestTapOffset; 8 | Offset? _latestDoubleTapOffset; 9 | Offset? _latestPanOffset; 10 | 11 | bool get tapRecognitionEnabled => _tapRecognitionEnabled; 12 | bool _tapRecognitionEnabled = false; 13 | 14 | bool get doubleTapRecognitionEnabled => _doubleTapRecognitionEnabled; 15 | bool _doubleTapRecognitionEnabled = false; 16 | 17 | bool get dragRecognitionEnabled => _dragRecognitionEnabled; 18 | bool _dragRecognitionEnabled = false; 19 | 20 | updateInteractionDetectionStates( 21 | TouchInteractionEvents interactionEvents) { 22 | if (interactionEvents.shouldHitTest.isFalse) return; 23 | 24 | if (interactionEvents.onRawInteraction.isNotNull) { 25 | _tapRecognitionEnabled = true; 26 | _doubleTapRecognitionEnabled = true; 27 | _dragRecognitionEnabled = true; 28 | } 29 | 30 | if (_tapRecognitionEnabled.isFalse) { 31 | _tapRecognitionEnabled = interactionEvents.onTap.isNotNull || 32 | interactionEvents.onTapUp.isNotNull || 33 | interactionEvents.onTapDown.isNotNull; 34 | } 35 | 36 | if (_doubleTapRecognitionEnabled.isFalse) { 37 | _doubleTapRecognitionEnabled = interactionEvents.onDoubleTap.isNotNull; 38 | } 39 | 40 | if (_dragRecognitionEnabled.isFalse) { 41 | _dragRecognitionEnabled = interactionEvents.onDrag.isNotNull || 42 | interactionEvents.onDragStart.isNotNull || 43 | interactionEvents.onDragEnd.isNotNull; 44 | } 45 | } 46 | 47 | @protected 48 | void onInteraction( 49 | TouchInteractionType interactionType, 50 | Offset localPosition, 51 | ); 52 | 53 | void onTapDown(TapDownDetails details) { 54 | _latestTapOffset = details.localPosition; 55 | onInteraction(TouchInteractionType.tapDown, details.localPosition); 56 | } 57 | 58 | void onTapUp(TapUpDetails details) { 59 | _latestTapOffset = details.localPosition; 60 | onInteraction(TouchInteractionType.tapUp, details.localPosition); 61 | } 62 | 63 | void onTap() { 64 | final latestTapOffset = _latestTapOffset; 65 | if (latestTapOffset != null) { 66 | onInteraction(TouchInteractionType.tap, latestTapOffset); 67 | } 68 | _latestTapOffset = null; 69 | } 70 | 71 | void onTapCancel() { 72 | _latestTapOffset = null; 73 | } 74 | 75 | void onDoubleTap() { 76 | final latestDoubleTapOffset = _latestDoubleTapOffset; 77 | if (latestDoubleTapOffset != null) { 78 | onInteraction(TouchInteractionType.doubleTap, latestDoubleTapOffset); 79 | } 80 | } 81 | 82 | void onDoubleTapDown(TapDownDetails details) { 83 | _latestDoubleTapOffset = details.localPosition; 84 | } 85 | 86 | void onDoubleTapCancel() { 87 | _latestDoubleTapOffset = null; 88 | } 89 | 90 | void onPanStart(DragStartDetails details) { 91 | _latestPanOffset = details.localPosition; 92 | onInteraction(TouchInteractionType.dragStart, details.localPosition); 93 | } 94 | 95 | void onPanUpdate(DragUpdateDetails details) { 96 | _latestPanOffset = details.localPosition; 97 | onInteraction(TouchInteractionType.dragUpdate, details.localPosition); 98 | } 99 | 100 | void onPanCancel() { 101 | final latestPanOffset = _latestPanOffset; 102 | if (latestPanOffset != null) { 103 | onInteraction(TouchInteractionType.dragEnd, latestPanOffset); 104 | } 105 | _latestPanOffset = null; 106 | } 107 | 108 | void onPanEnd(DragEndDetails details) { 109 | final latestPanOffset = _latestPanOffset; 110 | if (latestPanOffset != null) { 111 | onInteraction(TouchInteractionType.dragEnd, latestPanOffset); 112 | } 113 | _latestPanOffset = null; 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /example/linux/my_application.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | #include 4 | #ifdef GDK_WINDOWING_X11 5 | #include 6 | #endif 7 | 8 | #include "flutter/generated_plugin_registrant.h" 9 | 10 | struct _MyApplication { 11 | GtkApplication parent_instance; 12 | char** dart_entrypoint_arguments; 13 | }; 14 | 15 | G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) 16 | 17 | // Implements GApplication::activate. 18 | static void my_application_activate(GApplication* application) { 19 | MyApplication* self = MY_APPLICATION(application); 20 | GtkWindow* window = 21 | GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); 22 | 23 | // Use a header bar when running in GNOME as this is the common style used 24 | // by applications and is the setup most users will be using (e.g. Ubuntu 25 | // desktop). 26 | // If running on X and not using GNOME then just use a traditional title bar 27 | // in case the window manager does more exotic layout, e.g. tiling. 28 | // If running on Wayland assume the header bar will work (may need changing 29 | // if future cases occur). 30 | gboolean use_header_bar = TRUE; 31 | #ifdef GDK_WINDOWING_X11 32 | GdkScreen* screen = gtk_window_get_screen(window); 33 | if (GDK_IS_X11_SCREEN(screen)) { 34 | const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); 35 | if (g_strcmp0(wm_name, "GNOME Shell") != 0) { 36 | use_header_bar = FALSE; 37 | } 38 | } 39 | #endif 40 | if (use_header_bar) { 41 | GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); 42 | gtk_widget_show(GTK_WIDGET(header_bar)); 43 | gtk_header_bar_set_title(header_bar, "example"); 44 | gtk_header_bar_set_show_close_button(header_bar, TRUE); 45 | gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); 46 | } else { 47 | gtk_window_set_title(window, "example"); 48 | } 49 | 50 | gtk_window_set_default_size(window, 1280, 720); 51 | gtk_widget_show(GTK_WIDGET(window)); 52 | 53 | g_autoptr(FlDartProject) project = fl_dart_project_new(); 54 | fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments); 55 | 56 | FlView* view = fl_view_new(project); 57 | gtk_widget_show(GTK_WIDGET(view)); 58 | gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); 59 | 60 | fl_register_plugins(FL_PLUGIN_REGISTRY(view)); 61 | 62 | gtk_widget_grab_focus(GTK_WIDGET(view)); 63 | } 64 | 65 | // Implements GApplication::local_command_line. 66 | static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) { 67 | MyApplication* self = MY_APPLICATION(application); 68 | // Strip out the first argument as it is the binary name. 69 | self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); 70 | 71 | g_autoptr(GError) error = nullptr; 72 | if (!g_application_register(application, nullptr, &error)) { 73 | g_warning("Failed to register: %s", error->message); 74 | *exit_status = 1; 75 | return TRUE; 76 | } 77 | 78 | g_application_activate(application); 79 | *exit_status = 0; 80 | 81 | return TRUE; 82 | } 83 | 84 | // Implements GObject::dispose. 85 | static void my_application_dispose(GObject* object) { 86 | MyApplication* self = MY_APPLICATION(object); 87 | g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); 88 | G_OBJECT_CLASS(my_application_parent_class)->dispose(object); 89 | } 90 | 91 | static void my_application_class_init(MyApplicationClass* klass) { 92 | G_APPLICATION_CLASS(klass)->activate = my_application_activate; 93 | G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line; 94 | G_OBJECT_CLASS(klass)->dispose = my_application_dispose; 95 | } 96 | 97 | static void my_application_init(MyApplication* self) {} 98 | 99 | MyApplication* my_application_new() { 100 | return MY_APPLICATION(g_object_new(my_application_get_type(), 101 | "application-id", APPLICATION_ID, 102 | "flags", G_APPLICATION_NON_UNIQUE, 103 | nullptr)); 104 | } 105 | -------------------------------------------------------------------------------- /example/windows/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This file controls Flutter-level build steps. It should not be edited. 2 | cmake_minimum_required(VERSION 3.14) 3 | 4 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 5 | 6 | # Configuration provided via flutter tool. 7 | include(${EPHEMERAL_DIR}/generated_config.cmake) 8 | 9 | # TODO: Move the rest of this into files in ephemeral. See 10 | # https://github.com/flutter/flutter/issues/57146. 11 | set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") 12 | 13 | # === Flutter Library === 14 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") 15 | 16 | # Published to parent scope for install step. 17 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 18 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 19 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 20 | set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) 21 | 22 | list(APPEND FLUTTER_LIBRARY_HEADERS 23 | "flutter_export.h" 24 | "flutter_windows.h" 25 | "flutter_messenger.h" 26 | "flutter_plugin_registrar.h" 27 | "flutter_texture_registrar.h" 28 | ) 29 | list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") 30 | add_library(flutter INTERFACE) 31 | target_include_directories(flutter INTERFACE 32 | "${EPHEMERAL_DIR}" 33 | ) 34 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") 35 | add_dependencies(flutter flutter_assemble) 36 | 37 | # === Wrapper === 38 | list(APPEND CPP_WRAPPER_SOURCES_CORE 39 | "core_implementations.cc" 40 | "standard_codec.cc" 41 | ) 42 | list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") 43 | list(APPEND CPP_WRAPPER_SOURCES_PLUGIN 44 | "plugin_registrar.cc" 45 | ) 46 | list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") 47 | list(APPEND CPP_WRAPPER_SOURCES_APP 48 | "flutter_engine.cc" 49 | "flutter_view_controller.cc" 50 | ) 51 | list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") 52 | 53 | # Wrapper sources needed for a plugin. 54 | add_library(flutter_wrapper_plugin STATIC 55 | ${CPP_WRAPPER_SOURCES_CORE} 56 | ${CPP_WRAPPER_SOURCES_PLUGIN} 57 | ) 58 | apply_standard_settings(flutter_wrapper_plugin) 59 | set_target_properties(flutter_wrapper_plugin PROPERTIES 60 | POSITION_INDEPENDENT_CODE ON) 61 | set_target_properties(flutter_wrapper_plugin PROPERTIES 62 | CXX_VISIBILITY_PRESET hidden) 63 | target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) 64 | target_include_directories(flutter_wrapper_plugin PUBLIC 65 | "${WRAPPER_ROOT}/include" 66 | ) 67 | add_dependencies(flutter_wrapper_plugin flutter_assemble) 68 | 69 | # Wrapper sources needed for the runner. 70 | add_library(flutter_wrapper_app STATIC 71 | ${CPP_WRAPPER_SOURCES_CORE} 72 | ${CPP_WRAPPER_SOURCES_APP} 73 | ) 74 | apply_standard_settings(flutter_wrapper_app) 75 | target_link_libraries(flutter_wrapper_app PUBLIC flutter) 76 | target_include_directories(flutter_wrapper_app PUBLIC 77 | "${WRAPPER_ROOT}/include" 78 | ) 79 | add_dependencies(flutter_wrapper_app flutter_assemble) 80 | 81 | # === Flutter tool backend === 82 | # _phony_ is a non-existent file to force this command to run every time, 83 | # since currently there's no way to get a full input/output list from the 84 | # flutter tool. 85 | set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") 86 | set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) 87 | add_custom_command( 88 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 89 | ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} 90 | ${CPP_WRAPPER_SOURCES_APP} 91 | ${PHONY_OUTPUT} 92 | COMMAND ${CMAKE_COMMAND} -E env 93 | ${FLUTTER_TOOL_ENVIRONMENT} 94 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" 95 | windows-x64 $ 96 | VERBATIM 97 | ) 98 | add_custom_target(flutter_assemble DEPENDS 99 | "${FLUTTER_LIBRARY}" 100 | ${FLUTTER_LIBRARY_HEADERS} 101 | ${CPP_WRAPPER_SOURCES_CORE} 102 | ${CPP_WRAPPER_SOURCES_PLUGIN} 103 | ${CPP_WRAPPER_SOURCES_APP} 104 | ) 105 | -------------------------------------------------------------------------------- /example/windows/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Project-level configuration. 2 | cmake_minimum_required(VERSION 3.14) 3 | project(example LANGUAGES CXX) 4 | 5 | # The name of the executable created for the application. Change this to change 6 | # the on-disk name of your application. 7 | set(BINARY_NAME "example") 8 | 9 | # Explicitly opt in to modern CMake behaviors to avoid warnings with recent 10 | # versions of CMake. 11 | cmake_policy(SET CMP0063 NEW) 12 | 13 | # Define build configuration option. 14 | get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) 15 | if (IS_MULTICONFIG) 16 | set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" 17 | CACHE STRING "" FORCE) 18 | else () 19 | if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 20 | set(CMAKE_BUILD_TYPE "Debug" CACHE 21 | STRING "Flutter build mode" FORCE) 22 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 23 | "Debug" "Profile" "Release") 24 | endif () 25 | endif () 26 | # Define settings for the Profile build mode. 27 | set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") 28 | set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") 29 | set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") 30 | set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") 31 | 32 | # Use Unicode for all projects. 33 | add_definitions(-DUNICODE -D_UNICODE) 34 | 35 | # Compilation settings that should be applied to most targets. 36 | # 37 | # Be cautious about adding new options here, as plugins use this function by 38 | # default. In most cases, you should add new options to specific targets instead 39 | # of modifying this function. 40 | function(APPLY_STANDARD_SETTINGS TARGET) 41 | target_compile_features(${TARGET} PUBLIC cxx_std_17) 42 | target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") 43 | target_compile_options(${TARGET} PRIVATE /EHsc) 44 | target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") 45 | target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") 46 | endfunction() 47 | 48 | # Flutter library and tool build rules. 49 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") 50 | add_subdirectory(${FLUTTER_MANAGED_DIR}) 51 | 52 | # Application build; see runner/CMakeLists.txt. 53 | add_subdirectory("runner") 54 | 55 | # Generated plugin build rules, which manage building the plugins and adding 56 | # them to the application. 57 | include(flutter/generated_plugins.cmake) 58 | 59 | 60 | # === Installation === 61 | # Support files are copied into place next to the executable, so that it can 62 | # run in place. This is done instead of making a separate bundle (as on Linux) 63 | # so that building and running from within Visual Studio will work. 64 | set(BUILD_BUNDLE_DIR "$") 65 | # Make the "install" step default, as it's required to run. 66 | set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) 67 | if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 68 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 69 | endif () 70 | 71 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 72 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") 73 | 74 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 75 | COMPONENT Runtime) 76 | 77 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 78 | COMPONENT Runtime) 79 | 80 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 81 | COMPONENT Runtime) 82 | 83 | if (PLUGIN_BUNDLED_LIBRARIES) 84 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" 85 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 86 | COMPONENT Runtime) 87 | endif () 88 | 89 | # Fully re-copy the assets directory on each build to avoid having stale files 90 | # from a previous install. 91 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 92 | install(CODE " 93 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 94 | " COMPONENT Runtime) 95 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 96 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 97 | 98 | # Install the AOT library on non-Debug builds only. 99 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 100 | CONFIGURATIONS Profile;Release 101 | COMPONENT Runtime) 102 | -------------------------------------------------------------------------------- /lib/src/charts/data/core/cartesian/cartesian_data_internal.dart: -------------------------------------------------------------------------------- 1 | import 'package:chart_it/src/charts/data/core/cartesian/cartesian_grid_units.dart'; 2 | import 'package:chart_it/src/charts/state/painting_state.dart'; 3 | import 'package:equatable/equatable.dart'; 4 | import 'package:flutter/widgets.dart'; 5 | 6 | class CartesianData with EquatableMixin { 7 | List states; 8 | CartesianGridUnitsData gridUnitsData; 9 | 10 | CartesianData({ 11 | required this.states, 12 | required this.gridUnitsData, 13 | }); 14 | 15 | factory CartesianData.zero({ 16 | required CartesianGridUnitsData gridUnitsData, 17 | }) { 18 | return CartesianData( 19 | states: List.empty(), 20 | gridUnitsData: gridUnitsData, 21 | ); 22 | } 23 | 24 | static CartesianData lerp( 25 | CartesianData? current, 26 | CartesianData target, 27 | double t, 28 | ) { 29 | return CartesianData( 30 | states: PaintingState.lerpStateList(current?.states, target.states, t), 31 | gridUnitsData: CartesianGridUnitsData.lerp( 32 | current?.gridUnitsData, target.gridUnitsData, t), 33 | ); 34 | } 35 | 36 | @override 37 | List get props => [states, gridUnitsData]; 38 | } 39 | 40 | class CartesianDataTween extends Tween { 41 | /// A Tween to interpolate between two [CartesianData] 42 | /// 43 | /// [end] object must not be null. 44 | CartesianDataTween({ 45 | required CartesianData? begin, 46 | required CartesianData end, 47 | }) : super(begin: begin, end: end); 48 | 49 | @override 50 | CartesianData lerp(double t) => CartesianData.lerp(begin, end!, t); 51 | } 52 | 53 | abstract class CartesianConfig with EquatableMixin {} 54 | 55 | class CartesianPaintingGeometryData extends Equatable { 56 | final Rect graphPolygon; 57 | final Offset axisOrigin; 58 | 59 | final double graphUnitWidth; 60 | final double graphUnitHeight; 61 | 62 | final double valueUnitWidth; 63 | final double valueUnitHeight; 64 | 65 | final CartesianGridUnitsData unitData; 66 | 67 | final double xUnitValue; 68 | 69 | const CartesianPaintingGeometryData({ 70 | required this.graphPolygon, 71 | required this.axisOrigin, 72 | required this.graphUnitWidth, 73 | required this.graphUnitHeight, 74 | required this.valueUnitWidth, 75 | required this.valueUnitHeight, 76 | required this.unitData, 77 | required this.xUnitValue, 78 | }); 79 | 80 | static const zero = CartesianPaintingGeometryData( 81 | graphPolygon: Rect.zero, 82 | axisOrigin: Offset.zero, 83 | graphUnitWidth: 1, 84 | graphUnitHeight: 1, 85 | valueUnitWidth: 1, 86 | valueUnitHeight: 1, 87 | unitData: CartesianGridUnitsData.zero, 88 | xUnitValue: 1, 89 | ); 90 | 91 | @override 92 | List get props => [ 93 | graphPolygon, 94 | axisOrigin, 95 | graphUnitWidth, 96 | graphUnitHeight, 97 | valueUnitWidth, 98 | valueUnitHeight, 99 | unitData, 100 | xUnitValue 101 | ]; 102 | 103 | CartesianPaintingGeometryData copyWith({ 104 | Rect? graphPolygon, 105 | Offset? axisOrigin, 106 | double? graphUnitWidth, 107 | double? graphUnitHeight, 108 | double? valueUnitWidth, 109 | double? valueUnitHeight, 110 | CartesianGridUnitsData? unitData, 111 | EdgeInsets? graphEdgeInsets, 112 | double? xUnitValue, 113 | }) { 114 | return CartesianPaintingGeometryData( 115 | graphPolygon: graphPolygon ?? this.graphPolygon, 116 | axisOrigin: axisOrigin ?? this.axisOrigin, 117 | graphUnitWidth: graphUnitWidth ?? this.graphUnitWidth, 118 | graphUnitHeight: graphUnitHeight ?? this.graphUnitHeight, 119 | valueUnitWidth: valueUnitWidth ?? this.valueUnitWidth, 120 | valueUnitHeight: valueUnitHeight ?? this.valueUnitHeight, 121 | unitData: unitData ?? this.unitData, 122 | xUnitValue: xUnitValue ?? this.xUnitValue, 123 | ); 124 | } 125 | 126 | CartesianPaintingGeometryData atOffset(Offset offset) { 127 | return copyWith( 128 | graphPolygon: graphPolygon.translate(offset.dx, offset.dy), 129 | axisOrigin: axisOrigin + offset, 130 | ); 131 | } 132 | 133 | @override 134 | String toString() { 135 | return ''' 136 | CartesianPaintingGeometryData{ 137 | graphPolygon: $graphPolygon, 138 | axisOrigin: $axisOrigin, 139 | graphUnitWidth: $graphUnitWidth, 140 | graphUnitHeight: $graphUnitHeight, 141 | valueUnitWidth: $valueUnitWidth, 142 | valueUnitHeight: $valueUnitHeight, 143 | unitData: $unitData, 144 | xUnitValue: $xUnitValue, 145 | }'''; 146 | } 147 | } 148 | --------------------------------------------------------------------------------