### Installation Configuration for Flutter Application in CMake Source: https://github.com/jdongkhan/flutter_chart/blob/main/example/windows/CMakeLists.txt Configures the installation process for the Flutter application. It sets the installation prefix, defines directories for data and libraries, and installs the executable, ICU data, Flutter library, and bundled plugin libraries. ```cmake set(BUILD_BUNDLE_DIR "$") set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Initialize ChartWidget in Flutter Source: https://context7.com/jdongkhan/flutter_chart/llms.txt Demonstrates the basic setup of the ChartWidget, the main container for rendering charts in Flutter Chart Plus. It requires a coordinate render and can optionally accept a controller and foreground widget. ```dart import 'package:flutter_chart_plus/flutter_chart.dart'; SizedBox( height: 200, child: ChartWidget( coordinateRender: ChartDimensionsCoordinateRender( margin: const EdgeInsets.only(left: 40, top: 5, right: 0, bottom: 30), yAxis: [YAxis(min: 0, max: 500)], xAxis: XAxis(count: 7, max: 30), charts: [ // Add chart renders here ], ), controller: ChartController(), // Optional controller foregroundWidget: Text('Overlay'), // Optional foreground widget ), ) ``` -------------------------------- ### CMake Installation Rules Source: https://github.com/jdongkhan/flutter_chart/blob/main/example/linux/CMakeLists.txt Defines how the application and its resources are installed. It ensures a clean bundle directory and installs the executable, ICU data, Flutter library, bundled plugins, and assets. ```cmake set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() install(CODE " file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") " COMPONENT Runtime) set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) install(FILES "${bundled_library}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endforeach(bundled_library) set(FLUTTER_ASSET_DIR_NAME "flutter_assets") install(CODE " file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") " COMPONENT Runtime) install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Asset and AOT Library Installation in CMake Source: https://github.com/jdongkhan/flutter_chart/blob/main/example/windows/CMakeLists.txt Handles the installation of the Flutter assets directory and the AOT (Ahead-Of-Time) compiled library. The assets directory is re-copied on each build to ensure freshness, and the AOT library is installed only on non-Debug builds. ```cmake set(FLUTTER_ASSET_DIR_NAME "flutter_assets") install(CODE " file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") " COMPONENT Runtime) install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### Create Pie and Donut Charts in Flutter Source: https://context7.com/jdongkhan/flutter_chart/llms.txt Illustrates the creation of pie and donut charts with interactive features like tap selection, guide lines, and legends. Customization options include hollow radius for donuts and text styling. ```dart final List dataList = [ {'name': 'Category A', 'value': 300}, {'name': 'Category B', 'value': 200}, {'name': 'Category C', 'value': 150}, {'name': 'Category D', 'value': 100}, ]; SizedBox( height: 200, child: ChartWidget( coordinateRender: ChartCircularCoordinateRender( margin: const EdgeInsets.all(20), charts: [ Pie( data: dataList, position: (item, index) => double.parse(item['value'].toString()), holeRadius: 40, // Creates donut chart, 0 for full pie spaceWidth: 2, // Gap between slices guideLine: true, // Show guide lines guideLineWidth: 50, enableTap: true, // Enable tap selection centerTextStyle: const TextStyle( color: Colors.black, fontSize: 16, fontWeight: FontWeight.bold, ), valueFormatter: (item, percent) => '${(percent * 100).toStringAsFixed(1)}%', legendFormatter: (item, percent) => item['name'], legendValueFormatter: (item, percent) => '${item['value']}', ), ], ), ), ) ``` -------------------------------- ### Create a Line Chart with Flutter Chart Plus Source: https://context7.com/jdongkhan/flutter_chart/llms.txt Illustrates how to create a line chart using Flutter Chart Plus. This example shows how to configure axes, data points, multiple lines with different styles (curve, filled, gradient), and data point markers. ```dart final DateTime startTime = DateTime(2024, 1, 1); final List dataList = [ {'time': startTime.add(Duration(days: 1)), 'value1': 100, 'value2': 150}, {'time': startTime.add(Duration(days: 2)), 'value1': 200, 'value2': 180}, {'time': startTime.add(Duration(days: 3)), 'value1': 150, 'value2': 220}, {'time': startTime.add(Duration(days: 4)), 'value1': 300, 'value2': 250}, ]; SizedBox( height: 200, child: ChartWidget( coordinateRender: ChartDimensionsCoordinateRender( margin: const EdgeInsets.only(left: 40, top: 5, right: 30, bottom: 30), crossHair: const CrossHairStyle(adjustHorizontal: true, adjustVertical: true), yAxis: [ YAxis(min: 0, max: 500, drawGrid: true), ], xAxis: XAxis( count: 7, max: 20, zoom: true, formatter: (index) => startTime.add(Duration(days: index.toInt())).day.toString(), ), charts: [ Line( data: dataList, position: (item, index) => parserDateTimeToDayValue(item['time'] as DateTime, startTime), values: (item) => [item['value1'] as num], colors: [Colors.blue], isCurve: true, filled: true, dotRadius: 3, ), Line( data: dataList, position: (item, index) => parserDateTimeToDayValue(item['time'] as DateTime, startTime), values: (item) => [item['value2'] as num], colors: [Colors.green], strokeWidth: 2, ), ], ), ), ) ``` -------------------------------- ### Include Generated Configuration Source: https://github.com/jdongkhan/flutter_chart/blob/main/example/linux/flutter/CMakeLists.txt Includes a generated configuration file that provides project-specific settings. This file is typically created by the Flutter tool and should not be edited manually. It allows for dynamic configuration based on the Flutter project's setup. ```cmake # Configuration provided via flutter tool. include(${EPHEMERAL_DIR}/generated_config.cmake) ``` -------------------------------- ### Install AOT Library on Non-Debug Builds (CMake) Source: https://github.com/jdongkhan/flutter_chart/blob/main/example/linux/CMakeLists.txt This CMake script installs the AOT library to the specified destination directory, but only when the build type is not 'Debug'. It ensures the library is available for runtime components in release configurations. ```cmake if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Define CMake Minimum Version and Ephemeral Directory Source: https://github.com/jdongkhan/flutter_chart/blob/main/example/linux/flutter/CMakeLists.txt Sets the minimum required CMake version to 3.10 and defines a variable for the ephemeral directory, which is used to store generated build artifacts. This is a standard CMake setup for project configuration. ```cmake cmake_minimum_required(VERSION 3.10) set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") ``` -------------------------------- ### Configure Flutter Library Paths and Headers (CMake) Source: https://github.com/jdongkhan/flutter_chart/blob/main/example/windows/flutter/CMakeLists.txt Sets up essential paths and headers for the Flutter library. It defines the location of the Flutter DLL, ICU data file, and project build directory, making them accessible in the parent scope for installation and linking. ```cmake cmake_minimum_required(VERSION 3.14) set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") # Configuration provided via flutter tool. include(${EPHEMERAL_DIR}/generated_config.cmake) # TODO: Move the rest of this into files in ephemeral. See # https://github.com/flutter/flutter/issues/57146. set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") # === Flutter Library === set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") # Published to parent scope for install step. set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) list(APPEND FLUTTER_LIBRARY_HEADERS "flutter_export.h" "flutter_windows.h" "flutter_messenger.h" "flutter_plugin_registrar.h" "flutter_texture_registrar.h" ) list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") add_library(flutter INTERFACE) target_include_directories(flutter INTERFACE "${EPHEMERAL_DIR}" ) target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") add_dependencies(flutter flutter_assemble) ``` -------------------------------- ### Define Flutter Library and Related Paths Source: https://github.com/jdongkhan/flutter_chart/blob/main/example/linux/flutter/CMakeLists.txt Defines the path to the Flutter Linux GTK shared library and related files like ICU data. These variables are set in the parent scope to be accessible by other CMake targets and installation steps. ```cmake set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") # Published to parent scope for install step. set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) ``` -------------------------------- ### Find and Check PkgConfig Modules for GTK, GLIB, and GIO Source: https://github.com/jdongkhan/flutter_chart/blob/main/example/linux/flutter/CMakeLists.txt Uses PkgConfig to find and check for required system libraries: GTK, GLIB, and GIO. This ensures that the necessary development files for these libraries are available and configured correctly for the build. The `REQUIRED` keyword means the build will fail if these packages are not found. ```cmake # System-level dependencies. find_package(PkgConfig REQUIRED) pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) ``` -------------------------------- ### Create Bar Charts in Flutter Source: https://context7.com/jdongkhan/flutter_chart/llms.txt Demonstrates how to create simple, grouped, and stacked bar charts using the flutter_chart library. Supports horizontal and vertical orientations with customizable appearance and data handling. ```dart final DateTime startTime = DateTime(2024, 1, 1); final List dataList = [ {'time': startTime.add(Duration(days: 1)), 'value1': 100, 'value2': 150, 'value3': 80}, {'time': startTime.add(Duration(days: 2)), 'value1': 200, 'value2': 180, 'value3': 120}, {'time': startTime.add(Duration(days: 3)), 'value1': 150, 'value2': 220, 'value3': 100}, ]; // Simple Bar Chart SizedBox( height: 200, child: ChartWidget( coordinateRender: ChartDimensionsCoordinateRender( yAxis: [YAxis(min: 0, max: 500)], margin: const EdgeInsets.only(left: 40, top: 0, right: 0, bottom: 30), xAxis: XAxis( count: 7, max: 30, formatter: (index) => 'Day ${index.toInt()}', ), charts: [ Bar( data: dataList, position: (item, index) => parserDateTimeToDayValue(item['time'] as DateTime, startTime), value: (item) => item['value1'], color: Colors.blue, itemWidth: 15, highlightColor: Colors.yellow, valueFormatter: (item) => '${item['value1']}', ), ], ), ), ) // Stacked Bar Chart (Grouped Horizontal) SizedBox( height: 200, child: ChartWidget( coordinateRender: ChartDimensionsCoordinateRender( yAxis: [YAxis(min: 0, max: 500)], margin: const EdgeInsets.only(left: 40, top: 0, right: 0, bottom: 30), xAxis: XAxis(count: 7, max: 30), charts: [ StackBar( data: dataList, position: (item, index) => parserDateTimeToDayValue(item['time'] as DateTime, startTime), direction: Axis.horizontal, // Grouped side by side itemWidth: 10, highlightColor: Colors.yellow, values: (item) => [ double.parse(item['value1'].toString()), double.parse(item['value2'].toString()), double.parse(item['value3'].toString()), ], ), ], ), ), ) // Stacked Bar Chart (Vertical Stack) SizedBox( height: 200, child: ChartWidget( coordinateRender: ChartDimensionsCoordinateRender( yAxis: [YAxis(min: 0, max: 500)], xAxis: XAxis(count: 7, max: 30), charts: [ StackBar( data: dataList, position: (item, index) => parserDateTimeToDayValue(item['time'] as DateTime, startTime), direction: Axis.vertical, // Stacked on top itemWidth: 20, full: true, // Fill based on proportions values: (item) => [ item['value1'] as num, item['value2'] as num, item['value3'] as num, ], ), ], ), ), ) ``` -------------------------------- ### Initialize Flutter Web App with Service Worker Source: https://github.com/jdongkhan/flutter_chart/blob/main/example/web/index.html This JavaScript code snippet initializes a Flutter web application. It configures the service worker, loads the main Dart entrypoint, and initializes the Flutter engine. The 'onEntrypointLoaded' callback handles engine initialization and app running. ```javascript window.addEventListener('load', function(ev) { var loadingDiv = document.querySelector('#loading'); loadingDiv.textContent = "Loading entrypoint..."; _flutter.loader.loadEntrypoint({ serviceWorker: { serviceWorkerVersion: serviceWorkerVersion, }, onEntrypointLoaded: function(engineInitializer) { loadingDiv.textContent = "Initializing engine..."; engineInitializer.initializeEngine({ renderer: 'canvaskit', canvasKitBaseUrl: './canvaskit/' }).then(function(appRunner) { loadingDiv.textContent = "Running app..."; appRunner.runApp(); }); } }); }); ``` -------------------------------- ### Custom Command for Flutter Tool Backend Source: https://github.com/jdongkhan/flutter_chart/blob/main/example/linux/flutter/CMakeLists.txt Defines a custom CMake command to execute the Flutter tool backend script. This command is set up to run every time because its output is tied to a phony target (`_phony_`). It passes build configuration details to the script, which generates the Flutter library and headers. ```cmake # === Flutter tool backend === # _phony_ is a non-existent file to force this command to run every time, # since currently there's no way to get a full input/output list from the # flutter tool. add_custom_command( OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} ${CMAKE_CURRENT_BINARY_DIR}/_phony_ COMMAND ${CMAKE_COMMAND} -E env ${FLUTTER_TOOL_ENVIRONMENT} "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} VERBATIM ) ``` -------------------------------- ### Integrate Flutter Tool Backend (CMake) Source: https://github.com/jdongkhan/flutter_chart/blob/main/example/windows/flutter/CMakeLists.txt Configures a custom command to run the Flutter tool backend, which is essential for assembling Flutter artifacts. It uses a phony output file to ensure the command executes on every build and defines a custom target 'flutter_assemble' to manage dependencies. ```cmake # === Flutter tool backend === # _phony_ is a non-existent file to force this command to run every time, # since currently there's no way to get a full input/output list from the # flutter tool. set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) add_custom_command( OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} ${CPP_WRAPPER_SOURCES_APP} ${PHONY_OUTPUT} COMMAND ${CMAKE_COMMAND} -E env ${FLUTTER_TOOL_ENVIRONMENT} "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" windows-x64 $ VERBATIM ) add_custom_target(flutter_assemble DEPENDS "${FLUTTER_LIBRARY}" ${FLUTTER_LIBRARY_HEADERS} ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} ${CPP_WRAPPER_SOURCES_APP} ) ``` -------------------------------- ### CMake Project Configuration Source: https://github.com/jdongkhan/flutter_chart/blob/main/example/linux/CMakeLists.txt Sets up the minimum CMake version, project name, and executable name. It also defines the application ID and opts into modern CMake behaviors. ```cmake cmake_minimum_required(VERSION 3.10) project(runner LANGUAGES CXX) set(BINARY_NAME "example") set(APPLICATION_ID "com.example.example") cmake_policy(SET CMP0063 NEW) ``` -------------------------------- ### Implement Tooltips and Click Handling for Charts in Dart Source: https://context7.com/jdongkhan/flutter_chart/llms.txt Enable interactive chart features like tooltips and click callbacks. Customize tooltip appearance using `tooltipBuilder` and handle click events via `onClickChart`. Requires `flutter_chart` package. ```dart ChartDimensionsCoordinateRender( yAxis: [YAxis(min: 0, max: 500)], xAxis: XAxis(count: 7, max: 30), crossHair: const CrossHairStyle( verticalShow: true, horizontalShow: true, adjustHorizontal: true, // Snap to nearest point adjustVertical: true, color: Colors.grey, strokeWidth: 1, ), tooltipBuilder: (context, chartStates) { // Return a PreferredSizeWidget for custom tooltip return PreferredSize( preferredSize: const Size(120, 60), child: Container( padding: const EdgeInsets.all(8), child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: chartStates.map((state) { final selected = state.selectedIndex; if (selected == null) return const SizedBox.shrink(); return Text('Value: ${state.children[selected].yValue}'); }).toList(), ), ), ); }, onClickChart: (context, chartStates) { for (var state in chartStates) { if (state.selectedIndex != null) { print('Clicked index: ${state.selectedIndex}'); } } }, charts: [...], ) ``` -------------------------------- ### Define Flutter Library Headers and Target Source: https://github.com/jdongkhan/flutter_chart/blob/main/example/linux/flutter/CMakeLists.txt Lists the header files required for the Flutter library and defines an INTERFACE library target named 'flutter'. This target includes the necessary header directories and links against the Flutter shared library and system dependencies (GTK, GLIB, GIO). ```cmake list(APPEND FLUTTER_LIBRARY_HEADERS "fl_basic_message_channel.h" "fl_binary_codec.h" "fl_binary_messenger.h" "fl_dart_project.h" "fl_engine.h" "fl_json_message_codec.h" "fl_json_method_codec.h" "fl_message_codec.h" "fl_method_call.h" "fl_method_channel.h" "fl_method_codec.h" "fl_method_response.h" "fl_plugin_registrar.h" "fl_plugin_registry.h" "fl_standard_message_codec.h" "fl_standard_method_codec.h" "fl_string_codec.h" "fl_value.h" "fl_view.h" "flutter_linux.h" ) list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") add_library(flutter INTERFACE) target_include_directories(flutter INTERFACE "${EPHEMERAL_DIR}" ) target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") target_link_libraries(flutter INTERFACE PkgConfig::GTK PkgConfig::GLIB PkgConfig::GIO ) add_dependencies(flutter flutter_assemble) ``` -------------------------------- ### Applying Standard Compilation Settings in CMake Source: https://github.com/jdongkhan/flutter_chart/blob/main/example/windows/CMakeLists.txt Defines a CMake function `APPLY_STANDARD_SETTINGS` to apply common compilation features, options, and definitions to a target. This includes setting the C++ standard to C++17 and configuring warning levels and exception handling. ```cmake add_definitions(-DUNICODE -D_UNICODE) function(APPLY_STANDARD_SETTINGS TARGET) target_compile_features(${TARGET} PUBLIC cxx_std_17) target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") target_compile_options(${TARGET} PRIVATE /EHsc) target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") endfunction() ``` -------------------------------- ### Project Configuration and Build Settings in CMake Source: https://github.com/jdongkhan/flutter_chart/blob/main/example/windows/CMakeLists.txt Configures the CMake project, sets the binary name, and defines build types (Debug, Profile, Release). It also sets up specific linker and compiler flags for the Profile build mode. ```cmake cmake_minimum_required(VERSION 3.14) project(example LANGUAGES CXX) set(BINARY_NAME "example") cmake_policy(SET CMP0063 NEW) get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) if(IS_MULTICONFIG) set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" CACHE STRING "" FORCE) else() if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Flutter build mode" FORCE) set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Profile" "Release") endif() endif() set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") ``` -------------------------------- ### CMake Dependency and Target Definition Source: https://github.com/jdongkhan/flutter_chart/blob/main/example/linux/CMakeLists.txt Finds and links system dependencies like PkgConfig and GTK. It defines the main executable target, including Flutter-generated plugin registration files. ```cmake find_package(PkgConfig REQUIRED) pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") add_executable(${BINARY_NAME} "main.cc" "my_application.cc" "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" ) apply_standard_settings(${BINARY_NAME}) target_link_libraries(${BINARY_NAME} PRIVATE flutter) target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) add_dependencies(${BINARY_NAME} flutter_assemble) ``` -------------------------------- ### Custom CMake List Prepend Function Source: https://github.com/jdongkhan/flutter_chart/blob/main/example/linux/flutter/CMakeLists.txt Defines a custom CMake function `list_prepend` to prepend an element to each item in a list. This is a workaround for older CMake versions (pre-3.10) that do not support the `list(TRANSFORM ... PREPEND ...)` command. It iterates through the list and builds a new list with the prefix added. ```cmake function(list_prepend LIST_NAME PREFIX) set(NEW_LIST "") foreach(element ${${LIST_NAME}}) list(APPEND NEW_LIST "${PREFIX}${element}") endforeach(element) set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) endfunction() ``` -------------------------------- ### Configure Flutter Runner with CMake Source: https://github.com/jdongkhan/flutter_chart/blob/main/example/windows/runner/CMakeLists.txt This CMake script sets up the build environment for the Flutter runner application. It defines the project, specifies the source files, and configures build settings. The script also handles preprocessor definitions for versioning and links necessary libraries. ```cmake cmake_minimum_required(VERSION 3.14) project(runner LANGUAGES CXX) # Define the application target. To change its name, change BINARY_NAME in the # top-level CMakeLists.txt, not the value here, or `flutter run` will no longer # work. # # Any new source files that you add to the application should be added here. add_executable(${BINARY_NAME} WIN32 "flutter_window.cpp" "main.cpp" "utils.cpp" "win32_window.cpp" "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" "Runner.rc" "runner.exe.manifest" ) # Apply the standard set of build settings. This can be removed for applications # that need different build settings. apply_standard_settings(${BINARY_NAME}) # Add preprocessor definitions for the build version. target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"" ) target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") # Disable Windows macros that collide with C++ standard library functions. target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") # Add dependency libraries and include directories. Add any application-specific # dependencies here. target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") # Run the Flutter tool portions of the build. This must not be removed. add_dependencies(${BINARY_NAME} flutter_assemble) ``` -------------------------------- ### CMake Build Configuration and Settings Source: https://github.com/jdongkhan/flutter_chart/blob/main/example/linux/CMakeLists.txt Configures build types (Debug, Profile, Release) and applies standard compilation settings like C++ standard, warning levels, optimization, and NDEBUG definition. ```cmake if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Flutter build mode" FORCE) set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Profile" "Release") endif() function(APPLY_STANDARD_SETTINGS TARGET) target_compile_features(${TARGET} PUBLIC cxx_std_14) target_compile_options(${TARGET} PRIVATE -Wall -Werror) target_compile_options(${TARGET} PRIVATE "<$>:-O3>") target_compile_definitions(${TARGET} PRIVATE "<$>:NDEBUG>") endfunction() ``` -------------------------------- ### Custom Target for Flutter Assembly Source: https://github.com/jdongkhan/flutter_chart/blob/main/example/linux/flutter/CMakeLists.txt Creates a custom target named `flutter_assemble` that depends on the generated Flutter library and its headers. This target ensures that the Flutter library and headers are built before they are needed by other parts of the project. It acts as a dependency trigger for the custom build command. ```cmake add_custom_target(flutter_assemble DEPENDS "${FLUTTER_LIBRARY}" ${FLUTTER_LIBRARY_HEADERS} ) ``` -------------------------------- ### Define Flutter Wrapper Libraries (CMake) Source: https://github.com/jdongkhan/flutter_chart/blob/main/example/windows/flutter/CMakeLists.txt Defines static libraries for the Flutter C++ wrapper, separating core implementations from plugin-specific or application-specific components. It configures visibility, includes directories, and links against the main Flutter library. ```cmake # === Wrapper === list(APPEND CPP_WRAPPER_SOURCES_CORE "core_implementations.cc" "standard_codec.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") list(APPEND CPP_WRAPPER_SOURCES_PLUGIN "plugin_registrar.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") list(APPEND CPP_WRAPPER_SOURCES_APP "flutter_engine.cc" "flutter_view_controller.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") # Wrapper sources needed for a plugin. add_library(flutter_wrapper_plugin STATIC ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} ) apply_standard_settings(flutter_wrapper_plugin) set_target_properties(flutter_wrapper_plugin PROPERTIES POSITION_INDEPENDENT_CODE ON) set_target_properties(flutter_wrapper_plugin PROPERTIES CXX_VISIBILITY_PRESET hidden) target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) target_include_directories(flutter_wrapper_plugin PUBLIC "${WRAPPER_ROOT}/include" ) add_dependencies(flutter_wrapper_plugin flutter_assemble) # Wrapper sources needed for the runner. add_library(flutter_wrapper_app STATIC ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_APP} ) apply_standard_settings(flutter_wrapper_app) target_link_libraries(flutter_wrapper_app PUBLIC flutter) target_include_directories(flutter_wrapper_app PUBLIC "${WRAPPER_ROOT}/include" ) add_dependencies(flutter_wrapper_app flutter_assemble) ``` -------------------------------- ### Flutter Project Structure and Plugin Integration in CMake Source: https://github.com/jdongkhan/flutter_chart/blob/main/example/windows/CMakeLists.txt Includes subdirectories for Flutter managed code and the application runner. It also includes generated CMake files for managing plugin builds and integrating them into the application. ```cmake set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") add_subdirectory(${FLUTTER_MANAGED_DIR}) add_subdirectory("runner") include(flutter/generated_plugins.cmake) ``` -------------------------------- ### Create Progress Chart with Flutter Source: https://context7.com/jdongkhan/flutter_chart/llms.txt Creates progress indicators as semi-circular or full circular arcs with animation support. It allows customization of stroke width, end point markers, stroke caps, border colors, and arc direction. ```dart List progressList = [0.7, 0.4]; // Progress values (0.0 to 1.0) // Semi-circular Progress (Up) SizedBox( height: 200, child: ChartWidget( coordinateRender: ChartCircularCoordinateRender( animationDuration: const Duration(seconds: 1), margin: const EdgeInsets.only(bottom: 10), strokeCap: StrokeCap.round, borderColor: Colors.grey, borderWidth: 13, arcDirection: ArcDirection.up, charts: [ Progress( strokeWidth: 9, endPoint: true, // Show end point marker strokeCap: StrokeCap.round, data: progressList, position: (item, index) => item, ), ], ), ), ) // Full Circular Progress SizedBox( height: 200, child: ChartWidget( coordinateRender: ChartCircularCoordinateRender( animationDuration: const Duration(seconds: 1), strokeCap: StrokeCap.round, borderColor: Colors.grey, borderWidth: 13, arcDirection: ArcDirection.none, // Full circle charts: [ CircularProgress( strokeWidth: 9, strokeCap: StrokeCap.round, data: progressList, position: (item, index) => item, ), ], ), ), ) ``` -------------------------------- ### Configure XAxis and YAxis for Charts in Dart Source: https://context7.com/jdongkhan/flutter_chart/llms.txt Customize coordinate system axes with options for grid lines, zoom, labels, and styling. Supports multiple Y-axes and custom formatting for axis labels. Dependencies include `flutter_chart` package. ```dart ChartDimensionsCoordinateRender( margin: const EdgeInsets.only(left: 40, top: 5, right: 30, bottom: 30), xAxis: XAxis( count: 7, // Number of visible grid cells max: 30, // Maximum x value (enables scrolling if > count * interval) interval: 1, // Value per grid cell zoom: true, // Enable pinch zoom drawGrid: true, // Show vertical grid lines drawLine: true, // Show x-axis line drawLabel: true, // Show x-axis labels drawDivider: false, // Show tick marks formatter: (index) => 'Day ${index.toInt()}', divideCount: (zoom) => zoom > 2 ? 2 : null, // Subdivisions when zoomed textStyle: const TextStyle(fontSize: 12, color: Colors.grey), lineColor: const Color(0x99cccccc), ), yAxis: [ YAxis( min: 0, max: 500, count: 5, // Number of horizontal divisions drawGrid: true, // Show horizontal grid lines drawLine: true, // Show y-axis line drawLabel: true, // Show y-axis labels drawDivider: true, // Show tick marks formatter: (index) => '${index * 100}', textStyle: const TextStyle(fontSize: 12, color: Colors.grey), ), // Second Y-axis on right side YAxis( min: 0, max: 100, offset: (size) => Offset(size.width - 40, 0), ), ], charts: [...], ) ``` -------------------------------- ### Create Scatter Chart with Flutter Source: https://context7.com/jdongkhan/flutter_chart/llms.txt Generates a scatter plot chart where point styles (color, radius) can be customized based on data values. It requires data with time and value, and allows configuration of chart padding, axes, and point positioning. ```dart final DateTime startTime = DateTime(2024, 1, 1); final List dataList = [ {'time': startTime.add(Duration(days: 1)), 'value1': 100}, {'time': startTime.add(Duration(days: 2)), 'value1': 150}, {'time': startTime.add(Duration(days: 3)), 'value1': 450}, {'time': startTime.add(Duration(days: 4)), 'value1': 300}, ]; SizedBox( height: 200, child: ChartWidget( coordinateRender: ChartDimensionsCoordinateRender( padding: const EdgeInsets.only(left: 5, top: 0, right: 5, bottom: 0), yAxis: [YAxis(min: 0, max: 500, drawGrid: true)], xAxis: XAxis(count: 7, formatter: (value) => '${value.toInt()}'), charts: [ Scatter( data: dataList, position: (item, index) => parserDateTimeToDayValue(item['time'] as DateTime, startTime), value: (item) => item['value1'] as num, style: (item) => item['value1'] > 400 ? const ScatterStyle(color: Colors.red, radius: 4) : const ScatterStyle(color: Colors.blue, radius: 2), ), ], ), ), ) ``` -------------------------------- ### Create Radar Chart with Flutter Source: https://context7.com/jdongkhan/flutter_chart/llms.txt Generates a radar (spider) chart with customizable data series, border styles (polygon or circle), and legends. It requires a list of maps for data and supports configuring chart margins, grid lines, and fill colors. ```dart final List dataList = [ {'title': 'Food', 'value1': 600, 'value2': 300}, {'title': 'Clothing', 'value1': 400, 'value2': 200}, {'title': 'Transport', 'value1': 200, 'value2': 400}, {'title': 'Games', 'value1': 400, 'value2': 200}, {'title': 'Sports', 'value1': 100, 'value2': 300}, ]; SizedBox( height: 200, child: ChartWidget( coordinateRender: ChartCircularCoordinateRender( margin: const EdgeInsets.all(12), charts: [ Radar( max: 600, data: dataList, borderStyle: RadarBorderStyle.polygon, // or RadarBorderStyle.circle count: 5, // Number of grid lines fillColors: colors10.map((e) => e.withOpacity(0.2)).toList(), legendFormatter: () => dataList.map((e) => e['title']).toList(), valueFormatter: (item) => [item['value1'].toString(), item['value2'].toString()], values: (item) => [ double.parse(item['value1'].toString()), double.parse(item['value2'].toString()), ], ), ], ), ), ) ``` -------------------------------- ### Add Annotations to Charts in Dart Source: https://context7.com/jdongkhan/flutter_chart/llms.txt Enhance charts by adding visual annotations such as limit lines and text labels. Supports fixed or scrollable annotations and conditional visibility based on zoom level. Requires `flutter_chart` package. ```dart ChartDimensionsCoordinateRender( yAxis: [YAxis(min: 0, max: 500)], xAxis: XAxis(count: 7, max: 30), backgroundAnnotations: [ // Horizontal limit line LimitAnnotation( limit: 300, // Y-value for the line color: Colors.red, strokeWidth: 1, fixed: true, // Don't scroll with content ), ], foregroundAnnotations: [ // Text label at specific position LabelAnnotation( text: 'Peak', positions: [5, 400], // [x, y] values textStyle: const TextStyle(color: Colors.red, fontSize: 12), textAlign: TextAlign.center, offset: const Offset(0, -15), fixed: false, // Scrolls with content minZoomVisible: 1.0, // Only show when zoom >= 1.0 maxZoomVisible: 3.0, // Hide when zoom > 3.0 onTap: (annotation) { print('Label tapped: ${annotation.userInfo}'); }, userInfo: {'id': 1, 'name': 'Peak Point'}, ), // Label at fixed screen position LabelAnnotation( text: 'Fixed Label', anchor: (size) => Offset(size.width - 50, 20), textStyle: const TextStyle(color: Colors.blue), ), ], charts: [...], ) ``` -------------------------------- ### Create Inverted Coordinate System for Horizontal Charts in Dart Source: https://context7.com/jdongkhan/flutter_chart/llms.txt Generate horizontal bar charts or charts with an inverted coordinate system where the X-axis is vertical and the Y-axis is horizontal. This is achieved using `ChartInvertDimensionsCoordinateRender`. Requires `flutter_chart` package. ```dart final List dataList = [ {'category': 'A', 'value': 300}, {'category': 'B', 'value': 450}, {'category': 'C', 'value': 200}, ]; SizedBox( height: 200, child: ChartWidget( coordinateRender: ChartInvertDimensionsCoordinateRender( margin: const EdgeInsets.only(left: 25, top: 0, right: 0, bottom: 30), yAxis: [YAxis(min: 0, max: 500)], xAxis: XAxis( count: 5, max: 5, formatter: (index) => dataList[index.toInt()]['category'], ), charts: [ Bar( data: dataList, position: (item, index) => index.toDouble(), value: (item) => item['value'], color: Colors.blue, itemWidth: 20, ), ], ), ), ) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.