diff --git a/CHANGELOG.md b/CHANGELOG.md index 41cc7d8..87b4159 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ -## 0.0.1 +## 0.0.1 (Initial Release) + +- Initial release of the real_time_chart package. +- Added the RealTimeChart widget, which displays a real-time graph of data. +- Supports positive and negative values. +- Adapts height depending on max value. +- Includes example usage with a stream of data. + -* TODO: Describe initial release. diff --git a/README.md b/README.md index 02fe8ec..48bc8fe 100644 --- a/README.md +++ b/README.md @@ -1,39 +1,60 @@ - -TODO: Put a short description of the package here that helps potential users -know whether this package might be useful for them. ## Features - -TODO: List what your package can do. Maybe include images, gifs, or videos. +- Display real-time data on a graph +- Supports negative values +- Adapts height automatically based on the maximum value +- Customizable colors, axis labels, and grid lines ## Getting started -TODO: List prerequisites and provide or point to information on how to -start using the package. +To use this package, add `real_time_chart` as a dependency in your pubspec.yaml file. + +```yaml +dependencies: + real_time_chart: ^0.0.1 +``` ## Usage -TODO: Include short and useful examples for package users. Add longer examples -to `/example` folder. +To display a real-time chart, you can use the `RealTimeChart` widget. Here's an example of how to use it in your code: ```dart -const like = 'sample'; +import 'package:real_time_chart/real_time_chart.dart'; + +class RealTimeChartExample extends StatelessWidget { + @override + Widget build(BuildContext context) { + return RealTimeChart( + stream: positiveDataStream(), + graphColor = Colors.red, + ); + } +} + +Stream positiveDataStream() { + return Stream.periodic(const Duration(milliseconds: 500), (_) { + return Random().nextInt(300).toDouble(); + }).asBroadcastStream(); +} + ``` + ## Additional information -TODO: Tell users more about the package: where to find more information, how to -contribute to the package, how to file issues, what response they can expect -from the package authors, and more. +This package provides a simple solution for displaying real-time data in a graph format. It offers support for both positive and negative values and automatically adapts the height of the graph to fit the maximum value. + +If you encounter any issues or bugs while using the package, feel free to file an issue in the [issue tracker](https://github.com/tajaouart/real_time_chart/issues). We are committed to providing quick and helpful responses to any questions or concerns that you may have. + +If you would like to contribute to the development of this package, we welcome pull requests and any other forms of contribution. Your help and support are greatly appreciated! + + + diff --git a/example/lib/main.dart b/example/lib/main.dart index 7828fa7..dadd6e5 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,3 +1,9 @@ +// Copyright (c) 2023 Tajaouart Mounir +// +// This demo showcases the usage of the `RealTimeGraph` widget +// and provides an example of how to use it in a Flutter app. +// Website: https://tajaouart.com + import 'dart:math'; import 'package:flutter/material.dart'; @@ -8,22 +14,23 @@ void main() { } class MyApp extends StatelessWidget { - const MyApp({super.key}); + const MyApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return MaterialApp( - title: 'Flutter Demo', + debugShowCheckedModeBanner: false, + title: 'Real-Time Chart Demo', theme: ThemeData( primarySwatch: Colors.blue, ), - home: const MyHomePage(title: 'Flutter Demo Home Page'), + home: const MyHomePage(title: 'Real-Time Chart Demo'), ); } } class MyHomePage extends StatefulWidget { - const MyHomePage({super.key, required this.title}); + const MyHomePage({Key? key, required this.title}) : super(key: key); final String title; @@ -44,7 +51,9 @@ class _MyHomePageState extends State { width: double.maxFinite, child: SingleChildScrollView( child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ + // Display a real-time graph of positive data SizedBox( width: MediaQuery.of(context).size.width, height: MediaQuery.of(context).size.width * 0.8, @@ -55,6 +64,8 @@ class _MyHomePageState extends State { ), ), ), + + // Display a real-time graph of positive data as points const SizedBox(height: 32), SizedBox( width: MediaQuery.of(context).size.width, @@ -67,7 +78,15 @@ class _MyHomePageState extends State { ), ), ), + + // Display a real-time graph of positive and negative data const SizedBox(height: 32), + const Padding( + padding: EdgeInsets.all(16.0), + child: Text( + 'Supports negative values :', + ), + ), SizedBox( width: MediaQuery.of(context).size.width, height: MediaQuery.of(context).size.width * 0.8, @@ -80,7 +99,9 @@ class _MyHomePageState extends State { ), ), ), - const SizedBox(height: 32), + + // Display a real-time graph of positive and negative data as points + SizedBox( width: MediaQuery.of(context).size.width, height: MediaQuery.of(context).size.width * 0.8, diff --git a/lib/real_time_chart.dart b/lib/real_time_chart.dart index d90a910..997116c 100644 --- a/lib/real_time_chart.dart +++ b/lib/real_time_chart.dart @@ -1,3 +1,5 @@ +library real_time_chart; + export 'src/chart_display.dart'; export 'src/point.dart'; -export 'src/live_chart.dart'; +export 'src/real_time_chart.dart'; \ No newline at end of file diff --git a/lib/src/live_chart.dart b/lib/src/real_time_chart.dart similarity index 100% rename from lib/src/live_chart.dart rename to lib/src/real_time_chart.dart diff --git a/pubspec.yaml b/pubspec.yaml index 9a5150a..dd77ed4 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: real_time_chart -description: Real-Time Chart. +description: A Flutter package for displaying real-time charts with flexible customization options. version: 0.0.1 -homepage: +homepage: https://github.com/tajaouart/real_time_chart environment: sdk: '>=2.19.2 <3.0.0' @@ -16,39 +16,5 @@ dev_dependencies: sdk: flutter flutter_lints: ^2.0.0 -# For information on the generic Dart part of this file, see the -# following page: https://dart.dev/tools/pub/pubspec -# The following section is specific to Flutter packages. flutter: - - # To add assets to your package, add an assets section, like this: - # assets: - # - images/a_dot_burr.jpeg - # - images/a_dot_ham.jpeg - # - # For details regarding assets in packages, see - # https://flutter.dev/assets-and-images/#from-packages - # - # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.dev/assets-and-images/#resolution-aware - - # To add custom fonts to your package, add a fonts section here, - # in this "flutter" section. Each entry in this list should have a - # "family" key with the font family name, and a "fonts" key with a - # list giving the asset and other descriptors for the font. For - # example: - # fonts: - # - family: Schyler - # fonts: - # - asset: fonts/Schyler-Regular.ttf - # - asset: fonts/Schyler-Italic.ttf - # style: italic - # - family: Trajan Pro - # fonts: - # - asset: fonts/TrajanPro.ttf - # - asset: fonts/TrajanPro_Bold.ttf - # weight: 700 - # - # For details regarding fonts in packages, see - # https://flutter.dev/custom-fonts/#from-packages