Home
Softono
r

rainbow-me

Professional software vendor delivering innovative solutions on the Softono platform. Specialized in both open-source and proprietary software development.

Total Products
2

Software by rainbow-me

rainbow
Open Source

rainbow

![](https://pbs.twimg.com/profile_banners/1103191459409420288/1573207178/1500x500) ### ๐ŸŒˆ๏ธ Rainbow > the Ethereum wallet that lives in your pocket! ๐Ÿ“ฒ๏ธ [Available on the iOS App Store.](https://apps.apple.com/app/apple-store/id1457119021?pt=119997837&ct=github&mt=8) ๐Ÿค– [Android available on the Google Play Store](https://play.google.com/store/apps/details?id=me.rainbow&utm_campaign=gh&utm_source=referral&utm_medium=gh) ๐Ÿ’ป [Browser extension available on](https://rainbow.me/download?utm_campaign=gh&utm_source=referral&utm_medium=gh), [Chrome](https://chrome.google.com/webstore/detail/rainbow/opfgelmcmbiajamepnmloijbpoleiama?utm_campaign=gh&utm_source=referral&utm_medium=gh), [Brave](https://chrome.google.com/webstore/detail/rainbow/opfgelmcmbiajamepnmloijbpoleiama?utm_campaign=gh&utm_source=referral&utm_medium=gh), [Edge](https://chrome.google.com/webstore/detail/rainbow/opfgelmcmbiajamepnmloijbpoleiama?utm_campaign=gh&utm_source=referral&utm_medium=gh), [FireFox](https://addons.mozilla.org/en-US/firefox/addon/rainbow-extension/?utm_campaign=gh&utm_source=referral&utm_medium=gh), and [Arc](https://chrome.google.com/webstore/detail/rainbow/opfgelmcmbiajamepnmloijbpoleiama?utm_campaign=gh&utm_source=referral&utm_medium=gh). ๐• [Follow us on X](https://x.com/rainbowdotme) ## Setup > [!TIP] > **Internal developers** can also use the [`rainbow-me/rainbow-setup`](https://github.com/rainbow-me/rainbow-setup) > script to install all dependencies and configure the project in one step. ### Prerequisites 1. Install nvm: https://github.com/creationix/nvm 2. Install the required Node.js version: `nvm install` 3. Install Ruby (version specified in `.ruby-version`). macOS system Ruby is too old and will not work. Use a version manager such as [rbenv](https://github.com/rbenv/rbenv) or [rvm](https://rvm.io/). 4. Enable yarn: `corepack enable` **Note:** On future terminal sessions, run `nvm use` to activate the correct Node.js version. Alternatively, set up [automatic nvm switching](https://github.com/nvm-sh/nvm#deeper-shell-integration) in your shell. ### Internal developers Set up these **before** running `yarn install`, as the postinstall script reads `.env` and `rainbow-scripts` to generate build configs and run prebuild hooks. 1. Copy `dotenv` from [`rainbow-me/rainbow-env`](https://github.com/rainbow-me/rainbow-env) to `.env` in the project root. 2. Copy `android/app/google-services.json` from the same repo to `android/app/` in this project. 3. Clone [`rainbow-me/rainbow-scripts`](https://github.com/rainbow-me/rainbow-scripts) into the project root (the postinstall prebuild hooks depend on it). 4. Install dependencies and run setup: `yarn install && yarn setup` ### External contributors 1. Copy `.env.example` to `.env` and fill in your own API keys. Note that some features are currently not accessible; we are working with our Data Providers to provide open source API Keys. - Etherscan: https://etherscan.io/apis - Infura: https://infura.io/ - ETH Gas Station: https://docs.ethgasstation.info/ - Imgix: https://www.imgix.com/ 2. Provide your own `google-services.json` in `android/app/` from a personal Firebase project registered under the package name `me.rainbow`. 3. Install dependencies and run setup: `yarn install && yarn setup` The iOS `GoogleService-Info.plist` is already in the repo and gets its API key patched by the postinstall script from `GOOGLE_SERVICE_API_KEY` in your `.env`. ### iOS (macOS only) 1. Install the Xcode version pinned in [`.xcode-version`](./.xcode-version). Recommended: use the [`xcodes`](https://github.com/XcodesOrg/xcodes) CLI, which reads `.xcode-version` automatically: ```sh brew install xcodesorg/made/xcodes xcodes install ``` Alternatively, download the pinned version from [developer.apple.com/download](https://developer.apple.com/download/all/). CI and Bitrise build against the same pin, so local parity matters. 2. Install Watchman: `brew install watchman` 3. Install the required bundles and Pods: ``` yarn install-bundle && yarn install-pods ``` ### Android 1. Install JDK 17. Do **not** use the JDK bundled with Android Studio (it's JDK 21, which [causes build failures](https://reactnative.dev/docs/set-up-your-environment)). On macOS: ```sh brew install --cask zulu@17 ``` 2. Add to your shell profile (`~/.zshrc` or `~/.bashrc`): ```sh export JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-17.jdk/Contents/Home export ANDROID_HOME=$HOME/Library/Android/sdk # macOS # export ANDROID_HOME=$HOME/Android/Sdk # Linux export PATH=$PATH:$ANDROID_HOME/emulator export PATH=$PATH:$ANDROID_HOME/platform-tools ``` On Linux, also install system dependencies: `sudo apt install libsecret-tools watchman` 3. Install [Android Studio](https://developer.android.com/studio) (the standard setup wizard is fine). 4. Increase the IDE memory: **Android Studio > Settings > Memory Settings** and set the heap to at least 4096 MB. This project is large enough that the default 2048 MB will cause slow syncs and builds. 5. Set the Gradle JDK: **Settings > Build, Execution, Deployment > Build Tools > Gradle > Gradle JDK** and select the `JAVA_HOME` (Azul Zulu 17) entry. The default points to the bundled JDK 21. 6. Restart any open terminals so the new environment variables take effect. 7. Create an emulator via Android Studio > Device Manager (unless using a physical device). 8. Run the first build from the terminal to generate native headers that Android Studio needs for Gradle sync: ``` cd android && ./gradlew assembleDebug && cd .. ``` 9. Quit Android Studio completely, then reopen it from the terminal so Gradle sync picks up the generated headers: ``` open -a "Android Studio" # macOS ``` Always launch Android Studio this way so it inherits your shell PATH (including `node` from nvm). Launching from Spotlight or the Dock will cause Gradle sync to fail with "Cannot run program node". ## Developing Start Metro in one terminal: ``` yarn start ``` Then build and run: - **iOS:** Open `ios/Rainbow.xcworkspace` in Xcode (not the `.xcodeproj`) and press Cmd+R, or run `yarn ios` from the terminal. - **Android:** Open the `android/` folder in Android Studio, or run `yarn android` from the terminal.

Crypto & Blockchain Video Surveillance
4.4K Github Stars
react-native-animated-charts
Open Source

react-native-animated-charts

<p align="center"> <h1 align="center">React Native Animated Charts</h1> <h3 align="center">Set of components and helpers for building complex and beautifully animated charts.</h3> </p> ![](gifs/ios.gif) | ![](gifs/android.gif) | :----------------:|:---------------------:| The library was designed to create aesthetic, animated (so far only linear) charts based on a given input. The main assumptions of the library were to create smooth transitions between subsequent data sets. For this reason, we have discovered a shortage of existing libraries related to the charts. The current package was created as part of the [Rainbow.me project](https://rainbow.me/) and for this reason it was not designed as a complete and comprehensive solution for displaying various types of charts. However, we will be now using more charts in the whole application, so we believe that the number of functionalities in the application will gradually grow. Additionally, we are open to new Pull Requests. We want this library to become popular and complete thanks to community activity. It's a part of the [Rainbow.me project](https://rainbow.me/). ## Installation 1. Install [react-native-reanimated](https://docs.swmansion.com/react-native-reanimated/docs/next/fundamentals/installation) in the newest version. 2. ```bash yarn add @rainbow-me/animated-charts ``` The library has been verified with `2.0.0-alpha.6` version of reanimated. ### Reanimated Using TurboModules might have an impact on your current development flow and most likely you don't want to decrease your DX. Since we're not using reanimated in other places in the app, we made some tweaks to disable charts in development mode with compilation macros on iOS. You can find it [here](https://github.com/rainbow-me/rainbow/blob/develop/ios/Rainbow/AppDelegate.mm) Also, because we're using libraries which currently do not support reanimated 2, we [patched exports in reanimated](https://github.com/rainbow-me/rainbow/tree/develop/patches) Furthermore, we found few differences in how the `Animated` module works with and without TurboModules support, so we [made a trick](https://github.com/rainbow-me/rainbow/tree/develop/patches) to fallback to the not-TM version of Animated. Most likely, you don't need any of those patches. ## Example app We made a generic example to show briefly what's possible to achieve with this library. A Real-life example is available inside [Rainbow](https://github.com/rainbow-me)! In order to run an example clone this repo and navigate to `Example` then: ``` yarn && cd ios && pod install && cd .. react-native run-android react-native run-ios ``` ## API The library has been designed to provide as much flexibility as possible with the component-based API for easy integration with existing applications. ### Basic API Example ```jsx import React from 'react'; import {Dimensions, View} from 'react-native'; import {ChartDot, ChartPath, ChartPathProvider, monotoneCubicInterpolation} from '@rainbow-me/animated-charts'; export const {width: SIZE} = Dimensions.get('window'); export const data = [ {x: 1453075200, y: 1.47}, {x: 1453161600, y: 1.37}, {x: 1453248000, y: 1.53}, {x: 1453334400, y: 1.54}, {x: 1453420800, y: 1.52}, {x: 1453507200, y: 2.03}, {x: 1453593600, y: 2.10}, {x: 1453680000, y: 2.50}, {x: 1453766400, y: 2.30}, {x: 1453852800, y: 2.42}, {x: 1453939200, y: 2.55}, {x: 1454025600, y: 2.41}, {x: 1454112000, y: 2.43}, {x: 1454198400, y: 2.20}, ]; const points = monotoneCubicInterpolation({data, range: 40}); const BasicExample = () => ( <View style={{ backgroundColor: 'black' }}> <ChartPathProvider data={{ points, smoothingStrategy: 'bezier' }}> <ChartPath height={SIZE / 2} stroke="yellow" width={SIZE} /> <ChartDot style={{ backgroundColor: 'blue' }} /> </ChartPathProvider> </View> ); ``` The code above generates the chart below: ![](gifs/basic.png) ### Linear charts ### `ChartPathProvider` The whole chart's structure has to be wrapped with `ChartProvider`. It's responsible for data managing and itself does not have a visual impact on the layout. Under the hood, it uses context API to simplify manipulation with other components. The rule is to use one data series for each wrapper. It's important to have it as a separated component because under this component it's possible `useChartData` hook and put `ChartDot` component. However, if you don't need those features, you can pass `data` directly to `ChartPath` and drop this wrapper. | Prop name | type | default / obligatory | description | |-----------------|------------|------------------------|-------------| | `data` | <code>{ points: [Point], nativePoints: [Point], smoothingStrategy?: 'bezier'&#124;'simple'&#124;'complex', smoothingFactor }<code/> | obligatory | Object containing data structure and way to display them. Each of the properties is explained below. | - `points` is an array containing `Point`s to be displayed. A `Point` is an object containing `x` and `y` as a number. - `originalData` is an array of points that will not be drawn. However, if you used some strategy of interpolating data or simplifying you might want to present data slightly different from the real one. Then if you'd like labels to be fully correct you may want to provide real data before adjusting them. - `smoothingStrategy`. While presenting points path can be drawn with different approaches. - If `smoothingStrategy` is not provided (or set to any other value but for listed here), connects points using linear interpolation. - The `bezier` strategy connects points with a bezier path inspired by [d3 shape](https://github.com/d3/d3-shape/blob/master/src/curve/basis.js). It's not parametrized by `smoothingFactor`. - The `complex` strategy uses approach explained [here](https://medium.com/@francoisromain/smooth-a-svg-path-with-cubic-bezier-curves-e37b49d46c74) using cubic splines. It's parametrized by `smoothingFactor`. - The `simple` strategy is a bit simplified `complex` strategy using quadratic splines. It's parametrized by `smoothingFactor`. - `smoothingFactor`. Is a value from `0` to `1` defining how smooth a presentation should be. `0` means no smoothing, and it's the default. `smoothingFactor` has an impact if `smoothingStrategy` is `simple` or `complex`. - `yRange`. 2-elements array with numbers describing minY and maxY in this order. When not applied, charts are automatically adjusted vertically. However, when data are monotonical, they might present incorrectly without bounding due to numerical issues. ### `ChartPath` This component is used for showing the path itself. | Prop name | type | default / obligatory | description | |--------------------------------------|------------|------------------------|-------------| | `smoothingWhileTransitioningEnabled` | `number` | `false` | Although smoothing is not complex computing, it might impact performance in some low-end devices so while having a big set of data it might be worth disable smoothing while transitioning. | | `height` | `number` | obligatory | Height od the SVG canvas | | `width` | `number` | obligatory | Width od the SVG canvas | | `strokeWidth` | `number` | `1` | Width of the path. | | `selectedStrokeWidth` | `number` | `1` | Width of the path selected. | | `gestureEnabled` | `boolean` | `true` | Defines if interaction with the chart should be allowed or not | | `longPressGestureHandlerProps` | `object` | `{maxDist: 100000, minDurationMs: 0, shouldCancelWhenOutside: false}` | Under the hood we're using `LongPressGestureHandler` for handling interactions. It's recommended to not override its props. However, it might be useful while interacting with another GH. | | `selectedOpacity` | `number` | `0.7` | Target opacity of the path while touching the chart. | `hitSlop` | `number` | `0` | While scrubbing the chart touching edges of the screen you may want make points on the edges more accessible. With `hitSlop` it's possible to access points on edges doubling the speed of scrubbing beyond this margin. | | `hapticsEnabled` | `boolean` | `false` | On pressing in/out on the chart it might be expected to make haptic feedback. It will happen with `hapticsEnabled` set to `true`. | | `springConfig` | object | `{damping: 15, mass: 1, stiffness: 600}` | Object [defining the spring animation](https://docs.swmansion.com/react-native-reanimated/docs/next/animations). This spring is used for a dot's scale. | `timingFeedbackConfig` | object | `{duration: 80}` | Object [defining the timing animation](https://docs.swmansion.com/react-native-reanimated/docs/next/animations). `timingFeedbackConfig` is used for a path's opacity and width. | `timingAnimationConfig` | object | `{duration: 300}` | Object [defining the timing animation](https://docs.swmansion.com/react-native-reanimated/docs/next/animations). `timingAnimationConfig` is used for the transition between chart's data. | ...rest | `object` | `{}` | Props applied to SVG [Path](https://github.com/react-native-community/react-native-svg#path). | ### `ChartDot` Component for displaying the dot for scrubbing on the chart. | Prop name | type | default | description | |--------------|------------|---------|-------------| | `size` | `number` | `10` | Size of the dot. | | ...props | `object` | `{}` | Rest of the props applied to `Reanimated.View` including `style` | ### `ChartYLabel` & `ChartXLabel` Labels are useful while moving finger through the chart to show the exact value in given point. | Prop name | type | default | description | |--------------|----------------------|----------|-------------| | `format` | reanimated worklet | `a => a` | Worklet for formatting data from the chart. It can be useful when your data is a timestamp or currency. | | ...props | `object` | `{}` | Rest of the props applied to `TextInput` including `style` | ### `CurrentPositionVerticalLine` & `OpeningPositionHorizontalLine` CurrentPositionVerticalLine is a vertical line moving with user's finger through chart. OpeningPositionHorizontalLine is a horizontal static line on height of the first point. | Prop name | type | default | description | |--------------|----------------------|----------|-------------| | `color` | `string` | `#000000`| Color of the line. | | `thickness` | `number` | `2` | Thickness of the line. | | `length` | `number` | `null` | Length of the line. | | ...props | `object` | `{}` | Rest of the props applied to svg's `Line`. | ![](gifs/lines.png) ### Candle Charts TODO ### Pie charts TODO ## Helpers It's not essential in the library, but we have decided to include a lot of helpers we are (or we were) using for displaying charts. ## Interpolations We have two interpolators which share the most of the API: `bSplineInterpolation` and `monotoneCubicInterpolation`. ```js import { bSplineInterpolation as interpolator } from '@rainbow-me/animated-charts'; // import { monotoneCubicInterpolation as interpolator } from '@rainbow-me/animated-charts'; const interpolatedData = interpolator({data, range: 80}); ``` Code above generates 80 equidistant points from given dataset. Generator accepts object of parameters as an argument: - `data` - input of points. - `range` is the number of points of the output. - `includeExtremes`. If it's vital to include extremes in the output, set to true. However, the data might not be fully equidistant. - `removePointsSurroundingExtremes`. Makes sense only if `includeExtremes` set to `true`. When disabled, it might be possible that extremes look very "pointy". To get rid of this, you can remove points surrounding extremes. E.g. - `removePointsSurroundingExtremes = false` `o---------o----Min--o---------o---------o---------o---------o` - `removePointsSurroundingExtremes = true` `o--------------Min------------o---------o---------o---------o` ### `bSplineInterpolation({ degree = 3, ...params })` `bSplineInterpolation` is inspired by [victorian lib](https://github.com/networkcube/vistorian/blob/17e2be9b51267509ea67b5984421d8c03558d928/core/lib/BSpline.js) and uses [B-spline](https://en.wikipedia.org/wiki/B-spline) interpolation of a given `degree`. ### `monotoneCubicInterpolation({ ...params })` This curve is inspired by [d3 shape](https://github.com/d3/d3-shape/blob/master/src/curve/monotone.js). "Produces a cubic spline that preserves monotonicity in y, assuming monotonicity in x, as proposed by Steffen in A simple method for monotonic interpolation in one dimension: โ€œa smooth curve with continuous first-order derivatives that passes through any given set of data points without spurious oscillations. Local extrema can occur only at grid points where they are given by the data, but not in between two adjacent grid points.โ€ ## `simplifyData(data, pickRange = 10, includeExtremes = true)` This helper takes only one point per `pickRange`. Might be useful for very dense data. If it's important, it's possible to include extremes with the `includeExtremes` flag. E.g. `pickRange = 3, includeExtremes = true` ``` X are equidistant in this case Y:0 1 7 2 -3 0 1 2 S----------o----------E----------X----------E----------o----------X----------o----------S ``` `X` - points picked because `index%3=0` `S` โ€“ the first and the last points are always included. `E` โ€“ extremes. ## `useChartData` It's a bit advanced hook and contains information about current position of dot and corresponding values. Content of the result is changing often, so it's not worth deep documentation now. ## TODO The library has been released in a production-ready version. We use it inside the [Rainbow.me project](https://rainbow.me/) so it's verified for use in production. However, it relies on [React Native Reanimated 2.0](https://docs.swmansion.com/react-native-reanimated/) in the alpha version thus it might not work perfectly. Test it deeply before using it. Until the stable release of Reanimated 2, I think it's worth not marking this library as stable. Although the library works with Reanimated without any changes, we faced a few issues related to our (quite advanced) usage of the library. Thus we made some hacks we're not very proud of and it's for 99% something you should not do. However, if you see some crashes, you may try one of our hacks. There're a few things left to make it polished regarding linear charts: - [ ] Support for gestures - pinching, swiping, etc. - [ ] more parameters regarding interpolation, smoothing, and animations (i.e. allow to override `springConfig` and `timingConfig`) ## License Reanimated library is licensed under [The MIT License](LICENSE).

Mobile Development Web Components & Widgets
964 Github Stars