npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-chinamap

v1.0.3

Published

use svg to display chinamap

Downloads

10

Readme

react-native-chinamap

This is a component for display china distribution map by use svg

show Cases

IOS

Android

Prerequisites

This library uses react-native-svg to render its graphs. Therefore this library needs to be installed And linked into your project to work.

npm install react-native-svg --save

or

yarn add react-native-svg

and then

react-native link react-native-svg

installation

npm install react-native-chinamap --save

or

yarn add react-native-chinamap

Usage

/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 * @flow
 */

import React, { Component } from 'react';
import {
  StyleSheet,
  View,
  Text,
  Dimensions,
} from 'react-native';
import ChinaMap from 'react-native-chinamap';
const window = {
  width: Dimensions.get('window').width,
};

export default class App extends Component {
  state = {
    map: {
      data: [{
        code: 11,
        name: '北京市',
        provinceGradation: 5,
      },
      {
        code: 12,
        name: '天津市',
        provinceGradation: 2,
      },
      {
        code: 13,
        name: '河北省',
        provinceGradation: 3,
      }, {
        code: 61,
        provinceGradation: 4,
      }, {
        code: 62,
        provinceGradation: 3,
      }, {
        code: 65,
        name: '新疆',
        provinceGradation: 5,
      }],
      legend: [
        { gradation: 1, color: '#FFFFFF', min: '', max: '1万' },
        { gradation: 2, color: 'rgba(0, 122, 255, 0.2)', min: '1万', max: '3万' },
        { gradation: 3, color: 'rgba(0, 122, 255, 0.4)', min: '3万', max: '5万' },
        { gradation: 4, color: 'rgba(0, 122, 255, 0.6)', min: '5万', max: '10万' },
        { gradation: 5, color: 'rgba(0, 122, 255, 1)', min: '10万', max: '' },
      ],
    },
  }

  render() {
    const { data, legend } = this.state.map;
    return (
      <View style={styles.container}>
        <ChinaMap
          fillRule={'evenodd'}
          width={window.width}
          showLegend
          mapData={data}
          legend={legend}
          showShadow={true}
          backgroundColor={'#fff'}
          stroke='#dbdbdf'
        />
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#f5f5f5',
    alignSelf: 'center',
    overflow: 'hidden',
    paddingTop: 100,
  },
});

Documentation

Params

Key | Type | Default | description ---|---|---|--- fillRule | string | evenodd | evenodd / nonzero width | number | device width mapData | array legend | array | [{ gradation: 1, color: '#FFFFFF', min: '', max: '1万' }...] showLegend | boolean | true showShadow | boolean | true backgroundColor | string | #ffffff stroke | string | #dbdbdf strokeWidth | string | 0.5

Run example

git clone https://github.com/xiangming25/react-native-chinamap.git

cd react-native-chinamap/example

npm i

# run IOS: react-native run-ios
# run Android: react-native run-android