@tidepool/viz
Version:
Tidepool data visualization for diabetes device data.
682 lines (285 loc) • 21.4 kB
HTML
<html lang="" >
<head>
<meta charset="UTF-8">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>Common props · GitBook</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="description" content="">
<meta name="generator" content="GitBook 3.2.2">
<link rel="stylesheet" href="../../gitbook/style.css">
<link rel="stylesheet" href="../../gitbook/gitbook-plugin-highlight/website.css">
<link rel="stylesheet" href="../../gitbook/gitbook-plugin-search/search.css">
<link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
<meta name="HandheldFriendly" content="true"/>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
<link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">
<link rel="next" href="Docs.html" />
<link rel="prev" href="./" />
</head>
<body>
<div class="book">
<div class="book-summary">
<div id="book-search-input" role="search">
<input type="text" placeholder="Type to search" />
</div>
<nav role="navigation">
<ul class="summary">
<li class="chapter " data-level="1.1" data-path="../../">
<a href="../../">
Introduction
</a>
</li>
<li class="chapter " data-level="1.2" data-path="../StartHere.html">
<a href="../StartHere.html">
@tidepool/viz developer guide
</a>
<ul class="articles">
<li class="chapter " data-level="1.2.1" data-path="../Background.html">
<a href="../Background.html">
background
</a>
</li>
<li class="chapter " data-level="1.2.2" data-path="../FeatureOverview.html">
<a href="../FeatureOverview.html">
overview of features
</a>
</li>
<li class="chapter " data-level="1.2.3" data-path="../Architecture.html">
<a href="../Architecture.html">
planned architecture
</a>
</li>
<li class="chapter " data-level="1.2.4" data-path="../DirectoryStructure.html">
<a href="../DirectoryStructure.html">
app & directory structure
</a>
</li>
<li class="chapter " data-level="1.2.5" data-path="../CodeStyle.html">
<a href="../CodeStyle.html">
code style
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.3" data-path="../views/">
<a href="../views/">
per-view documentation
</a>
<ul class="articles">
<li class="chapter " data-level="1.3.1" data-path="../../src/components/settings/">
<a href="../../src/components/settings/">
Device Settings view
</a>
</li>
<li class="chapter " data-level="1.3.2" data-path="../views/Trends.html">
<a href="../views/Trends.html">
Trends view
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.4" data-path="../Storybook.html">
<a href="../Storybook.html">
use of React Storybook
</a>
</li>
<li class="chapter " data-level="1.5" data-path="../deps/">
<a href="../deps/">
usage of dependencies
</a>
<ul class="articles">
<li class="chapter " data-level="1.5.1" data-path="../deps/D3.html">
<a href="../deps/D3.html">
D3
</a>
</li>
<li class="chapter " data-level="1.5.2" data-path="../deps/GSAP.html">
<a href="../deps/GSAP.html">
GSAP
</a>
</li>
<li class="chapter " data-level="1.5.3" data-path="../deps/Moment.html">
<a href="../deps/Moment.html">
Moment
</a>
</li>
<li class="chapter " data-level="1.5.4" data-path="../deps/React.html">
<a href="../deps/React.html">
React
</a>
</li>
<li class="chapter " data-level="1.5.5" data-path="../deps/ReactMotion.html">
<a href="../deps/ReactMotion.html">
React Motion
</a>
</li>
<li class="chapter " data-level="1.5.6" data-path="../deps/Redux.html">
<a href="../deps/Redux.html">
Redux
</a>
</li>
<li class="chapter " data-level="1.5.7" data-path="../deps/Webpack.html">
<a href="../deps/Webpack.html">
webpack
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.6" data-path="../../src/utils/">
<a href="../../src/utils/">
utilities
</a>
<ul class="articles">
<li class="chapter " data-level="1.6.1" data-path="../../src/utils/apidocs/">
<a href="../../src/utils/apidocs/">
API docs for utilities
</a>
<ul class="articles">
<li class="chapter " data-level="1.6.1.1" data-path="../../src/utils/apidocs/basal.html">
<a href="../../src/utils/apidocs/basal.html">
basal
</a>
</li>
<li class="chapter " data-level="1.6.1.2" data-path="../../src/utils/apidocs/bloodglucose.html">
<a href="../../src/utils/apidocs/bloodglucose.html">
blood glucose
</a>
</li>
<li class="chapter " data-level="1.6.1.3" data-path="../../src/utils/apidocs/bolus.html">
<a href="../../src/utils/apidocs/bolus.html">
bolus
</a>
</li>
<li class="chapter " data-level="1.6.1.4" data-path="../../src/utils/apidocs/datetime.html">
<a href="../../src/utils/apidocs/datetime.html">
datetime
</a>
</li>
<li class="chapter " data-level="1.6.1.5" data-path="../../src/utils/apidocs/format.html">
<a href="../../src/utils/apidocs/format.html">
format
</a>
</li>
<li class="chapter " data-level="1.6.1.6" data-path="../../src/utils/apidocs/misc.html">
<a href="../../src/utils/apidocs/misc.html">
misc
</a>
</li>
</ul>
</li>
</ul>
</li>
<li class="chapter " data-level="1.7" data-path="./">
<a href="./">
misc
</a>
<ul class="articles">
<li class="chapter active" data-level="1.7.1" data-path="CommonProps.html">
<a href="CommonProps.html">
Common props
</a>
</li>
<li class="chapter " data-level="1.7.2" data-path="Docs.html">
<a href="Docs.html">
Docs setup & publishing
</a>
</li>
<li class="chapter " data-level="1.7.3" data-path="TimeRenderingModes.html">
<a href="TimeRenderingModes.html">
Time-rendering modes
</a>
</li>
</ul>
</li>
<li class="divider"></li>
<li>
<a href="https://www.gitbook.com" target="blank" class="gitbook-link">
Published with GitBook
</a>
</li>
</ul>
</nav>
</div>
<div class="book-body">
<div class="body-inner">
<div class="book-header" role="navigation">
<!-- Title -->
<h1>
<i class="fa fa-circle-o-notch fa-spin"></i>
<a href="../.." >Common props</a>
</h1>
</div>
<div class="page-wrapper" tabindex="-1" role="main">
<div class="page-inner">
<div id="book-search-results">
<div class="search-noresults">
<section class="normal markdown-section">
<h2 id="common-props-in-tidepool-data-visualization-code">Common props in Tidepool data visualization code</h2>
<p>Several of the pieces of <a href="../FeatureOverview.html#shared-state">the state common to most, if not all, of Tidepool's data visualization views</a> are most often encountered in the code as props passed to React components. This page provides a quick reference describing the canonical forms of these pieces of state since they occur and are used (for example: as a parameter in a utility function) <strong>very</strong> frequently.</p>
<ul>
<li><a href="#bgPrefs"><code>bgPrefs</code></a></li>
<li><a href="#timePrefs"><code>timePrefs</code></a></li>
</ul>
<h3 id="bgprefs"><code>bgPrefs</code></h3>
<p><code>bgPrefs</code> is an object with two properties: <code>bgUnits</code> and <code>bgBounds</code>. Sometimes these component properties are passed around on their own, and sometimes <code>bgPrefs</code> is passed around as a whole. (As we increase our commitment to support for mmol/L as well as mg/dL blood glucose units, it will probably be necessary to access both <code>bgUnits</code> and <code>bgBounds</code> simultaneously most of the time, so it is probably a good idea to just get used to passing around <code>bgPrefs</code> as a whole.)</p>
<p><code>bgUnits</code> is a String value that can be either <code>mg/dL</code> or <code>mmol/L</code>. To avoid typos and capitalization errors, we export a constant for each of these strings from src/utils/constants.js; use them with <code>import { MGDL_UNITS, MMOLL_UNITS } from 'path/to/utils/constants'</code>.</p>
<p><code>bgBounds</code> is an Object with five numerical fields:</p>
<ul>
<li><code>veryLowThreshold</code> encodes the threshold (logic is <) for encoding a blood glucose value as "very low"</li>
<li>(a value >= <code>veryLowThreshold</code> and < <code>targetLowerBound</code> is "low")</li>
<li><code>targetLowerBound</code> encodes the lower bound for the user's target blood glucose range; logic is >= the threshold is "target"</li>
<li><code>targetUpperBound</code> encodes the upper bound for the user's target blood glucose range; logic is <= the threshold is "target"</li>
<li>(a value > <code>targetUpperBound</code> and <= <code>veryHighThreshold</code> is "high")</li>
<li><code>veryHighThreshold</code> encodes the threshold (logic is >) for encoding a blood glucose value as "very high"</li>
<li><code>clampThreshold</code> encodes the value at which we clamp the blood glucose scale (logic is >); read about clamping scales in <a href="https://github.com/d3/d3-scale#continuous_clamp" title="d3-scale: clamp()" target="_blank">the d3-scale documentation</a></li>
</ul>
<p>The function <code>classifyBgValue</code> exported from the blood glucose utilities in <code>src/utils/bloodglucose.js</code> will return the classification for any blood glucose value given the <code>value</code> and the <code>bgBounds</code>. (See also <a href="../../src/utils/apidocs/bloodglucose.html">all the API documentation for blood glucose utility functions</a>.)</p>
<h3 id="timeprefs"><code>timePrefs</code></h3>
<p><code>timePrefs</code> is an object with two properties: <code>timezoneAware</code> and <code>timezoneName</code>. The <code>timezoneAware</code> property is a simple Boolean indicating whether or not the user wants to view data in timezone-aware mode; <code>timezoneAware</code> defaults to <code>true</code>. Because the extraction of a named timezone depends in part on the value of <code>timezoneAware</code><sup><a href="#fn_a" id="reffn_a">a</a></sup>, <code>timePrefs</code> should <strong>always</strong> be passed around as an entire object, and the utility function <code>getTimezoneFromTimePrefs</code> exported from the datetime utilities in <code>src/utils/datetime.js</code> should be used to extract the timezone String when required. (See also <a href="../../src/utils/apidocs/datetime.html">all the API documentation for datetime utility functions</a>.)</p>
<p><code>timezoneName</code> is a String timezone that the <a href="https://momentjs.com/" title="Moment.js" target="_blank">Moment.js</a> datetime utility library recognizes. Moment.js in turn recognizes all timezones from the <a href="https://www.iana.org/time-zones 'IANA Time Zone Database" target="_blank">IANA Time Zone Database</a>.</p>
<blockquote id="fn_a">
<sup>a</sup>. In brief, if <code>timezoneAware</code> is <code>false</code>, then <code>UTC</code> is used for the timezone String in all circumstances and methods where a timezoe String is required.<a href="#reffn_a" title="Jump back to footnote [a] in the text."> ↩</a>
</blockquote>
</section>
</div>
<div class="search-results">
<div class="has-results">
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
<ul class="search-results-list"></ul>
</div>
<div class="no-results">
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
</div>
</div>
</div>
</div>
</div>
</div>
<a href="./" class="navigation navigation-prev " aria-label="Previous page: misc">
<i class="fa fa-angle-left"></i>
</a>
<a href="Docs.html" class="navigation navigation-next " aria-label="Next page: Docs setup & publishing">
<i class="fa fa-angle-right"></i>
</a>
</div>
<script>
var gitbook = gitbook || [];
gitbook.push(function() {
gitbook.page.hasChanged({"page":{"title":"Common props","level":"1.7.1","depth":2,"next":{"title":"Docs setup & publishing","level":"1.7.2","depth":2,"path":"docs/misc/Docs.md","ref":"docs/misc/Docs.md","articles":[]},"previous":{"title":"misc","level":"1.7","depth":1,"path":"docs/misc/README.md","ref":"docs/misc/README.md","articles":[{"title":"Common props","level":"1.7.1","depth":2,"path":"docs/misc/CommonProps.md","ref":"docs/misc/CommonProps.md","articles":[]},{"title":"Docs setup & publishing","level":"1.7.2","depth":2,"path":"docs/misc/Docs.md","ref":"docs/misc/Docs.md","articles":[]},{"title":"Time-rendering modes","level":"1.7.3","depth":2,"path":"docs/misc/TimeRenderingModes.md","ref":"docs/misc/TimeRenderingModes.md","articles":[]}]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"docs/misc/CommonProps.md","mtime":"2017-05-30T14:36:05.000Z","type":"markdown"},"gitbook":{"version":"3.2.2","time":"2017-05-31T15:26:30.892Z"},"basePath":"../..","book":{"language":""}});
});
</script>
</div>
<script src="../../gitbook/gitbook.js"></script>
<script src="../../gitbook/theme.js"></script>
<script src="../../gitbook/gitbook-plugin-search/search-engine.js"></script>
<script src="../../gitbook/gitbook-plugin-search/search.js"></script>
<script src="../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
<script src="../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
<script src="../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
<script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
</body>
</html>