1.1.7 • Published 2 years ago

react-native-bubble-chart v1.1.7

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

react-native-bubble-chart

An easy-to-use customizable bubble animation chart, similar to the Apple Music genre selection

Features

  • iOS Support (In beta)
  • Typescript Sup port
  • Customizable

iOS Example

plot

Installation

yarn add react-native-bubble-chart
npm install react-native-bubble-chart --save

iOS Installation

If you're using React Native versions > 60.0, it's relatively straightforward.

cd ios && pod install

For versions below 0.60.0, use rnpm links

  • Run bash react-native link react-native-bubble-select
  • If linking fails, follow the manual linking steps

Usage

import * as React from 'react';
import {
  StyleSheet,
  View,
  Text,
  SafeAreaView,
  Button,
  Platform,
  Dimensions,
} from 'react-native';
import BubbleSelect, { Bubble, BubbleNode } from 'react-native-bubble-chart';
import randomCity, { randomCities } from './randomCity';

const { width, height } = Dimensions.get('window');

export default function App() {
  const [cities, setCities] = React.useState<any[]>([]);
  const [force, setForce] = React.useState(false);
  const [selectedCites, setSelectedCities] = React.useState<BubbleNode[]>([]);
  const [removedCities, setRemovedCities] = React.useState<BubbleNode[]>([]);

  React.useEffect(() => {
    if (force) {
      setCities(randomCities());
    }
  }, [force]);

  React.useEffect(() => {
    if (Platform.OS === 'ios') {
      setForce(true);
    } else {
      setCities(randomCities());
    }
  }, []);

  const addCity = () => {
    setCities([...cities, randomCity()]);
  };

  const handleSelect = (bubble: BubbleNode) => {
    setSelectedCities([...selectedCites, bubble]);
  };

  const handleDeselect = (bubble: BubbleNode) => {
    setSelectedCities(selectedCites.filter(({ id }) => id !== bubble.id));
  };

  const handleRemove = (bubble: BubbleNode) => {
    console.log(bubble);
    setRemovedCities([...removedCities, bubble]);
  };

  return (
    <BubbleSelect
      onSelect={handleSelect}
      onDeselect={handleDeselect}
      onRemove={handleRemove}
      width={width}
      height={height}
      fontName={Platform.select({
        ios: 'SinhalaSangamMN-Bold',
        android: 'sans-serif-medium',
      })}
      autoSize={true}
    >
      {cities.map((city, index) => (
        <Bubble
          key={city.id}
          id={city.id}
          text={city.text}
          title={city.text}
          // subTitle={city.text}
          value={Math.round((Math.random() * 91 + 10) * 100) / 100}
          surfix="%"
          valueSize={14}
          titleSize={18}
          color={city.color}
          selectedColor={city.selectedColor}
          selectedScale={city.selectedScale}
          gradient={city.gradient}
          lineHeight={16}
          icon={
            index % 2
              ? require('../assets/plus.png')
              : require('../assets/download.png')
          }
          iconSize={32}
        />
      ))}
    </BubbleSelect>
  );
}

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

acceptsJSONStreamabsolute-pathabort-controllerababacornacorn-jsxaggregate-erroracorn-walkacorn-globalsagent-baseadd-streamansi-alignansi-cyanajvansi-colorsanseransi-escapesansi-regexansi-stylesansi-fragmentsansi-grayansi-redansi-wrapargparseanymatcharr-diffarr-flattenarr-unionarray-ifyarray-includesarray-maparray-unionarray-reducearray-uniquearray.prototype.flatmaparray-slicearray.prototype.maparrifyasapassign-symbolsast-typesat-least-nodeasync-retryasyncasynckitastral-regexbabel-plugin-dynamic-import-nodebabel-eslintatobbabel-plugin-polyfill-corejs2babel-plugin-polyfill-corejs3babel-plugin-polyfill-regeneratorbabel-jestbabel-plugin-istanbulbabel-plugin-jest-hoistbabel-preset-current-node-syntaxbalanced-matchbabel-plugin-syntax-trailing-function-commasbabel-preset-fbjsbabel-preset-jestbase64-jsbasebefore-after-hookbig-integerarray-filterbrace-expansionbracesbrowserslistblbplist-parserbplist-creatorbserbrowser-process-hrtimebindingsbufferbuffer-crc32buffer-fromcache-basebytescacheable-requestcall-bindcaller-pathcamelcasecaller-callsitecallsitescaniuse-litechalkcapture-exitcamelcase-keyschar-regexchardetclean-stackclass-utilsci-infocjs-module-lexercli-boxescli-cursorboxencli-widthcli-spinnersclone-deepclone-responsecliuicocollect-v8-coveragecollection-visitcolor-namecolor-supportcombined-streamcolor-convertcolorettecommand-existscommandercommondircompare-funccomponent-emitterconcat-mapcompressiblecompressioncloneconfigstoreconnectconventional-changelogconventional-changelog-angularconventional-changelog-atomconventional-changelog-codemirrorconventional-changelog-coreconventional-changelog-conventionalcommitsconventional-changelog-emberconventional-changelog-expressconventional-changelog-jqueryconventional-changelog-eslintconventional-changelog-preset-loaderconventional-changelog-jshintconventional-commits-filterconventional-changelog-writerconventional-commits-parserconventional-recommended-bumpcore-js-compatconvert-source-mapcopy-descriptorcosmiconfigcross-spawncore-util-iscore-jscsstypeconcat-streamcssomdargsdata-uri-to-bufferdebugcrypto-random-stringdata-urlsdateformatdayjsdecamelizedecamelize-keysdedentdecode-uri-componentdecimal.jsdeep-extendcssstyledeepmergedeep-isdefaultsdefine-propertydeldefine-propertiesdefer-to-connectdelayed-streamdegeneratordenodeifydecompress-responsedepddestroydir-globdiff-sequencesdeprecationdetect-newlinedoctrineduplexer3electron-to-chromiumemoji-regexee-firstdot-propend-of-streamemitteryerror-exencodingenvinfoencodeurlerror-stack-parserenquireres-abstracterrorhandleres-array-method-boxes-properlyescaladees-get-iteratores-shim-unscopablesescape-string-regexpdomexceptionescape-goatescodegeneslint-plugin-jesteslint-plugin-reacteslint-plugin-eslint-commentses-to-primitiveeslint-plugin-flowtypeescape-htmleslint-plugin-react-hookseslint-plugin-react-native-globalseslint-plugin-react-nativeeslint-visitor-keyseslint-scopeeslint-utilsespreeesrecurseestraverseesutilsesqueryeventemitter3etagexecaevent-target-shimexec-shexpand-bracketsexitesprimaexpectexternal-editorextend-shallowfast-globfast-difffancy-logfastqfast-deep-equalfast-json-stable-stringifyfast-levenshteinfb-watchmanfbjs-css-varsfbjs-scriptsfbjsfill-rangefiguresfile-entry-cachefilter-objfile-uri-to-pathextglobfind-cache-dirfor-infinalhandlerflattedform-datafind-upflat-cachefreshfunction-bindftpfseventsfs.realpathfs-extrafragment-cachegensyncget-caller-filefunction.prototype.namefunctional-red-black-treeget-intrinsicget-package-typefunctions-have-namesget-stdinget-symbol-descriptionget-streamget-urigit-raw-commitsget-valuegit-remote-origin-urlgit-semver-tagsgit-upglobglob-parentglobalsgit-url-parsegitconfiglocalgraceful-fsglobal-dirsgotgrowlyglobbyhashas-flaghandlebarsget-pkg-repohas-bigintshard-rejectionhas-valuehas-symbolshas-property-descriptorshas-valueshas-yarnhermes-enginehosted-git-infohtml-encoding-snifferhttp-cache-semanticshas-tostringtaghtml-escaperhuman-signalshttp-proxy-agenthttp-errorshttps-proxy-agentignoreieee754iconv-liteimage-sizehermes-profile-transformerimport-cwdimport-freshimport-frominflightinheritsimport-lazyindent-stringimurmurhashipimport-localiniis-absoluteinquirerinterpretinternal-slotis-arrayishis-accessor-descriptorinvariantis-boolean-objectis-core-moduleis-bigintis-argumentsis-bufferis-ciis-callableis-date-objectis-data-descriptoris-descriptoris-extglobis-directoryis-extendableis-git-dirtyis-git-repositoryis-fullwidth-code-pointis-dockeris-generator-fnis-installed-globallyis-globis-interactiveis-mapis-npmis-negative-zerois-path-insideis-path-cwdis-number-objectis-numberis-objis-relativeis-plain-objis-plain-objectis-setis-streamis-regexis-shared-array-bufferis-potential-custom-element-nameis-stringis-unc-pathis-symbolis-unicode-supportedis-windowsis-typedarrayis-text-pathis-weakrefisexeis-wslis-yarn-globalistanbul-lib-coverageis-sshisarrayistanbul-lib-reportisobjectisomorphic-fetchistanbul-lib-instrumentistanbul-reportsistanbul-lib-source-mapsiterate-valuejest-diffiterate-iteratorjest-clijest-configjest-eachjest-environment-jsdomjest-get-typejest-environment-nodejest-haste-mapjest-docblockjest-jasmine2jest-leak-detectorjest-message-utiljest-mockjest-matcher-utilsjest-pnp-resolverjest-changed-filesjest-resolve-dependenciesjest-regex-utiljest-runnerjest-runtimejest-serializerjest-snapshotjest-workerjest-validatejest-watcherjs-tokensjest-utiljetifierjest-resolvejsescjsdomjsc-androidjson-parse-even-better-errorsjs-yamljson-bufferjson-parse-better-errorsjson-schema-traversejson-stable-stringifyjson-stable-stringify-without-jsonifyjson5json-stringify-safejsonifyjsonparsejsx-ast-utilskleurkeyvkind-ofklawlines-and-columnslatest-versionlevenlevnlodash.debouncelocate-pathlodashload-json-filelodash.ismatchlodash.mergelodash.truncatelodash.throttlelogkittyloose-envifylowercase-keyslog-symbolsjsonfilemacos-releasemakeerrorlru-cachemap-visitmake-dirmap-objmerge-streammap-cachemerge2meowmetro-babel-transformermetro-cachemetro-configmetro-babel-registermetrometro-minify-uglifymetro-react-native-babel-presetmetro-react-native-babel-transformermicromatchmetro-resolvermetro-source-mapmetro-coremimic-fnmetro-inspector-proxymetro-symbolicatemimeminimatchmime-dbmimic-responsemime-typesminimistminimist-optionsmin-indentmsmodify-valuesmkdirpmute-streammixin-deepnanomatchnatural-comparenanneo-asyncnetmasknice-trynew-github-release-urlnode-fetchnode-releasesnegotiatornocachenode-notifiernode-int64npm-run-pathnormalize-package-datanode-stream-zipnullthrowsobject-assignnormalize-urlnormalize-pathob1object-copyobject-inspectobject-visitobject-keysobject.assignobject.entriesnwsapiobject.hasownobject.pickonetimeonceobject.valueson-finishedon-headersopenoptionatoroptionsos-nameos-tmpdirobject.fromentriesorap-cancelablep-limitp-each-seriesp-finallyp-mapp-locatep-tryparse-jsonparent-modulepac-resolverpac-proxy-agentpackage-jsonparse-node-versionpath-is-absoluteparse-urlpascalcaseparse-pathpath-existsparseurlpath-typepicomatchpicocolorsparse5path-keypath-parsepiratespifyplistplugin-errorposix-character-classesprelude-lsprepend-filepretty-formatprettier-linter-helpersprepend-httppkg-dirprop-typesprogresspromptspromiseprocess-nextick-argspromise.allsettledproxy-agentprotocolspseudomappupapumppslqueue-microtaskqqsquery-stringquick-lrupunycoderange-parserraw-bodyreact-isreact-devtools-corercreact-refreshread-pkgread-pkg-uprechoirregeneratereadable-streamregenerator-transformredentregenerate-unicode-propertiesregenerator-runtimeregexpu-coreregex-notregistry-auth-tokenregexp.prototype.flagsproxy-from-envregjsgenregjsparserrequire-directoryrepeat-stringremove-trailing-separatorregexppresolverepeat-elementrequire-from-stringrequire-main-filenameresolve-cwdresolve-globalresolve-fromresolve-urlresponselikereusifyrimrafrestore-cursorretregistry-urlrsvprx-literetryrun-asyncrx-lite-aggregatessafe-buffersafe-regexrxjssafer-bufferschedulersemverrun-parallelsanesaxessemver-diffsaxsendserve-staticserialize-errorset-valuesetprototypeofsetimmediateshallow-cloneshebang-commandshelljssignal-exitshebang-regexshellwordsshell-quotesimple-plistsisteransislashside-channelset-blockingslice-ansismart-buffersnapdragonsnapdragon-nodesockssnapdragon-utilsocks-proxy-agentsource-map-resolvesource-mapsource-map-supportsource-map-urlspdx-correctspdx-expression-parsespdx-exceptionssplit-on-firstspdx-license-idssplitsplit2split-stringsprintf-jsstack-utilsstacktrace-parserstackframestatic-extendstring-widthstrict-uri-encodestream-buffersstring-lengthstring.prototype.matchallstrip-ansistring.prototype.trimendstring.prototype.trimstartstrip-eofstrip-bomsupports-colorstrip-json-commentsstrip-indentsudo-promptsupports-hyperlinkstablestrip-final-newlinesymbol-treetempsupports-preserve-symlinks-flagtemp-writetemp-dirtest-excludeterminal-linktext-tabletext-extensionsthroatthroughto-fast-propertiestime-stampthrough2tmptmplto-object-pathto-readable-streamto-regex-rangeto-regextough-cookietoidentifiertr46trim-newlinesstatusestslibtsutilstype-detecttype-checktype-festtypedarraytypedarray-to-bufferuglify-esuglify-jsunc-path-regexunicode-canonical-property-names-ecmascriptunicode-match-property-ecmascriptunicode-match-property-value-ecmascriptua-parser-jsunicode-property-aliases-ecmascriptultronunique-stringunbox-primitiveuniversal-user-agentunion-valueuniversalifyupdate-notifierunset-valueunpipeuri-jsurixurl-joinuseuse-sync-external-storeurl-parse-laxuse-subscriptionutil-deprecateutils-mergev8-to-istanbulv8-compile-cacheuuidvlqvalidate-npm-package-licensevaryvm2walkerwcwidthwhatwg-encodingw3c-hr-timewebidl-conversionsw3c-xmlserializerwhichwhatwg-fetchwhatwg-mimetypewhich-modulewhatwg-urlwhich-boxed-primitivewildcard-matchwrap-ansiwidest-linewrappywindows-releaseword-wrapwordwrapwrite-file-atomicwsxml-name-validatorxcodexdg-basedirxmlcharsxmldocxmlbuilderxpipexregexpy18nxtendyargs-parseryallistyargsyamlstring_decoderyocto-queue
1.1.7

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago

0.1.0

2 years ago