ventilatorgraph 0.1.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 51

GraphWithPointer for mimic Ventilator Monitor Graph #

Recently people had been developing ventilator using Andruino and Flutter and one of the component needed is the Graphic showing input data from the sensor to the monitor. This widget use the same logic which had an index variable that can be use to update the data on the screen as we loop the pointer along the sccreen. The widget uses a List as the source of the data and also an index as pointer to display and will scale the information to fit the display. Take a look at the example to see how it can be used.

The display can be customised using the following values:

  • backgroundColor : set the Background Color (default Colors.black)
  • lineColor : set the Color (default Colors.redAccent)
  • segmentYColor : set the segment Y Color (default Colors.white)

The other settings are

  • minY : set the minimal data Value (default 0)
  • maxY : set the maximum data Value (default 1)
  • totalSegmentY : set the total segment of the Y Value ( default 5 )
  • index : set the current pointer
  • dataSet : set List of the input data

minY and maxY are used by the widget to determine the scaling factor so all data values are displayed. These values can be altered to modify the data display scale. index will be used to show a moving block or pointer along the screen.

Ventilator Graph Demo

[0.1.0] - 21 May 2020. #

  • fix bug on the upper side line segment

[0.0.5] - 18 May 2020. #

  • added default value

[0.0.4] - 18 May 2020. #

  • added demo file

[0.0.3] - 18 May 2020. #

  • fix bug and md file

[0.0.2] - 17 May 2020. #

  • add example tab

[0.0.1] - 17 May 2020. #

  • initial release

example/main.dart

import 'package:ventilatorgraph/ventilatorgraph.dart';
import 'package:flutter/material.dart';
import 'dart:math';
import 'dart:async';

void main() => runApp(new MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: "Ventilator Graph Display Example",
      home: GraphVentilator(),
    );
  }
}

class GraphVentilator extends StatefulWidget {
  static String id = 'Graph Ventilator';

  @override
  _GraphVentilatorState createState() => _GraphVentilatorState();
}

class _GraphVentilatorState extends State<GraphVentilator> {
  int index = 0;
  double maxData = 1;
  double minData = -1;
  int dataWidth = 100;
  int lineSegment = 3;
  List dataSetPressure = List();
  List dataSetFlow = List();
  double radians = 0.0;
  Timer _timer;

  ///generate sample data using sines and cosines wave
  _generateData(Timer t) {
    var sv = sin((radians * pi));
    var cv = cos((radians * pi));

    ///move the pointer along the grapht and add data to the current pointer
    setState(() {
      index++;
      if (index == dataWidth) {
        index = 0;
      }
      dataSetPressure[index.toInt()] = sv;
      dataSetFlow[index.toInt()] = cv;
    });

    radians += 0.05;
    if (radians >= 2.0) {
      radians = 0.0;
    }
  }

  List generateDataSet(int maxData) {
    List dataSet = List();
    for (int i = 0; i < dataWidth; i++) {
      dataSet.add(maxData);
    }
    return dataSet;
  }

  @override
  void dispose() {
    // TODO: implement dispose
    super.dispose();
  }

  @override
  void initState() {
    // TODO: implement initState
    super.initState();

    /// populate our data set
    dataSetPressure = generateDataSet(maxData.toInt());
    dataSetFlow = generateDataSet(maxData.toInt());

    /// start moving the pointer
    _timer = Timer.periodic(Duration(milliseconds: 60), _generateData);
  }

  @override
  Widget build(BuildContext context) {
    //dataSet = generateDataSet(maxData.toInt());
    return Scaffold(
      body: SafeArea(
        child: Column(
          children: <Widget>[
            Expanded(
              child: GraphWithPointer(
                index: index,
                maxY: maxData,
                minY: minData,
                totalSegmentY: lineSegment,
                dataSet: dataSetPressure,
                backgroundColor: Color.fromRGBO(58, 66, 86, 1.0),
                lineColor: Colors.blueAccent,
                segmentYColor: Colors.white,
              ),
            ),
            Expanded(
              child: GraphWithPointer(
                index: index,
                maxY: maxData,
                minY: minData,
                totalSegmentY: lineSegment,
                dataSet: dataSetFlow,
                backgroundColor: Color.fromRGBO(58, 66, 86, 1.0),
                lineColor: Colors.yellowAccent,
                segmentYColor: Colors.white,
              ),
            ),
          ],
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  ventilatorgraph: ^0.1.0

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:ventilatorgraph/ventilatorgraph.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
6
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
51
Learn more about scoring.

We analyzed this package on Jul 9, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.14
  • Flutter: 1.17.5

Analysis suggestions

Package not compatible with SDK dart

Because:

  • ventilatorgraph that is a package requiring null.

Maintenance suggestions

The description is too long. (-10 points)

Search engines display only the first part of the description. Try to keep the value of the description field in your package's pubspec.yaml file between 60 and 180 characters.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.1
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies
flutter_test