Skip to content

Commit

Permalink
add first working release, with line graph only
Browse files Browse the repository at this point in the history
  • Loading branch information
douglasr committed May 9, 2024
1 parent af2aff9 commit 38ab1dc
Show file tree
Hide file tree
Showing 9 changed files with 462 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.DS_Store
bin/*
builds/*
/.vscode/settings.json
3 changes: 3 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Contributing

Fork the repo and make a pull request for any additions, fixes or updates.
21 changes: 21 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023-2024 Douglas Robertson (douglas@edgeoftheearth.com)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
81 changes: 81 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,82 @@
# CIQ Tools Graphing
(c)2023-2024 Douglas Robertson

Author: Douglas Robertson (GitHub: [douglasr](https://github.com/douglasr); Garmin Connect: dbrobert)

## Overview
For the best user experience and minial friction, it is usually ideal to try and keep the interface and flow on apps similar to the native Garmin functionality. As such, the CIQ Tools Graphic barrel is a clone of the graphing functionality present within Garmin devices natively.

## License
This Connect IQ barrel is licensed under the "MIT License", which essentially means that while the original author retains the copyright to the original code, you are free to do whatever you'd like with this code (or any derivative of it). See the LICENSE.txt file for complete details.

## Graph Types
The following graph types are currently available:
- Line Graph (generic and 7-day weekly)

More graphs will be made available as time permits. If you want/need a graph type not yet available, consider helping out. See the CONTRIBUTING.md file for details.

## Using the Barrel
This project cannot be used on it's own; it is designed to be included in existing projects.

### Include the Barrel
Download the barrel file (and associated debug.xml) and include it in your project.
See [Shareable Libraries](https://developer.garmin.com/connect-iq/core-topics/shareable-libraries/) on the Connect IQ Developer site for more details.

### Displaying the Graph
The graphing module contains classes that extend the ```Toybox.WatchUi.Drawable``` object, which then render the actual graph. As such, you can display graphs within your app by either adding the drawable to a layout or by creating a graph drawable object and calling the ```draw()``` function on it.

Regardless of the method used to render you graph, you will still need to pass the data points (and, optionally, labels for the X-axis); see below for details on that.

#### Add Graph to a Layout
To add a graph to a layout simply include a ```<drawable>``` tag:
```
<drawable id="LineGraph" class="CIQToolsGraphing.Line.Generic">
<param name="x">40</param>
<param name="y">100</param>
<param name="width">180</param>
<param name="height">100</param>
<param name="visible">true</param>
<param name="bgColor">0x000000</param>
<param name="graphColor">0xAAAAAA</param>
<param name="pointColor">0x00AAFF</param>
<param name="textColor">0xFFFFFF</param>
<param name="textFont">Graphics.FONT_SYSTEM_XTINY</param>
<param name="lineStyle">@CIQToolsGraphing.LINE_STYLE_DOTTED</param>
<param name="border">false</param>
</drawable>
```

#### Display the Graph Directly (via code)
```
var lineGraph = new CIQToolsGraphing.Line.Generic({
:identifier => "LineGraph"
:locX => 40,
:locY => 100,
:width => 180,
:height => 100,
:visible => true,
:bgColor => 0x000000,
:graphColor => 0xAAAAAA,
:pointColor => 0x00AAFF,
:textColor => 0xFFFFFF,
:textFont => Graphics.FONT_SYSTEM_XTINY,
:lineStyle => CIQToolsGraphing.LINE_STYLE_DOTTED,
:border => false
});
lineGraph.draw();
```

### Adding/Updating Data for the Graph
Data for the graph must be added dynamically, by calling the ```setDataPoints()``` function on the appropriate graphic object.

```
var dataPoints = [5,8,2,12,11,14,10];
var lineGraph = View.findDrawableById("LineGraph") as CIQToolsGraphing.Line.Weekly;
lineGraph.setDataPoints(dataPoints);
```

## Contributing
Please see the CONTRIBUTING.md file for details on how contribute.

### Contributors
* [Douglas Robertson](https://github.com/douglasr)
6 changes: 6 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CIQ Tools - Graphing
--------------------
(c)2023-2024 Douglas Robertson (douglas@edgeoftheearth.com)

0.1.0 -- 09-May-2024
- first release (partial)
36 changes: 36 additions & 0 deletions manifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0"?>
<!-- This is a generated file. It is highly recommended that you DO NOT edit this file. -->
<iq:manifest version="3" xmlns:iq="http://www.garmin.com/xml/connectiq">
<iq:barrel id="41fef5c9-a799-4856-b0a7-f3fae8c443c5" module="CIQToolsGraphing" version="0.1.0" minApiLevel="2.4.0">
<!--
Use the following from the Visual Studio Code comand palette to edit
the build targets:
"Monkey C: Set Products by Product Category" - Lets you add all products
that belong to the same product category
"Monkey C: Edit Products" - Lets you add or remove any product
-->
<iq:products/>
<!--
Use "Monkey C: Edit Permissions" from the Visual Studio Code command
palette to update permissions.
-->
<iq:permissions/>
<!--
Use "Monkey C: Edit Languages" from the Visual Studio Code command
palette to edit your compatible language list.
-->
<iq:languages/>
<!--
Use "Monkey C: Configure Monkey Barrel" from the Visual Studio Code
command palette to edit the included barrels.
-->
<iq:barrels/>
<!--
Use "Monkey C: Edit Annotations" from the Visual Studio Code
command palette to edit the annotations.
-->
<iq:annotations>
<iq:annotation>LineGraph</iq:annotation>
</iq:annotations>
</iq:barrel>
</iq:manifest>
2 changes: 2 additions & 0 deletions monkey.jungle
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
project.manifest = manifest.xml
project.typecheck = 2
3 changes: 3 additions & 0 deletions resources/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<strings>
<string id="DaysOfWeekAbbr">M,T,W,T,F,S,S</string>
</strings>
Loading

0 comments on commit 38ab1dc

Please sign in to comment.